<script setup lang="ts">
import { RowDeleteAction, RowEditAction } from '@/components/button';
import { useCan } from '@/composables/useCan';
import { destroy } from '@/routes/admin/master/suppliers';
import type { SupplierListItem } from '@/types/supplier';

defineProps<{
    supplier: SupplierListItem;
}>();

const emit = defineEmits<{
    edit: [supplier: SupplierListItem];
}>();

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

<template>
    <div class="flex items-center justify-end gap-1">
        <RowEditAction v-if="can('suppliers.update')" @click="emit('edit', supplier)" />
        <RowDeleteAction v-if="can('suppliers.delete')" :action-url="destroy.url(supplier.id)" title="Hapus supplier?"
            :description="`Supplier ${supplier.name} akan dihapus secara permanen. Tindakan ini tidak dapat dibatalkan.`"
            error-message="Gagal menghapus supplier." />
    </div>
</template>
