| 1 |
import type { Field, NameSubField, AddressSubField } from '@/types/field' |
| 2 |
|
| 3 |
export type ParentFieldTemplate = Omit< |
| 4 |
Field, |
| 5 |
'id' | 'formId' | 'fieldIndex' | 'position' | 'value' |
| 6 |
> & { |
| 7 |
nameFields?: NameSubField[] |
| 8 |
addressFields?: AddressSubField[] |
| 9 |
} |
| 10 |
|
| 11 |
type SubFieldsBuilder = (getLabel: (key: string) => string) => unknown[] |
| 12 |
|
| 13 |
export interface ParentChildFieldConfig { |
| 14 |
type: string |
| 15 |
buildSubFields: SubFieldsBuilder |
| 16 |
subFieldKey: string |
| 17 |
} |
| 18 |
|
| 19 |
export const parentChildFieldConfigs: Record<string, ParentChildFieldConfig> = { |
| 20 |
name: { |
| 21 |
type: 'name', |
| 22 |
buildSubFields: (getLabel) => [ |
| 23 |
{ |
| 24 |
type: 'text', |
| 25 |
id: '', |
| 26 |
modelValue: '', |
| 27 |
label: getLabel('first_name'), |
| 28 |
required: false, |
| 29 |
optionHide: false, |
| 30 |
description: '', |
| 31 |
placeholder: '', |
| 32 |
labelPosition: 'default', |
| 33 |
}, |
| 34 |
{ |
| 35 |
type: 'text', |
| 36 |
id: '', |
| 37 |
modelValue: '', |
| 38 |
label: getLabel('last_name'), |
| 39 |
required: false, |
| 40 |
optionHide: false, |
| 41 |
description: '', |
| 42 |
placeholder: '', |
| 43 |
labelPosition: 'default', |
| 44 |
}, |
| 45 |
], |
| 46 |
subFieldKey: 'nameFields', |
| 47 |
}, |
| 48 |
address: { |
| 49 |
type: 'address', |
| 50 |
buildSubFields: (getLabel) => [ |
| 51 |
{ |
| 52 |
type: 'streetAddress', |
| 53 |
id: '', |
| 54 |
label: getLabel('street_address'), |
| 55 |
value: '', |
| 56 |
placeholder: '', |
| 57 |
required: false, |
| 58 |
hideLabel: false, |
| 59 |
description: '', |
| 60 |
requiredMessage: '', |
| 61 |
visible: true, |
| 62 |
}, |
| 63 |
{ |
| 64 |
type: 'addressLine2', |
| 65 |
id: '', |
| 66 |
label: getLabel('address_line_2'), |
| 67 |
value: '', |
| 68 |
placeholder: '', |
| 69 |
required: false, |
| 70 |
hideLabel: false, |
| 71 |
description: '', |
| 72 |
requiredMessage: '', |
| 73 |
visible: true, |
| 74 |
}, |
| 75 |
{ |
| 76 |
type: 'city', |
| 77 |
id: '', |
| 78 |
label: getLabel('city'), |
| 79 |
value: '', |
| 80 |
placeholder: '', |
| 81 |
required: false, |
| 82 |
hideLabel: false, |
| 83 |
description: '', |
| 84 |
requiredMessage: '', |
| 85 |
visible: true, |
| 86 |
}, |
| 87 |
{ |
| 88 |
type: 'state', |
| 89 |
id: '', |
| 90 |
label: getLabel('state'), |
| 91 |
value: '', |
| 92 |
placeholder: '', |
| 93 |
required: false, |
| 94 |
hideLabel: false, |
| 95 |
description: '', |
| 96 |
requiredMessage: '', |
| 97 |
visible: true, |
| 98 |
}, |
| 99 |
{ |
| 100 |
type: 'zip', |
| 101 |
id: '', |
| 102 |
label: getLabel('zip'), |
| 103 |
value: '', |
| 104 |
placeholder: '', |
| 105 |
required: false, |
| 106 |
hideLabel: false, |
| 107 |
description: '', |
| 108 |
requiredMessage: '', |
| 109 |
visible: true, |
| 110 |
}, |
| 111 |
{ |
| 112 |
type: 'country', |
| 113 |
id: '', |
| 114 |
label: getLabel('country'), |
| 115 |
value: '', |
| 116 |
placeholder: '', |
| 117 |
required: false, |
| 118 |
hideLabel: false, |
| 119 |
description: '', |
| 120 |
requiredMessage: '', |
| 121 |
visible: true, |
| 122 |
}, |
| 123 |
], |
| 124 |
subFieldKey: 'addressFields', |
| 125 |
}, |
| 126 |
} |
| 127 |
|