fix(#2199): fix disabled input in change pass

keep-around/11ba998252d14e10552e3bffcce91ab0afdc9329
Andrei Dekterev 4 years ago
parent 15173b9593
commit 5f34b492b5
  1. 3
      src/features/AuthServiceApp/components/ChangePassword/hooks.tsx
  2. 5
      src/features/AuthServiceApp/components/ChangePassword/index.tsx
  3. 3
      src/features/AuthServiceApp/components/Input/index.tsx
  4. 2
      src/features/AuthServiceApp/components/PasswordInput/index.tsx
  5. 15
      src/features/AuthServiceApp/components/RecoveryPopup/hooks.tsx
  6. 9
      src/features/AuthServiceApp/components/RecoveryPopup/index.tsx
  7. 2
      src/features/AuthServiceApp/config/lexics.tsx

@ -12,6 +12,7 @@ export const useChangePasswordForm = () => {
const [isFetching, setIsFetching] = useState(false) const [isFetching, setIsFetching] = useState(false)
const [password, setPassword] = useState('') const [password, setPassword] = useState('')
const [confirmPassword, setConfirmPassword] = useState('') const [confirmPassword, setConfirmPassword] = useState('')
const [disabled, setDisabled] = useState(true)
const { const {
checkPassword, checkPassword,
@ -39,6 +40,7 @@ export const useChangePasswordForm = () => {
if (!checkPassword(value)) { if (!checkPassword(value)) {
setError('check_password') setError('check_password')
} else { } else {
setDisabled(false)
setError('') setError('')
} }
setPassword(value) setPassword(value)
@ -66,6 +68,7 @@ export const useChangePasswordForm = () => {
return { return {
confirmPassword, confirmPassword,
disabled,
error, error,
handleSubmit, handleSubmit,
isFetching, isFetching,

@ -18,6 +18,7 @@ import {
const ChangePassword = () => { const ChangePassword = () => {
const { const {
confirmPassword, confirmPassword,
disabled,
error, error,
handleSubmit, handleSubmit,
isFetching, isFetching,
@ -53,13 +54,13 @@ const ChangePassword = () => {
placeholderLexic='password_repeat' placeholderLexic='password_repeat'
value={confirmPassword} value={confirmPassword}
onChange={onConfirmPasswordChange} onChange={onConfirmPasswordChange}
disabled={disabled}
/> />
</InputGroup> </InputGroup>
<Error> <Error>
<T9n t={error} /> <T9n t={error} />
</Error> </Error>
<ButtonsBlock marginTop={error ? 20 : 0}>
<ButtonsBlock>
<ButtonSolid disabled={isSubmitDisabled}> <ButtonSolid disabled={isSubmitDisabled}>
{ {
isFetching isFetching

@ -12,6 +12,7 @@ type Props = Pick<InputHTMLAttributes<HTMLInputElement>, (
'autoComplete' | 'autoComplete' |
'autoFocus' | 'autoFocus' |
'className' | 'className' |
'disabled' |
'name' | 'name' |
'onBlur' | 'onBlur' |
'onChange' | 'onChange' |
@ -29,6 +30,7 @@ export const Input = ({
autoComplete, autoComplete,
autoFocus, autoFocus,
className, className,
disabled,
leftContent, leftContent,
name, name,
onBlur, onBlur,
@ -49,6 +51,7 @@ export const Input = ({
<InputStyled <InputStyled
autoComplete={autoComplete} autoComplete={autoComplete}
autoFocus={autoFocus} autoFocus={autoFocus}
disabled={disabled}
onBlur={onBlur} onBlur={onBlur}
onChange={onChange} onChange={onChange}
onFocus={onFocus} onFocus={onFocus}

@ -48,6 +48,7 @@ type Props = ComponentProps<typeof Input>
export const PasswordInput = ({ export const PasswordInput = ({
autoComplete, autoComplete,
className, className,
disabled,
leftContent, leftContent,
name, name,
onBlur, onBlur,
@ -62,6 +63,7 @@ export const PasswordInput = ({
<Input <Input
autoComplete={autoComplete} autoComplete={autoComplete}
className={className} className={className}
disabled={disabled}
onBlur={onBlur} onBlur={onBlur}
onChange={onChange} onChange={onChange}
onFocus={onFocus} onFocus={onFocus}

@ -36,15 +36,14 @@ export const useRecovery = (setIsModalOpen: (value: boolean) => void) => {
setIsFetching(false) setIsFetching(false)
} }
const handleSubmit = () => { const handleSubmit = async () => {
if (isSendMessage && !isFetching) { try {
closePopup()
} else {
setIsFetching(true) setIsFetching(true)
loginCheckChangePass(email) await loginCheckChangePass(email)
.then(() => setIsSendMessage(true)) setIsFetching(false)
.then(() => setIsFetching(false)) setIsSendMessage(true)
.catch(handleError) } catch (err) {
handleError(String(err))
} }
} }

@ -72,10 +72,15 @@ export const RecoveryPopup = (props: Props) => {
</Fragment> </Fragment>
)} )}
<Footer> <Footer>
{!isSendMessage ? (
<ApplyButton onClick={handleSubmit} disabled={isSendBtnDisabled}> <ApplyButton onClick={handleSubmit} disabled={isSendBtnDisabled}>
{(isFetching && <ArrowLoader />) {isFetching ? <ArrowLoader /> : <T9n t='send' />}
|| (isSendMessage ? 'Ok' : <T9n t='send' />)}
</ApplyButton> </ApplyButton>
) : (
<ApplyButton onClick={closePopup}>
Ok
</ApplyButton>
)}
</Footer> </Footer>
</Body> </Body>
</Wrapper> </Wrapper>

@ -26,7 +26,7 @@ export const lexics = {
login: 13404, login: 13404,
password_new: 15056, password_new: 15056,
password_repeat: 15057, password_repeat: 15057,
recovery_email: 16238, recovery_email: 15833,
register: 13328, register: 13328,
registration_email: 16239, registration_email: 16239,
registration_successful: 12945, registration_successful: 12945,

Loading…
Cancel
Save