sidebar-nav.tsx146 lines, 4.4 KB
| 1 | "use client"; |
| 2 | |
| 3 | import { Button } from "@/components/ui/button"; |
| 4 | import { useAuth } from "@/lib/hooks/auth"; |
| 5 | import { cn } from "@/lib/utils"; |
| 6 | import { |
| 7 | CreditCardIcon, |
| 8 | HistoryIcon, |
| 9 | LogOutIcon, |
| 10 | PlayIcon, |
| 11 | UserIcon, |
| 12 | VideoIcon, |
| 13 | } from "lucide-react"; |
| 14 | import Image from "next/image"; |
| 15 | import Link from "next/link"; |
| 16 | import { usePathname } from "next/navigation"; |
| 17 | import SubscriptionStatus from "./subscription-status"; |
| 18 | |
| 19 | const navigation = [ |
| 20 | { |
| 21 | name: "New Video", |
| 22 | href: "/dashboard", |
| 23 | icon: VideoIcon, |
| 24 | description: "Upload a new video to be processed", |
| 25 | }, |
| 26 | { |
| 27 | name: "My Videos", |
| 28 | href: "/dashboard/videos", |
| 29 | icon: PlayIcon, |
| 30 | description: "View your uploaded videos", |
| 31 | }, |
| 32 | { |
| 33 | name: "Processing", |
| 34 | href: "/dashboard/history", |
| 35 | icon: HistoryIcon, |
| 36 | description: "View your video processing history", |
| 37 | }, |
| 38 | { |
| 39 | name: "Subscription", |
| 40 | href: "/subscriptions/manage", |
| 41 | icon: CreditCardIcon, |
| 42 | description: "Manage your subscription plan", |
| 43 | }, |
| 44 | { |
| 45 | name: "Profile", |
| 46 | href: "/dashboard/profile", |
| 47 | icon: UserIcon, |
| 48 | description: "Manage your account settings", |
| 49 | }, |
| 50 | ]; |
| 51 | |
| 52 | export default function SidebarNav() { |
| 53 | const pathname = usePathname(); |
| 54 | const { user, logout } = useAuth(); |
| 55 | |
| 56 | return ( |
| 57 | <div className="hidden md:flex md:w-72 md:flex-col"> |
| 58 | <div className="flex flex-col flex-grow bg-white border-r border-gray-200"> |
| 59 | {/* logo section */} |
| 60 | <div className="flex items-center h-16 flex-shrink-0 px-6 border-b border-gray-200"> |
| 61 | <Link href="/dashboard" className="flex items-center gap-2"> |
| 62 | <Image |
| 63 | src="/logo.svg" |
| 64 | alt="logo" |
| 65 | width={32} |
| 66 | height={32} |
| 67 | className="w-8 h-8" |
| 68 | /> |
| 69 | <span className="text-xl font-bold">Video Processor</span> |
| 70 | </Link> |
| 71 | </div> |
| 72 | |
| 73 | {/* navigation links */} |
| 74 | <div className="flex-grow flex flex-col pt-5 pb-4 overflow-y-auto"> |
| 75 | <nav className="flex-1 px-3 space-y-2"> |
| 76 | {navigation.map((item) => { |
| 77 | const isActive = pathname === item.href; |
| 78 | return ( |
| 79 | <Link |
| 80 | key={item.name} |
| 81 | href={item.href} |
| 82 | className={cn( |
| 83 | "group relative flex items-center px-4 py-3 text-sm rounded-lg transition-all duration-200 ease-in-out", |
| 84 | isActive |
| 85 | ? "bg-primary text-primary-foreground shadow-sm" |
| 86 | : "text-gray-700 hover:bg-gray-100" |
| 87 | )} |
| 88 | > |
| 89 | <item.icon |
| 90 | className={cn( |
| 91 | "flex-shrink-0 size-5 transition-colors duration-200", |
| 92 | isActive |
| 93 | ? "text-primary-foreground" |
| 94 | : "text-gray-500 group-hover:text-gray-700" |
| 95 | )} |
| 96 | aria-hidden="true" |
| 97 | /> |
| 98 | <div className="ml-3 flex flex-col"> |
| 99 | <span className="font-medium">{item.name}</span> |
| 100 | <span |
| 101 | className={cn( |
| 102 | "text-xs mt-0.5", |
| 103 | isActive |
| 104 | ? "text-primary-foreground/80" |
| 105 | : "text-gray-500" |
| 106 | )} |
| 107 | > |
| 108 | {item.description} |
| 109 | </span> |
| 110 | </div> |
| 111 | {isActive && ( |
| 112 | <span |
| 113 | className="absolute right-2 size-1.5 rounded-full bg-primary-foreground/80" |
| 114 | aria-hidden="true" |
| 115 | /> |
| 116 | )} |
| 117 | </Link> |
| 118 | ); |
| 119 | })} |
| 120 | </nav> |
| 121 | |
| 122 | {/* footer section */} |
| 123 | <div className="px-3 pb-4 mt-auto space-y-4"> |
| 124 | {/* Subscription status */} |
| 125 | <SubscriptionStatus /> |
| 126 | |
| 127 | {/* User info */} |
| 128 | <div className="flex items-center justify-between"> |
| 129 | <p className="text-sm text-gray-500"> |
| 130 | Logged in as <span className="font-medium">{user?.name}</span> |
| 131 | </p> |
| 132 | <Button |
| 133 | variant="ghost" |
| 134 | size="icon" |
| 135 | className="p-2" |
| 136 | onClick={logout} |
| 137 | > |
| 138 | <LogOutIcon className="size-4" /> |
| 139 | </Button> |
| 140 | </div> |
| 141 | </div> |
| 142 | </div> |
| 143 | </div> |
| 144 | </div> |
| 145 | ); |
| 146 | } |