<script setup lang="ts">
import { RowDeleteAction, RowEditAction } from '@/components/button';
import { useCan } from '@/composables/useCan';
import type { PurchaseListItem } from '@/types/purchase';
import { edit, destroy } from '@/routes/admin/manage/purchases';

defineProps<{
    purchase: PurchaseListItem;
}>();

const { can } = useCan();
</script>

<template>
    <div class="flex items-center justify-end gap-1">
        <RowEditAction v-if="can('purchases.update')" :href="edit.url(purchase.id)" />
        <RowDeleteAction v-if="can('purchases.delete')" :action-url="destroy.url(purchase.id)" title="Hapus belanja?"
            :description="`Belanja ${purchase.total_formatted} dari ${purchase.supplier_name} akan dihapus. Stok bahan baku akan dikurangi.`"
            error-message="Gagal menghapus belanja." />
    </div>
</template>
