Skip to content

Commit

Permalink
Add possibility for setting required fields in ContactInfoSection
Browse files Browse the repository at this point in the history
Since it should be possible to vary the required fields depending on the
context. In this case user creation vs user info form.
  • Loading branch information
spaceo committed Oct 18, 2023
1 parent 5ef6b0b commit f843c31
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/apps/create-patron-user-info/UserInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ const UserInfo: FC<UserInfoProps> = ({ cpr }) => {
inLine
changePatron={changePatron}
patron={patron}
requiredFields={["email"]}
/>
<PincodeSection required changePincode={setPin} />
{t("createPatronChangePickupHeaderText") && (
Expand Down
6 changes: 5 additions & 1 deletion src/components/contact-info-section/ContactInfoSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ interface ContactInfoSectionProps {
inLine: boolean;
changePatron: ChangePatronProps;
showCheckboxes: boolean;
requiredFields?: ("email" | "phone")[];
}

const ContactInfoSection: FC<ContactInfoSectionProps> = ({
patron,
inLine,
changePatron,
showCheckboxes
showCheckboxes,
requiredFields = []
}) => {
const t = useText();
const inputsClass = clsx("dpl-input", { input__desktop: inLine });
Expand All @@ -42,6 +44,7 @@ const ContactInfoSection: FC<ContactInfoSectionProps> = ({
className={inputsClass}
changePatron={changePatron}
patron={patron}
isRequired={requiredFields.includes("phone")}
showCheckboxes={showCheckboxes && textNotificationsEnabledConfig}
/>
<ContactInfoEmail
Expand All @@ -50,6 +53,7 @@ const ContactInfoSection: FC<ContactInfoSectionProps> = ({
})}
changePatron={changePatron}
patron={patron}
isRequired={requiredFields.includes("email")}
showCheckboxes={showCheckboxes}
/>
</ContactInfoInputs>
Expand Down

0 comments on commit f843c31

Please sign in to comment.