<script setup lang="ts">
import { Head } from '@inertiajs/vue3';
import BackButton from '@/components/button/BackButton.vue';
import AdminLayout from '@/layouts/AdminLayout.vue';
import { index, store } from '@/routes/admin/manage/cuttings';
import type {
    CuttingMaterialCartItem,
    CuttingProductCatalogItem,
    CuttingRawMaterialCatalogItem,
    CuttingResultCartItem,
} from '@/types/cutting';
import type { CategoryOption } from '@/types/product';
import type { EnumOption } from '@/types/raw-material';
import CuttingPosForm from './form/CuttingPosForm.vue';

defineProps<{
    rawMaterialCatalog: CuttingRawMaterialCatalogItem[];
    productCatalog: CuttingProductCatalogItem[];
    draftMaterials: CuttingMaterialCartItem[];
    draftResults: CuttingResultCartItem[];
    categories: CategoryOption[];
    units: EnumOption[];
}>();
</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>

            <BackButton :href="index.url()" />
        </div>

        <CuttingPosForm
            :raw-material-catalog="rawMaterialCatalog"
            :product-catalog="productCatalog"
            :draft-materials="draftMaterials"
            :draft-results="draftResults"
            :categories="categories"
            :units="units"
            :submit-url="store.url()"
            method="post"
            submit-label="Simpan"
        />
    </AdminLayout>
</template>
