feat: alert after delete in rekammedis and obat

This commit is contained in:
yosaphatprs 2025-11-28 17:09:14 +07:00
parent ac39d8df2e
commit b78cbc4fe6
3 changed files with 80 additions and 2 deletions

View File

@ -28,6 +28,8 @@ const pendingDeleteItem = ref<T | null>(null);
const hasStatusColumn = () => props.columns.some((col) => col.key === "status");
const hasUserIdProcessColumn = () =>
props.columns.some((col) => col.key === "user_id_process");
const hasLastSyncColumn = () =>
props.columns.some((col) => col.key === "last_sync");
const formatCellValue = (item: T, columnKey: keyof T) => {
const value = item[columnKey];
@ -148,6 +150,29 @@ const handleDeleteCancel = () => {
Review
</RouterLink>
</td>
<td v-if="hasLastSyncColumn()">
<RouterLink
v-if="item.last_sync && item.id.split('_')[0] === 'REKAM'"
:to="`rekam-medis/${item.id.split('_')[1]}`"
class="text-dark hover:underline hover:text-white"
>
Review
</RouterLink>
<RouterLink
v-if="item.last_sync && item.id.split('_')[0] === 'OBAT'"
:to="`pemberian-obat/${item.id.split('_')[1]}`"
class="text-dark hover:underline hover:text-white"
>
Review
</RouterLink>
<RouterLink
v-if="item.last_sync && item.id.split('_')[0] === 'TINDAKAN'"
:to="`pemberian-tindakan/${item.id.split('_')[1]}`"
class="text-dark hover:underline hover:text-white"
>
Review
</RouterLink>
</td>
<td
v-if="item.deleted_status === 'DELETE_VALIDATION'"
v-for="column in columns"

View File

@ -34,6 +34,7 @@ interface ApiResponse {
const data = ref<ObatData[]>([]);
const searchObat = ref("");
const sortBy = ref("id");
const isDeleteSuccess = ref<boolean>(false);
const router = useRouter();
const route = useRoute();
@ -156,7 +157,10 @@ const handleUpdate = (item: ObatData) => {
const handleDelete = async (item: ObatData) => {
try {
await api.delete(`/obat/${item.id}`);
const result = await api.delete(`/obat/${item.id}`);
if (result) {
isDeleteSuccess.value = true;
}
await fetchData();
} catch (error) {
console.error("Error deleting obat:", error);
@ -250,6 +254,27 @@ onMounted(async () => {
</RouterLink>
</div>
<div
role="alert"
class="alert alert-success m-4 shadow-md"
v-if="isDeleteSuccess"
>
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6 shrink-0 stroke-current"
fill="none"
viewBox="0 0 24 24"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"
/>
</svg>
<span>Data obat berhasil dikirim untuk validasi penghapusan</span>
</div>
<!-- Data Table -->
<DataTable
:data="data"

View File

@ -36,6 +36,7 @@ interface ApiResponse {
const data = ref<RekamMedis[]>([]);
const searchRekamMedis = ref("");
const sortBy = ref("waktu_visit");
const isDeleteSuccess = ref<boolean>(false);
const router = useRouter();
const route = useRoute();
@ -275,7 +276,10 @@ const handleUpdate = (item: RekamMedis) => {
const handleDelete = async (item: RekamMedis) => {
try {
await api.delete(`/rekammedis/${item.id_visit}`);
const result = await api.delete(`/rekammedis/${item.id_visit}`);
if (result) {
isDeleteSuccess.value = true;
}
await fetchData();
} catch (error) {
console.error("Error deleting rekam medis:", error);
@ -602,6 +606,30 @@ onBeforeUnmount(() => {
</RouterLink>
</div>
<div
role="alert"
class="alert alert-success m-4 shadow-md"
v-if="isDeleteSuccess"
>
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6 shrink-0 stroke-current"
fill="none"
viewBox="0 0 24 24"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"
/>
</svg>
<span
>Data rekam medis berhasil dikirim untuk validasi
penghapusan</span
>
</div>
<!-- Data Table -->
<DataTable
:data="data"