-
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 4405/hold pages js disabled #429
base: hold-pages
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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.
This works very well. I left a comment about the general architecture but some questions:
- shouldn't the query params be escaped?
- it feels a bit unsafe having the patron's email in the query params. I don't think there's anything that can be done.
- What if a value like
requestNotes
is very long? Thankfully, I think the limit is big so there's no need to worry but something to keep in mind.
example: validatedFields=[{"key":"emailAddress","isInvalid":false},{"key":"startPage","isInvalid":true},{"key":"endPage","isInvalid":true},{"key":"chapterTitle","isInvalid":true}]&formState={"source":"sierra-nypl","emailAddress":"[email protected]","startPage":"","endPage":"","chapterTitle":"","author":"","date":"","volume":"","issue":"","requestNotes":""}
const { id } = params | ||
const { formInvalid } = query | ||
const serverValidationFailed = formInvalid ? JSON.parse(formInvalid) : false |
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.
Is it possible to pass the formInvalid
object to the component so you can then remove the router.query?.formState
call? The values are already being parsed in the server so it doesn't seem necessary to do it again in the client.
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.
The router.query?.formState call is responsible for pre-populating the form fields, whereas the formInvalid query param is just responsible for setting the page's status. I could derive the "invalid" status using the form's state, but it would require some weird changes to the component (moving the error status setting from the submit handler to a useEffect), and I felt that this was cleaner since there was already a switch statement in getServerSideProps that sets the page status before the component renders.
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.
Just cause you mentioned there being a lot happening in the getServerSideProps
, maybe the email fetch can be moved to the server/api/hold
file with the other fetchers
The query params should definitely be escaped. I'm seeing them escaped in chrome's address bar (same as in the unit test), where are you seeing them unescaped? Not sure if I understand the security concern about the email address in the url. Wouldn't the patron who submitted the form be the only one who sees the redirect url (not including NYPL staff)? |
Ticket:
This PR does the following:
How has this been tested?
Accessibility concerns or updates
Checklist: