From 8e58b1e204be97123996ba074e065a3a53f93149 Mon Sep 17 00:00:00 2001 From: Kasper Birch Date: Mon, 16 Sep 2024 15:49:07 +0200 Subject: [PATCH] Add checkbox for `receiveSms` when creating user To enable this functionality, I modified `showCheckboxes` in `ContactInfoSection` to accept an array of `"email" | "phone"`. This adjustment is necessary because the `receiveEmail` option is required when creating users. --- src/apps/create-patron-user-info/UserInfo.tsx | 3 ++- src/apps/patron-page/PatronPage.tsx | 2 +- src/apps/patron-page/PatronPageSkeleton.tsx | 2 +- .../contact-info-section/ContactInfoSection.tsx | 8 +++++--- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/apps/create-patron-user-info/UserInfo.tsx b/src/apps/create-patron-user-info/UserInfo.tsx index f2c32a6747..2da33a4d37 100644 --- a/src/apps/create-patron-user-info/UserInfo.tsx +++ b/src/apps/create-patron-user-info/UserInfo.tsx @@ -47,6 +47,7 @@ const UserInfo: FC = ({ cpr, registerSuccessCallback }) => { set(copyUser, key, newValue); setPatron(copyUser); }; + const handleSubmit = (e: FormEvent) => { e.preventDefault(); setIsLoading(true); @@ -80,7 +81,7 @@ const UserInfo: FC = ({ cpr, registerSuccessCallback }) => {
handleSubmit(e)} ref={formRef}> { changePatron={changePatron} patron={patron} inLine={false} - showCheckboxes + showCheckboxes={["email", "phone"]} /> )} {patron?.resident && } diff --git a/src/apps/patron-page/PatronPageSkeleton.tsx b/src/apps/patron-page/PatronPageSkeleton.tsx index 45a980d0f5..87800a65b9 100644 --- a/src/apps/patron-page/PatronPageSkeleton.tsx +++ b/src/apps/patron-page/PatronPageSkeleton.tsx @@ -17,7 +17,7 @@ const PatronPageSkeleton: React.FC = () => { changePatron={() => {}} patron={null} inLine={false} - showCheckboxes + showCheckboxes={["email", "phone"]} /> ); diff --git a/src/components/contact-info-section/ContactInfoSection.tsx b/src/components/contact-info-section/ContactInfoSection.tsx index 4e2627dc65..b36cc5604c 100644 --- a/src/components/contact-info-section/ContactInfoSection.tsx +++ b/src/components/contact-info-section/ContactInfoSection.tsx @@ -12,7 +12,7 @@ interface ContactInfoSectionProps { inLine?: boolean; isDouble?: boolean; changePatron: ChangePatronProps; - showCheckboxes: boolean; + showCheckboxes: ("email" | "phone")[]; requiredFields?: ("email" | "phone")[]; } @@ -43,7 +43,9 @@ const ContactInfoSection: FC = ({ changePatron={changePatron} patron={patron} isRequired={requiredFields.includes("phone")} - showCheckboxes={showCheckboxes && textNotificationsEnabledConfig} + showCheckboxes={ + showCheckboxes.includes("phone") && textNotificationsEnabledConfig + } /> = ({ changePatron={changePatron} patron={patron} isRequired={requiredFields.includes("email")} - showCheckboxes={showCheckboxes} + showCheckboxes={showCheckboxes.includes("email")} />