Files
simrsx-fe/app/services/vclaim-unit.service.ts

31 lines
935 B
TypeScript

// Base
import * as base from './_crud-base'
const path = '/api/v1/reference/unit'
const pathOld = '/api/vclaim/v1/reference/unit'
const name = 'unit'
export function getList(params: any = null) {
const isNew = true
let url = !isNew ? pathOld : path
if (params?.unitCode) {
url += `/${params.unitCode}`
delete params.unitCode
}
return base.getList(url, params, name)
}
export async function getValueLabelList(params: any = null): Promise<{ value: string; label: string }[]> {
let data: { value: string; label: string }[] = []
const result = await getList(params)
if (result.success) {
const resultData = result.body?.response?.faskes || []
const resultUnique = [...new Map(resultData.map((item: any) => [item.kode, item])).values()]
data = resultUnique.map((item: any) => ({
value: item.kode ? String(item.kode) : '',
label: `${item.kode} - ${item.nama}`,
}))
}
return data
}