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

defineProps<{
    category: CategoryListItem;
}>();

const emit = defineEmits<{
    edit: [category: CategoryListItem];
}>();

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

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