forked from ddrilling/asb_cloud_front
Кнопка ОК переименована в Сохранить, добавлено блокирование кнопки до валидации формы
This commit is contained in:
parent
278ebeb573
commit
f6f5fa15be
@ -23,9 +23,14 @@ const fieldRules = [...passwordRules, ...createPasswordRules]
|
||||
export const ChangePassword = memo<ChangePasswordProps>(({ user, visible, onCancel, onOk }) => {
|
||||
const [showLoader, setShowLoader] = useState<boolean>(false)
|
||||
const [password, setPassword] = useState<string>('')
|
||||
const [isDisabled, setIsDisabled] = useState(true)
|
||||
|
||||
const [form] = useForm()
|
||||
|
||||
const onFormChange = async () => await form.validateFields()
|
||||
.then(() => setIsDisabled(false))
|
||||
.catch(() => setIsDisabled(true))
|
||||
|
||||
const onModalCancel = () => {
|
||||
form.resetFields()
|
||||
onCancel?.()
|
||||
@ -52,6 +57,10 @@ export const ChangePassword = memo<ChangePasswordProps>(({ user, visible, onCanc
|
||||
visible={visible}
|
||||
onCancel={onModalCancel}
|
||||
onOk={() => form.submit()}
|
||||
okText={'Сохранить'}
|
||||
okButtonProps={{
|
||||
disabled: isDisabled
|
||||
}}
|
||||
>
|
||||
<LoaderPortal show={showLoader}>
|
||||
<Form
|
||||
@ -59,6 +68,7 @@ export const ChangePassword = memo<ChangePasswordProps>(({ user, visible, onCanc
|
||||
form={form}
|
||||
name={'change-password'}
|
||||
onFinish={onFormFinish}
|
||||
onChange={onFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
label={'Новый пароль'}
|
||||
|
Loading…
Reference in New Issue
Block a user