<script setup lang="ts">
import { Head } from '@inertiajs/vue3';
import { useCan } from '@/composables/useCan';
import AdminLayout from '@/layouts/AdminLayout.vue';
import type { CuttingListItem } from '@/types/cutting';
import StockPendingApprovalSection from './table/StockPendingApprovalSection.vue';
import StockPendingSection from './table/StockPendingSection.vue';

defineProps<{
    pendingCuttings: CuttingListItem[];
    pendingApprovalCuttings: CuttingListItem[];
}>();

const { can } = useCan();
const isOwner = can('owner_verifications.verify');
</script>

<template>
    <Head title="Verifikasi Stok" />

    <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">
                    Verifikasi Stok
                </h2>
            </div>
        </div>

        <StockPendingApprovalSection v-if="isOwner" :cuttings="pendingApprovalCuttings" />
        <StockPendingSection v-else :cuttings="pendingCuttings" />
    </AdminLayout>
</template>
