refactor: maintain local state for PhoneInput typing to prevent input reset and add helper utilities for E.164 conversion.

This commit is contained in:
estifanos
2026-08-20 08:21:51 +00:00
parent 366ddd23a7
commit a0560f9cbc
5 changed files with 134 additions and 39 deletions

View File

@@ -14,7 +14,7 @@ import {
type FormSectionConfig,
type Vessel,
} from '@ema-platform/api';
import { AmharicDatePicker, CountrySelect } from '@ema-platform/ui';
import { AmharicDatePicker, CountrySelect, PhoneInput } from '@ema-platform/ui';
import { useTranslation } from 'react-i18next';
import { LocationPicker } from '../../location/components/LocationPicker';
@@ -223,6 +223,12 @@ export function ConfigDrivenSection({
value={(value as string) ?? ''}
onChange={(v) => onChange(field.key, v)}
/>
) : field.type === 'PHONE' ? (
<PhoneInput
{...common}
value={(value as string) ?? ''}
onChange={(v) => onChange(field.key, v)}
/>
) : field.type === 'TEXTAREA' ? (
<Textarea
{...common}

View File

@@ -147,12 +147,13 @@ export function AddressFormContent({
onChange={(val) => setValue('nationality', val || '', { shouldValidate: true })}
error={errors.nationality?.message}
/>
<TextInput
<PhoneInput
label={t('profileFields.primaryPhoneNumber')}
description={t('profileAddress.accountManagedHint')}
required
readOnly
{...register('primaryPhoneNumber')}
value={watch('primaryPhoneNumber') || ''}
onChange={(val) => setValue('primaryPhoneNumber', val, { shouldValidate: true })}
error={errors.primaryPhoneNumber?.message}
/>
<PhoneInput