From dc42896efe85e9e6a55c474c633e8cbd705d085b Mon Sep 17 00:00:00 2001 From: ngc2207 Date: Tue, 4 Feb 2025 14:35:26 +0800 Subject: [PATCH] feat(dashboard): refactor layout and remove unused components, integrate new sidebar and breadcrumb structure --- src/app/(dashboard)/layout.tsx | 59 +++++++++++----- src/app/(dashboard)/page.tsx | 2 +- src/app/dashboard/layout.tsx | 49 ------------- src/app/dashboard/page.tsx | 15 ---- src/components/mobile-sidebar.tsx | 30 -------- src/components/navbar.tsx | 17 ----- src/components/navigation.tsx | 61 ---------------- src/components/sidebar.tsx | 23 ------ src/features/auth/components/user-button.tsx | 74 -------------------- 9 files changed, 42 insertions(+), 288 deletions(-) delete mode 100644 src/app/dashboard/layout.tsx delete mode 100644 src/app/dashboard/page.tsx delete mode 100644 src/components/mobile-sidebar.tsx delete mode 100644 src/components/navbar.tsx delete mode 100644 src/components/navigation.tsx delete mode 100644 src/components/sidebar.tsx delete mode 100644 src/features/auth/components/user-button.tsx diff --git a/src/app/(dashboard)/layout.tsx b/src/app/(dashboard)/layout.tsx index 3b1654c..ec177e7 100644 --- a/src/app/(dashboard)/layout.tsx +++ b/src/app/(dashboard)/layout.tsx @@ -1,26 +1,49 @@ -import { Navbar } from "@/components/navbar"; -import { Sidebar } from "@/components/sidebar"; +import { + SidebarInset, + SidebarProvider, + SidebarTrigger, +} from "@/components/ui/sidebar"; +import { + Breadcrumb, + BreadcrumbItem, + BreadcrumbLink, + BreadcrumbList, + BreadcrumbPage, + BreadcrumbSeparator, +} from "@/components/ui/breadcrumb"; +import { AppSidebar } from "@/components/app-sidebar"; +import { Separator } from "@/components/ui/separator"; interface DashboardLayoutProps { children: React.ReactNode; } -const DashboardLayout = ({ children }: DashboardLayoutProps) => { +export default function DashboardLayout({ children }: DashboardLayoutProps) { return ( -
-
-
- -
-
-
- -
{children}
+ + + +
+
+ + + + + + + Building Your Application + + + + + Data Fetching + + +
-
-
-
+ +
{children}
+ + ); -}; - -export default DashboardLayout; +} diff --git a/src/app/(dashboard)/page.tsx b/src/app/(dashboard)/page.tsx index 08110f3..dc62b14 100644 --- a/src/app/(dashboard)/page.tsx +++ b/src/app/(dashboard)/page.tsx @@ -2,7 +2,7 @@ import { redirect } from "next/navigation"; import { getCurrent } from "@/features/auth/actions"; import { CreateWorkspaceForm } from "@/features/workspaces/components/create-workspace-form"; -export default async function HomePage() { +export default async function DashboardPage() { const user = await getCurrent(); if (!user) redirect("/sign-in"); diff --git a/src/app/dashboard/layout.tsx b/src/app/dashboard/layout.tsx deleted file mode 100644 index c54bea2..0000000 --- a/src/app/dashboard/layout.tsx +++ /dev/null @@ -1,49 +0,0 @@ -import { AppSidebar } from "@/components/app-sidebar"; -import { - Breadcrumb, - BreadcrumbItem, - BreadcrumbLink, - BreadcrumbList, - BreadcrumbPage, - BreadcrumbSeparator, -} from "@/components/ui/breadcrumb"; -import { Separator } from "@/components/ui/separator"; -import { - SidebarInset, - SidebarProvider, - SidebarTrigger, -} from "@/components/ui/sidebar"; - -interface DashboardLayoutProps { - children: React.ReactNode; -} - -export default function DashboardLayout({ children }: DashboardLayoutProps) { - return ( - - - -
-
- - - - - - - Building Your Application - - - - - Data Fetching - - - -
-
-
{children}
-
-
- ); -} diff --git a/src/app/dashboard/page.tsx b/src/app/dashboard/page.tsx deleted file mode 100644 index dc62b14..0000000 --- a/src/app/dashboard/page.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import { redirect } from "next/navigation"; -import { getCurrent } from "@/features/auth/actions"; -import { CreateWorkspaceForm } from "@/features/workspaces/components/create-workspace-form"; - -export default async function DashboardPage() { - const user = await getCurrent(); - - if (!user) redirect("/sign-in"); - - return ( -
- -
- ); -} diff --git a/src/components/mobile-sidebar.tsx b/src/components/mobile-sidebar.tsx deleted file mode 100644 index c033d27..0000000 --- a/src/components/mobile-sidebar.tsx +++ /dev/null @@ -1,30 +0,0 @@ -"use client"; - -import { Sidebar } from "./sidebar"; -import { Button } from "./ui/button"; -import { MenuIcon } from "lucide-react"; -import { useEffect, useState } from "react"; -import { usePathname } from "next/navigation"; -import { Sheet, SheetContent, SheetTrigger } from "./ui/sheet"; - -export const MobileSidebar = () => { - const [isOpen, setIsOpen] = useState(false); - const pathname = usePathname(); - - useEffect(() => { - setIsOpen(false); - }, [pathname]); - - return ( - - - - - - - - - ); -}; diff --git a/src/components/navbar.tsx b/src/components/navbar.tsx deleted file mode 100644 index 6f27ca0..0000000 --- a/src/components/navbar.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import { UserButton } from "@/features/auth/components/user-button"; -import { MobileSidebar } from "./mobile-sidebar"; - -export const Navbar = () => { - return ( - - ); -}; diff --git a/src/components/navigation.tsx b/src/components/navigation.tsx deleted file mode 100644 index 1f50d2a..0000000 --- a/src/components/navigation.tsx +++ /dev/null @@ -1,61 +0,0 @@ -import { - GoHome, - GoHomeFill, - GoCheckCircle, - GoCheckCircleFill, -} from "react-icons/go"; -import Link from "next/link"; -import { cn } from "@/lib/utils"; -import { SettingsIcon, UsersIcon } from "lucide-react"; - -const routes = [ - { - label: "Home", - href: "", - icon: GoHome, - activeIcon: GoHomeFill, - }, - { - label: "My Tasks", - href: "/tasks", - icon: GoCheckCircle, - activeIcon: GoCheckCircleFill, - }, - { - label: "Settings", - href: "/settings", - icon: SettingsIcon, - activeIcon: SettingsIcon, - }, - { - label: "Members", - href: "/members", - icon: UsersIcon, - activeIcon: UsersIcon, - }, -]; - -export const Navigation = () => { - return ( - - ); -}; diff --git a/src/components/sidebar.tsx b/src/components/sidebar.tsx deleted file mode 100644 index 80639e0..0000000 --- a/src/components/sidebar.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import Link from "next/link"; -import Image from "next/image"; -import { Navigation } from "./navigation"; -import { Separator } from "./ui/separator"; - -export const Sidebar = () => { - return ( - - ); -}; diff --git a/src/features/auth/components/user-button.tsx b/src/features/auth/components/user-button.tsx deleted file mode 100644 index 121106f..0000000 --- a/src/features/auth/components/user-button.tsx +++ /dev/null @@ -1,74 +0,0 @@ -"use client"; - -import { - DropdownMenu, - DropdownMenuContent, - DropdownMenuItem, - DropdownMenuTrigger, -} from "@/components/ui/dropdown-menu"; -import { useLogout } from "../api/use-logout"; -import { Loader, LogOut } from "lucide-react"; -import { useCurrent } from "../api/use-current"; -import { Separator } from "@/components/ui/separator"; -import { Avatar, AvatarFallback } from "@/components/ui/avatar"; - -export const UserButton = () => { - const { mutate: logout } = useLogout(); - const { data: user, isLoading } = useCurrent(); - - if (isLoading) { - return ( -
- -
- ); - } - - if (!user) { - return null; - } - - const { name, email } = user; - - const avatarFallback = name - ? name.charAt(0).toUpperCase() - : email.charAt(0).toUpperCase() ?? "U"; - - return ( - - - - - {avatarFallback} - - - - -
- - - {avatarFallback} - - -
-

{name || "User"}

-

{email}

-
-
- - logout()} - className="h-10 flex items-center justify-center font-medium cursor-pointer" - > - - Log out - -
-
- ); -};