import { NavMain } from '@/components/nav-main';
import { NavUser } from '@/components/nav-user';
import { Sidebar, SidebarContent, SidebarFooter, SidebarHeader, SidebarMenu, SidebarMenuButton, SidebarMenuItem } from '@/components/ui/sidebar';
import { type NavItem } from '@/types';
import { Link, usePage } from '@inertiajs/react';
import { ArrowDownToLine, ArrowUpToLine, History, LayoutGrid, ListChecks, UserIcon, Users } from 'lucide-react';
import AppLogo from './app-logo';

const mainNavItems: NavItem[] = [
    {
        title: 'Dashboard',
        href: '/dashboard',
        icon: LayoutGrid,
    },
    {
        title: 'Deposit',
        href: '/deposit',
        icon: ArrowUpToLine,
    },
    {
        title: 'Withdraw',
        href: '/withdraw',
        icon: ArrowDownToLine,
    },
    {
        title: 'Deposit List',
        href: '/deposit-list',
        icon: ListChecks,
    },
    {
        title: 'History',
        href: '/history',
        icon: History,
    },
    {
        title: 'Referrals',
        href: '/referrals',
        icon: Users,
    },
];

const adminNavItems: NavItem[] = [
    {
        title: 'Dashboard',
        href: '/dashboard',
        icon: LayoutGrid,
    },
    {
        title: 'Manage Deposits',
        href: '/deposit',
        icon: ArrowUpToLine,
    },
    {
        title: 'Manage Withdrawals',
        href: '/withdraw',
        icon: ArrowDownToLine,
    },
    {
        title: 'Manage Users',
        href: '/users',
        icon: UserIcon,
    },
];

// const footerNavItems: NavItem[] = [
//     {
//         title: 'Repository',
//         href: 'https://github.com/laravel/react-starter-kit',
//         icon: Folder,
//     },
//     {
//         title: 'Documentation',
//         href: 'https://laravel.com/docs/starter-kits#react',
//         icon: BookOpen,
//     },
// ];

export function AppSidebar() {
    const { roles } = usePage().props.auth;
    
    return (
        <Sidebar collapsible="icon" variant="inset">
            <SidebarHeader>
                <SidebarMenu>
                    <SidebarMenuItem>
                        <SidebarMenuButton size="lg" asChild>
                            <Link href="/dashboard" prefetch>
                                <AppLogo />
                            </Link>
                        </SidebarMenuButton>
                    </SidebarMenuItem>
                </SidebarMenu>
            </SidebarHeader>

            <SidebarContent>
                <NavMain items={roles.includes('user') ? mainNavItems : adminNavItems} />
            </SidebarContent>

            <SidebarFooter>
                {/* <NavFooter items={footerNavItems} className="mt-auto" /> */}
                <NavUser />
            </SidebarFooter>
        </Sidebar>
    );
}
