fix: redirect users to /refresh on unauth and mod webview links

This commit is contained in:
Christel Westerberg
2024-05-16 16:57:22 +02:00
parent 777fd1e5b6
commit 9e4f41ee46
29 changed files with 358 additions and 105 deletions

View File

@@ -1,14 +1,14 @@
import { notFound, redirect } from "next/navigation"
import { notFound } from "next/navigation"
import { serverClient } from "@/lib/trpc/server"
import { Blocks } from "@/components/Loyalty/Blocks"
import { Blocks } from "@/components/Loyalty/Blocks/WebView"
import Sidebar from "@/components/Loyalty/Sidebar"
import MaxWidth from "@/components/MaxWidth"
import styles from "./page.module.css"
import type { LangParams, PageArgs, UriParams } from "@/types/params"
import { LangParams, PageArgs, UriParams } from "@/types/params"
export default async function AboutScandicFriends({
params,
@@ -18,26 +18,16 @@ export default async function AboutScandicFriends({
return notFound()
}
const loyaltyPage = await serverClient({
onError() {
const returnUrl = new URLSearchParams({
returnurl: `${params.lang}/webview/${searchParams.uri}`,
})
const refreshUrl = `/${params.lang}/webview/refresh?${returnUrl.toString()}`
redirect(refreshUrl)
},
}).contentstack.loyaltyPage.get({
const loyaltyPage = await serverClient().contentstack.loyaltyPage.get({
href: searchParams.uri,
locale: params.lang,
})
return (
<section className={styles.content}>
{loyaltyPage.sidebar ? <Sidebar blocks={loyaltyPage.sidebar} /> : null}
<MaxWidth className={styles.blocks} tag="main">
<Blocks blocks={loyaltyPage.blocks} />
<Blocks blocks={loyaltyPage.blocks} lang={params.lang} />
</MaxWidth>
</section>
)