Merged in feat/move-my-pages-to-overview (pull request #109)

Feat/move my pages to overview

Approved-by: Michael Zetterberg
This commit is contained in:
Simon.Emanuelsson
2024-04-16 08:33:52 +00:00
committed by Michael Zetterberg
17 changed files with 62 additions and 54 deletions

View File

@@ -1,10 +0,0 @@
import { serverClient } from "@/lib/trpc/server"
import Breadcrumbs from "@/components/MyPages/Breadcrumbs"
export default async function MyPagesBreadcrumbs() {
const breadcrumbs = await serverClient().contentstack.breadcrumbs.get({
href: "/my-pages",
})
return <Breadcrumbs breadcrumbs={breadcrumbs} />
}

View File

@@ -0,0 +1,26 @@
import { _ } from "@/lib/translation"
import { serverClient } from "@/lib/trpc/server"
import MaxWidth from "@/components/MaxWidth"
import Overview from "@/components/MyPages/Blocks/Overview"
import Shortcuts from "@/components/MyPages/Blocks/Shortcuts"
import UpcomingStays from "@/components/MyPages/Blocks/UpcomingStays"
import styles from "./page.module.css"
import type { LangParams, PageArgs } from "@/types/params"
export default async function MyPage({ params }: PageArgs<LangParams>) {
const user = await serverClient().user.get()
return (
<MaxWidth className={styles.blocks} tag="main">
<Overview user={user} />
<UpcomingStays lang={params.lang} stays={user.stays} />
<Shortcuts
shortcuts={user.shortcuts}
subtitle={_("The community at your fingertips")}
title={_("Handy Shortcuts")}
/>
</MaxWidth>
)
}

View File

@@ -1,26 +1,10 @@
import { _ } from "@/lib/translation"
import { serverClient } from "@/lib/trpc/server"
import { redirect } from "next/navigation"
import MaxWidth from "@/components/MaxWidth"
import Overview from "@/components/MyPages/Blocks/Overview"
import Shortcuts from "@/components/MyPages/Blocks/Shortcuts"
import UpcomingStays from "@/components/MyPages/Blocks/UpcomingStays"
import styles from "./page.module.css"
import { overview } from "@/constants/routes/myPages"
import type { LangParams, PageArgs } from "@/types/params"
export default async function MyPage({ params }: PageArgs<LangParams>) {
const user = await serverClient().user.get()
return (
<MaxWidth className={styles.blocks} tag="main">
<Overview user={user} />
<UpcomingStays lang={params.lang} stays={user.stays} />
<Shortcuts
shortcuts={user.shortcuts}
subtitle={_("The community at your fingertips")}
title={_("Handy Shortcuts")}
/>
</MaxWidth>
)
export default function MyPages({ params }: PageArgs<LangParams>) {
redirect(overview[params.lang])
return null
}

View File

@@ -1,3 +0,0 @@
export default function Default() {
return null
}

View File

@@ -1,3 +0,0 @@
export default function Default() {
return null
}

View File

@@ -1,3 +0,0 @@
export default function Default() {
return null
}

View File

@@ -1,3 +0,0 @@
export default function Default() {
return null
}

View File

@@ -1,3 +0,0 @@
export default function Default() {
return null
}

View File

@@ -1,4 +1,4 @@
import { benefits, myPages, profile, profileEdit } from "./myPages"
import { benefits, myPages, overview, profile, profileEdit } from "./myPages"
/**
* These are routes in code we know requires auth
@@ -8,6 +8,7 @@ import { benefits, myPages, profile, profileEdit } from "./myPages"
export const authRequired = [
...Object.values(benefits),
...Object.values(myPages),
...Object.values(overview),
...Object.values(profile),
...Object.values(profileEdit),
]

View File

@@ -17,6 +17,16 @@ export const myPages = {
sv: "/sv/mina-sidor",
}
/** @type {import('@/types/routes').LangRoute} */
export const overview = {
da: `${myPages.da}/oversigt`,
de: `${myPages.de}/uberblick`,
en: `${myPages.en}/overview`,
fi: `${myPages.fi}/yleiskatsaus`,
no: `${myPages.no}/oversikt`,
sv: `${myPages.sv}/oversikt`,
}
/** TODO: Update to relevant paths */
/** @type {import('@/types/routes').LangRoute} */
export const profile = {

View File

@@ -1,7 +1,13 @@
import createJiti from "jiti"
import { login } from "./constants/routes/handleAuth.js"
import { benefits, myPages, profile, profileEdit } from "./constants/routes/myPages.js"
import {
benefits,
myPages,
overview,
profile,
profileEdit,
} from "./constants/routes/myPages.js"
const jiti = createJiti(new URL(import.meta.url).pathname)
jiti("./env/server")
@@ -76,11 +82,17 @@ const nextConfig = {
{ source: login.no, destination: "/no/login" },
{ source: login.sv, destination: "/sv/login" },
{ source: myPages.da, destination: "/da/my-pages" },
{ source: myPages.de, destination: "/de/my-pages" },
{ source: myPages.fi, destination: "/fi/my-pages" },
{ source: myPages.no, destination: "/no/my-pages" },
{ source: myPages.sv, destination: "/sv/my-pages" },
{ source: myPages.da, destination: "/da/my-pages/overview" },
{ source: myPages.de, destination: "/de/my-pages/overview" },
{ source: myPages.fi, destination: "/fi/my-pages/overview" },
{ source: myPages.no, destination: "/no/my-pages/overview" },
{ source: myPages.sv, destination: "/sv/my-pages/overview" },
{ source: overview.da, destination: "/da/my-pages/overview" },
{ source: overview.de, destination: "/de/my-pages/overview" },
{ source: overview.fi, destination: "/fi/my-pages/overview" },
{ source: overview.no, destination: "/no/my-pages/overview" },
{ source: overview.sv, destination: "/sv/my-pages/overview" },
{ source: profile.da, destination: "/da/my-pages/profile" },
{ source: profile.de, destination: "/de/my-pages/profile" },