Skip to content

Commit

Permalink
Return eligiblilty reasons in response
Browse files Browse the repository at this point in the history
  • Loading branch information
dgcohen committed Dec 11, 2024
1 parent 7f8e542 commit ac55072
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 58 deletions.
108 changes: 52 additions & 56 deletions src/components/HoldPages/HoldRequestErrorBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,62 +58,58 @@ const HoldRequestErrorBanner = ({
},
}}
content={
<>
<Box>
{HOLD_PAGE_CONTACT_PREFIXES?.[errorStatus] ? (
<Text>
<>
{HOLD_PAGE_CONTACT_PREFIXES?.[errorStatus]}
{" Please try again, "}
<Button
id="hold-contact"
onClick={() =>
onContact({
id: item.id,
barcode: item.barcode,
callNumber: item.callNumber,
bibId: item.bibId,
notificationText: `Request failed for call number ${item.callNumber}`,
})
}
buttonType="link"
// TODO: Ask DS team to make button link variant match the default link styles
sx={{
display: "inline",
fontWeight: "inherit",
fontSize: "inherit",
p: 0,
height: "auto",
textAlign: "left",
minHeight: "auto",
textDecorationStyle: "dotted",
textDecorationThickness: "1px",
textUnderlineOffset: "2px",
}}
>
contact us
</Button>{" "}
for assistance, or{" "}
<RCLink href="/search">start a new search.</RCLink>
</>
</Text>
) : null}
{(() => {
switch (errorStatus) {
case "invalid":
return "Some fields contain errors. Please correct and submit again."
case "patronIneligible":
return patronEligibilityStatus ? (
<PatronErrors
patronEligibilityStatus={patronEligibilityStatus}
/>
) : null
default:
return null
}
})()}
</Box>
</>
<Box>
{HOLD_PAGE_CONTACT_PREFIXES?.[errorStatus] ? (
<Text>
{HOLD_PAGE_CONTACT_PREFIXES?.[errorStatus]}
{" Please try again, "}
<Button
id="hold-contact"
onClick={() =>
onContact({
id: item.id,
barcode: item.barcode,
callNumber: item.callNumber,
bibId: item.bibId,
notificationText: `Request failed for call number ${item.callNumber}`,
})
}
buttonType="link"
// TODO: Ask DS team to make button link variant match the default link styles
sx={{
display: "inline",
fontWeight: "inherit",
fontSize: "inherit",
p: 0,
height: "auto",
textAlign: "left",
minHeight: "auto",
textDecorationStyle: "dotted",
textDecorationThickness: "1px",
textUnderlineOffset: "2px",
}}
>
contact us
</Button>{" "}
for assistance, or{" "}
<RCLink href="/search">start a new search.</RCLink>
</Text>
) : null}
{(() => {
switch (errorStatus) {
case "invalid":
return "Some fields contain errors. Please correct and submit again."
case "patronIneligible":
return patronEligibilityStatus ? (
<PatronErrors
patronEligibilityStatus={patronEligibilityStatus}
/>
) : null
default:
return null
}
})()}
</Box>
}
mb="s"
/>
Expand Down
4 changes: 2 additions & 2 deletions src/server/api/hold.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,10 @@ export async function fetchPatronEligibility(
}

if (eligibilityResult.eligibility === false) {
return { status: 401 }
return { status: 401, ...eligibilityResult }
}

return { status: 200, ...eligibilityResult } as PatronEligibilityStatus
return { status: 200, ...eligibilityResult }
} catch (error) {
console.error(
`Error fetching hold request eligibility in fetchPatronEligibility server function, patronId: ${patronId}`,
Expand Down

0 comments on commit ac55072

Please sign in to comment.