import Link from "next/link";
import { cn } from "@/lib/utils";
import {
    FileText, Building2, Megaphone, Flag, Users, BarChart3
} from "lucide-react";

interface QuickAction {
    label: string;
    description: string;
    icon: React.ElementType;
    href: string;
    color: string;
    badge?: number;
}

interface QuickActionsProps {
    pendingApprovals?: number;
    reportedContent?: number;
}

export function QuickActions({ pendingApprovals = 0, reportedContent = 0 }: QuickActionsProps) {
    const actions: QuickAction[] = [
        {
            label: "Review Pending Jobs",
            description: `${pendingApprovals} waiting`,
            icon: FileText,
            href: "/admin/jobs/moderation",
            color: "orange",
            badge: pendingApprovals,
        },
        {
            label: "Verify Companies",
            description: "Review profiles",
            icon: Building2,
            href: "/admin/companies",
            color: "blue",
        },
        {
            label: "Send Announcement",
            description: "Platform-wide",
            icon: Megaphone,
            href: "/admin/announcements",
            color: "purple",
        },
        {
            label: "Review Reports",
            description: `${reportedContent} open`,
            icon: Flag,
            href: "/admin/reports",
            color: "red",
            badge: reportedContent,
        },
        {
            label: "User Management",
            description: "Search & manage",
            icon: Users,
            href: "/admin/users",
            color: "green",
        },
        {
            label: "Platform Analytics",
            description: "View metrics",
            icon: BarChart3,
            href: "/admin/analytics",
            color: "amber",
        },
    ];

    const colorClasses: Record<string, { bg: string; iconColor: string; hoverBorder: string }> = {
        orange: { bg: "bg-orange-50", iconColor: "text-orange-500", hoverBorder: "hover:border-orange-200" },
        blue: { bg: "bg-blue-50", iconColor: "text-blue-500", hoverBorder: "hover:border-blue-200" },
        purple: { bg: "bg-purple-50", iconColor: "text-purple-500", hoverBorder: "hover:border-purple-200" },
        red: { bg: "bg-red-50", iconColor: "text-red-500", hoverBorder: "hover:border-red-200" },
        green: { bg: "bg-emerald-50", iconColor: "text-emerald-500", hoverBorder: "hover:border-emerald-200" },
        amber: { bg: "bg-amber-50", iconColor: "text-amber-500", hoverBorder: "hover:border-amber-200" },
    };

    return (
        <div className="grid grid-cols-2 gap-3">
            {actions.map((action) => {
                const colors = colorClasses[action.color] || colorClasses.blue;
                return (
                    <Link
                        key={action.href}
                        href={action.href}
                        className={cn(
                            "relative flex flex-col items-center gap-2 rounded-xl border border-slate-100 bg-white p-4 text-center shadow-sm transition-all hover:shadow-md",
                            colors.hoverBorder
                        )}
                    >
                        <div className={cn(
                            "flex h-10 w-10 items-center justify-center rounded-lg",
                            colors.bg
                        )}>
                            <action.icon className={cn("h-5 w-5", colors.iconColor)} />
                        </div>
                        <div>
                            <p className="text-sm font-semibold text-slate-800">{action.label}</p>
                            <p className="mt-0.5 text-xs text-slate-400">{action.description}</p>
                        </div>
                        {action.badge !== undefined && action.badge > 0 && (
                            <span className="absolute -right-1 -top-1 flex h-5 min-w-5 items-center justify-center rounded-full bg-red-500 px-1.5 text-[10px] font-bold text-white">
                                {action.badge}
                            </span>
                        )}
                    </Link>
                );
            })}
        </div>
    );
}
