From f629c07ec9ddadc5f76297d72ef4f019a17a0f27 Mon Sep 17 00:00:00 2001 From: Adam Antal Date: Wed, 27 Dec 2023 14:12:10 +0100 Subject: [PATCH 1/3] Take default interest period from library config in UserListItems comp To be consistent all places, we use this default interest period. Plus default interest period on the patron isn't adjustable anywhere in the project. --- src/components/reservation/UserListItems.tsx | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/components/reservation/UserListItems.tsx b/src/components/reservation/UserListItems.tsx index 8ca023f373..21b27b85d8 100644 --- a/src/components/reservation/UserListItems.tsx +++ b/src/components/reservation/UserListItems.tsx @@ -36,12 +36,7 @@ export interface UserListItemsProps { const UserListItems: FC = ({ patron, - patron: { - defaultInterestPeriod, - preferredPickupBranch, - phoneNumber, - emailAddress - }, + patron: { preferredPickupBranch, phoneNumber, emailAddress }, branches, selectedBranch, selectBranchHandler, @@ -74,7 +69,7 @@ const UserListItems: FC = ({ return ( <> - {defaultInterestPeriod && ( + {interestPeriods && ( <> = ({ buttonAriaLabel={t("changeInterestPeriodText")} /> From 76e61b83ec3fe5b8022ec56020fa48380092c603 Mon Sep 17 00:00:00 2001 From: Adam Antal Date: Wed, 27 Dec 2023 14:14:38 +0100 Subject: [PATCH 2/3] Convert interest period values to strings before comparing them We were experiencing problems with default values in dropdowns, because when comparing two values, although they were same, they were not of the same type (string/number), which cause buggy behavior. --- src/components/Dropdown/Dropdown.tsx | 2 +- src/components/reservation/helper.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/Dropdown/Dropdown.tsx b/src/components/Dropdown/Dropdown.tsx index 7169be29e0..cebe7d04a8 100644 --- a/src/components/Dropdown/Dropdown.tsx +++ b/src/components/Dropdown/Dropdown.tsx @@ -71,7 +71,7 @@ const Dropdown: React.FunctionComponent = ({ value={value} className={classes.option} disabled={disabled} - selected={value === defaultValue} + selected={value.toString() === defaultValue?.toString()} > {optionsLabel} diff --git a/src/components/reservation/helper.ts b/src/components/reservation/helper.ts index b20c5a97a2..0afa820ff6 100644 --- a/src/components/reservation/helper.ts +++ b/src/components/reservation/helper.ts @@ -34,9 +34,9 @@ export const getNoInterestAfter = ( interestPeriod: Periods, t: UseTextFunction ) => { - const interestPeriodFound = interestPeriod.interestPeriods.find( - ({ value }) => value === String(days) - ); + const interestPeriodFound = interestPeriod.interestPeriods.find((period) => { + return period.value.toString() === days.toString(); + }); if (interestPeriodFound) { return interestPeriodFound.label; From c771f0d97f200ed8a993a3d54ab8173c354cb0f5 Mon Sep 17 00:00:00 2001 From: Adam Antal Date: Tue, 2 Jan 2024 13:01:29 +0100 Subject: [PATCH 3/3] Accept selectedInterest prop in PickupModal as string or number Because it is either one or the other. --- src/components/reservation/UserListItems.tsx | 3 +-- src/components/reservation/forms/NoInterestAfterModal.tsx | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/components/reservation/UserListItems.tsx b/src/components/reservation/UserListItems.tsx index 21b27b85d8..733e03393e 100644 --- a/src/components/reservation/UserListItems.tsx +++ b/src/components/reservation/UserListItems.tsx @@ -80,8 +80,7 @@ const UserListItems: FC = ({ /> diff --git a/src/components/reservation/forms/NoInterestAfterModal.tsx b/src/components/reservation/forms/NoInterestAfterModal.tsx index 2451f0be33..f63fa63d6a 100644 --- a/src/components/reservation/forms/NoInterestAfterModal.tsx +++ b/src/components/reservation/forms/NoInterestAfterModal.tsx @@ -6,7 +6,7 @@ import { RequestStatus } from "../../../core/utils/types/request"; import { Periods } from "../types"; export interface PickupModalProps { - selectedInterest: number; + selectedInterest: number | string; setSelectedInterest: (value: number) => void; saveCallback?: () => void; reservationStatus?: RequestStatus;