store/resources/js/pages/admin/master/raw-materials/table/data-table-actions.vue
Yoga Pangestu bca6da8653
Some checks are pending
linter / quality (push) Waiting to run
tests / ci (8.3) (push) Waiting to run
tests / ci (8.4) (push) Waiting to run
tests / ci (8.5) (push) Waiting to run
feat: implement raw material deletion validation to prevent deletion if used in active cutting
2026-07-24 23:31:08 +07:00

39 lines
1.2 KiB
Vue

<script setup lang="ts">
import { RowDeleteAction, RowEditAction } from '@/components/button';
import { useCan } from '@/composables/useCan';
import { edit, destroy } from '@/routes/admin/master/raw_materials';
import type { RawMaterialListItem } from '@/types/raw-material';
defineProps<{
material: RawMaterialListItem;
}>();
const { can } = useCan();
function onDeleteError(errors: Record<string, string>): string | void {
const firstError = Object.values(errors)[0];
if (firstError) {
return firstError;
}
}
</script>
<template>
<div class="flex items-center justify-end gap-1">
<RowEditAction
v-if="can('raw_materials.update')"
:href="edit.url(material.id)"
tooltip="Ubah"
/>
<RowDeleteAction
v-if="can('raw_materials.delete')"
:action-url="destroy.url(material.id)"
title="Hapus bahan baku?"
:description="`Apakah Anda yakin ingin menghapus bahan baku ${material.name}? Tindakan ini tidak dapat dibatalkan.`"
error-message="Gagal menghapus bahan baku."
:on-error="onDeleteError"
/>
</div>
</template>