fix: netlify doesn't seem to handle redirects in a server action therefor we do the redirect on the client instead
This commit is contained in:
@@ -26,12 +26,12 @@ export default function Error({
|
||||
return (
|
||||
<GenericError
|
||||
title={intl.formatMessage({
|
||||
id: "We could not connect your accounts",
|
||||
id: "Something went wrong",
|
||||
})}
|
||||
>
|
||||
<Body textAlign="center">
|
||||
{intl.formatMessage({
|
||||
id: "We could not connect your accounts to give you access. Please contact us and we’ll help you resolve this issue.",
|
||||
id: "Please try again later",
|
||||
})}
|
||||
</Body>
|
||||
<SASModalContactBlock />
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use client"
|
||||
|
||||
import Image from "next/image"
|
||||
import { useRouter } from "next/navigation"
|
||||
import { type ReactNode, useTransition } from "react"
|
||||
import { FormProvider, useForm } from "react-hook-form"
|
||||
import { useIntl } from "react-intl"
|
||||
@@ -24,8 +25,11 @@ export function LinkAccountForm({
|
||||
onSubmit,
|
||||
}: {
|
||||
initialDateOfBirth: string | null
|
||||
onSubmit: (dateOfBirth: string) => Promise<void>
|
||||
onSubmit: (
|
||||
dateOfBirth: string
|
||||
) => Promise<{ success: boolean; redirectUrl?: string }>
|
||||
}) {
|
||||
const router = useRouter()
|
||||
let [isPending, startTransition] = useTransition()
|
||||
const intl = useIntl()
|
||||
const form = useForm<LinkAccountForm>({
|
||||
@@ -39,7 +43,12 @@ export function LinkAccountForm({
|
||||
startTransition(async () => {
|
||||
if (!data.dateOfBirth || !data.termsAndConditions) return
|
||||
|
||||
await onSubmit(data.dateOfBirth)
|
||||
const result = await onSubmit(data.dateOfBirth)
|
||||
if (!result.success || !result.redirectUrl) {
|
||||
throw new Error("Unable to redirect")
|
||||
}
|
||||
|
||||
router.push(result.redirectUrl)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -25,7 +25,10 @@ export default async function SASxScandicLinkPage({
|
||||
console.log("updating date of birth")
|
||||
}
|
||||
|
||||
redirect(`/${params.lang}/sas-x-scandic/login?intent=link`)
|
||||
return {
|
||||
redirectUrl: `/${params.lang}/sas-x-scandic/login?intent=link`,
|
||||
success: true,
|
||||
}
|
||||
}
|
||||
|
||||
return alreadyLinked ? (
|
||||
|
||||
@@ -29,4 +29,7 @@ TERM = "xterm"
|
||||
package = "@netlify/plugin-nextjs"
|
||||
|
||||
[images]
|
||||
remote_images = ["https://imagevault-stage.scandichotels.com.*", "https://imagevault.scandichotels.com.*"]
|
||||
remote_images = [
|
||||
"https://imagevault-stage.scandichotels.com.*",
|
||||
"https://imagevault.scandichotels.com.*",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user