First steps towards the SAS partnership * otp flow now pretends to do the linking * Update LinkAccountForm header * Update redirect times * Clean up comments * Set maxAge on sas cookies * make all SAS routes protected * Merge remote-tracking branch 'refs/remotes/origin/feature/sas-login' into feature/sas-login * Require auth for sas link flow * Fix resend otp * Add error support to OneTimePasswordForm * Add Sentry to SAS error boundary * Move SAS_REQUEST_OTP_STATE_STORAGE_COOKIE_NAME * Add missing translations * Merge branch 'master' of bitbucket.org:scandic-swap/web into feature/sas-login * Merge branch 'feature/sas-login' of bitbucket.org:scandic-swap/web into feature/sas-login * Add TooManyCodesError component * Refactor GenericError to support new errors * Add FailedAttemptsError * remove removed component <VWOScript/> * Merge branch 'feature/sas-login' of bitbucket.org:scandic-swap/web into feature/sas-login * remove local cookie-bot reference * Fix sas campaign logo scaling * feature toggle the SAS stuff * Merge branch 'feature/sas-login' of bitbucket.org:scandic-swap/web into feature/sas-login * fix: use env vars for SAS endpoints Approved-by: Linus Flood
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import { redirect } from "next/navigation"
|
|
import React from "react"
|
|
|
|
import { getProfileSafely } from "@/lib/trpc/memoizedRequests"
|
|
|
|
import { AlreadyLinkedError } from "../components/AlreadyLinkedError"
|
|
import { SASModal } from "../components/SASModal"
|
|
import { LinkAccountForm } from "./LinkAccountForm"
|
|
|
|
import type { LangParams, PageArgs } from "@/types/params"
|
|
|
|
export default async function SASxScandicLinkPage({
|
|
params,
|
|
}: PageArgs<LangParams>) {
|
|
const profile = await getProfileSafely()
|
|
|
|
// TODO actually check if profile is already linked
|
|
const alreadyLinked = false
|
|
|
|
async function handleLinkAccount(dateOfBirth: string) {
|
|
"use server"
|
|
|
|
if (dateOfBirth !== profile?.dateOfBirth) {
|
|
// TODO update users date of birth here
|
|
console.log("updating date of birth")
|
|
}
|
|
|
|
redirect(`/${params.lang}/sas-x-scandic/login?intent=link`)
|
|
}
|
|
|
|
return alreadyLinked ? (
|
|
<AlreadyLinkedError />
|
|
) : (
|
|
<SASModal>
|
|
<LinkAccountForm
|
|
initialDateOfBirth={profile?.dateOfBirth ?? null}
|
|
onSubmit={handleLinkAccount}
|
|
/>
|
|
</SASModal>
|
|
)
|
|
}
|