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

defineProps<{
    customer: CustomerListItem;
}>();

const emit = defineEmits<{
    edit: [customer: CustomerListItem];
}>();

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

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