Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCC-3762 - Patron Eligibility Errors #415

Merged
merged 11 commits into from
Dec 17, 2024

Conversation

dgcohen
Copy link
Contributor

@dgcohen dgcohen commented Dec 10, 2024

Ticket:

This PR does the following:

  • Server function fetchPatronEligibility that fetches a patron's eligibility status from Discovery API
  • HoldRequestErrorBanner component responsible for showing the user request errors based on the request error status (including ineligibilty reasons).
  • Eligibility validation on the server side.

How has this been tested?

  • Unit tests

Accessibility concerns or updates

  • NA

Checklist:

  • I updated the CHANGELOG with the appropriate information and JIRA ticket number (if applicable).
  • I have added relevant accessibility documentation for this pull request.
  • All new and existing tests passed.

Copy link

vercel bot commented Dec 10, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
research-catalog ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 16, 2024 9:30pm

@dgcohen dgcohen changed the base branch from main to hold-pages December 10, 2024 16:35
@dgcohen dgcohen changed the title Scc 3762/patron eligibility errors SCC-3762 - Patron Eligibility Errors Dec 10, 2024
@dgcohen dgcohen requested review from EdwinGuzman and charmingduchess and removed request for EdwinGuzman December 11, 2024 14:47
@dgcohen dgcohen marked this pull request as ready for review December 11, 2024 14:47
@dgcohen dgcohen requested a review from EdwinGuzman December 11, 2024 14:47
Copy link
Member

@EdwinGuzman EdwinGuzman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor comments. Can you share a few test patron accounts to try to get all use cases locally? (this can be done on slack)

pages/api/hold/request/[id]/edd.ts Outdated Show resolved Hide resolved
pages/api/hold/request/[id]/index.ts Outdated Show resolved Hide resolved
pages/hold/request/[id]/edd.tsx Outdated Show resolved Hide resolved
pages/hold/request/[id]/index.tsx Outdated Show resolved Hide resolved
src/components/HoldPages/HoldRequestErrorBanner.tsx Outdated Show resolved Hide resolved
})

// Server side redirect on ineligibility when Js is disabled
// TODO: Move this to seaprate API route
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you want to move this to a separate API route?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be able to remove the jsEnabled flag from the client call.

Copy link
Member

@EdwinGuzman EdwinGuzman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Latest round looks good. Some comments but I think these should be fixed:

  1. When going to an EDD page, the exact reason does not come up. Shouldn't it? It does come up for the hold request form:
    Screenshot 2024-12-12 at 12 58 56 PM

  2. When a patron cannot place holds on either Holds or EDD, disable the form. I can still submit a request on the on-site use page and can fill out the EDD form:
    Screenshot 2024-12-12 at 12 57 14 PM

  3. The following is low priority so not necessary for this PR. The no-js form submission redirects to a broken result:
    Screenshot 2024-12-12 at 12 58 08 PM


// Server side redirect on ineligibility when Js is disabled
// TODO: Move this to seaprate API route
// TODO: Parse these query params in getServerSideProps
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no query params. This brings up a good point. I was a bit worried about how this was being done, but now I see the POST request is doing the eligibility check, then the redirect happens, then the page does the eligibility check again in getServerSideProps. I don't think there's a harm in checking twice, but ideally, this would only happen once.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although, I have no good suggestions but I think this is a problem you can think about and recommend solution(s) later.

error.message
)

return { status: 500 }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a message and say it was a server issue? It seems this would be the case when the NYPL Platform eligibility endpoint is down, right?

@@ -40,7 +60,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
// JS-Disabled functionality

// Redirect to confirmation page
res.redirect(
return res.redirect(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this not redirecting without the return statement here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was but i added it for consistency after adding it elsewhere as one of Edwin's suggestions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we combine the edd and physical hold request api routes?

Copy link
Contributor Author

@dgcohen dgcohen Dec 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes but i think we should do this as a follow-up optimization ticket since it'll involve potentially refactoring the posting functions as well.

patronId: patronId.value,
source: source.value,
pickupLocation: pickupLocation.value,
patronId: patronId?.value,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What case would allow for this request to be made with undefined values for these required fields? I think the optional chaining implies that case is expected.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This maybe was unclear. Can you remove the optional chaining? I don't see why we would want to send a hold request that didn't have these values defined.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pages/hold/request/[id]/index.tsx Outdated Show resolved Hide resolved
pages/hold/request/[id]/index.tsx Show resolved Hide resolved
src/components/HoldPages/HoldRequestErrorBanner.tsx Outdated Show resolved Hide resolved
src/components/HoldPages/PatronIneligibilityErrors.tsx Outdated Show resolved Hide resolved
__test__/pages/hold/eddRequestPage.test.tsx Show resolved Hide resolved
__test__/pages/hold/eddRequestPage.test.tsx Outdated Show resolved Hide resolved
@dgcohen
Copy link
Contributor Author

dgcohen commented Dec 16, 2024

Latest round looks good. Some comments but I think these should be fixed:

  1. When going to an EDD page, the exact reason does not come up. Shouldn't it? It does come up for the hold request form:
    Screenshot 2024-12-12 at 12 58 56 PM
  2. When a patron cannot place holds on either Holds or EDD, disable the form. I can still submit a request on the on-site use page and can fill out the EDD form:
    Screenshot 2024-12-12 at 12 57 14 PM
  3. The following is low priority so not necessary for this PR. The no-js form submission redirects to a broken result:
    Screenshot 2024-12-12 at 12 58 08 PM

Fixed both of the issues you pointed out except for the No-js one, opening a follow up ticket for that.

Copy link
Member

@EdwinGuzman EdwinGuzman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updates look good but tbh I cannot test this locally. I get merge conflicts when I pull locally. I think it's because of a force push in the history. So I will approve based on the updates but will have to test on train-research-catalog once it's deployed.

patronId: patronId.value,
source: source.value,
pickupLocation: pickupLocation.value,
patronId: patronId?.value,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This maybe was unclear. Can you remove the optional chaining? I don't see why we would want to send a hold request that didn't have these values defined.

@dgcohen dgcohen merged commit 429a2eb into hold-pages Dec 17, 2024
3 checks passed
@dgcohen dgcohen deleted the SCC-3762/patron-eligibility-errors branch December 17, 2024 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants