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 }) => {
|
export const ChangePassword = memo<ChangePasswordProps>(({ user, visible, onCancel, onOk }) => {
|
||||||
const [showLoader, setShowLoader] = useState<boolean>(false)
|
const [showLoader, setShowLoader] = useState<boolean>(false)
|
||||||
const [password, setPassword] = useState<string>('')
|
const [password, setPassword] = useState<string>('')
|
||||||
|
const [isDisabled, setIsDisabled] = useState(true)
|
||||||
|
|
||||||
const [form] = useForm()
|
const [form] = useForm()
|
||||||
|
|
||||||
|
const onFormChange = async () => await form.validateFields()
|
||||||
|
.then(() => setIsDisabled(false))
|
||||||
|
.catch(() => setIsDisabled(true))
|
||||||
|
|
||||||
const onModalCancel = () => {
|
const onModalCancel = () => {
|
||||||
form.resetFields()
|
form.resetFields()
|
||||||
onCancel?.()
|
onCancel?.()
|
||||||
@ -52,6 +57,10 @@ export const ChangePassword = memo<ChangePasswordProps>(({ user, visible, onCanc
|
|||||||
visible={visible}
|
visible={visible}
|
||||||
onCancel={onModalCancel}
|
onCancel={onModalCancel}
|
||||||
onOk={() => form.submit()}
|
onOk={() => form.submit()}
|
||||||
|
okText={'Сохранить'}
|
||||||
|
okButtonProps={{
|
||||||
|
disabled: isDisabled
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<LoaderPortal show={showLoader}>
|
<LoaderPortal show={showLoader}>
|
||||||
<Form
|
<Form
|
||||||
@ -59,6 +68,7 @@ export const ChangePassword = memo<ChangePasswordProps>(({ user, visible, onCanc
|
|||||||
form={form}
|
form={form}
|
||||||
name={'change-password'}
|
name={'change-password'}
|
||||||
onFinish={onFormFinish}
|
onFinish={onFormFinish}
|
||||||
|
onChange={onFormChange}
|
||||||
>
|
>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
label={'Новый пароль'}
|
label={'Новый пароль'}
|
||||||
|
Loading…
Reference in New Issue
Block a user