import AuthenticatedLayout from "@/Layouts/AuthenticatedLayout";
import { Head, Link } from "@inertiajs/react";
import { Package, ArrowLeft } from "lucide-react";
import { Button } from "@/Components/ui/button";
import ProductForm from "@/Components/Product/ProductForm";
import { getCreateBreadcrumbs } from "@/utils/breadcrumb";
import type { Category } from "./Index";
import type { Unit } from "@/Components/Unit/UnitManagerDialog";

interface Props {
    categories: Category[];
    units: Unit[];
}

export default function Create({ categories, units }: Props) {
    return (
        <AuthenticatedLayout
            breadcrumbs={getCreateBreadcrumbs("products")}
        >
            <Head title="新增商品" />

            <div className="container mx-auto p-6 max-w-7xl">
                {/* Header */}
                <div className="mb-6">
                    <Link href={route("products.index")}>
                        <Button
                            variant="outline"
                            className="gap-2 button-outlined-primary mb-4"
                        >
                            <ArrowLeft className="h-4 w-4" />
                            返回商品列表
                        </Button>
                    </Link>

                    <div className="mb-4">
                        <h1 className="text-2xl font-bold text-grey-0 flex items-center gap-2">
                            <Package className="h-6 w-6 text-primary-main" />
                            新增商品
                        </h1>
                        <p className="text-gray-500 mt-1">
                            建立新的商品資料，包含基本資訊、價格與單位設定。
                        </p>
                    </div>
                </div>

                {/* 表單內容 */}
                <ProductForm
                    categories={categories}
                    units={units}
                />
            </div>
        </AuthenticatedLayout >
    );
}
