Skip to content

Commit

Permalink
beneficiery without mail (#1606)
Browse files Browse the repository at this point in the history
* made email optional when creating person as Beneficiery

* added build tasks

* formatting fixes
  • Loading branch information
quantum-grit authored Sep 29, 2023
1 parent ec318f9 commit 626952b
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = {
'sentry.client.config.js',
'sentry.server.config.js',
'next-sitemap.config.js',
'e2e/*'
'e2e/*',
],
rules: {
'react/display-name': 'off',
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ yarn.lock
package-lock.json
public/fonts
public/img
public/js
manifests
.github
!.github/workflows
Expand Down
23 changes: 23 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "build",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [],
"label": "npm: build",
"detail": "yarn build"
},
{
"type": "typescript",
"tsconfig": "tsconfig.build.json",
"problemMatcher": ["$tsc"],
"group": "build",
"label": "tsc: build - tsconfig.build.json"
}
]
}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ Watch releases of this repository to be notified about future updates:
## Contributors ✨

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->

[![All Contributors](https://img.shields.io/badge/all_contributors-72-orange.svg?style=flat-square)](#contributors-)

<!-- ALL-CONTRIBUTORS-BADGE:END -->

Please check [contributors guide](https://github.com/podkrepi-bg/frontend/blob/master/CONTRIBUTING.md) for:
Expand Down
2 changes: 1 addition & 1 deletion public/locales/en/admin.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
"view": "View",
"edit": "Edit",
"delete": "Delete"
},
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export enum IrregularityReason {
export type PersonFormData = {
firstName: string
lastName: string
email: string
phone: string | undefined
email?: string
phone?: string
}

export type InfoFormData = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/person/PersonAutoCompleteFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const personFilter = (
const name = `${option.firstName.toLowerCase()} ${option.lastName.toLowerCase()}`
return (
name.includes(state.inputValue.toLowerCase()) ||
option.email.toLowerCase().includes(state.inputValue.toLowerCase())
option.email?.toLowerCase().includes(state.inputValue.toLowerCase())
)
})

Expand Down
20 changes: 17 additions & 3 deletions src/components/common/person/grid/CreateForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,28 @@ import { useCreateBeneficiary } from 'service/beneficiary'
import OrganizerRelationSelect from 'components/admin/beneficiary/OrganizerRelationSelect'
import CountrySelect from 'components/admin/countries/CountrySelect'
import CitySelect from 'components/admin/cities/CitySelect'
import { treeItemClasses } from '@mui/lab'

const validationSchema = yup
.object()
.defined()
.shape({
firstName: name.required(),
lastName: name.required(),
email: email.required(),
email: email
.when('isBeneficiary', {
is: true,
then: email.notRequired(),
otherwise: email.required(),
})
.when('isCoordinator', {
is: true,
then: email.required(),
})
.when('isOrganizer', {
is: true,
then: email.required(),
}),
phone: phone.notRequired(),
isCoordinator: yup.bool().required(),
isOrganizer: yup.bool().required(),
Expand All @@ -60,8 +74,8 @@ const validationSchema = yup
const initialValues: AdminPersonFormData = {
firstName: '',
lastName: '',
email: '',
phone: '',
email: undefined,
phone: undefined,
isOrganizer: false,
isCoordinator: false,
isBeneficiary: false,
Expand Down
19 changes: 16 additions & 3 deletions src/components/common/person/grid/EditForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,20 @@ const validationSchema = yup
.shape({
firstName: name.required(),
lastName: name.required(),
email: email.required(),
email: email
.when('isBeneficiary', {
is: true,
then: email.notRequired(),
otherwise: email.required(),
})
.when('isCoordinator', {
is: true,
then: email.required(),
})
.when('isOrganizer', {
is: true,
then: email.required(),
}),
phone: phone.notRequired(),
isCoordinator: yup.bool().required(),
isOrganizer: yup.bool().required(),
Expand Down Expand Up @@ -70,8 +83,8 @@ export default function EditForm() {
const initialValues = {
firstName: data?.firstName ?? '',
lastName: data?.lastName ?? '',
email: data?.email ?? '',
phone: data?.phone ?? '',
email: data?.email ?? undefined,
phone: data?.phone ?? undefined,
isCoordinator: !!data?.coordinators,
coordinatorId: data?.coordinators?.id,
coordinatorCampaigns: data?.coordinators?._count?.campaigns,
Expand Down
6 changes: 3 additions & 3 deletions src/gql/person.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export type PersonResponse = {
id: string
firstName: string
lastName: string
email: string
phone: string
email?: string
phone?: string
address: string
company: string
createdAt: string
Expand Down Expand Up @@ -43,7 +43,7 @@ export type PersonPaginatedResponse = {
export type PersonFormData = {
firstName: string
lastName: string
email: string
email?: string
phone?: string
legalEntity: boolean
companyName?: string
Expand Down
20 changes: 3 additions & 17 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
{
"compilerOptions": {
"target": "ESNext",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": false,
"checkJs": false,
"skipLibCheck": true,
Expand All @@ -32,16 +28,6 @@
"incremental": true,
"outDir": ".next"
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
],
"exclude": [
"node_modules",
".next",
"e2e"

]

"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules", ".next", "e2e"]
}

0 comments on commit 626952b

Please sign in to comment.