-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
47e0cf6
commit a77d0e4
Showing
27 changed files
with
240 additions
and
325 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ node_modules | |
.turbo | ||
|
||
# Env files | ||
.env | ||
.env | ||
.env.local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { DynamicBreadCrumbs } from "@/components/dynamic-breadcrumbs"; | ||
|
||
export default function Layout({ children }: { children: React.ReactNode }) { | ||
return ( | ||
<section className="mx-auto max-w-lg space-y-2 py-12"> | ||
<DynamicBreadCrumbs /> | ||
{children} | ||
</section> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Accounts } from "@/components/user/accounts"; | ||
import { useSupabaseServer } from "@/modules/utils/server"; | ||
import { cookies } from "next/headers"; | ||
import { redirect } from "next/navigation"; | ||
|
||
export default async function Page() { | ||
const supabase = useSupabaseServer({ cookies }); | ||
|
||
const { | ||
data: { user }, | ||
} = await supabase.auth.getUser(); | ||
|
||
if (!user) { | ||
redirect("/login"); | ||
} | ||
|
||
return <Accounts userId={user.id} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { DynamicBreadCrumbs } from "@/components/dynamic-breadcrumbs"; | ||
import { DynamicNavigationLinks } from "@/components/dynamic-navigation-links"; | ||
|
||
export default function Layout({ children }: { children: React.ReactNode }) { | ||
return ( | ||
<section className="mx-auto max-w-2xl space-y-6 py-12 lg:max-w-4xl"> | ||
<header className="space-y-2"> | ||
<DynamicBreadCrumbs /> | ||
<h2 className="text-5xl font-semibold tracking-tight">Settings</h2> | ||
<p>Manage your accounts, profile and credentials settings</p> | ||
</header> | ||
<div className="flex flex-col gap-6 lg:flex-row"> | ||
<nav className="-ml-4 h-full min-w-[30%]"> | ||
<DynamicNavigationLinks | ||
items={[ | ||
{ | ||
href: "/settings/accounts", | ||
label: "Accounts", | ||
}, | ||
{ | ||
href: "/settings/profile", | ||
label: "Profile", | ||
}, | ||
{ | ||
href: "/settings/credentials", | ||
label: "Credentials", | ||
}, | ||
]} | ||
/> | ||
</nav> | ||
<div className="w-full">{children}</div> | ||
</div> | ||
</section> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
"use client"; | ||
|
||
import * as React from "react"; | ||
import { | ||
Breadcrumb, | ||
BreadcrumbItem, | ||
BreadcrumbLink, | ||
BreadcrumbList, | ||
BreadcrumbSeparator, | ||
} from "@/components/ui/breadcrumb"; | ||
import Link from "next/link"; | ||
import { usePathname } from "next/navigation"; | ||
|
||
export const DynamicBreadCrumbs: React.FC = () => { | ||
const pathname = usePathname(); | ||
|
||
const paths = React.useMemo(() => { | ||
const segments = pathname.split("/").filter(Boolean); | ||
|
||
return segments.reduce<{ href: string; label: string }[]>( | ||
(acc, curr, index) => { | ||
const href = `/${segments.slice(0, index + 1).join("/")}`; | ||
const label = | ||
curr.charAt(0).toUpperCase() + curr.slice(1).replaceAll("-", " "); | ||
|
||
acc.push({ href, label }); | ||
return acc; | ||
}, | ||
[{ href: "/", label: "Home" }] | ||
); | ||
}, [pathname]); | ||
|
||
return ( | ||
<Breadcrumb> | ||
<BreadcrumbList> | ||
{paths.map(({ href, label }, index) => ( | ||
<React.Fragment key={href}> | ||
{index !== paths.length - 1 ? ( | ||
<BreadcrumbItem> | ||
<BreadcrumbLink asChild> | ||
<Link href={href}>{label}</Link> | ||
</BreadcrumbLink> | ||
</BreadcrumbItem> | ||
) : ( | ||
<BreadcrumbItem> | ||
<span className="text-foreground">{label}</span> | ||
</BreadcrumbItem> | ||
)} | ||
{index !== paths.length - 1 && <BreadcrumbSeparator />} | ||
</React.Fragment> | ||
))} | ||
</BreadcrumbList> | ||
</Breadcrumb> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"use client"; | ||
|
||
import * as React from "react"; | ||
import { Button } from "@/components/ui/button"; | ||
import Link from "next/link"; | ||
import { usePathname } from "next/navigation"; | ||
|
||
export const DynamicNavigationLinks: React.FC<{ | ||
items: { href: string; label: string }[]; | ||
}> = ({ items }) => { | ||
const pathname = usePathname(); | ||
|
||
return ( | ||
<div className="space-x-1 lg:space-x-0 lg:space-y-1"> | ||
{items.map(({ href, label }) => ( | ||
<Button | ||
key={href} | ||
className="lg:w-full lg:justify-start" | ||
asChild | ||
variant="ghost" | ||
> | ||
{href === pathname ? ( | ||
<span className="bg-accent">{label}</span> | ||
) : ( | ||
<Link href={href}>{label}</Link> | ||
)} | ||
</Button> | ||
))} | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.