<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/purchases';
import type {
    PurchaseCartItem,
    PurchaseCatalogItem,
    SelectOption,
} from '@/types/purchase';
import PurchasePosForm from './form/PurchasePosForm.vue';

defineProps<{
    suppliers: SelectOption[];
    catalog: PurchaseCatalogItem[];
    draftItems: PurchaseCartItem[];
}>();
</script>

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

    <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 Belanja
                </h2>
            </div>

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

        <PurchasePosForm
            :suppliers="suppliers"
            :catalog="catalog"
            :draft-items="draftItems"
            :submit-url="store.url()"
            method="post"
            submit-label="Simpan"
        />
    </AdminLayout>
</template>
