import { Head, usePage } from '@inertiajs/react';
import { CalendarClock, CheckSquare, Clock, FileWarning } from 'lucide-react';
import { EmptyState } from '@/components/empty-state';
import { PageHeader } from '@/components/page-header';
import {
    Card,
    CardContent,
    CardDescription,
    CardHeader,
    CardTitle,
} from '@/components/ui/card';
import { dashboard } from '@/routes';

const widgets = [
    {
        title: "Today's Hearings",
        description: 'Court appearances scheduled for today.',
        icon: CalendarClock,
        empty: 'No hearings today',
        hint: 'Hearings you are assigned to will appear here.',
    },
    {
        title: 'My Tasks',
        description: 'Tasks assigned to you, due soonest first.',
        icon: CheckSquare,
        empty: 'Nothing due',
        hint: 'Tasks assigned to you will show up here.',
    },
    {
        title: 'Pending Approvals',
        description: 'Items awaiting your sign-off.',
        icon: FileWarning,
        empty: 'All caught up',
        hint: 'Approvals that need your attention will appear here.',
    },
    {
        title: 'Upcoming Deadlines',
        description: 'Deadlines across your matters.',
        icon: Clock,
        empty: 'No upcoming deadlines',
        hint: 'Matter deadlines will be tracked here.',
    },
];

export default function Dashboard() {
    const name = usePage().props.auth?.user?.name ?? '';
    const firstName = name.split(' ')[0];

    return (
        <>
            <Head title="My Day" />
            <div className="flex flex-col gap-6 p-4">
                <PageHeader
                    title={firstName ? `Good day, ${firstName}` : 'My Day'}
                    subtitle="Here's what needs your attention. Live widgets arrive in a later phase."
                />

                <div className="grid gap-4 md:grid-cols-2 xl:grid-cols-4">
                    {widgets.map((w) => (
                        <Card key={w.title} className="flex flex-col">
                            <CardHeader>
                                <CardTitle className="flex items-center gap-2 text-base">
                                    <w.icon className="size-4 text-primary" />
                                    {w.title}
                                </CardTitle>
                                <CardDescription>
                                    {w.description}
                                </CardDescription>
                            </CardHeader>
                            <CardContent className="flex-1 p-0">
                                <EmptyState
                                    icon={w.icon}
                                    title={w.empty}
                                    description={w.hint}
                                />
                            </CardContent>
                        </Card>
                    ))}
                </div>
            </div>
        </>
    );
}

Dashboard.layout = {
    breadcrumbs: [
        {
            title: 'My Day',
            href: dashboard(),
        },
    ],
};
