wip: data masih dead pixel upload sukses
This commit is contained in:
@@ -10,7 +10,8 @@ import { PersonAddressSchema } from '~/schemas/person-address.schema'
|
||||
import { PersonContactListSchema } from '~/schemas/person-contact.schema'
|
||||
import { PersonFamiliesSchema } from '~/schemas/person-family.schema'
|
||||
import { ResponsiblePersonSchema } from '~/schemas/person-relative.schema'
|
||||
import { postPatient } from '~/services/patient.service'
|
||||
import { postPatient, uploadAttachment } from '~/services/patient.service'
|
||||
import { uploadCode } from '~/lib/constants'
|
||||
|
||||
// #region Props & Emits
|
||||
const props = defineProps<{
|
||||
@@ -97,13 +98,26 @@ async function sendRequest() {
|
||||
|
||||
try {
|
||||
const result = await postPatient(formData)
|
||||
const patientData: PatientBase = result.body
|
||||
const patientData: PatientBase = result.body.data
|
||||
if (result.success) {
|
||||
console.log('Patient created successfully:', patientData)
|
||||
const createdPatientId = patientData.id
|
||||
|
||||
// void run uploadAttachment in background so this try-catch non blocking
|
||||
// behavior: fire-and-forget
|
||||
if (patient?.values.residentIdentityFile) {
|
||||
void uploadAttachment(patient?.values.residentIdentityFile, createdPatientId, 'ktp')
|
||||
}
|
||||
|
||||
if (patient?.values.familyIdentityFile) {
|
||||
void uploadAttachment(patient?.values.familyIdentityFile, createdPatientId, 'kk')
|
||||
}
|
||||
// 30s
|
||||
await new Promise((r) => setTimeout(r, 30_000))
|
||||
|
||||
// If has callback provided redirect to callback with patientData
|
||||
if (props.callbackUrl) {
|
||||
await navigateTo(props.callbackUrl + '?patient-id=' + patientData.person_id)
|
||||
await navigateTo(props.callbackUrl + '?patient-id=' + patientData.id)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -115,7 +129,6 @@ async function sendRequest() {
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error creating patient:', error)
|
||||
// Handle error - show error message to user
|
||||
}
|
||||
}
|
||||
// #endregion region
|
||||
|
||||
Reference in New Issue
Block a user