chore(debug): auth

This commit is contained in:
Michael Zetterberg
2024-05-15 14:59:28 +02:00
parent a734ba848a
commit 2097807062
44 changed files with 460 additions and 42 deletions

View File

@@ -1,12 +1,12 @@
export const breadcrumbs = {
"/my-pages": [
"/my-pages2": [
{
title: "My Pages",
},
],
"/my-pages/profile": [
"/my-pages2/profile": [
{
href: "/my-pages",
href: "/my-pages2",
title: "My Pages",
},
{

View File

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

View File

@@ -0,0 +1,17 @@
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} />
}

View File

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

View File

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

View File

@@ -0,0 +1,17 @@
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} />
}

View File

@@ -0,0 +1,17 @@
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} />
}

View File

@@ -0,0 +1,17 @@
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} />
}

View File

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

View File

@@ -0,0 +1,17 @@
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} />
}

View File

@@ -0,0 +1,16 @@
export const breadcrumbs = {
"/my-pages2": [
{
title: "My Pages",
},
],
"/my-pages2/profile": [
{
href: "/my-pages2",
title: "My Pages",
},
{
title: "My Profile",
},
],
}

View File

@@ -0,0 +1,27 @@
.layout {
--header-height: 4.5rem;
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;
padding-left: 0;
padding-right: 0;
position: relative;
}
@media screen and (min-width: 950px) {
.content {
gap: 10rem;
grid-template-columns: 25rem 1fr;
padding-bottom: 17.5rem;
padding-left: 2.4rem;
padding-right: 2.4rem;
padding-top: 5.8rem;
}
}

View File

@@ -0,0 +1,26 @@
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>
)
}

View File

@@ -0,0 +1,15 @@
.blocks {
display: grid;
gap: 4.2rem;
padding-top: 4rem;
padding-left: 2rem;
padding-right: 2rem;
}
@media screen and (min-width: 950px) {
.blocks {
gap: 6.4rem;
padding-left: 0;
padding-right: 0;
}
}

View File

@@ -0,0 +1,35 @@
import { redirect } from "next/navigation"
import { myPages, overview } from "@/constants/routes/myPages"
import { serverClient } from "@/lib/trpc/server"
import MaxWidth from "@/components/MaxWidth"
import Content from "@/components/MyPages/AccountPage/Content"
import styles from "./page.module.css"
import type { LangParams, PageArgs, UriParams } from "@/types/params"
export default async function MyPages({
params,
searchParams,
}: PageArgs<LangParams, UriParams>) {
if (!searchParams.uri) {
throw new Error("Bad URI")
}
const myPagesRoot = myPages[params.lang].replace(`/${params.lang}`, "")
if (searchParams.uri === myPagesRoot) {
redirect(overview[params.lang])
}
const accountPage = await serverClient().contentstack.accountPage.get({
url: searchParams.uri,
lang: params.lang,
})
return (
<MaxWidth className={styles.blocks} tag="main">
<Content lang={params.lang} content={accountPage.content} />
</MaxWidth>
)
}

View File

@@ -0,0 +1,5 @@
import CommunicationPreferences from "@/components/MyProfile/CommunicationPreferences"
export default function Communication() {
return <CommunicationPreferences />
}

View File

@@ -0,0 +1,5 @@
import CommunicationPreferences from "@/components/MyProfile/CommunicationPreferences"
export default function Communication() {
return <CommunicationPreferences />
}

View File

@@ -0,0 +1,5 @@
import CreditCards from "@/components/MyProfile/CreditCards"
export default function CreditCardSlot() {
return <CreditCards />
}

View File

@@ -0,0 +1,5 @@
import CreditCards from "@/components/MyProfile/CreditCards"
export default function CreditCardSlot() {
return <CreditCards />
}

View File

@@ -0,0 +1,38 @@
"use client"
import { profile } from "@/constants/routes/myPages"
import { _ } from "@/lib/translation"
import { useProfileStore } from "@/stores/edit-profile"
import Button from "@/components/TempDesignSystem/Button"
import Link from "@/components/TempDesignSystem/Link"
import type { LangParams, PageArgs } from "@/types/params"
export default function EditProfile({ params }: PageArgs<LangParams>) {
const isPending = useProfileStore((store) => store.pending)
const isValid = useProfileStore((store) => store.valid)
return (
<>
<Button
aria-label="Cancel"
asChild
bgcolor="white"
form="edit-profile"
size="small"
type="reset"
>
<Link href={profile[params.lang]}>{_("Cancel")}</Link>
</Button>
<Button
bgcolor="quarternary"
disabled={!isValid || isPending}
form="edit-profile"
size="small"
type="submit"
weight="regular"
>
{_("Save")}
</Button>
</>
)
}

View File

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

View File

@@ -0,0 +1,5 @@
import MembershipCard from "@/components/MyProfile/MembershipCard"
export default function MembershipCardSlot() {
return <MembershipCard />
}

View File

@@ -0,0 +1,5 @@
import MembershipCard from "@/components/MyProfile/MembershipCard"
export default function MembershipCardSlot() {
return <MembershipCard />
}

View File

@@ -0,0 +1,5 @@
import Password from "@/components/MyProfile/Password"
export default function PasswordSlot() {
return <Password />
}

View File

@@ -0,0 +1,5 @@
import Password from "@/components/MyProfile/Password"
export default function PasswordSlot() {
return <Password />
}

View File

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

View File

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

View File

@@ -0,0 +1,5 @@
import EditProfile from "@/components/MyProfile/Profile/Edit"
export default function EditProfileSlot() {
return <EditProfile />
}

View File

@@ -0,0 +1,8 @@
"use client"
import type { ErrorPage } from "@/types/next/error"
export default function ProfileError({ error }: ErrorPage) {
console.error(error)
return <h1>Error happened, Profile</h1>
}

View File

@@ -0,0 +1,5 @@
import Profile from "@/components/MyProfile/Profile"
export default function ProfileInfo() {
return <Profile />
}

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,15 @@
import { profileEdit } from "@/constants/routes/myPages"
import { _ } from "@/lib/translation"
import Button from "@/components/TempDesignSystem/Button"
import Link from "@/components/TempDesignSystem/Link"
import type { LangParams, PageArgs } from "@/types/params"
export default function ProfileView({ params }: PageArgs<LangParams>) {
return (
<Button asChild bgcolor="quarternary" size="small" weight="regular">
<Link href={profileEdit[params.lang]}>{_("Edit")}</Link>
</Button>
)
}

View File

@@ -0,0 +1,5 @@
import Wishes from "@/components/MyProfile/Wishes"
export default function WishesSlot() {
return <Wishes />
}

View File

@@ -0,0 +1,5 @@
import Wishes from "@/components/MyProfile/Wishes"
export default function WishesSlot() {
return <Wishes />
}

View File

@@ -0,0 +1,5 @@
import "../profileLayout.css"
export default function EditProfilePage() {
return null
}

View File

@@ -0,0 +1,33 @@
import MaxWidth from "@/components/MaxWidth"
import type { ProfileLayoutProps } from "@/types/components/myPages/myProfile/layout"
export default function ProfileLayout({
children,
communication,
creditCards,
edit,
membershipCard,
password,
profile,
view,
wishes,
}: React.PropsWithChildren<ProfileLayoutProps>) {
return (
<MaxWidth className="profile-page" tag="main">
<div className="profile-btns">
{edit}
{view}
</div>
{profile}
{children}
<section className="profile-cards">
{communication}
{wishes}
{membershipCard}
{creditCards}
{password}
</section>
</MaxWidth>
)
}

View File

@@ -0,0 +1,5 @@
import "./profileLayout.css"
export default function ProfilePage() {
return null
}

View File

@@ -0,0 +1,27 @@
/**
* Due to css import issues with parallell routes we are forced to
* use a regular css file and import it in the page.tsx
*/
.profile-page {
display: grid;
gap: 3rem;
}
.profile-btns {
align-items: center;
display: flex;
gap: 1rem;
justify-content: flex-end;
position: absolute;
right: 0;
/* Creates the 16px gap from design */
top: -1.6rem;
/* Moves itself to top of container to avoid calc */
transform: translateY(-100%);
}
.profile-cards {
display: grid;
gap: 0.4rem;
grid-template-columns: 1fr 1fr;
}