feat: improve structure and error handling
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
export default function Default() {
|
||||
return null
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
import { benefits } from "@/constants/routes/myPages"
|
||||
import { serverClient } from "@/lib/trpc/server"
|
||||
|
||||
import Breadcrumbs from "@/components/MyPages/Breadcrumbs"
|
||||
|
||||
import type { LangParams, PageArgs } from "@/types/params"
|
||||
|
||||
export default async function BenefitsBreadcrumbs({
|
||||
params,
|
||||
}: PageArgs<LangParams>) {
|
||||
const href = benefits[params.lang].replace(`/${params.lang}`, "")
|
||||
const breadcrumbs = await serverClient().contentstack.breadcrumbs.get({
|
||||
href,
|
||||
locale: params.lang,
|
||||
})
|
||||
return <Breadcrumbs breadcrumbs={breadcrumbs} />
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
export default function Default() {
|
||||
return null
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
export default function Default() {
|
||||
return null
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
import { overview } from "@/constants/routes/myPages"
|
||||
import { serverClient } from "@/lib/trpc/server"
|
||||
|
||||
import Breadcrumbs from "@/components/MyPages/Breadcrumbs"
|
||||
|
||||
import type { LangParams, PageArgs } from "@/types/params"
|
||||
|
||||
export default async function OverviewBreadcrumbs({
|
||||
params,
|
||||
}: PageArgs<LangParams>) {
|
||||
const href = overview[params.lang].replace(`/${params.lang}`, "")
|
||||
const breadcrumbs = await serverClient().contentstack.breadcrumbs.get({
|
||||
href,
|
||||
locale: params.lang,
|
||||
})
|
||||
return <Breadcrumbs breadcrumbs={breadcrumbs} />
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
import { profile } from "@/constants/routes/myPages"
|
||||
import { serverClient } from "@/lib/trpc/server"
|
||||
|
||||
import Breadcrumbs from "@/components/MyPages/Breadcrumbs"
|
||||
|
||||
import type { LangParams, PageArgs } from "@/types/params"
|
||||
|
||||
export default async function ProfileBreadcrumbs({
|
||||
params,
|
||||
}: PageArgs<LangParams>) {
|
||||
const href = profile[params.lang].replace(`/${params.lang}`, "")
|
||||
const breadcrumbs = await serverClient().contentstack.breadcrumbs.get({
|
||||
href,
|
||||
locale: params.lang,
|
||||
})
|
||||
return <Breadcrumbs breadcrumbs={breadcrumbs} />
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
import { profile } from "@/constants/routes/myPages"
|
||||
import { serverClient } from "@/lib/trpc/server"
|
||||
|
||||
import Breadcrumbs from "@/components/MyPages/Breadcrumbs"
|
||||
|
||||
import type { LangParams, PageArgs } from "@/types/params"
|
||||
|
||||
export default async function ProfileBreadcrumbs({
|
||||
params,
|
||||
}: PageArgs<LangParams>) {
|
||||
const href = profile[params.lang].replace(`/${params.lang}`, "")
|
||||
const breadcrumbs = await serverClient().contentstack.breadcrumbs.get({
|
||||
href,
|
||||
locale: params.lang,
|
||||
})
|
||||
return <Breadcrumbs breadcrumbs={breadcrumbs} />
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
export default function Default() {
|
||||
return null
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
import { stays } from "@/constants/routes/myPages"
|
||||
import { serverClient } from "@/lib/trpc/server"
|
||||
|
||||
import Breadcrumbs from "@/components/MyPages/Breadcrumbs"
|
||||
|
||||
import type { LangParams, PageArgs } from "@/types/params"
|
||||
|
||||
export default async function StaysBreadcrumbs({
|
||||
params,
|
||||
}: PageArgs<LangParams>) {
|
||||
const href = stays[params.lang].replace(`/${params.lang}`, "")
|
||||
const breadcrumbs = await serverClient().contentstack.breadcrumbs.get({
|
||||
href,
|
||||
locale: params.lang,
|
||||
})
|
||||
return <Breadcrumbs breadcrumbs={breadcrumbs} />
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
import { firaMono, firaSans } from "@/app/[lang]/(live)/fonts"
|
||||
import Header from "@/components/MyPages/Header"
|
||||
import Sidebar from "@/components/MyPages/Sidebar"
|
||||
|
||||
import styles from "./layout.module.css"
|
||||
|
||||
import type { MyPagesLayoutProps } from "@/types/components/myPages/layout"
|
||||
|
||||
export default async function MyPagesLayout({
|
||||
breadcrumbs,
|
||||
children,
|
||||
params,
|
||||
}: React.PropsWithChildren<MyPagesLayoutProps>) {
|
||||
return (
|
||||
<div
|
||||
className={`${firaMono.variable} ${firaSans.variable} ${styles.layout}`}
|
||||
>
|
||||
<Header lang={params.lang} />
|
||||
{breadcrumbs}
|
||||
<div className={styles.content}>
|
||||
<Sidebar lang={params.lang} />
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import { auth } from "@/auth"
|
||||
|
||||
export default async function ByPass() {
|
||||
const session = await auth()
|
||||
|
||||
return <pre>{JSON.stringify(session, null, 2)}</pre>
|
||||
}
|
||||
@@ -17,5 +17,5 @@ export default async function ProtectedLayout({
|
||||
redirect(`/${params.lang}/login`)
|
||||
}
|
||||
|
||||
return <>{children}</>
|
||||
return children
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ export async function GET(request: NextRequest) {
|
||||
// If all else fails, always redirect to startpage
|
||||
const redirectTo =
|
||||
returnUrl ||
|
||||
request.headers.get("x-redirect-to") ||
|
||||
request.nextUrl.searchParams.get("redirectTo") ||
|
||||
"/"
|
||||
|
||||
|
||||
@@ -13,25 +13,14 @@ import type { LangParams, PageArgs } from "@/types/params"
|
||||
export default async function MyPages({
|
||||
params,
|
||||
}: PageArgs<LangParams & { path: string[] }>) {
|
||||
const baseUrl = myPages[params.lang].replace(`/${params.lang}`, "")
|
||||
const pathUrl = params.path.join("/")
|
||||
|
||||
const accountPage = await serverClient().contentstack.accountPage.get({
|
||||
url: `${baseUrl}/${pathUrl}`,
|
||||
lang: params.lang,
|
||||
})
|
||||
|
||||
const breadcrumbs = await serverClient().contentstack.breadcrumbs.get({
|
||||
href: `${baseUrl}/${pathUrl}`,
|
||||
locale: params.lang,
|
||||
})
|
||||
const accountPage = await serverClient().contentstack.accountPage.get()
|
||||
|
||||
return (
|
||||
<>
|
||||
<Breadcrumbs breadcrumbs={breadcrumbs} />
|
||||
<Breadcrumbs />
|
||||
|
||||
<div className={styles.content}>
|
||||
<Sidebar lang={params.lang} />
|
||||
<Sidebar />
|
||||
<MaxWidth className={styles.blocks} tag="main">
|
||||
{accountPage.content.length ? (
|
||||
<Content lang={params.lang} content={accountPage.content} />
|
||||
|
||||
@@ -1,13 +1,3 @@
|
||||
.layout {
|
||||
--header-height: 4.5rem;
|
||||
|
||||
background-color: var(--Brand-Coffee-Subtle);
|
||||
display: grid;
|
||||
font-family: var(--ff-fira-sans);
|
||||
grid-template-rows: var(--header-height) auto 1fr;
|
||||
min-height: 100dvh;
|
||||
}
|
||||
|
||||
.content {
|
||||
display: grid;
|
||||
padding-bottom: 7.7rem;
|
||||
21
app/[lang]/(live)/(protected)/my-pages/[[...uri]]/layout.tsx
Normal file
21
app/[lang]/(live)/(protected)/my-pages/[[...uri]]/layout.tsx
Normal file
@@ -0,0 +1,21 @@
|
||||
import Breadcrumbs from "@/components/MyPages/Breadcrumbs"
|
||||
import Sidebar from "@/components/MyPages/Sidebar"
|
||||
|
||||
import styles from "./layout.module.css"
|
||||
|
||||
import { LangParams, LayoutArgs, UriParams } from "@/types/params"
|
||||
|
||||
export default async function MyPagesURILayout({
|
||||
children,
|
||||
}: React.PropsWithChildren<LayoutArgs<LangParams & UriParams>>) {
|
||||
return (
|
||||
<>
|
||||
<Breadcrumbs />
|
||||
|
||||
<div className={styles.content}>
|
||||
<Sidebar />
|
||||
{children}
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
export const breadcrumbs = {
|
||||
"/my-pages": [
|
||||
{
|
||||
title: "My Pages",
|
||||
},
|
||||
],
|
||||
"/my-pages/profile": [
|
||||
{
|
||||
href: "/my-pages",
|
||||
title: "My Pages",
|
||||
},
|
||||
{
|
||||
title: "My Profile",
|
||||
},
|
||||
],
|
||||
}
|
||||
@@ -1,19 +1,16 @@
|
||||
import { firaMono, firaSans } from "@/app/[lang]/(live)/fonts"
|
||||
import Header from "@/components/MyPages/Header"
|
||||
|
||||
import styles from "./layout.module.css"
|
||||
|
||||
import type { MyPagesLayoutProps } from "@/types/components/myPages/layout"
|
||||
import { LangParams, LayoutArgs } from "@/types/params"
|
||||
|
||||
export default async function MyPagesLayout({
|
||||
children,
|
||||
params,
|
||||
}: React.PropsWithChildren<MyPagesLayoutProps>) {
|
||||
}: React.PropsWithChildren<LayoutArgs<LangParams>>) {
|
||||
return (
|
||||
<div
|
||||
className={`${firaMono.variable} ${firaSans.variable} ${styles.layout}`}
|
||||
>
|
||||
<Header lang={params.lang} />
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user