wip: data masih dead pixel upload sukses

This commit is contained in:
Khafid Prayoga
2025-10-15 16:37:41 +07:00
parent 4976916780
commit 20b96ab7e4
7 changed files with 86 additions and 27 deletions
+17 -4
View File
@@ -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