| 1 | import React, { useMemo } from "react";
|
|---|
| 2 | import { Outlet, useNavigate } from "react-router-dom";
|
|---|
| 3 |
|
|---|
| 4 | import { SidebarInset, SidebarProvider } from "@relume_io/relume-ui";
|
|---|
| 5 |
|
|---|
| 6 | import DashboardSidebar from "./components/DashboardSidebar.jsx";
|
|---|
| 7 | import DashboardTopbar from "./components/DashboardTopbar.jsx";
|
|---|
| 8 | import { clearAuthSession } from "../../utils/authSession";
|
|---|
| 9 |
|
|---|
| 10 | const DashboardLayout = () => {
|
|---|
| 11 | const navigate = useNavigate();
|
|---|
| 12 |
|
|---|
| 13 | const user = useMemo(() => {
|
|---|
| 14 | try {
|
|---|
| 15 | const raw = localStorage.getItem("authUser");
|
|---|
| 16 | return raw ? JSON.parse(raw) : null;
|
|---|
| 17 | } catch {
|
|---|
| 18 | return null;
|
|---|
| 19 | }
|
|---|
| 20 | }, []);
|
|---|
| 21 |
|
|---|
| 22 | const username = user?.username ?? "";
|
|---|
| 23 |
|
|---|
| 24 | const onLogout = () => {
|
|---|
| 25 | clearAuthSession();
|
|---|
| 26 | navigate("/", { replace: true });
|
|---|
| 27 | };
|
|---|
| 28 |
|
|---|
| 29 | return (
|
|---|
| 30 | <SidebarProvider>
|
|---|
| 31 | {/* App shell background */}
|
|---|
| 32 | <div className="pointer-events-none fixed inset-0 -z-10">
|
|---|
| 33 | <div className="absolute inset-0 bg-base-300/10" />
|
|---|
| 34 | <div className="absolute inset-0 bg-radial-[circle_at_20%_20%] from-green-400/10 via-transparent to-transparent" />
|
|---|
| 35 | <div className="absolute inset-0 bg-radial-[circle_at_80%_30%] from-blue-400/10 via-transparent to-transparent" />
|
|---|
| 36 | <div className="absolute inset-0 bg-linear-to-b from-black/10 via-transparent to-black/25" />
|
|---|
| 37 | </div>
|
|---|
| 38 |
|
|---|
| 39 | <DashboardSidebar />
|
|---|
| 40 |
|
|---|
| 41 | <SidebarInset className="pt-16 lg:pt-0">
|
|---|
| 42 | <DashboardTopbar username={username} onLogout={onLogout} />
|
|---|
| 43 |
|
|---|
| 44 | <div className="h-[calc(100vh-4rem)] overflow-auto">
|
|---|
| 45 | <div className="mx-auto w-full max-w-7xl px-4 py-6 sm:px-6 sm:py-8 lg:px-8 lg:py-10">
|
|---|
| 46 | <div className="rounded-3xl border border-white/10 bg-base-100/60 shadow-[0_0_0_1px_rgba(255,255,255,0.04),0_24px_90px_rgba(0,0,0,0.35)] backdrop-blur-xl">
|
|---|
| 47 | <div className="p-4 sm:p-6 lg:p-8">
|
|---|
| 48 | <Outlet />
|
|---|
| 49 | </div>
|
|---|
| 50 | </div>
|
|---|
| 51 | </div>
|
|---|
| 52 | </div>
|
|---|
| 53 | </SidebarInset>
|
|---|
| 54 | </SidebarProvider>
|
|---|
| 55 | );
|
|---|
| 56 | };
|
|---|
| 57 |
|
|---|
| 58 | export default DashboardLayout;
|
|---|