From 752e8e11da086b62ee4a39ef8f8daa2ec38846cd Mon Sep 17 00:00:00 2001 From: Simon Emanuelsson Date: Thu, 11 Apr 2024 18:51:38 +0200 Subject: [PATCH] feat: move my-pages view to overview --- .../my-pages/@breadcrumbs/page.tsx | 10 ------- .../my-pages/{ => overview}/page.module.css | 2 +- .../(protected)/my-pages/overview/page.tsx | 26 +++++++++++++++++++ .../(live)/(protected)/my-pages/page.tsx | 26 ++++--------------- .../{ => [...catchAll]}/page.tsx | 0 .../profile/@communication/default.tsx | 3 --- .../@creditCards/{ => [...catchAll]}/page.tsx | 0 .../my-pages/profile/@creditCards/default.tsx | 3 --- .../{ => [...catchAll]}/page.tsx | 0 .../profile/@membershipCard/default.tsx | 3 --- .../@password/{ => [...catchAll]}/page.tsx | 0 .../my-pages/profile/@password/default.tsx | 3 --- .../@wishes/{ => [...catchAll]}/page.tsx | 0 .../my-pages/profile/@wishes/default.tsx | 3 --- constants/routes/authRequired.ts | 3 ++- constants/routes/myPages.js | 10 +++++++ next.config.js | 24 ++++++++++++----- 17 files changed, 62 insertions(+), 54 deletions(-) delete mode 100644 app/[lang]/(live)/(protected)/my-pages/@breadcrumbs/page.tsx rename app/[lang]/(live)/(protected)/my-pages/{ => overview}/page.module.css (99%) create mode 100644 app/[lang]/(live)/(protected)/my-pages/overview/page.tsx rename app/[lang]/(live)/(protected)/my-pages/profile/@communication/{ => [...catchAll]}/page.tsx (100%) delete mode 100644 app/[lang]/(live)/(protected)/my-pages/profile/@communication/default.tsx rename app/[lang]/(live)/(protected)/my-pages/profile/@creditCards/{ => [...catchAll]}/page.tsx (100%) delete mode 100644 app/[lang]/(live)/(protected)/my-pages/profile/@creditCards/default.tsx rename app/[lang]/(live)/(protected)/my-pages/profile/@membershipCard/{ => [...catchAll]}/page.tsx (100%) delete mode 100644 app/[lang]/(live)/(protected)/my-pages/profile/@membershipCard/default.tsx rename app/[lang]/(live)/(protected)/my-pages/profile/@password/{ => [...catchAll]}/page.tsx (100%) delete mode 100644 app/[lang]/(live)/(protected)/my-pages/profile/@password/default.tsx rename app/[lang]/(live)/(protected)/my-pages/profile/@wishes/{ => [...catchAll]}/page.tsx (100%) delete mode 100644 app/[lang]/(live)/(protected)/my-pages/profile/@wishes/default.tsx diff --git a/app/[lang]/(live)/(protected)/my-pages/@breadcrumbs/page.tsx b/app/[lang]/(live)/(protected)/my-pages/@breadcrumbs/page.tsx deleted file mode 100644 index 50eff2e46..000000000 --- a/app/[lang]/(live)/(protected)/my-pages/@breadcrumbs/page.tsx +++ /dev/null @@ -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 -} diff --git a/app/[lang]/(live)/(protected)/my-pages/page.module.css b/app/[lang]/(live)/(protected)/my-pages/overview/page.module.css similarity index 99% rename from app/[lang]/(live)/(protected)/my-pages/page.module.css rename to app/[lang]/(live)/(protected)/my-pages/overview/page.module.css index 94d971d2d..58bb298ff 100644 --- a/app/[lang]/(live)/(protected)/my-pages/page.module.css +++ b/app/[lang]/(live)/(protected)/my-pages/overview/page.module.css @@ -11,4 +11,4 @@ padding-left: 0; padding-right: 0; } -} \ No newline at end of file +} diff --git a/app/[lang]/(live)/(protected)/my-pages/overview/page.tsx b/app/[lang]/(live)/(protected)/my-pages/overview/page.tsx new file mode 100644 index 000000000..2a76f5785 --- /dev/null +++ b/app/[lang]/(live)/(protected)/my-pages/overview/page.tsx @@ -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) { + const user = await serverClient().user.get() + return ( + + + + + + ) +} diff --git a/app/[lang]/(live)/(protected)/my-pages/page.tsx b/app/[lang]/(live)/(protected)/my-pages/page.tsx index 2a76f5785..d262e6802 100644 --- a/app/[lang]/(live)/(protected)/my-pages/page.tsx +++ b/app/[lang]/(live)/(protected)/my-pages/page.tsx @@ -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) { - const user = await serverClient().user.get() - return ( - - - - - - ) +export default function MyPages({ params }: PageArgs) { + redirect(overview[params.lang]) + return null } diff --git a/app/[lang]/(live)/(protected)/my-pages/profile/@communication/page.tsx b/app/[lang]/(live)/(protected)/my-pages/profile/@communication/[...catchAll]/page.tsx similarity index 100% rename from app/[lang]/(live)/(protected)/my-pages/profile/@communication/page.tsx rename to app/[lang]/(live)/(protected)/my-pages/profile/@communication/[...catchAll]/page.tsx diff --git a/app/[lang]/(live)/(protected)/my-pages/profile/@communication/default.tsx b/app/[lang]/(live)/(protected)/my-pages/profile/@communication/default.tsx deleted file mode 100644 index 86b9e9a38..000000000 --- a/app/[lang]/(live)/(protected)/my-pages/profile/@communication/default.tsx +++ /dev/null @@ -1,3 +0,0 @@ -export default function Default() { - return null -} diff --git a/app/[lang]/(live)/(protected)/my-pages/profile/@creditCards/page.tsx b/app/[lang]/(live)/(protected)/my-pages/profile/@creditCards/[...catchAll]/page.tsx similarity index 100% rename from app/[lang]/(live)/(protected)/my-pages/profile/@creditCards/page.tsx rename to app/[lang]/(live)/(protected)/my-pages/profile/@creditCards/[...catchAll]/page.tsx diff --git a/app/[lang]/(live)/(protected)/my-pages/profile/@creditCards/default.tsx b/app/[lang]/(live)/(protected)/my-pages/profile/@creditCards/default.tsx deleted file mode 100644 index 86b9e9a38..000000000 --- a/app/[lang]/(live)/(protected)/my-pages/profile/@creditCards/default.tsx +++ /dev/null @@ -1,3 +0,0 @@ -export default function Default() { - return null -} diff --git a/app/[lang]/(live)/(protected)/my-pages/profile/@membershipCard/page.tsx b/app/[lang]/(live)/(protected)/my-pages/profile/@membershipCard/[...catchAll]/page.tsx similarity index 100% rename from app/[lang]/(live)/(protected)/my-pages/profile/@membershipCard/page.tsx rename to app/[lang]/(live)/(protected)/my-pages/profile/@membershipCard/[...catchAll]/page.tsx diff --git a/app/[lang]/(live)/(protected)/my-pages/profile/@membershipCard/default.tsx b/app/[lang]/(live)/(protected)/my-pages/profile/@membershipCard/default.tsx deleted file mode 100644 index 86b9e9a38..000000000 --- a/app/[lang]/(live)/(protected)/my-pages/profile/@membershipCard/default.tsx +++ /dev/null @@ -1,3 +0,0 @@ -export default function Default() { - return null -} diff --git a/app/[lang]/(live)/(protected)/my-pages/profile/@password/page.tsx b/app/[lang]/(live)/(protected)/my-pages/profile/@password/[...catchAll]/page.tsx similarity index 100% rename from app/[lang]/(live)/(protected)/my-pages/profile/@password/page.tsx rename to app/[lang]/(live)/(protected)/my-pages/profile/@password/[...catchAll]/page.tsx diff --git a/app/[lang]/(live)/(protected)/my-pages/profile/@password/default.tsx b/app/[lang]/(live)/(protected)/my-pages/profile/@password/default.tsx deleted file mode 100644 index 86b9e9a38..000000000 --- a/app/[lang]/(live)/(protected)/my-pages/profile/@password/default.tsx +++ /dev/null @@ -1,3 +0,0 @@ -export default function Default() { - return null -} diff --git a/app/[lang]/(live)/(protected)/my-pages/profile/@wishes/page.tsx b/app/[lang]/(live)/(protected)/my-pages/profile/@wishes/[...catchAll]/page.tsx similarity index 100% rename from app/[lang]/(live)/(protected)/my-pages/profile/@wishes/page.tsx rename to app/[lang]/(live)/(protected)/my-pages/profile/@wishes/[...catchAll]/page.tsx diff --git a/app/[lang]/(live)/(protected)/my-pages/profile/@wishes/default.tsx b/app/[lang]/(live)/(protected)/my-pages/profile/@wishes/default.tsx deleted file mode 100644 index 86b9e9a38..000000000 --- a/app/[lang]/(live)/(protected)/my-pages/profile/@wishes/default.tsx +++ /dev/null @@ -1,3 +0,0 @@ -export default function Default() { - return null -} diff --git a/constants/routes/authRequired.ts b/constants/routes/authRequired.ts index 6ef63b02b..9cb32aaa6 100644 --- a/constants/routes/authRequired.ts +++ b/constants/routes/authRequired.ts @@ -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), ] diff --git a/constants/routes/myPages.js b/constants/routes/myPages.js index d4ed671ef..7444c9fb6 100644 --- a/constants/routes/myPages.js +++ b/constants/routes/myPages.js @@ -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 = { diff --git a/next.config.js b/next.config.js index 0622194d1..a2edb87b4 100644 --- a/next.config.js +++ b/next.config.js @@ -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" },