"use client";

import * as React from "react";
import {
    Archive,
    Bold,
    Bolt,
    BookCheck,
    BookMarked,
    Command,
    DatabaseBackup,
    FileKey2,
    Flag,
    FolderArchive,
    Frame,
    GalleryVertical,
    Home,
    LifeBuoy,
    NotepadText,
    Scale,
    Send,
    SquareTerminal,
} from "lucide-react";

import { NavMain } from "@/components/nav-main";
import { NavSecondary } from "@/components/nav-secondary";
import { NavUser } from "@/components/nav-user";
import {
    Sidebar,
    SidebarContent,
    SidebarFooter,
    SidebarHeader,
    SidebarMenu,
    SidebarMenuButton,
    SidebarMenuItem,
} from "@/components/ui/sidebar";
import { Link, usePage } from "@inertiajs/react";
import { PageProps } from "@/types";

const data = {
    user: {
        name: "shadcn",
        email: "m@example.com",
        avatar: "/avatars/shadcn.jpg",
    },
    navMain: [
        {
            title: "Dashboard",
            url: "/dashboard",
            icon: Home,
        },
        {
            title: "Pelaporan",
            url: "/admin/pelaporan",
            icon: BookMarked,
        },
        {
            title: "Verifikasi Pelaporan",
            url: "/admin/verifikasi",
            icon: BookCheck,
        },
        {
            title: "Penegakan Hukum",
            url: "/admin/hukum",
            icon: Scale,
        },
        {
            title: "Perizinan Lingkungan",
            url: "/admin/perizinan-lingkungan",
            icon: FileKey2,
        },
        {
            title: "History Perusahaan",
            url: "/admin/history-perusahaan",
            icon: GalleryVertical,
        },
        {
            title: "Post",
            url: "/admin/post",
            icon: Frame,
        },
        {
            title: "Reporting",
            url: "#",
            icon: Flag,
            isActive: true,
            items: [
                {
                    title: "Rekapitulasi",
                    url: "/admin/rekap",
                },
                {
                    title: "SKL & SPL",
                    url: "/admin/skl-spl",
                },
                {
                    title: "Daftar Perusahaan",
                    url: "/admin/daftar-perusahaan",
                },
                {
                    title: "SKL",
                    url: "/admin/skl",
                },
                {
                    title: "SPL",
                    url: "/admin/spl",
                },
            ],
        },
        {
            title: "Data Master",
            url: "#",
            icon: FolderArchive,
            isActive: true,
            items: [
                {
                    title: "Kategori Post",
                    url: "/admin/kategori",
                },
                {
                    title: "Sub Kategori Post",
                    url: "/admin/subkategori",
                },
                {
                    title: "Dinas LH",
                    url: "/admin/verifikator",
                },
                {
                    title: "Jenis Kegiatan",
                    url: "/admin/jeniskegiatan",
                },
                {
                    title: "Jenis Dokumen Izin",
                    url: "/admin/jenisdokil",
                },
                {
                    title: "Perusahaan",
                    url: "/admin/perusahaan",
                },
                {
                    title: "History Kegiatan",
                    url: "/admin/historykegiatan",
                },
                {
                    title: "Jenis Sanksi",
                    url: "/admin/jenissanksi",
                },
                {
                    title: "Status Penaatan",
                    url: "/admin/penaatan",
                },
            ],
        },
        {
            title: "Pengaturan",
            url: "#",
            icon: Bolt,
            isActive: true,
            items: [
                {
                    title: "Pengguna",
                    url: "/admin/pengguna",
                },
                {
                    title: "Role",
                    url: "/admin/role",
                },
            ],
        },
    ],
    navSecondary: [
        {
            title: "Tentang",
            url: "/admin/tentang",
            icon: LifeBuoy,
        },
        {
            title: "Catatan Sistem",
            url: "#",
            icon: NotepadText,
        },
        {
            title: "Backup",
            url: "#",
            icon: Archive,
        },
        {
            title: "Restore",
            url: "#",
            icon: DatabaseBackup,
        },
    ],
};

export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
    const { auth } = usePage<PageProps>().props;

    return (
        <Sidebar variant="inset" {...props}>
            <SidebarHeader>
                <SidebarMenu>
                    <SidebarMenuItem>
                        <SidebarMenuButton size="lg" asChild>
                            <Link href={route("dashboard")}>
                                <div className="flex aspect-square size-8 items-center justify-center rounded-lg text-sidebar-primary-foreground">
                                    {/* <Command className="size-4" /> */}
                                    <img
                                        src="/assets/logo_skl.svg"
                                        alt="Logo"
                                        className="w-12 h-12 md:w-16 md:h-16"
                                    />
                                </div>
                                <div className="grid flex-1 text-left text-sm leading-tight">
                                    <span className="truncate font-semibold">
                                        SKL
                                    </span>
                                    <span className="truncate text-xs">
                                        Status Ketaatan Lingkungan
                                    </span>
                                </div>
                            </Link>
                        </SidebarMenuButton>
                    </SidebarMenuItem>
                </SidebarMenu>
            </SidebarHeader>
            <SidebarContent>
                <NavMain items={data.navMain} />
                <NavSecondary items={data.navSecondary} className="mt-auto" />
            </SidebarContent>
            <SidebarFooter>
                <NavUser user={auth.user} />
            </SidebarFooter>
        </Sidebar>
    );
}
