refactor: fixes to custom field

This commit is contained in:
Carlos Valente
2025-07-11 16:49:41 +02:00
parent 4d419c0877
commit d8c1c38123
20 changed files with 103 additions and 108 deletions
@@ -16,7 +16,7 @@ interface CustomFieldEntryProps {
colour: string;
label: string;
fieldKey: string;
type: 'string' | 'image';
type: CustomField['type'];
onEdit: (key: CustomFieldKey, patch: CustomField) => Promise<void>;
onDelete: (key: CustomFieldKey) => Promise<void>;
}
@@ -42,7 +42,7 @@ export default function CustomFieldForm(props: CustomFieldsFormProps) {
watch,
formState: { errors, isSubmitting, isValid, isDirty },
} = useForm<CustomFieldFormData>({
defaultValues: { type: 'string', label: initialLabel || '', colour: initialColour || '' },
defaultValues: { type: 'text', label: initialLabel || '', colour: initialColour || '' },
resetOptions: {
keepDirtyValues: true,
},
@@ -96,7 +96,7 @@ export default function CustomFieldForm(props: CustomFieldsFormProps) {
onValueChange={(value) => setValue('type', value, { shouldDirty: true })}
value={watch('type')}
items={[
{ value: 'string', label: 'Text' },
{ value: 'text', label: 'Text' },
{ value: 'image', label: 'Image' },
]}
/>
@@ -30,7 +30,7 @@ export default function EntryEditorCustomFields({
const { backgroundColor, color } = getAccessibleColour(customFields[fieldKey].colour);
const labelText = customFields[fieldKey].label;
if (customFields[fieldKey].type === 'string') {
if (customFields[fieldKey].type === 'text') {
return (
<EventTextArea
key={key}