39 lines
1.2 KiB
Vue
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>
|