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 - Hold Confirmation Details #413

Merged
merged 54 commits into from
Dec 12, 2024

Conversation

dgcohen
Copy link
Contributor

@dgcohen dgcohen commented Dec 9, 2024

Ticket:

This PR does the following:

  • Adds the function fetchHoldDetails that returns a patron ID (used to redirect to 404 on logged-in patron ID mismatch) and the pickup location (rendered in the item table).
  • Renders a link to the bib in the confirmation message.
  • Renders a search link beneath the FAQ
  • Server-side redirect handling on confirmation page
  • Adds a distinct Item details table for confirmation (and renames the request version)

How has this been tested?

  • Added 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.

dgcohen and others added 30 commits December 2, 2024 11:53
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be refactored to not use ternaries? Instead, something like {pickupLocationLabel && <.../>}.

Copy link
Contributor Author

@dgcohen dgcohen Dec 10, 2024

Choose a reason for hiding this comment

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

I tried to remove the ternary but it ended up breaking the page due to a DS issue where the List component errors out with no useful message when it receives a null child instead of a fragment. I restored the ternaries and will bring this up with the DS team.

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 provide a bib id to replicate this?

Copy link
Member

@EdwinGuzman EdwinGuzman Dec 11, 2024

Choose a reason for hiding this comment

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

For now, can you use a regular dl tag to remove the tertiaries if it's easy to replicate the styles?

Copy link
Contributor Author

@dgcohen dgcohen Dec 11, 2024

Choose a reason for hiding this comment

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

I was able to fix this by passing the list children as a listItems prop in DetailElement instead of as children.

Copy link
Contributor Author

@dgcohen dgcohen Dec 11, 2024

Choose a reason for hiding this comment

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

Actually nevermind, that didn't work. There's no example bib since it always errors out whenever null is rendered in a DS component (you can try it out by replacing the ternaries here with the && syntax Vera suggested). I believe the error should be addressed in the DS, but I could be wrong.

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.

Looks good but some comments.

The description List issue is interesting. I think the issue is with DetailElement not returning a proper default value. Share the bib where this error is happening to replicate and test, thanks.

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 provide a bib id to replicate this?

Copy link
Member

@EdwinGuzman EdwinGuzman Dec 11, 2024

Choose a reason for hiding this comment

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

For now, can you use a regular dl tag to remove the tertiaries if it's easy to replicate the styles?

Comment on lines +45 to +52
pickupLocationLabel,
discoveryBibResult,
}: HoldConfirmationPageProps) {
const metadataTitle = `Request Confirmation | ${SITE_NAME}`

const bib = new Bib(discoveryBibResult)
const item = bib?.items[0]

Copy link
Member

Choose a reason for hiding this comment

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

Lines 50-51 is already performed in getServerSideProps. You can remove discoveryBibResult and instead return item from the server. When you do so, you might get a serialization issue but you can fix it with JSON.parse(JSON.stringify(item)).

Copy link
Contributor Author

@dgcohen dgcohen Dec 11, 2024

Choose a reason for hiding this comment

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

We've run into this issue before where models can't be properly serialized in getServerSideProps since they contain functions. What we can do is pass just the needed fields but this would slightly limit the flexibility and increase the number of props passed to the component.

The alternative is to remove the model initialization on the server side to avoid running it twice, but we would need to call the discovery response parameters directly which might be fine.

Copy link
Member

Choose a reason for hiding this comment

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

You don't need bib in this component so you can only return item. It would limit to just the current fields you need but you don't need anything else according to the designs (at least for now).

You&apos;re all set! We have received your on-site request for
TODO replace with bib link
</Text>
<>
Copy link
Member

Choose a reason for hiding this comment

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

nit: don't need the fragment here


if (patronId !== patronIdFromResponse) {
throw new Error(
"Error in HoldConfirmationPage getServerSideProps: Logged in patron Id doesn't match the patron Id in the hold request."
)
}

// TODO: Determine error state when there are errors in hold details endpoint reponse
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, as we discussed in person, throwing an error here will redirect the user to a 404 page which isn't correct. From the user flow:

  • the patron submits a POST request and it succeeds
  • they get sent to the confirmation page,
  • the GET request with the requestId fails

Instead of redirecting to the 404 page, the patron should still be sent to the confirmation page with a message that the hold confirmation details could not be fetched. This is slightly out of scope so the TODO is correct. Create a ticket to work on proper error handling and redirecting.

const { discoveryBibResult } = await fetchBib(bibId, {}, itemId)

if (!discoveryBibResult?.items?.length) {
throw new Error("Hold Confirmation Page - Item not found")
Copy link
Member

Choose a reason for hiding this comment

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

Similar idea here as to the above, so include this.

@dgcohen
Copy link
Contributor Author

dgcohen commented Dec 11, 2024

Looks good but some comments.

The description List issue is interesting. I think the issue is with DetailElement not returning a proper default value. Share the bib where this error is happening to replicate and test, thanks.

I'm a little reluctant to replace with a dl element since this doesn't really address the root issue of the List component not being able to accept null children and would involve duplication of styles when the fragment ternary syntax works.

@EdwinGuzman
Copy link
Member

I'm a little reluctant to replace with a dl element since this doesn't really address the root issue of the List component not being able to accept null children and would involve duplication of styles when the fragment ternary syntax works.

Yeah, I agree. It's not a blocker so it can wait for a better DS fix, but you'll just have to live with the not-so-great-looking syntax for now.

@@ -14,6 +14,7 @@ import type {
} from "../../types/bibDetailsTypes"
import { rtlOrLtr, isItTheLastElement } from "../../utils/bibUtils"
import type { ReactNode } from "react"
import { child } from "winston"
Copy link
Member

Choose a reason for hiding this comment

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

Don't think you meant this but it doesn't seemed used.

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.

Make sure to remove the "winston" import. I'll create a ticket for the DS List issue.

@dgcohen dgcohen merged commit 8afc6fe into hold-pages Dec 12, 2024
3 checks passed
@dgcohen dgcohen deleted the SCC-3762/hold-confirmation-server-functions branch December 12, 2024 19:41
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