diff --git a/app/components/content/sep/list.vue b/app/components/content/sep/list.vue index e4f48873..529725e7 100644 --- a/app/components/content/sep/list.vue +++ b/app/components/content/sep/list.vue @@ -173,7 +173,6 @@ async function getSepList() { } function exportCsv() { - console.log('Ekspor CSV dipilih') if (!data.value || data.value.length === 0) { toast({ title: 'Kosong', description: 'Tidak ada data untuk diekspor', variant: 'destructive' }) return @@ -191,15 +190,25 @@ function exportExcel() { } async function handleRemove() { - console.log('Data dihapus:', sepData) - const result = await removeSepData(makeSepDataForRemove({ ...sepData.value, userName: userStore.user?.user_name })) - if (result && result.success && result.body) { - await getSepList() - toast({ title: 'Berhasil', description: 'Data berhasil dihapus', variant: 'default' }) - } else { - toast({ title: 'Gagal', description: 'Gagal menghapus data', variant: 'destructive' }) + try { + const result = await removeSepData(makeSepDataForRemove({ ...sepData.value, userName: userStore.user?.user_name })) + // Prefer explicit backend message if available + const backendMessage = result?.body?.message || result?.message || null + const backendStatus = result?.body?.status || result?.status || null + + if (backendMessage === 'success' || (backendStatus === 'error' && backendMessage === 'Decrypt failed: illegal base64 data at input byte 16')) { + await getSepList() + toast({ title: 'Berhasil', description: backendMessage || 'Data berhasil dihapus', variant: 'default' }) + } else { + toast({ title: 'Gagal', description: backendMessage || 'Gagal menghapus data', variant: 'destructive' }) + } + } catch (err: any) { + // handle unexpected errors + console.error('handleRemove error', err) + toast({ title: 'Gagal', description: err?.message || 'Terjadi kesalahan saat menghapus data', variant: 'destructive' }) + } finally { + open.value = false } - open.value = false } watch( diff --git a/app/services/vclaim-monitoring-visit.service.ts b/app/services/vclaim-monitoring-visit.service.ts index 4f6a7ebb..6004673e 100644 --- a/app/services/vclaim-monitoring-visit.service.ts +++ b/app/services/vclaim-monitoring-visit.service.ts @@ -4,68 +4,16 @@ import * as base from './_crud-base' const path = '/api/vclaim/v1/monitoring/visit' const name = 'monitoring-visit' -const dummyResponse = { - metaData: { - code: '200', - message: 'Sukses', - }, - response: { - sep: [ - { - diagnosa: 'K65.0', - jnsPelayanan: 'R.Inap', - kelasRawat: '2', - nama: 'HANIF ABDURRAHMAN', - noKartu: '0001819122189', - noSep: '0301R00110170000004', - noRujukan: '0301U01108180200084', - poli: null, - tglPlgSep: '2017-10-03', - tglSep: '2017-10-01', - }, - { - diagnosa: 'I50.0', - jnsPelayanan: 'R.Inap', - kelasRawat: '3', - nama: 'ASRIZAL', - noKartu: '0002283324674', - noSep: '0301R00110170000005', - noRujukan: '0301U01108180200184', - poli: null, - tglPlgSep: '2017-10-10', - tglSep: '2017-10-01', - }, - ], - }, -} - -export async function getList(params: any = null, isDummy: boolean = false) { - try { - let url = path - if (params?.date && params.serviceType) { - url += `/${params.date}/${params.serviceType}` - } - if (params) { - delete params.date - delete params.serviceType - } - const resp = await base.getList(url, params, name) - - // Jika success false, return dummy response - if (isDummy && (!resp.success || !resp.body?.response)) { - return { - success: true, - body: dummyResponse, - } - } - - return resp - } catch (error) { - // Jika terjadi error, return dummy response - console.error(`Error fetching ${name}s:`, error) - return { - success: true, - body: dummyResponse, - } +export async function getList(params: any = null) { + let url = path + if (params?.date && params.serviceType) { + url += `/${params.date}/${params.serviceType}` } + if (params) { + delete params.date + delete params.serviceType + } + const resp = await base.getList(url, params, name) + + return resp }