Merge branch 'dev' into feat/role-check
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
// Base
|
||||
import * as base from './_crud-base'
|
||||
|
||||
// Types
|
||||
import type { Ethnic } from '~/models/ethnic'
|
||||
|
||||
const path = '/api/v1/ethnic'
|
||||
const name = 'ethnic'
|
||||
|
||||
export function create(data: any) {
|
||||
return base.create(path, data, name)
|
||||
}
|
||||
|
||||
export function getList(params: any = null) {
|
||||
return base.getList(path, params, name)
|
||||
}
|
||||
|
||||
export function getDetail(id: number | string) {
|
||||
return base.getDetail(path, id, name)
|
||||
}
|
||||
|
||||
export function update(id: number | string, data: any) {
|
||||
return base.update(path, id, data, name)
|
||||
}
|
||||
|
||||
export function remove(id: number | string) {
|
||||
return base.remove(path, id, name)
|
||||
}
|
||||
|
||||
export async function getValueLabelList(
|
||||
params: any = null,
|
||||
useCodeAsValue = false,
|
||||
): Promise<{ value: string; label: string }[]> {
|
||||
let data: { value: string; label: string }[] = []
|
||||
const result = await getList(params)
|
||||
if (result.success) {
|
||||
const resultData = result.body?.data || []
|
||||
data = resultData.map((item: Ethnic) => ({
|
||||
value: useCodeAsValue ? item.code : item.id ? Number(item.id) : item.code,
|
||||
label: item.name,
|
||||
}))
|
||||
}
|
||||
return data
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// Base
|
||||
import * as base from './_crud-base'
|
||||
|
||||
// Types
|
||||
import type { Language } from '~/models/language'
|
||||
|
||||
const path = '/api/v1/language'
|
||||
const name = 'language'
|
||||
|
||||
export function create(data: any) {
|
||||
return base.create(path, data, name)
|
||||
}
|
||||
|
||||
export function getList(params: any = null) {
|
||||
return base.getList(path, params, name)
|
||||
}
|
||||
|
||||
export function getDetail(id: number | string) {
|
||||
return base.getDetail(path, id, name)
|
||||
}
|
||||
|
||||
export function update(id: number | string, data: any) {
|
||||
return base.update(path, id, data, name)
|
||||
}
|
||||
|
||||
export function remove(id: number | string) {
|
||||
return base.remove(path, id, name)
|
||||
}
|
||||
|
||||
export async function getValueLabelList(
|
||||
params: any = null,
|
||||
useCodeAsValue = false,
|
||||
): Promise<{ value: string; label: string }[]> {
|
||||
let data: { value: string; label: string }[] = []
|
||||
const result = await getList(params)
|
||||
if (result.success) {
|
||||
const resultData = result.body?.data || []
|
||||
data = resultData.map((item: Language) => ({
|
||||
value: useCodeAsValue ? item.code : item.id ? Number(item.id) : item.code,
|
||||
label: item.name,
|
||||
}))
|
||||
}
|
||||
return data
|
||||
}
|
||||
@@ -101,7 +101,7 @@ export async function removePatient(id: number) {
|
||||
}
|
||||
}
|
||||
|
||||
export async function uploadAttachment(file: File, userId: number, key: UploadCodeKey) {
|
||||
export async function uploadAttachment(file: File, personId: number, key: UploadCodeKey) {
|
||||
try {
|
||||
const resolvedKey = uploadCode[key]
|
||||
if (!resolvedKey) {
|
||||
@@ -110,11 +110,14 @@ export async function uploadAttachment(file: File, userId: number, key: UploadCo
|
||||
|
||||
// siapkan form-data body
|
||||
const formData = new FormData()
|
||||
formData.append('code', resolvedKey)
|
||||
formData.append('content', file)
|
||||
formData.append('entityType_code', 'person')
|
||||
formData.append('ref_id', String(personId))
|
||||
// formData.append('upload_employee_id', String(userId))
|
||||
formData.append('type_code', resolvedKey)
|
||||
|
||||
// kirim via xfetch
|
||||
const resp = await xfetch(`${mainUrl}/${userId}/upload`, 'POST', formData)
|
||||
const resp = await xfetch(`/api/v1/upload-file`, 'POST', formData)
|
||||
|
||||
// struktur hasil sama seperti patchPatient
|
||||
const result: any = {}
|
||||
|
||||
Reference in New Issue
Block a user