Skip to content

Commit

Permalink
Update app/routes/wow.out-of-stock.tsx
Browse files Browse the repository at this point in the history
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
cohenaj194 and coderabbitai[bot] authored Nov 22, 2024
1 parent d77eb40 commit 26f603f
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions app/routes/wow.out-of-stock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,28 @@ type ActionResponseType =
| ({ data: OutOfStockItem[] } & { sortby: string })

export const loader: LoaderFunction = async ({ request }) => {
const params = new URL(request.url).searchParams
try {
const params = new URL(request.url).searchParams

const values = Object.fromEntries(
Object.entries(defaultFormValues).map(([key, defaultValue]) => [
key,
params.get(key) || defaultValue
])
)
const values = Object.fromEntries(
Object.entries(defaultFormValues).map(([key, defaultValue]) => [
key,
params.get(key) || defaultValue
])
)

const validParams = validateInput.safeParse(values)
if (!validParams.success) {
const validParams = validateInput.safeParse(values)
if (!validParams.success) {
return json({
exception: parseZodErrorsToDisplayString(validParams.error, inputMap)
})
}
return json(validParams.data)
} catch (error) {
return json({
exception: parseZodErrorsToDisplayString(validParams.error, inputMap)
exception: "Invalid URL format"
})
}
return json(validParams.data)
}

export const action: ActionFunction = async ({ request }) => {
Expand Down

0 comments on commit 26f603f

Please sign in to comment.