<script setup lang="ts">
import { Head, Link } from '@inertiajs/vue3';
import { ArrowLeft } from '@lucide/vue';
import PurchasePosForm from './form/PurchasePosForm.vue';
import { Button } from '@/components/ui/button';
import AdminLayout from '@/layouts/AdminLayout.vue';
import type { PurchaseCartItem, PurchaseCatalogItem, SelectOption } from '@/types/purchase';

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>

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

        <PurchasePosForm
            :suppliers="suppliers"
            :catalog="catalog"
            :draft-items="draftItems"
            submit-url="/admin/manage/purchases"
            method="post"
            submit-label="Simpan"
        />
    </AdminLayout>
</template>
