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.
This commit is contained in:
Khafid Prayoga
2025-10-10 10:38:43 +07:00
parent 7f6e0cc1fd
commit 44433d67c8
@@ -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 })
}))
</script>
<template>