From 44433d67c82f2cba897f926445698e15f7c175b1 Mon Sep 17 00:00:00 2001 From: Khafid Prayoga Date: Fri, 10 Oct 2025 10:38:43 +0700 Subject: [PATCH] refactor(select-relations): replace hardcoded options with relationshipCodes constant Use the centralized relationshipCodes constant from lib/constants instead of maintaining a duplicate list of options. This improves maintainability and ensures consistency across the application. --- .../person-relative/_common/select-relations.vue | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/app/components/app/person-relative/_common/select-relations.vue b/app/components/app/person-relative/_common/select-relations.vue index 179976bf..5c3d2594 100644 --- a/app/components/app/person-relative/_common/select-relations.vue +++ b/app/components/app/person-relative/_common/select-relations.vue @@ -4,6 +4,7 @@ import FieldGroup from '~/components/pub/my-ui/form/field-group.vue' import Field from '~/components/pub/my-ui/form/field.vue' import Select from '~/components/pub/my-ui/form/select.vue' import { cn } from '~/lib/utils' +import { relationshipCodes } from '~/lib/constants' const props = defineProps<{ fieldName: string @@ -18,15 +19,11 @@ const props = defineProps<{ const { fieldName = 'phoneNumber', errors, class: containerClass, selectClass, fieldGroupClass } = props -const emergencyContactOptions = [ - { label: 'Diri sendiri', value: 'self' }, - { label: 'Orang Tua', value: 'parent' }, - { label: 'Anak', value: 'child' }, - { label: 'Keluarga lain', value: 'relative' }, - { label: 'Petugas instansi lainnya', value: 'institution_officer' }, - { label: 'Petugas kesehatan', value: 'health_officer' }, - { label: 'Lainnya', value: 'other', priority: -1 }, -] +const emergencyContactOptions = Object.entries(relationshipCodes).map(([value, label]) => ({ + label, + value, + ...(value === 'other' && { priority: -1 }) +}))