<script setup lang="ts">
import { RowDeleteAction, RowEditAction } from '@/components/button';
import { useCan } from '@/composables/useCan';
import { destroy } from '@/routes/admin/finance/expenses';
import type { ExpenseListItem } from '@/types/expense';

defineProps<{
    expense: ExpenseListItem;
}>();

const emit = defineEmits<{
    edit: [expense: ExpenseListItem];
}>();

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

<template>
    <div class="flex items-center justify-end gap-1">
        <RowEditAction v-if="can('expenses.update')" @click="emit('edit', expense)" />
        <RowDeleteAction v-if="can('expenses.delete')" :action-url="destroy.url(expense.id)" title="Hapus pengeluaran?"
            :description="`Pengeluaran ${expense.amount_formatted} akan dihapus. Saldo kas akan disesuaikan.`"
            error-message="Gagal menghapus pengeluaran." />
    </div>
</template>
