fix problem update address
This commit is contained in:
@@ -33,7 +33,7 @@ const Select: FC<Props> = (props: Props) => {
|
||||
)}>
|
||||
{
|
||||
props.placeholder &&
|
||||
<option value="" disabled selected>{props.placeholder}</option>
|
||||
<option value="" disabled>{props.placeholder}</option>
|
||||
}
|
||||
{
|
||||
props.items?.map((item) => {
|
||||
|
||||
@@ -32,7 +32,7 @@ const AddressForm: FC<AddressFormProps> = ({ selectedAddress, isEditMode, onCanc
|
||||
|
||||
type FormData = CreateAddressType & { password?: string; quotaMB?: number }
|
||||
|
||||
const { register, handleSubmit, formState: { errors }, setValue, reset, setError, clearErrors, getValues
|
||||
const { register, handleSubmit, formState: { errors }, setValue, reset, setError, clearErrors
|
||||
} = useForm<FormData>({
|
||||
defaultValues: {
|
||||
domainId: domain?.data?.domain?.id,
|
||||
@@ -134,7 +134,7 @@ const AddressForm: FC<AddressFormProps> = ({ selectedAddress, isEditMode, onCanc
|
||||
password: '',
|
||||
domainId: selectedAddress.domain.id,
|
||||
quotaMB: selectedAddress.emailQuota ? Math.round(selectedAddress.emailQuota / (1024 * 1024)) : undefined,
|
||||
templateId: selectedAddress.template || undefined,
|
||||
templateId: selectedAddress.template || '',
|
||||
})
|
||||
setForwarders(selectedAddress.forwarders || [])
|
||||
} else if (!isEditMode) {
|
||||
@@ -144,11 +144,11 @@ const AddressForm: FC<AddressFormProps> = ({ selectedAddress, isEditMode, onCanc
|
||||
password: '',
|
||||
domainId: domain?.data?.domain?.id,
|
||||
quotaMB: undefined,
|
||||
templateId: domain?.data?.template,
|
||||
templateId: domain?.data?.template || '',
|
||||
})
|
||||
setForwarders([])
|
||||
}
|
||||
}, [selectedAddress, isEditMode, reset, domain])
|
||||
}, [selectedAddress, isEditMode, reset, domain, templates])
|
||||
|
||||
return (
|
||||
<div className='xl:w-[350px] w-full bg-white rounded-4xl p-8'>
|
||||
@@ -196,8 +196,7 @@ const AddressForm: FC<AddressFormProps> = ({ selectedAddress, isEditMode, onCanc
|
||||
}))
|
||||
: []
|
||||
}
|
||||
onChange={(e) => setValue('templateId', e.target.value)}
|
||||
value={getValues('templateId')}
|
||||
{...register('templateId')}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user