Skip to content

Commit

Permalink
Encode redirect uri
Browse files Browse the repository at this point in the history
  • Loading branch information
dgcohen committed Jan 3, 2025
1 parent 406169e commit a6177a0
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions pages/api/hold/request/[id]/edd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,24 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
})
}

// JS-Disabled functionality
// JS-Disabled error validation/redirect
const formInvalid = eddFormIsInvalid(validatedFields)

if (formInvalid) {
return res.redirect(
`${BASE_URL}${
PATHS.HOLD_REQUEST
}/${holdId}/edd?formInvalid=${JSON.stringify(
formInvalid
)}&validatedFields=${JSON.stringify(
validatedFields
)}&formState=${JSON.stringify(formState)}`
)
const formInvalidQuery = `formInvalid=${JSON.stringify(formInvalid)}`
const validatedFieldsQuery = `validatedFields=${JSON.stringify(
validatedFields
)}`
const formStateQuery = `formState=${JSON.stringify(formState)}`

const invalidFormRedirectUrl =
encodeURI(`${BASE_URL}${PATHS.HOLD_REQUEST}/${holdId}/edd?
)}&${formInvalidQuery}&${validatedFieldsQuery}&${formStateQuery}`)

return res.redirect(invalidFormRedirectUrl)
}

// Redirect to confirmation page
// Redirect to confirmation page if there are no errors
return res.redirect(
`${BASE_URL}${PATHS.HOLD_CONFIRMATION}/${holdId}?pickupLocation=edd&requestId=${requestId}`
)
Expand Down

0 comments on commit a6177a0

Please sign in to comment.