diff --git a/.pnp.cjs b/.pnp.cjs index 004b47301..0dcae2d59 100644 --- a/.pnp.cjs +++ b/.pnp.cjs @@ -151,7 +151,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["url-loader", "virtual:9909ff5388c6b6a3a46f12eb37c0afb449fcd1eedb9f02d871bde711a076c929583f48ecc4b85fa6d71478b076104a25f83dee45bc69687a22f551c576d7595d#npm:4.1.1"],\ ["uuid", "npm:9.0.0"],\ ["webpack", "virtual:9909ff5388c6b6a3a46f12eb37c0afb449fcd1eedb9f02d871bde711a076c929583f48ecc4b85fa6d71478b076104a25f83dee45bc69687a22f551c576d7595d#npm:5.96.1"],\ - ["yup", "npm:0.32.11"]\ + ["yup", "npm:1.4.0"]\ ],\ "linkType": "SOFT"\ }]\ @@ -8823,13 +8823,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { }]\ ]],\ ["@types/lodash", [\ - ["npm:4.14.184", {\ - "packageLocation": "./.yarn/cache/@types-lodash-npm-4.14.184-aec91d64ae-6d9a4d67f7.zip/node_modules/@types/lodash/",\ - "packageDependencies": [\ - ["@types/lodash", "npm:4.14.184"]\ - ],\ - "linkType": "HARD"\ - }],\ ["npm:4.14.191", {\ "packageLocation": "./.yarn/cache/@types-lodash-npm-4.14.191-67a04a969b-ba0d5434e1.zip/node_modules/@types/lodash/",\ "packageDependencies": [\ @@ -19561,7 +19554,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["url-loader", "virtual:9909ff5388c6b6a3a46f12eb37c0afb449fcd1eedb9f02d871bde711a076c929583f48ecc4b85fa6d71478b076104a25f83dee45bc69687a22f551c576d7595d#npm:4.1.1"],\ ["uuid", "npm:9.0.0"],\ ["webpack", "virtual:9909ff5388c6b6a3a46f12eb37c0afb449fcd1eedb9f02d871bde711a076c929583f48ecc4b85fa6d71478b076104a25f83dee45bc69687a22f551c576d7595d#npm:5.96.1"],\ - ["yup", "npm:0.32.11"]\ + ["yup", "npm:1.4.0"]\ ],\ "linkType": "SOFT"\ }]\ @@ -19670,15 +19663,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "linkType": "HARD"\ }]\ ]],\ - ["nanoclone", [\ - ["npm:0.2.1", {\ - "packageLocation": "./.yarn/cache/nanoclone-npm-0.2.1-972ee958a0-96b2954e22.zip/node_modules/nanoclone/",\ - "packageDependencies": [\ - ["nanoclone", "npm:0.2.1"]\ - ],\ - "linkType": "HARD"\ - }]\ - ]],\ ["nanoid", [\ ["npm:3.3.4", {\ "packageLocation": "./.yarn/cache/nanoid-npm-3.3.4-3d250377d6-2fddd6dee9.zip/node_modules/nanoid/",\ @@ -21296,10 +21280,10 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { }]\ ]],\ ["property-expr", [\ - ["npm:2.0.5", {\ - "packageLocation": "./.yarn/cache/property-expr-npm-2.0.5-6f6bda4c65-4ebe82ce45.zip/node_modules/property-expr/",\ + ["npm:2.0.6", {\ + "packageLocation": "./.yarn/cache/property-expr-npm-2.0.6-2a0857ed05-89977f4bb2.zip/node_modules/property-expr/",\ "packageDependencies": [\ - ["property-expr", "npm:2.0.5"]\ + ["property-expr", "npm:2.0.6"]\ ],\ "linkType": "HARD"\ }]\ @@ -24300,6 +24284,15 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "linkType": "HARD"\ }]\ ]],\ + ["tiny-case", [\ + ["npm:1.0.3", {\ + "packageLocation": "./.yarn/cache/tiny-case-npm-1.0.3-8c9747c74e-3f7a30c39d.zip/node_modules/tiny-case/",\ + "packageDependencies": [\ + ["tiny-case", "npm:1.0.3"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["tiny-invariant", [\ ["npm:1.2.0", {\ "packageLocation": "./.yarn/cache/tiny-invariant-npm-1.2.0-024338c59c-e09a718a7c.zip/node_modules/tiny-invariant/",\ @@ -24845,6 +24838,13 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["type-fest", "npm:0.21.3"]\ ],\ "linkType": "HARD"\ + }],\ + ["npm:2.19.0", {\ + "packageLocation": "./.yarn/cache/type-fest-npm-2.19.0-918b953248-a4ef07ece2.zip/node_modules/type-fest/",\ + "packageDependencies": [\ + ["type-fest", "npm:2.19.0"]\ + ],\ + "linkType": "HARD"\ }]\ ]],\ ["type-is", [\ @@ -26399,17 +26399,14 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { }]\ ]],\ ["yup", [\ - ["npm:0.32.11", {\ - "packageLocation": "./.yarn/cache/yup-npm-0.32.11-dbaff8ca9c-43a16786b4.zip/node_modules/yup/",\ + ["npm:1.4.0", {\ + "packageLocation": "./.yarn/cache/yup-npm-1.4.0-599c24806a-20a2ee0c1e.zip/node_modules/yup/",\ "packageDependencies": [\ - ["yup", "npm:0.32.11"],\ - ["@babel/runtime", "npm:7.18.9"],\ - ["@types/lodash", "npm:4.14.184"],\ - ["lodash", "npm:4.17.21"],\ - ["lodash-es", "npm:4.17.21"],\ - ["nanoclone", "npm:0.2.1"],\ - ["property-expr", "npm:2.0.5"],\ - ["toposort", "npm:2.0.2"]\ + ["yup", "npm:1.4.0"],\ + ["property-expr", "npm:2.0.6"],\ + ["tiny-case", "npm:1.0.3"],\ + ["toposort", "npm:2.0.2"],\ + ["type-fest", "npm:2.19.0"]\ ],\ "linkType": "HARD"\ }]\ diff --git a/.yarn/cache/@types-lodash-npm-4.14.184-aec91d64ae-6d9a4d67f7.zip b/.yarn/cache/@types-lodash-npm-4.14.184-aec91d64ae-6d9a4d67f7.zip deleted file mode 100644 index 41d5cec2a..000000000 Binary files a/.yarn/cache/@types-lodash-npm-4.14.184-aec91d64ae-6d9a4d67f7.zip and /dev/null differ diff --git a/.yarn/cache/nanoclone-npm-0.2.1-972ee958a0-96b2954e22.zip b/.yarn/cache/nanoclone-npm-0.2.1-972ee958a0-96b2954e22.zip deleted file mode 100644 index b549d7978..000000000 Binary files a/.yarn/cache/nanoclone-npm-0.2.1-972ee958a0-96b2954e22.zip and /dev/null differ diff --git a/.yarn/cache/property-expr-npm-2.0.5-6f6bda4c65-4ebe82ce45.zip b/.yarn/cache/property-expr-npm-2.0.6-2a0857ed05-89977f4bb2.zip similarity index 62% rename from .yarn/cache/property-expr-npm-2.0.5-6f6bda4c65-4ebe82ce45.zip rename to .yarn/cache/property-expr-npm-2.0.6-2a0857ed05-89977f4bb2.zip index a393c4f48..3370492f9 100644 Binary files a/.yarn/cache/property-expr-npm-2.0.5-6f6bda4c65-4ebe82ce45.zip and b/.yarn/cache/property-expr-npm-2.0.6-2a0857ed05-89977f4bb2.zip differ diff --git a/.yarn/cache/tiny-case-npm-1.0.3-8c9747c74e-3f7a30c39d.zip b/.yarn/cache/tiny-case-npm-1.0.3-8c9747c74e-3f7a30c39d.zip new file mode 100644 index 000000000..37c0ecfe6 Binary files /dev/null and b/.yarn/cache/tiny-case-npm-1.0.3-8c9747c74e-3f7a30c39d.zip differ diff --git a/.yarn/cache/type-fest-npm-2.19.0-918b953248-a4ef07ece2.zip b/.yarn/cache/type-fest-npm-2.19.0-918b953248-a4ef07ece2.zip new file mode 100644 index 000000000..e499820ab Binary files /dev/null and b/.yarn/cache/type-fest-npm-2.19.0-918b953248-a4ef07ece2.zip differ diff --git a/.yarn/cache/yup-npm-0.32.11-dbaff8ca9c-43a16786b4.zip b/.yarn/cache/yup-npm-0.32.11-dbaff8ca9c-43a16786b4.zip deleted file mode 100644 index 3d83f3d01..000000000 Binary files a/.yarn/cache/yup-npm-0.32.11-dbaff8ca9c-43a16786b4.zip and /dev/null differ diff --git a/.yarn/cache/yup-npm-1.4.0-599c24806a-20a2ee0c1e.zip b/.yarn/cache/yup-npm-1.4.0-599c24806a-20a2ee0c1e.zip new file mode 100644 index 000000000..1c6752248 Binary files /dev/null and b/.yarn/cache/yup-npm-1.4.0-599c24806a-20a2ee0c1e.zip differ diff --git a/package.json b/package.json index 45490c63a..ca1e2fc59 100644 --- a/package.json +++ b/package.json @@ -84,7 +84,7 @@ "tslib": "^2.4.0", "tss-react": "^4.1.3", "uuid": "^9.0.0", - "yup": "^0.32.11" + "yup": "^1.4.0" }, "devDependencies": { "@brainly/onesky-utils": "1.4.2", diff --git a/pages/api/Schema/ContactPrimaryAddress/datahandler.ts b/pages/api/Schema/ContactPrimaryAddress/datahandler.ts index c9f2540ef..ebfd512f5 100644 --- a/pages/api/Schema/ContactPrimaryAddress/datahandler.ts +++ b/pages/api/Schema/ContactPrimaryAddress/datahandler.ts @@ -8,7 +8,10 @@ const getAddressesResponseSchema = object({ relationships: object({ addresses: object({ data: array().of( - object({ id: string().required(), type: string().required() }), + object({ + id: string().required(), + type: string().required(), + }).required(), ), }).required(), }).required(), diff --git a/src/components/Contacts/ContactDetails/ContactDetailsTab/Mailing/EditMailingInfoModal/EditMailingInfoModal.tsx b/src/components/Contacts/ContactDetails/ContactDetailsTab/Mailing/EditMailingInfoModal/EditMailingInfoModal.tsx index 7d7844bfc..8f1ad6ff0 100644 --- a/src/components/Contacts/ContactDetails/ContactDetailsTab/Mailing/EditMailingInfoModal/EditMailingInfoModal.tsx +++ b/src/components/Contacts/ContactDetails/ContactDetailsTab/Mailing/EditMailingInfoModal/EditMailingInfoModal.tsx @@ -67,7 +67,7 @@ export const EditMailingInfoModal: React.FC = ({ // Add additional language locales here, for multiline TextField support const multilineLocales = ['de']; - const mailingInfoSchema: yup.SchemaOf< + const mailingInfoSchema: yup.ObjectSchema< Pick< ContactUpdateInput, 'id' | 'greeting' | 'envelopeGreeting' | 'sendNewsletter' diff --git a/src/components/Contacts/ContactDetails/ContactDetailsTab/Mailing/addressSchema.ts b/src/components/Contacts/ContactDetails/ContactDetailsTab/Mailing/addressSchema.ts index ca192881c..a48c0e472 100644 --- a/src/components/Contacts/ContactDetails/ContactDetailsTab/Mailing/addressSchema.ts +++ b/src/components/Contacts/ContactDetails/ContactDetailsTab/Mailing/addressSchema.ts @@ -28,7 +28,7 @@ export const addressSchema = yup.object({ address.street, ), ), - primaryMailingAddress: yup.boolean().nullable(false), + primaryMailingAddress: yup.boolean().defined(), }); export type AddressSchema = yup.InferType; diff --git a/src/components/Contacts/ContactDetails/ContactDetailsTab/Other/EditContactOtherModal/EditContactOtherModal.tsx b/src/components/Contacts/ContactDetails/ContactDetailsTab/Other/EditContactOtherModal/EditContactOtherModal.tsx index bd49e85d2..579504ba2 100644 --- a/src/components/Contacts/ContactDetails/ContactDetailsTab/Other/EditContactOtherModal/EditContactOtherModal.tsx +++ b/src/components/Contacts/ContactDetails/ContactDetailsTab/Other/EditContactOtherModal/EditContactOtherModal.tsx @@ -173,7 +173,7 @@ export const EditContactOtherModal: React.FC = ({ dataFilteredByName?.contacts.nodes || []; - const contactOtherSchema: yup.SchemaOf< + const contactOtherSchema: yup.ObjectSchema< Pick< ContactUpdateInput, | 'id' @@ -192,7 +192,7 @@ export const EditContactOtherModal: React.FC = ({ churchName: yup.string().nullable(), preferredContactMethod: yup .mixed() - .oneOf([...Object.values(PreferredContactMethodEnum), null]) + .oneOf(Object.values(PreferredContactMethodEnum)) .nullable(), locale: yup.string().nullable(), timezone: yup.string().nullable(), diff --git a/src/components/Contacts/ContactDetails/ContactDetailsTab/People/Items/PersonModal/personModalHelper.tsx b/src/components/Contacts/ContactDetails/ContactDetailsTab/People/Items/PersonModal/personModalHelper.tsx index 7f567b3c6..8d743cb7d 100644 --- a/src/components/Contacts/ContactDetails/ContactDetailsTab/People/Items/PersonModal/personModalHelper.tsx +++ b/src/components/Contacts/ContactDetails/ContactDetailsTab/People/Items/PersonModal/personModalHelper.tsx @@ -9,7 +9,7 @@ import { import { NewSocial, Person } from './PersonModal'; interface GetPersonSchemaReturnedValues { - personSchema: yup.SchemaOf< + personSchema: yup.ObjectSchema< Omit >; initialPerson: (PersonCreateInput | PersonUpdateInput) & NewSocial; @@ -26,25 +26,27 @@ export const getPersonSchema = ( title: yup.string().nullable(), suffix: yup.string().nullable(), phoneNumbers: yup.array().of( - yup.object({ - id: yup.string().nullable(), - number: yup.string().when('destroy', { - is: true, - then: yup.string().nullable(), - otherwise: yup - .string() - .required(t('This field is required')) - .nullable() - .test( - 'is-phone-number', - t('This field is not a valid phone number'), - (val) => typeof val === 'string' && /\d/.test(val), - ), - }), - destroy: yup.boolean().default(false), - primary: yup.boolean().default(false), - historic: yup.boolean().default(false), - }), + yup + .object({ + id: yup.string().nullable(), + number: yup.string().when('destroy', { + is: true, + then: (schema) => schema.nullable(), + otherwise: (schema) => + schema + .required(t('This field is required')) + .nullable() + .test( + 'is-phone-number', + t('This field is not a valid phone number'), + (val) => typeof val === 'string' && /\d/.test(val), + ), + }), + destroy: yup.boolean().default(false), + primary: yup.boolean().default(false), + historic: yup.boolean().default(false), + }) + .required(), ), emailAddresses: yup.array().of( yup.object({ @@ -59,38 +61,48 @@ export const getPersonSchema = ( }), ), facebookAccounts: yup.array().of( - yup.object({ - id: yup.string().nullable(), - destroy: yup.boolean().default(false), - username: yup.string().required(), - }), + yup + .object({ + id: yup.string().nullable(), + destroy: yup.boolean().default(false), + username: yup.string().required(), + }) + .required(), ), linkedinAccounts: yup.array().of( - yup.object({ - id: yup.string().nullable(), - destroy: yup.boolean().default(false), - publicUrl: yup.string().required(), - }), + yup + .object({ + id: yup.string().nullable(), + destroy: yup.boolean().default(false), + publicUrl: yup.string().required(), + }) + .required(), ), twitterAccounts: yup.array().of( - yup.object({ - id: yup.string().nullable(), - destroy: yup.boolean().default(false), - screenName: yup.string().required(), - }), + yup + .object({ + id: yup.string().nullable(), + destroy: yup.boolean().default(false), + screenName: yup.string().required(), + }) + .required(), ), websites: yup.array().of( - yup.object({ - id: yup.string().nullable(), - destroy: yup.boolean().default(false), - url: yup.string().required(), - }), + yup + .object({ + id: yup.string().nullable(), + destroy: yup.boolean().default(false), + url: yup.string().required(), + }) + .required(), ), newSocials: yup.array().of( - yup.object({ - value: yup.string().required(), - type: yup.string().required(), - }), + yup + .object({ + value: yup.string().required(), + type: yup.string().required(), + }) + .required(), ), optoutEnewsletter: yup.boolean().default(false), birthdayDay: yup.number().nullable(), diff --git a/src/components/Contacts/ContactDetails/ContactDetailsTab/Tags/ContactTags.tsx b/src/components/Contacts/ContactDetails/ContactDetailsTab/Tags/ContactTags.tsx index 204d294cf..97e8a64fa 100644 --- a/src/components/Contacts/ContactDetails/ContactDetailsTab/Tags/ContactTags.tsx +++ b/src/components/Contacts/ContactDetails/ContactDetailsTab/Tags/ContactTags.tsx @@ -38,7 +38,7 @@ interface ContactTagsProps { } const tagSchema = yup.object({ - tagList: yup.array().of(yup.string()).default([]), + tagList: yup.array().of(yup.string().required()).default([]), }); export const ContactTags: React.FC = ({ diff --git a/src/components/Contacts/ContactDetails/ContactDonationsTab/PartnershipInfo/EditPartnershipInfoModal/EditPartnershipInfoModal.tsx b/src/components/Contacts/ContactDetails/ContactDonationsTab/PartnershipInfo/EditPartnershipInfoModal/EditPartnershipInfoModal.tsx index 21970f800..8af1ca3a1 100644 --- a/src/components/Contacts/ContactDetails/ContactDonationsTab/PartnershipInfo/EditPartnershipInfoModal/EditPartnershipInfoModal.tsx +++ b/src/components/Contacts/ContactDetails/ContactDonationsTab/PartnershipInfo/EditPartnershipInfoModal/EditPartnershipInfoModal.tsx @@ -87,10 +87,7 @@ const SelectInteractive = styled(Select, { const contactPartnershipSchema = yup.object({ id: yup.string().required(), - status: yup - .mixed() - .oneOf([...Object.values(StatusEnum), null]) - .nullable(), + status: yup.mixed().oneOf(Object.values(StatusEnum)).nullable(), pledgeAmount: yup.number().moreThan(-1).nullable(), pledgeStartDate: nullableDateTime(), pledgeReceived: yup.boolean().default(false).nullable(), diff --git a/src/components/Contacts/MassActions/AddTags/MassActionsAddTagsModal.tsx b/src/components/Contacts/MassActions/AddTags/MassActionsAddTagsModal.tsx index 94b14c675..9ebb8f76e 100644 --- a/src/components/Contacts/MassActions/AddTags/MassActionsAddTagsModal.tsx +++ b/src/components/Contacts/MassActions/AddTags/MassActionsAddTagsModal.tsx @@ -53,7 +53,7 @@ const AddTagIcon = styled(Add)(() => ({ })); const tagSchema = yup.object({ - tagList: yup.array().of(yup.string()).default([]).nullable(), + tagList: yup.array().of(yup.string().required()).default([]).nullable(), }); export const MassActionsAddTagsModal: React.FC< diff --git a/src/components/Contacts/MassActions/RemoveTags/MassActionsRemoveTagsModal.tsx b/src/components/Contacts/MassActions/RemoveTags/MassActionsRemoveTagsModal.tsx index 5ce179793..fa6583256 100644 --- a/src/components/Contacts/MassActions/RemoveTags/MassActionsRemoveTagsModal.tsx +++ b/src/components/Contacts/MassActions/RemoveTags/MassActionsRemoveTagsModal.tsx @@ -51,7 +51,7 @@ const RemoveTagIcon = styled(Remove)(() => ({ })); const tagSchema = yup.object({ - tagList: yup.array().of(yup.string()).default([]).nullable(), + tagList: yup.array().of(yup.string().required()).default([]).nullable(), }); export const MassActionsRemoveTagsModal: React.FC< diff --git a/src/components/Dashboard/ThisWeek/NewsletterMenu/MenuItems/LogNewsLetter/LogNewsletter.tsx b/src/components/Dashboard/ThisWeek/NewsletterMenu/MenuItems/LogNewsLetter/LogNewsletter.tsx index 8a0baf205..8e278c6f9 100644 --- a/src/components/Dashboard/ThisWeek/NewsletterMenu/MenuItems/LogNewsLetter/LogNewsletter.tsx +++ b/src/components/Dashboard/ThisWeek/NewsletterMenu/MenuItems/LogNewsLetter/LogNewsletter.tsx @@ -81,7 +81,7 @@ const LoadingIndicator = styled(CircularProgress)(({ theme }) => ({ const taskSchema = yup.object({ activityType: yup - .mixed() + .mixed() .oneOf([...Object.values(ActivityTypeEnum), 'BOTH' as const]) .defined(), completedAt: nullableDateTime(), diff --git a/src/components/Layouts/Primary/TopBar/Items/AddMenu/Items/CreateContact/CreateContact.tsx b/src/components/Layouts/Primary/TopBar/Items/AddMenu/Items/CreateContact/CreateContact.tsx index 4ee980e67..276bc9e05 100644 --- a/src/components/Layouts/Primary/TopBar/Items/AddMenu/Items/CreateContact/CreateContact.tsx +++ b/src/components/Layouts/Primary/TopBar/Items/AddMenu/Items/CreateContact/CreateContact.tsx @@ -59,7 +59,7 @@ const LoadingIndicator = styled(CircularProgress)(({ theme }) => ({ margin: theme.spacing(0, 1, 0, 0), })); -const contactSchema: yup.SchemaOf> = +const contactSchema: yup.ObjectSchema> = yup.object({ name: yup.string().required(), }); diff --git a/src/components/Layouts/Primary/TopBar/Items/AddMenu/Items/CreateMultipleContacts/CreateMultipleContacts.tsx b/src/components/Layouts/Primary/TopBar/Items/AddMenu/Items/CreateMultipleContacts/CreateMultipleContacts.tsx index 2c662831f..f0e0b923c 100644 --- a/src/components/Layouts/Primary/TopBar/Items/AddMenu/Items/CreateMultipleContacts/CreateMultipleContacts.tsx +++ b/src/components/Layouts/Primary/TopBar/Items/AddMenu/Items/CreateMultipleContacts/CreateMultipleContacts.tsx @@ -86,29 +86,31 @@ interface ContactTable { contacts: ContactRow[]; } -const contactsSchema = yup.object().shape({ +const contactsSchema = yup.object({ contacts: yup.array().of( - yup.object().shape({ - firstName: yup.string(), - spouseName: yup.string(), - lastName: yup.string(), - address: yup.object({ - city: yup.string(), - country: yup.string(), - location: yup.string(), - metroArea: yup.string(), - postalCode: yup.string(), - region: yup.string(), - state: yup.string(), - street: yup.string(), - }), - phone: yup.string(), - email: yup.string(), - status: yup - .mixed() - .oneOf([...Object.values(StatusEnum), null]) - .nullable(), - }), + yup + .object({ + firstName: yup.string(), + spouseName: yup.string(), + lastName: yup.string(), + address: yup.object({ + city: yup.string(), + country: yup.string(), + location: yup.string(), + metroArea: yup.string(), + postalCode: yup.string(), + region: yup.string(), + state: yup.string(), + street: yup.string(), + }), + phone: yup.string(), + email: yup.string(), + status: yup + .mixed() + .oneOf(Object.values(StatusEnum)) + .nullable(), + }) + .required(), ), }); diff --git a/src/components/Settings/Accounts/InviteForm/InviteForm.tsx b/src/components/Settings/Accounts/InviteForm/InviteForm.tsx index 433256100..99809f8a5 100644 --- a/src/components/Settings/Accounts/InviteForm/InviteForm.tsx +++ b/src/components/Settings/Accounts/InviteForm/InviteForm.tsx @@ -32,7 +32,7 @@ type FormikSchema = { email: string; }; -const formikSchema: yup.SchemaOf = yup.object({ +const formikSchema: yup.ObjectSchema = yup.object({ email: yup.string().email().required(), }); diff --git a/src/components/Settings/Accounts/MergeForm/MergeForm.tsx b/src/components/Settings/Accounts/MergeForm/MergeForm.tsx index 7a86acb0a..c2d516d19 100644 --- a/src/components/Settings/Accounts/MergeForm/MergeForm.tsx +++ b/src/components/Settings/Accounts/MergeForm/MergeForm.tsx @@ -47,7 +47,7 @@ type FormikSchema = { accept: boolean; }; -const formikSchema: yup.SchemaOf = yup.object({ +const formikSchema: yup.ObjectSchema = yup.object({ selectedAccountId: yup.string().required(), accept: yup.boolean().oneOf([true], 'Field must be checked').required(), }); diff --git a/src/components/Settings/Admin/ImpersonateUser/ImpersonateUserAccordion.tsx b/src/components/Settings/Admin/ImpersonateUser/ImpersonateUserAccordion.tsx index 48e248fe8..fdfa96221 100644 --- a/src/components/Settings/Admin/ImpersonateUser/ImpersonateUserAccordion.tsx +++ b/src/components/Settings/Admin/ImpersonateUser/ImpersonateUserAccordion.tsx @@ -29,12 +29,11 @@ type ImpersonateUserFormType = { reason: string; }; -const ImpersonateUserSchema: yup.SchemaOf = yup.object( - { +const ImpersonateUserSchema: yup.ObjectSchema = + yup.object({ user: yup.string().email().required(), reason: yup.string().required(), - }, -); + }); export const ImpersonateUserAccordion: React.FC = ({ handleAccordionChange, diff --git a/src/components/Settings/Admin/ResetAccount/ResetAccountAccordion.tsx b/src/components/Settings/Admin/ResetAccount/ResetAccountAccordion.tsx index 415dd6bdf..22cf66739 100644 --- a/src/components/Settings/Admin/ResetAccount/ResetAccountAccordion.tsx +++ b/src/components/Settings/Admin/ResetAccount/ResetAccountAccordion.tsx @@ -28,13 +28,12 @@ type ImpersonateUserFormType = { reason?: string; }; -const ImpersonateUserSchema: yup.SchemaOf = yup.object( - { +const ImpersonateUserSchema: yup.ObjectSchema = + yup.object({ user: yup.string().email().required(), account: yup.string().required(), reason: yup.string(), - }, -); + }); export const ResetAccountAccordion: React.FC = ({ handleAccordionChange, diff --git a/src/components/Settings/Organization/ImpersonateUser/ImpersonateUserAccordion.tsx b/src/components/Settings/Organization/ImpersonateUser/ImpersonateUserAccordion.tsx index f24577325..7462803a5 100644 --- a/src/components/Settings/Organization/ImpersonateUser/ImpersonateUserAccordion.tsx +++ b/src/components/Settings/Organization/ImpersonateUser/ImpersonateUserAccordion.tsx @@ -33,12 +33,11 @@ type ImpersonateUserFormType = { reason: string; }; -const impersonateUserSchema: yup.SchemaOf = yup.object( - { +const impersonateUserSchema: yup.ObjectSchema = + yup.object({ user: yup.string().email().required(), reason: yup.string().required(), - }, -); + }); export const ImpersonateUserAccordion: React.FC = ({ handleAccordionChange, diff --git a/src/components/Settings/Organization/ManageOrganizationAccess/ManageOrganizationAccessAccordion.tsx b/src/components/Settings/Organization/ManageOrganizationAccess/ManageOrganizationAccessAccordion.tsx index d8f0d303a..a131984ea 100644 --- a/src/components/Settings/Organization/ManageOrganizationAccess/ManageOrganizationAccessAccordion.tsx +++ b/src/components/Settings/Organization/ManageOrganizationAccess/ManageOrganizationAccessAccordion.tsx @@ -61,11 +61,10 @@ type ImpersonateUserFormType = { username: string; }; -const impersonateUserSchema: yup.SchemaOf = yup.object( - { +const impersonateUserSchema: yup.ObjectSchema = + yup.object({ username: yup.string().email().required(), - }, -); + }); export const ManageOrganizationAccessAccordion: React.FC = ({ handleAccordionChange, diff --git a/src/components/Settings/integrations/Mailchimp/MailchimpAccordion.tsx b/src/components/Settings/integrations/Mailchimp/MailchimpAccordion.tsx index 099658ac3..8af5ca364 100644 --- a/src/components/Settings/integrations/Mailchimp/MailchimpAccordion.tsx +++ b/src/components/Settings/integrations/Mailchimp/MailchimpAccordion.tsx @@ -41,7 +41,7 @@ import { } from './MailchimpAccount.generated'; import { DeleteMailchimpAccountModal } from './Modals/DeleteMailchimpModal'; -const mailchimpSchema: yup.SchemaOf< +const mailchimpSchema: yup.ObjectSchema< Pick > = yup.object({ autoLogCampaigns: yup.boolean().required(), diff --git a/src/components/Settings/integrations/Organization/Modals/OrganizationEditAccountModal.tsx b/src/components/Settings/integrations/Organization/Modals/OrganizationEditAccountModal.tsx index ac35cbecf..6dd30f107 100644 --- a/src/components/Settings/integrations/Organization/Modals/OrganizationEditAccountModal.tsx +++ b/src/components/Settings/integrations/Organization/Modals/OrganizationEditAccountModal.tsx @@ -68,7 +68,7 @@ export const OrganizationEditAccountModal: React.FC< return; }; - const OrganizationSchema: yup.SchemaOf< + const OrganizationSchema: yup.ObjectSchema< Omit > = yup.object({ username: yup.string().required(), diff --git a/src/components/Settings/integrations/Organization/schema.ts b/src/components/Settings/integrations/Organization/schema.ts index 8fb964693..bb67fe540 100644 --- a/src/components/Settings/integrations/Organization/schema.ts +++ b/src/components/Settings/integrations/Organization/schema.ts @@ -19,7 +19,7 @@ export type OrganizationFormikSchema = { password: string | undefined; }; -export const OrganizationSchema: yup.SchemaOf = +export const OrganizationSchema: yup.ObjectSchema = yup.object({ selectedOrganization: yup .object({ @@ -31,26 +31,16 @@ export const OrganizationSchema: yup.SchemaOf = disableNewUsers: yup.boolean().nullable(), }) .required(), - username: yup - .string() - .when('selectedOrganization', (organization, schema) => { - if ( - getOrganizationType(organization?.apiClass, organization?.oauth) === - OrganizationTypesEnum.LOGIN - ) { - return schema.required('Must enter username'); - } - return schema; - }), - password: yup - .string() - .when('selectedOrganization', (organization, schema) => { - if ( - getOrganizationType(organization?.apiClass, organization?.oauth) === - OrganizationTypesEnum.LOGIN - ) { - return schema.required('Must enter password'); - } - return schema; - }), + username: yup.string().when('selectedOrganization', { + is: (organization: OrganizationFormikSchema['selectedOrganization']) => + getOrganizationType(organization?.apiClass, organization?.oauth) === + OrganizationTypesEnum.LOGIN, + then: (schema) => schema.required('Must enter username'), + }), + password: yup.string().when('selectedOrganization', { + is: (organization: OrganizationFormikSchema['selectedOrganization']) => + getOrganizationType(organization?.apiClass, organization?.oauth) === + OrganizationTypesEnum.LOGIN, + then: (schema) => schema.required('Must enter password'), + }), }); diff --git a/src/components/Settings/notifications/NotificationsTable.tsx b/src/components/Settings/notifications/NotificationsTable.tsx index 32470a542..408dc03a8 100644 --- a/src/components/Settings/notifications/NotificationsTable.tsx +++ b/src/components/Settings/notifications/NotificationsTable.tsx @@ -53,24 +53,29 @@ type NotificationPreference = Pick< >; }; -const notificationSchema: yup.SchemaOf<{ +const notificationSchema: yup.ObjectSchema<{ notifications: NotificationPreference[]; }> = yup.object({ - notifications: yup.array( - yup.object({ - app: yup.boolean().required(), - email: yup.boolean().required(), - task: yup.boolean().required(), - notificationType: yup.object({ - id: yup.string().required(), - descriptionTemplate: yup.string().required(), - type: yup - .mixed() - .oneOf(Object.values(NotificationTypeTypeEnum)) - .required(), - }), - }), - ), + notifications: yup + .array() + .of( + yup + .object({ + app: yup.boolean().required(), + email: yup.boolean().required(), + task: yup.boolean().required(), + notificationType: yup.object({ + id: yup.string().required(), + descriptionTemplate: yup.string().required(), + type: yup + .mixed() + .oneOf(Object.values(NotificationTypeTypeEnum)) + .required(), + }), + }) + .required(), + ) + .required(), }); interface NotificationsTableProps { diff --git a/src/components/Settings/preferences/accordions/AccountNameAccordion/AccountNameAccordion.tsx b/src/components/Settings/preferences/accordions/AccountNameAccordion/AccountNameAccordion.tsx index 33d1ab8fb..76c3b0fa9 100644 --- a/src/components/Settings/preferences/accordions/AccountNameAccordion/AccountNameAccordion.tsx +++ b/src/components/Settings/preferences/accordions/AccountNameAccordion/AccountNameAccordion.tsx @@ -11,7 +11,7 @@ import { AccountList } from 'src/graphql/types.generated'; import useGetAppSettings from 'src/hooks/useGetAppSettings'; import { useUpdateAccountPreferencesMutation } from '../UpdateAccountPreferences.generated'; -const accountPreferencesSchema: yup.SchemaOf> = +const accountPreferencesSchema: yup.ObjectSchema> = yup.object({ name: yup.string().required(), }); diff --git a/src/components/Settings/preferences/accordions/CurrencyAccordion/CurrencyAccordion.tsx b/src/components/Settings/preferences/accordions/CurrencyAccordion/CurrencyAccordion.tsx index 488e0233c..f6c57ad58 100644 --- a/src/components/Settings/preferences/accordions/CurrencyAccordion/CurrencyAccordion.tsx +++ b/src/components/Settings/preferences/accordions/CurrencyAccordion/CurrencyAccordion.tsx @@ -11,7 +11,7 @@ import { FormWrapper } from 'src/components/Shared/Forms/FormWrapper'; import { AccountListSettingsInput } from 'src/graphql/types.generated'; import { useUpdateAccountPreferencesMutation } from '../UpdateAccountPreferences.generated'; -const preferencesSchema: yup.SchemaOf< +const preferencesSchema: yup.ObjectSchema< Pick > = yup.object({ currency: yup.string().required(), diff --git a/src/components/Settings/preferences/accordions/DefaultAccountAccordion/DefaultAccountAccordion.tsx b/src/components/Settings/preferences/accordions/DefaultAccountAccordion/DefaultAccountAccordion.tsx index 8d87eef24..01626681e 100644 --- a/src/components/Settings/preferences/accordions/DefaultAccountAccordion/DefaultAccountAccordion.tsx +++ b/src/components/Settings/preferences/accordions/DefaultAccountAccordion/DefaultAccountAccordion.tsx @@ -21,7 +21,7 @@ interface DefaultAccountAccordionProps { disabled?: boolean; } -const preferencesSchema: yup.SchemaOf> = +const preferencesSchema: yup.ObjectSchema> = yup.object({ defaultAccountList: yup.string().required(), }); diff --git a/src/components/Settings/preferences/accordions/EarlyAdopterAccordion/EarlyAdopterAccordion.tsx b/src/components/Settings/preferences/accordions/EarlyAdopterAccordion/EarlyAdopterAccordion.tsx index 89f3721df..5f565d6f1 100644 --- a/src/components/Settings/preferences/accordions/EarlyAdopterAccordion/EarlyAdopterAccordion.tsx +++ b/src/components/Settings/preferences/accordions/EarlyAdopterAccordion/EarlyAdopterAccordion.tsx @@ -11,7 +11,7 @@ import { AccountListSettingsInput } from 'src/graphql/types.generated'; import useGetAppSettings from 'src/hooks/useGetAppSettings'; import { useUpdateAccountPreferencesMutation } from '../UpdateAccountPreferences.generated'; -const accountPreferencesSchema: yup.SchemaOf< +const accountPreferencesSchema: yup.ObjectSchema< Pick > = yup.object({ tester: yup.boolean().required(), diff --git a/src/components/Settings/preferences/accordions/HomeCountryAccordion/HomeCountryAccordion.tsx b/src/components/Settings/preferences/accordions/HomeCountryAccordion/HomeCountryAccordion.tsx index 2d54b38bd..3e8f5f805 100644 --- a/src/components/Settings/preferences/accordions/HomeCountryAccordion/HomeCountryAccordion.tsx +++ b/src/components/Settings/preferences/accordions/HomeCountryAccordion/HomeCountryAccordion.tsx @@ -10,7 +10,7 @@ import { FormWrapper } from 'src/components/Shared/Forms/FormWrapper'; import { AccountListSettingsInput } from 'src/graphql/types.generated'; import { useUpdateAccountPreferencesMutation } from '../UpdateAccountPreferences.generated'; -const preferencesSchema: yup.SchemaOf< +const preferencesSchema: yup.ObjectSchema< Pick > = yup.object({ homeCountry: yup.string(), diff --git a/src/components/Settings/preferences/accordions/HourToSendNotificationsAccordion/HourToSendNotificationsAccordion.tsx b/src/components/Settings/preferences/accordions/HourToSendNotificationsAccordion/HourToSendNotificationsAccordion.tsx index 5e634b0f6..599d0b4ec 100644 --- a/src/components/Settings/preferences/accordions/HourToSendNotificationsAccordion/HourToSendNotificationsAccordion.tsx +++ b/src/components/Settings/preferences/accordions/HourToSendNotificationsAccordion/HourToSendNotificationsAccordion.tsx @@ -12,7 +12,7 @@ import { Preference } from 'src/graphql/types.generated'; import useGetAppSettings from 'src/hooks/useGetAppSettings'; import { useUpdatePersonalPreferencesMutation } from '../UpdatePersonalPreferences.generated'; -const preferencesSchema: yup.SchemaOf< +const preferencesSchema: yup.ObjectSchema< Pick > = yup.object({ hourToSendNotifications: yup.number().default(null).nullable(), diff --git a/src/components/Settings/preferences/accordions/LanguageAccordion/LanguageAccordion.tsx b/src/components/Settings/preferences/accordions/LanguageAccordion/LanguageAccordion.tsx index a9c1b48e2..cc5089c50 100644 --- a/src/components/Settings/preferences/accordions/LanguageAccordion/LanguageAccordion.tsx +++ b/src/components/Settings/preferences/accordions/LanguageAccordion/LanguageAccordion.tsx @@ -12,9 +12,10 @@ import useGetAppSettings from 'src/hooks/useGetAppSettings'; import { formatLanguage, languages } from 'src/lib/data/languages'; import { useUpdatePersonalPreferencesMutation } from '../UpdatePersonalPreferences.generated'; -const preferencesSchema: yup.SchemaOf> = yup.object({ - locale: yup.string().required(), -}); +const preferencesSchema: yup.ObjectSchema> = + yup.object({ + locale: yup.string().required(), + }); interface LanguageAccordionProps { handleAccordionChange: (panel: string) => void; diff --git a/src/components/Settings/preferences/accordions/LocaleAccordion/LocaleAccordion.tsx b/src/components/Settings/preferences/accordions/LocaleAccordion/LocaleAccordion.tsx index eee84b963..ebe1858d1 100644 --- a/src/components/Settings/preferences/accordions/LocaleAccordion/LocaleAccordion.tsx +++ b/src/components/Settings/preferences/accordions/LocaleAccordion/LocaleAccordion.tsx @@ -11,7 +11,7 @@ import { FormWrapper } from 'src/components/Shared/Forms/FormWrapper'; import { Preference } from 'src/graphql/types.generated'; import { useUpdatePersonalPreferencesMutation } from '../UpdatePersonalPreferences.generated'; -const preferencesSchema: yup.SchemaOf> = +const preferencesSchema: yup.ObjectSchema> = yup.object({ localeDisplay: yup.string().required(), }); diff --git a/src/components/Settings/preferences/accordions/MonthlyGoalAccordion/MonthlyGoalAccordion.tsx b/src/components/Settings/preferences/accordions/MonthlyGoalAccordion/MonthlyGoalAccordion.tsx index b944ed92e..1f0d76d7a 100644 --- a/src/components/Settings/preferences/accordions/MonthlyGoalAccordion/MonthlyGoalAccordion.tsx +++ b/src/components/Settings/preferences/accordions/MonthlyGoalAccordion/MonthlyGoalAccordion.tsx @@ -12,7 +12,7 @@ import { useLocale } from 'src/hooks/useLocale'; import { currencyFormat } from 'src/lib/intlFormat'; import { useUpdateAccountPreferencesMutation } from '../UpdateAccountPreferences.generated'; -const accountPreferencesSchema: yup.SchemaOf< +const accountPreferencesSchema: yup.ObjectSchema< Pick > = yup.object({ monthlyGoal: yup.number().required(), diff --git a/src/components/Settings/preferences/accordions/PrimaryOrgAccordion/PrimaryOrgAccordion.tsx b/src/components/Settings/preferences/accordions/PrimaryOrgAccordion/PrimaryOrgAccordion.tsx index 405b16c81..fd613fc58 100644 --- a/src/components/Settings/preferences/accordions/PrimaryOrgAccordion/PrimaryOrgAccordion.tsx +++ b/src/components/Settings/preferences/accordions/PrimaryOrgAccordion/PrimaryOrgAccordion.tsx @@ -11,7 +11,7 @@ import { FormWrapper } from 'src/components/Shared/Forms/FormWrapper'; import { AccountList } from 'src/graphql/types.generated'; import { useUpdateAccountPreferencesMutation } from '../UpdateAccountPreferences.generated'; -const preferencesSchema: yup.SchemaOf< +const preferencesSchema: yup.ObjectSchema< Pick > = yup.object({ salaryOrganizationId: yup.string().required(), diff --git a/src/components/Settings/preferences/accordions/TimeZoneAccordion/TimeZoneAccordion.tsx b/src/components/Settings/preferences/accordions/TimeZoneAccordion/TimeZoneAccordion.tsx index 9d44f4348..2a0331a68 100644 --- a/src/components/Settings/preferences/accordions/TimeZoneAccordion/TimeZoneAccordion.tsx +++ b/src/components/Settings/preferences/accordions/TimeZoneAccordion/TimeZoneAccordion.tsx @@ -10,7 +10,7 @@ import { FormWrapper } from 'src/components/Shared/Forms/FormWrapper'; import { Preference } from 'src/graphql/types.generated'; import { useUpdatePersonalPreferencesMutation } from '../UpdatePersonalPreferences.generated'; -const preferencesSchema: yup.SchemaOf> = +const preferencesSchema: yup.ObjectSchema> = yup.object({ timeZone: yup.string().required(), }); diff --git a/src/components/Task/MassActions/AddTags/MassActionsTasksAddTagsModal.tsx b/src/components/Task/MassActions/AddTags/MassActionsTasksAddTagsModal.tsx index 81b6798fd..67d76aff2 100644 --- a/src/components/Task/MassActions/AddTags/MassActionsTasksAddTagsModal.tsx +++ b/src/components/Task/MassActions/AddTags/MassActionsTasksAddTagsModal.tsx @@ -54,7 +54,7 @@ const AddTagIcon = styled(Add)(() => ({ })); const tagSchema = yup.object({ - tagList: yup.array().of(yup.string()).default([]).nullable(), + tagList: yup.array().of(yup.string().required()).default([]).nullable(), }); export const MassActionsTasksAddTagsModal: React.FC< diff --git a/src/components/Task/MassActions/EditTasks/MassActionsEditTasksModal.tsx b/src/components/Task/MassActions/EditTasks/MassActionsEditTasksModal.tsx index db8400a5f..c7da4f3a9 100644 --- a/src/components/Task/MassActions/EditTasks/MassActionsEditTasksModal.tsx +++ b/src/components/Task/MassActions/EditTasks/MassActionsEditTasksModal.tsx @@ -41,8 +41,8 @@ const massActionsEditTasksSchema = yup.object({ .mixed() .nullable() .when('taskPhase', { - is: (value: any) => !!value, - then: yup.mixed().required('Must select a Task Action'), + is: (value: PhaseEnum | null | undefined) => !!value, + then: (schema) => schema.required('Must select a Task Action'), }), userId: yup.string().nullable(), startAt: nullableDateTime(), diff --git a/src/components/Task/MassActions/RemoveTags/MassActionsTasksRemoveTagsModal.tsx b/src/components/Task/MassActions/RemoveTags/MassActionsTasksRemoveTagsModal.tsx index e5222110a..32335d09e 100644 --- a/src/components/Task/MassActions/RemoveTags/MassActionsTasksRemoveTagsModal.tsx +++ b/src/components/Task/MassActions/RemoveTags/MassActionsTasksRemoveTagsModal.tsx @@ -56,7 +56,7 @@ const RemoveTagIcon = styled(Remove)(() => ({ })); const tagSchema = yup.object({ - tagList: yup.array().of(yup.string()).default([]).nullable(), + tagList: yup.array().of(yup.string().required()).default([]).nullable(), }); export const MassActionsTasksRemoveTagsModal: React.FC< diff --git a/src/components/Task/Modal/Form/LogForm/TaskModalLogForm.test.tsx b/src/components/Task/Modal/Form/LogForm/TaskModalLogForm.test.tsx index 44610d138..0ebde17aa 100644 --- a/src/components/Task/Modal/Form/LogForm/TaskModalLogForm.test.tsx +++ b/src/components/Task/Modal/Form/LogForm/TaskModalLogForm.test.tsx @@ -182,7 +182,9 @@ describe('TaskModalLogForm', () => { expect(getByLabelText('Tags')).toBeInTheDocument(); expect(getByLabelText('Assignee')).toBeInTheDocument(); - userEvent.click(getByText('Save')); + const saveButton = getByText('Save'); + await waitFor(() => expect(saveButton).not.toBeDisabled()); + userEvent.click(saveButton); await waitFor(() => expect(onClose).toHaveBeenCalled()); }, 25000); diff --git a/src/components/Task/Modal/Form/LogForm/TaskModalLogForm.tsx b/src/components/Task/Modal/Form/LogForm/TaskModalLogForm.tsx index 20cbbbf25..a199e2497 100644 --- a/src/components/Task/Modal/Form/LogForm/TaskModalLogForm.tsx +++ b/src/components/Task/Modal/Form/LogForm/TaskModalLogForm.tsx @@ -75,10 +75,10 @@ const taskSchema = yup.object({ taskPhase: yup.mixed().required(), activityType: yup.mixed().required(), subject: yup.string().required(), - contactIds: yup.array().of(yup.string()).default([]), + contactIds: yup.array().of(yup.string().required()).default([]), completedAt: nullableDateTime(), userId: yup.string().nullable(), - tagList: yup.array().of(yup.string()).default([]), + tagList: yup.array().of(yup.string().required()).default([]), displayResult: yup.mixed().nullable(), result: yup.mixed().nullable(), changeContactStatus: yup.boolean(), diff --git a/src/components/Tool/Appeal/InitialPage/AddAppealForm/AddAppealForm.tsx b/src/components/Tool/Appeal/InitialPage/AddAppealForm/AddAppealForm.tsx index bb60acd46..7a07f3b24 100644 --- a/src/components/Tool/Appeal/InitialPage/AddAppealForm/AddAppealForm.tsx +++ b/src/components/Tool/Appeal/InitialPage/AddAppealForm/AddAppealForm.tsx @@ -188,17 +188,21 @@ const appealFormSchema = yup.object({ (value) => parseFloat(value as unknown as string) >= 0, ), statuses: yup.array().of( - yup.object({ - name: yup.string(), - value: yup.string(), - }), + yup + .object({ + name: yup.string(), + value: yup.string(), + }) + .required(), ), - tags: yup.array().of(yup.string()), + tags: yup.array().of(yup.string().required()), exclusions: yup.array().of( - yup.object({ - name: yup.string(), - value: yup.string(), - }), + yup + .object({ + name: yup.string(), + value: yup.string(), + }) + .required(), ), }); type Attributes = yup.InferType; diff --git a/src/components/Tool/Appeal/Modals/AddContactToAppealModal/AddContactToAppealModal.tsx b/src/components/Tool/Appeal/Modals/AddContactToAppealModal/AddContactToAppealModal.tsx index c5b7e8270..5f9a7568e 100644 --- a/src/components/Tool/Appeal/Modals/AddContactToAppealModal/AddContactToAppealModal.tsx +++ b/src/components/Tool/Appeal/Modals/AddContactToAppealModal/AddContactToAppealModal.tsx @@ -26,7 +26,7 @@ interface AddContactFormikSchema { contactIds: string[]; } -const AddContactSchema: yup.SchemaOf = yup.object({ +const AddContactSchema: yup.ObjectSchema = yup.object({ contactIds: yup.array().of(yup.string().required()).default([]), }); diff --git a/src/components/Tool/Appeal/Modals/EditAppealHeaderInfoModal/EditAppealHeaderInfoModal.tsx b/src/components/Tool/Appeal/Modals/EditAppealHeaderInfoModal/EditAppealHeaderInfoModal.tsx index fbec871b7..af2bdc869 100644 --- a/src/components/Tool/Appeal/Modals/EditAppealHeaderInfoModal/EditAppealHeaderInfoModal.tsx +++ b/src/components/Tool/Appeal/Modals/EditAppealHeaderInfoModal/EditAppealHeaderInfoModal.tsx @@ -31,7 +31,7 @@ export type EditAppealFormikSchema = { amount: number; }; -const EditAppealSchema: yup.SchemaOf = yup.object({ +const EditAppealSchema: yup.ObjectSchema = yup.object({ name: yup.string().required(i18n.t('Please enter a name')), amount: yup .number() diff --git a/src/components/Tool/FixPhoneNumbers/Contact.test.tsx b/src/components/Tool/FixPhoneNumbers/Contact.test.tsx index f3711142b..f37e26ba1 100644 --- a/src/components/Tool/FixPhoneNumbers/Contact.test.tsx +++ b/src/components/Tool/FixPhoneNumbers/Contact.test.tsx @@ -195,9 +195,7 @@ describe('Fix PhoneNumber Contact', () => { const addButton = getByTestId('addButton-contactTestId'); expect(addButton).toBeDisabled(); - expect( - await findByText('This field is not a valid phone number'), - ).toBeVisible(); + expect(await findByText('This field is required')).toBeVisible(); }); it('should show an error message if there is an invalid number', async () => { @@ -327,10 +325,7 @@ describe('Fix PhoneNumber Contact', () => { const { getByTestId, getAllByTestId } = render(); const textInput = getByTestId('textfield-contactTestId-number2'); userEvent.clear(textInput); - expect(textInput).toHaveValue(''); - userEvent.type(textInput, 'p'); - expect(textInput).toHaveValue('p'); - userEvent.click(textInput); + userEvent.type(textInput, 'pq'); await waitFor(() => { expect(getAllByTestId('statusSelectError')[1]).toHaveTextContent( diff --git a/src/components/Tool/GoogleImport/GoogleImport.tsx b/src/components/Tool/GoogleImport/GoogleImport.tsx index 725bc25c9..13aa15528 100644 --- a/src/components/Tool/GoogleImport/GoogleImport.tsx +++ b/src/components/Tool/GoogleImport/GoogleImport.tsx @@ -79,11 +79,13 @@ const Section = styled(Box)(({ theme }) => ({ })); const googleImportSchema = yup.object({ - tagsForAllList: yup.array().of(yup.string()).default([]), + tagsForAllList: yup.array().of(yup.string().required()).default([]), override: yup.string(), importByGroup: yup.string(), - groupTags: yup.object(), - groups: yup.array().of(yup.string()).default([]), + // Override the inferred type of this field because yup does not yet have a record type where keys + // can be any string + groupTags: yup.object() as yup.ObjectSchema>, + groups: yup.array().of(yup.string().required()).default([]), }); type Attributes = yup.InferType; diff --git a/src/components/Tool/TntConnect/TntConnect.tsx b/src/components/Tool/TntConnect/TntConnect.tsx index 47e16bde3..9f2eef91b 100644 --- a/src/components/Tool/TntConnect/TntConnect.tsx +++ b/src/components/Tool/TntConnect/TntConnect.tsx @@ -83,7 +83,7 @@ const useStyles = makeStyles()(() => ({ })); const tntSchema = yup.object({ - selectedTags: yup.array().of(yup.string()).default([]), + selectedTags: yup.array().of(yup.string().required()).default([]), override: yup.string().required(), }); diff --git a/yarn.lock b/yarn.lock index f868ae549..edc8ef16c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2008,7 +2008,7 @@ __metadata: languageName: node linkType: hard -"@babel/runtime@npm:^7.0.0, @babel/runtime@npm:^7.1.2, @babel/runtime@npm:^7.10.2, @babel/runtime@npm:^7.11.2, @babel/runtime@npm:^7.12.5, @babel/runtime@npm:^7.14.5, @babel/runtime@npm:^7.15.4, @babel/runtime@npm:^7.18.3, @babel/runtime@npm:^7.18.9, @babel/runtime@npm:^7.3.1, @babel/runtime@npm:^7.5.5, @babel/runtime@npm:^7.7.2, @babel/runtime@npm:^7.8.3, @babel/runtime@npm:^7.8.4, @babel/runtime@npm:^7.8.7, @babel/runtime@npm:^7.9.2": +"@babel/runtime@npm:^7.0.0, @babel/runtime@npm:^7.1.2, @babel/runtime@npm:^7.10.2, @babel/runtime@npm:^7.11.2, @babel/runtime@npm:^7.12.5, @babel/runtime@npm:^7.14.5, @babel/runtime@npm:^7.18.3, @babel/runtime@npm:^7.18.9, @babel/runtime@npm:^7.3.1, @babel/runtime@npm:^7.5.5, @babel/runtime@npm:^7.7.2, @babel/runtime@npm:^7.8.3, @babel/runtime@npm:^7.8.4, @babel/runtime@npm:^7.8.7, @babel/runtime@npm:^7.9.2": version: 7.18.9 resolution: "@babel/runtime@npm:7.18.9" dependencies: @@ -5964,13 +5964,6 @@ __metadata: languageName: node linkType: hard -"@types/lodash@npm:^4.14.175": - version: 4.14.184 - resolution: "@types/lodash@npm:4.14.184" - checksum: 6d9a4d67f7f9d0ec3fd21174f3dd3d00629dc1227eb469450eace53adbc1f7e2330699c28d0fe093e5f0fef0f0e763098be1f779268857213224af082b62be21 - languageName: node - linkType: hard - "@types/lodash@npm:^4.14.191": version: 4.14.191 resolution: "@types/lodash@npm:4.14.191" @@ -15157,7 +15150,7 @@ __metadata: url-loader: ^4.1.1 uuid: ^9.0.0 webpack: ^5.96.1 - yup: ^0.32.11 + yup: ^1.4.0 languageName: unknown linkType: soft @@ -15235,13 +15228,6 @@ __metadata: languageName: node linkType: hard -"nanoclone@npm:^0.2.1": - version: 0.2.1 - resolution: "nanoclone@npm:0.2.1" - checksum: 96b2954e22f70561f41e20d69856266c65583c2a441dae108f1dc71b716785d2c8038dac5f1d5e92b117aed3825f526b53139e2e5d6e6db8a77cfa35b3b8bf40 - languageName: node - linkType: hard - "nanoid@npm:^3.3.4": version: 3.3.4 resolution: "nanoid@npm:3.3.4" @@ -16638,10 +16624,10 @@ __metadata: languageName: node linkType: hard -"property-expr@npm:^2.0.4": - version: 2.0.5 - resolution: "property-expr@npm:2.0.5" - checksum: 4ebe82ce45aaf1527e96e2ab84d75d25217167ec3ff6378cf83a84fb4abc746e7c65768a79d275881602ae82f168f9a6dfaa7f5e331d0fcc83d692770bcce5f1 +"property-expr@npm:^2.0.5": + version: 2.0.6 + resolution: "property-expr@npm:2.0.6" + checksum: 89977f4bb230736c1876f460dd7ca9328034502fd92e738deb40516d16564b850c0bbc4e052c3df88b5b8cd58e51c93b46a94bea049a3f23f4a022c038864cab languageName: node linkType: hard @@ -19213,6 +19199,13 @@ __metadata: languageName: node linkType: hard +"tiny-case@npm:^1.0.3": + version: 1.0.3 + resolution: "tiny-case@npm:1.0.3" + checksum: 3f7a30c39d5b0e1bc097b0b271bec14eb5b836093db034f35a0de26c14422380b50dc12bfd37498cf35b192f5df06f28a710712c87ead68872a9e37ad6f6049d + languageName: node + linkType: hard + "tiny-invariant@npm:^1.1.0": version: 1.2.0 resolution: "tiny-invariant@npm:1.2.0" @@ -19638,6 +19631,13 @@ __metadata: languageName: node linkType: hard +"type-fest@npm:^2.19.0": + version: 2.19.0 + resolution: "type-fest@npm:2.19.0" + checksum: a4ef07ece297c9fba78fc1bd6d85dff4472fe043ede98bd4710d2615d15776902b595abf62bd78339ed6278f021235fb28a96361f8be86ed754f778973a0d278 + languageName: node + linkType: hard + "type-is@npm:^1.6.18, type-is@npm:~1.6.18": version: 1.6.18 resolution: "type-is@npm:1.6.18" @@ -20975,18 +20975,15 @@ __metadata: languageName: node linkType: hard -"yup@npm:^0.32.11": - version: 0.32.11 - resolution: "yup@npm:0.32.11" +"yup@npm:^1.4.0": + version: 1.4.0 + resolution: "yup@npm:1.4.0" dependencies: - "@babel/runtime": ^7.15.4 - "@types/lodash": ^4.14.175 - lodash: ^4.17.21 - lodash-es: ^4.17.21 - nanoclone: ^0.2.1 - property-expr: ^2.0.4 + property-expr: ^2.0.5 + tiny-case: ^1.0.3 toposort: ^2.0.2 - checksum: 43a16786b47cc910fed4891cebdd89df6d6e31702e9462e8f969c73eac88551ce750732608012201ea6b93802c8847cb0aa27b5d57370640f4ecf30f9f97d4b0 + type-fest: ^2.19.0 + checksum: 20a2ee0c1e891979ca16b34805b3a3be9ab4bea6ea3d2f9005b998b4dc992d0e4d7b53e5f4d8d9423420046630fb44fdf0ecf7e83bc34dd83392bca046c5229d languageName: node linkType: hard