-
Notifications
You must be signed in to change notification settings - Fork 0
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
SCC-3762 - Hold Confirmation Details #413
Conversation
…/hold-confirmation-server-functions
…C-3762/hold-confirmation-server-functions
There was a problem hiding this comment.
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 && <.../>}
.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
pickupLocationLabel, | ||
discoveryBibResult, | ||
}: HoldConfirmationPageProps) { | ||
const metadataTitle = `Request Confirmation | ${SITE_NAME}` | ||
|
||
const bib = new Bib(discoveryBibResult) | ||
const item = bib?.items[0] | ||
|
There was a problem hiding this comment.
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))
.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).
pages/hold/confirmation/[id].tsx
Outdated
You're all set! We have received your on-site request for | ||
TODO replace with bib link | ||
</Text> | ||
<> |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
pages/hold/confirmation/[id].tsx
Outdated
const { discoveryBibResult } = await fetchBib(bibId, {}, itemId) | ||
|
||
if (!discoveryBibResult?.items?.length) { | ||
throw new Error("Hold Confirmation Page - Item not found") |
There was a problem hiding this comment.
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.
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. |
src/components/BibPage/BibDetail.tsx
Outdated
@@ -14,6 +14,7 @@ import type { | |||
} from "../../types/bibDetailsTypes" | |||
import { rtlOrLtr, isItTheLastElement } from "../../utils/bibUtils" | |||
import type { ReactNode } from "react" | |||
import { child } from "winston" |
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
Ticket:
This PR does the following:
How has this been tested?
Accessibility concerns or updates
Checklist: