-
+
@@ -403,10 +403,10 @@ watch(
diff --git a/app/components/app/person-address/entry-form.vue b/app/components/app/person-address/entry-form.vue
index c12ed0c0..1c9998d7 100644
--- a/app/components/app/person-address/entry-form.vue
+++ b/app/components/app/person-address/entry-form.vue
@@ -160,7 +160,9 @@ watch(
:validation-schema="formSchema"
:validate-on-mount="false"
validation-mode="onSubmit"
- :initial-values="initialValues ? { locationType: 'domicile', ...initialValues } : { locationType: 'domicile' }"
+ :initial-values="
+ initialValues ? { locationType_code: 'domicile', ...initialValues } : { locationType_code: 'domicile' }
+ "
>
-
+
@@ -251,7 +253,7 @@ watch(
{
regency_code: currentAddressValues.regency_code || undefined,
district_code: currentAddressValues.district_code || undefined,
village_code: currentAddressValues.village_code || undefined,
- postalCode_code: currentAddressValues.postalCode_code || undefined,
+ postalRegion_code: currentAddressValues.postalRegion_code || undefined,
address: currentAddressValues.address || undefined,
rt: currentAddressValues.rt || undefined,
rw: currentAddressValues.rw || undefined,
@@ -64,10 +64,7 @@ onMounted(() => {
// #endregion
// #region Functions
-// #endregion region
-
-// #region Utilities & event handlers
-async function submitAll() {
+async function sendRequest() {
const [patient, address, addressRelative, families, contacts, emergencyContact] = await Promise.all([
personPatientForm.value?.validate(),
personAddressForm.value?.validate(),
@@ -95,6 +92,7 @@ async function submitAll() {
}
const formData = genPatient(formDataRequest)
+ console.log(formData)
payload.value = formData
try {
@@ -120,6 +118,21 @@ async function submitAll() {
// Handle error - show error message to user
}
}
+// #endregion region
+
+// #region Utilities & event handlers
+async function handleActionClick(eventType: string) {
+ if (eventType === 'submit') {
+ await sendRequest()
+ return
+ }
+
+ if (eventType === 'cancel') {
+ navigateTo({
+ name: 'client-patient',
+ })
+ }
+}
// #endregion
// #region Watchers
@@ -141,7 +154,7 @@ watch(
regency_code: currentAddressValues.regency_code || undefined,
district_code: currentAddressValues.district_code || undefined,
village_code: currentAddressValues.village_code || undefined,
- postalCode_code: currentAddressValues.postalCode_code || undefined,
+ postalRegion_code: currentAddressValues.postalRegion_code || undefined,
address: currentAddressValues.address || undefined,
rt: currentAddressValues.rt || undefined,
rw: currentAddressValues.rw || undefined,
@@ -172,7 +185,7 @@ watch(
regency_code: newAddressValues.regency_code || undefined,
district_code: newAddressValues.district_code || undefined,
village_code: newAddressValues.village_code || undefined,
- postalCode_code: newAddressValues.postalCode_code || undefined,
+ postalRegion_code: newAddressValues.postalRegion_code || undefined,
address: newAddressValues.address || undefined,
rt: newAddressValues.rt || undefined,
rw: newAddressValues.rw || undefined,
@@ -191,7 +204,7 @@ watch(
if (
(isSameAddress === true || isSameAddress === '1') &&
personAddressForm.value?.values &&
- personAddressRelativeForm.value
+ personAddressRelativeForm.value?.values
) {
// Ketika isSameAddress diubah menjadi true, copy alamat sekarang ke alamat KTP
const currentAddressValues = personAddressForm.value.values
@@ -202,7 +215,7 @@ watch(
regency_code: currentAddressValues.regency_code || undefined,
district_code: currentAddressValues.district_code || undefined,
village_code: currentAddressValues.village_code || undefined,
- postalCode_code: currentAddressValues.postalCode_code || undefined,
+ postalRegion_code: currentAddressValues.postalRegion_code || undefined,
address: currentAddressValues.address || undefined,
rt: currentAddressValues.rt || undefined,
rw: currentAddressValues.rw || undefined,
@@ -249,7 +262,7 @@ watch(
/>
diff --git a/app/composables/usePostalCodes.ts b/app/composables/usePostalRegion.ts
similarity index 65%
rename from app/composables/usePostalCodes.ts
rename to app/composables/usePostalRegion.ts
index d2e8ff34..79b04955 100644
--- a/app/composables/usePostalCodes.ts
+++ b/app/composables/usePostalRegion.ts
@@ -1,23 +1,23 @@
import { ref, computed, watch, readonly, type Ref } from 'vue'
import { refDebounced } from '@vueuse/core'
-import type { PostalCode } from '~/models/postal-code'
+import type { PostalRegion } from '~/models/postal-region'
import type { SelectItem } from '~/components/pub/my-ui/form/select.vue'
-import * as postalCodeService from '../services/postal-code.service'
+import * as postalRegionService from '~/services/postal-region.service'
// Global cache untuk postal codes berdasarkan village code
-const postalCodesCache = ref