diff --git a/.eslintrc.js b/.eslintrc.js index 4cb46eede..37b2cbf0c 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -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', diff --git a/.prettierignore b/.prettierignore index 162c6de6b..a1174a3c8 100644 --- a/.prettierignore +++ b/.prettierignore @@ -4,6 +4,7 @@ yarn.lock package-lock.json public/fonts public/img +public/js manifests .github !.github/workflows diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 000000000..e354213e8 --- /dev/null +++ b/.vscode/tasks.json @@ -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" + } + ] +} diff --git a/README.md b/README.md index f6ca97ac8..74fe9987d 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,9 @@ Watch releases of this repository to be notified about future updates: ## Contributors ✨ + [![All Contributors](https://img.shields.io/badge/all_contributors-72-orange.svg?style=flat-square)](#contributors-) + Please check [contributors guide](https://github.com/podkrepi-bg/frontend/blob/master/CONTRIBUTING.md) for: diff --git a/public/locales/en/admin.json b/public/locales/en/admin.json index 86b6b3a3d..5ff27c959 100644 --- a/public/locales/en/admin.json +++ b/public/locales/en/admin.json @@ -16,5 +16,5 @@ "view": "View", "edit": "Edit", "delete": "Delete" - }, + } } diff --git a/src/components/client/irregularity/helpers/irregularity.types.ts b/src/components/client/irregularity/helpers/irregularity.types.ts index f6a7657f5..b06ec2721 100644 --- a/src/components/client/irregularity/helpers/irregularity.types.ts +++ b/src/components/client/irregularity/helpers/irregularity.types.ts @@ -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 = { diff --git a/src/components/common/person/PersonAutoCompleteFilter.ts b/src/components/common/person/PersonAutoCompleteFilter.ts index 38eedbab9..3e854bfef 100644 --- a/src/components/common/person/PersonAutoCompleteFilter.ts +++ b/src/components/common/person/PersonAutoCompleteFilter.ts @@ -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()) ) }) diff --git a/src/components/common/person/grid/CreateForm.tsx b/src/components/common/person/grid/CreateForm.tsx index 6784baeda..6dd372329 100644 --- a/src/components/common/person/grid/CreateForm.tsx +++ b/src/components/common/person/grid/CreateForm.tsx @@ -27,6 +27,7 @@ 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() @@ -34,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(), @@ -60,8 +74,8 @@ const validationSchema = yup const initialValues: AdminPersonFormData = { firstName: '', lastName: '', - email: '', - phone: '', + email: undefined, + phone: undefined, isOrganizer: false, isCoordinator: false, isBeneficiary: false, diff --git a/src/components/common/person/grid/EditForm.tsx b/src/components/common/person/grid/EditForm.tsx index 8fc05ab7a..0bfa6228e 100644 --- a/src/components/common/person/grid/EditForm.tsx +++ b/src/components/common/person/grid/EditForm.tsx @@ -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(), @@ -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, diff --git a/src/gql/person.d.ts b/src/gql/person.d.ts index 3cb764cc4..0acc5cf57 100644 --- a/src/gql/person.d.ts +++ b/src/gql/person.d.ts @@ -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 @@ -43,7 +43,7 @@ export type PersonPaginatedResponse = { export type PersonFormData = { firstName: string lastName: string - email: string + email?: string phone?: string legalEntity: boolean companyName?: string diff --git a/tsconfig.json b/tsconfig.json index 38d176097..34d5bfbac 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,11 +1,7 @@ { "compilerOptions": { "target": "ESNext", - "lib": [ - "dom", - "dom.iterable", - "esnext" - ], + "lib": ["dom", "dom.iterable", "esnext"], "allowJs": false, "checkJs": false, "skipLibCheck": true, @@ -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"] }