diff --git a/app/components/app/patient/preview.vue b/app/components/app/patient/preview.vue index a72233a5..79eba5a3 100644 --- a/app/components/app/patient/preview.vue +++ b/app/components/app/patient/preview.vue @@ -7,15 +7,19 @@ import type { PersonRelative } from '~/models/person-relative' import DetailRow from '~/components/pub/my-ui/form/view/detail-row.vue' import DetailSection from '~/components/pub/my-ui/form/view/detail-section.vue' -import { educationCodes, genderCodes, occupationCodes, personContactTypes, relationshipCodes, religionCodes } from '~/lib/constants' +import { + educationCodes, + genderCodes, + occupationCodes, + personContactTypes, + relationshipCodes, + religionCodes, +} from '~/lib/constants' import { mapToComboboxOptList } from '~/lib/utils' // #region Props & Emits const props = defineProps<{ person: Person - personAddresses: PersonAddress[] - personContacts: PersonContact[] - personRelatives: PersonRelative[] }>() const emit = defineEmits<{ @@ -32,8 +36,18 @@ const occupationOptions = mapToComboboxOptList(occupationCodes) const relationshipOptions = mapToComboboxOptList(relationshipCodes) const personContactTypeOptions = mapToComboboxOptList(personContactTypes) -const residentAddress = 'Jl. Puncak Borobudur Blok M No. 321, Lowokwaru, Kota Malang, Jawa Timur' -const primaryAddress = 'Perumahan Araya Cluster B, No 22, Blimbing, Kota Malang, Jawa Timur' +// Computed addresses from nested data +const residentAddress = computed(() => { + const addresses = props.person.addresses + const resident = addresses?.find((addr) => addr.locationType === 'resident') + return resident?.address || 'Jl. Puncak Borobudur Blok M No. 321, Lowokwaru, Kota Malang, Jawa Timur' +}) + +const primaryAddress = computed(() => { + const addresses = props.person.addresses + const primary = addresses?.find((addr) => addr.locationType === 'primary') + return primary?.address || 'Perumahan Araya Cluster B, No 22, Blimbing, Kota Malang, Jawa Timur' +}) const patientAge = computed(() => { if (!props.person.birthDate) { @@ -96,7 +110,9 @@ function onClick(type: string) { {{ educationOptions.find((item) => item.code === person.education_code)?.label || '-' }} - {{ occupationOptions.find((item) => item.code === person.occupation_code)?.label || person.occupation_name || '-' }} + {{ + occupationOptions.find((item) => item.code === person.occupation_code)?.label || person.occupation_name || '-' + }} @@ -105,13 +121,13 @@ function onClick(type: string) { {{ primaryAddress || '-' }} - -