Skip to content
Snippets Groups Projects
Commit 6c59f1e2 authored by Yusuf Akgül's avatar Yusuf Akgül :hatching_chick:
Browse files

Merge branch 'UserProfile' into 'main'

Log Out button

See merge request !18
parents 1ed0fc36 6645dbe4
No related branches found
No related tags found
1 merge request!18Log Out button
Pipeline #35720 passed
...@@ -5,7 +5,6 @@ import { dashboardConfig } from "@/lib/config/dashboard" ...@@ -5,7 +5,6 @@ import { dashboardConfig } from "@/lib/config/dashboard"
interface DashboardLayoutProps { interface DashboardLayoutProps {
children?: React.ReactNode children?: React.ReactNode
} }
export default async function ContentLayout({ export default async function ContentLayout({
children, children,
}: DashboardLayoutProps) { }: DashboardLayoutProps) {
...@@ -15,7 +14,6 @@ export default async function ContentLayout({ ...@@ -15,7 +14,6 @@ export default async function ContentLayout({
<aside className="hidden w-[200px] flex-col md:flex"> <aside className="hidden w-[200px] flex-col md:flex">
<div className="sticky top-0"> <div className="sticky top-0">
<DashboardNav items={dashboardConfig.sidebarNav} /> <DashboardNav items={dashboardConfig.sidebarNav} />
<button>Logout</button>
</div> </div>
</aside> </aside>
<main className="flex w-full flex-1 flex-col overflow-hidden"> <main className="flex w-full flex-1 flex-col overflow-hidden">
......
...@@ -7,6 +7,7 @@ import { SidebarNavItem } from "@/types"; ...@@ -7,6 +7,7 @@ import { SidebarNavItem } from "@/types";
import Link from "next/link"; import Link from "next/link";
import { usePathname } from "next/navigation"; import { usePathname } from "next/navigation";
import { ModeToggle } from "./mode-toggle"; import { ModeToggle } from "./mode-toggle";
import {signIn, signOut, useSession } from "next-auth/react"
interface DashboardNavProps { interface DashboardNavProps {
items: SidebarNavItem[] items: SidebarNavItem[]
...@@ -14,11 +15,11 @@ interface DashboardNavProps { ...@@ -14,11 +15,11 @@ interface DashboardNavProps {
export default function DashboardNav({ items }: DashboardNavProps) { export default function DashboardNav({ items }: DashboardNavProps) {
const path = usePathname() const path = usePathname()
const { data: session } = useSession();
if (!items?.length) { if (!items?.length) {
return null return null
} }
const isLoaded = true const isLoaded = true
const user = "test" const user = "test"
...@@ -30,7 +31,7 @@ export default function DashboardNav({ items }: DashboardNavProps) { ...@@ -30,7 +31,7 @@ export default function DashboardNav({ items }: DashboardNavProps) {
<Icons.logoWhite className="h-7 w-7 hidden dark:block" /> <Icons.logoWhite className="h-7 w-7 hidden dark:block" />
</Link> </Link>
</div> </div>
{isLoaded && user ? {session?.user && isLoaded && user ?
(items.map((item, index) => { (items.map((item, index) => {
const Icon = Icons[item.icon as keyof IconsType || "arrowRight"]; const Icon = Icons[item.icon as keyof IconsType || "arrowRight"];
if (item.title === "My Profile") { if (item.title === "My Profile") {
...@@ -62,7 +63,15 @@ export default function DashboardNav({ items }: DashboardNavProps) { ...@@ -62,7 +63,15 @@ export default function DashboardNav({ items }: DashboardNavProps) {
</p> </p>
</div> </div>
} }
<ModeToggle /> {session?.user &&
<>
<p className="text-sky-600"> {session?.user.name}</p>
<button className=" text-red-500" onClick={() => signOut()}>
Sign Out
</button>
</>
}
<ModeToggle />
</nav> </nav>
) )
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment