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:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user