<script setup lang="ts">
import { Head, Link } from '@inertiajs/vue3';
import { ArrowLeft } from '@lucide/vue';
import CuttingPosForm from './form/CuttingPosForm.vue';
import { Button } from '@/components/ui/button';
import AdminLayout from '@/layouts/AdminLayout.vue';
import type { CuttingMaterialCartItem, CuttingProductCatalogItem, CuttingRawMaterialCatalogItem, CuttingResultCartItem } from '@/types/cutting';

defineProps<{
    rawMaterialCatalog: CuttingRawMaterialCatalogItem[];
    productCatalog: CuttingProductCatalogItem[];
    draftMaterials: CuttingMaterialCartItem[];
    draftResults: CuttingResultCartItem[];
}>();
</script>

<template>
    <Head title="Tambah Cutting" />

    <AdminLayout>
        <div class="flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
            <div class="space-y-1">
                <h2 class="text-2xl font-bold tracking-tight">
                    Tambah Cutting
                </h2>
            </div>

            <Button variant="outline" as-child class="shrink-0 self-start sm:self-center">
                <Link href="/admin/manage/cuttings">
                    <ArrowLeft class="size-4" />
                    Kembali
                </Link>
            </Button>
        </div>

        <CuttingPosForm
            :raw-material-catalog="rawMaterialCatalog"
            :product-catalog="productCatalog"
            :draft-materials="draftMaterials"
            :draft-results="draftResults"
            submit-url="/admin/manage/cuttings"
            method="post"
            submit-label="Simpan"
        />
    </AdminLayout>
</template>
