Skip to content

Commit

Permalink
Merge pull request #809 from danskernesdigitalebibliotek/fix/interest…
Browse files Browse the repository at this point in the history
…-period

Fix/interest period
  • Loading branch information
Adamik10 authored Jan 3, 2024
2 parents f4d75c2 + c771f0d commit befce1a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/components/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const Dropdown: React.FunctionComponent<DropdownProps> = ({
value={value}
className={classes.option}
disabled={disabled}
selected={value === defaultValue}
selected={value.toString() === defaultValue?.toString()}
>
{optionsLabel}
</option>
Expand Down
13 changes: 5 additions & 8 deletions src/components/reservation/UserListItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,7 @@ export interface UserListItemsProps {

const UserListItems: FC<UserListItemsProps> = ({
patron,
patron: {
defaultInterestPeriod,
preferredPickupBranch,
phoneNumber,
emailAddress
},
patron: { preferredPickupBranch, phoneNumber, emailAddress },
branches,
selectedBranch,
selectBranchHandler,
Expand Down Expand Up @@ -74,7 +69,7 @@ const UserListItems: FC<UserListItemsProps> = ({

return (
<>
{defaultInterestPeriod && (
{interestPeriods && (
<>
<ReservationFormListItem
icon={LoanHistoryIcon}
Expand All @@ -84,7 +79,9 @@ const UserListItems: FC<UserListItemsProps> = ({
buttonAriaLabel={t("changeInterestPeriodText")}
/>
<NoInterestAfterModal
selectedInterest={selectedInterest ?? defaultInterestPeriod}
selectedInterest={
selectedInterest ?? interestPeriods.defaultInterestPeriod.value
}
setSelectedInterest={setSelectedInterest}
/>
</>
Expand Down
2 changes: 1 addition & 1 deletion src/components/reservation/forms/NoInterestAfterModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/components/reservation/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit befce1a

Please sign in to comment.