feat(vclaim-monitoring): enhance getList function to return dummy response on failure
This commit is contained in:
@@ -4,14 +4,68 @@ import * as base from './_crud-base'
|
||||
const path = '/api/vclaim/v1/monitoring/visit'
|
||||
const name = 'monitoring-visit'
|
||||
|
||||
export 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
|
||||
}
|
||||
return base.getList(url, params, name)
|
||||
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) {
|
||||
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 (!resp.success) {
|
||||
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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user