Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
imhson committed Aug 28, 2023
1 parent fbb4478 commit 14d5809
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 22 deletions.
24 changes: 13 additions & 11 deletions src/components/pages/profile/changingPasswordModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import SuccessImg from 'images/ninja.svg'
import { validatePassword } from 'src/utils'
import CheckSquare from 'images/icons/check_square_fill.svg'
import { useTranslation } from 'react-i18next'
import _ from 'lodash'
export default function ChangingPasswordModal({ open, setOpen }) {
const [success, setSuccess] = useState(false)
const [loading, setLoading] = useState(false)
Expand All @@ -22,16 +23,18 @@ export default function ChangingPasswordModal({ open, setOpen }) {
const r2 = useRef<any>()
const { t } = useTranslation()
useEffect(() => {
if (!open) {
setSuccess(false)
setLoading(false)
setRepasswordValidateSuccess(false)
setCurrentPassword('')
setCurrentPasswordError('')
setNewPassword('')
setRePassword('')
setRePasswordError('')
}
_.delay(() => {
if (!open) {
setSuccess(false)
setLoading(false)
setRepasswordValidateSuccess(false)
setCurrentPassword('')
setCurrentPasswordError('')
setNewPassword('')
setRePassword('')
setRePasswordError('')
}
}, 1000)
}, [open])
useEffect(() => {
setRePasswordError('')
Expand Down Expand Up @@ -150,7 +153,6 @@ export default function ChangingPasswordModal({ open, setOpen }) {
size='lg'
onClick={() => {
setOpen(false)
setSuccess(false)
}}>
{t('Continue')}
</FilledButton>
Expand Down
23 changes: 12 additions & 11 deletions src/components/pages/profile/settingPasswordModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import SuccessImg from 'images/ninja.svg'
import { validatePassword } from 'src/utils'
import CheckSquare from 'images/icons/check_square_fill.svg'
import { useTranslation } from 'react-i18next'
import _ from 'lodash'
export default function SettingPasswordModal({ open, setOpen, profile }) {
const [success, setSuccess] = useState(false)
const [loading, setLoading] = useState(false)
Expand All @@ -19,14 +20,16 @@ export default function SettingPasswordModal({ open, setOpen, profile }) {
const { t } = useTranslation()
const r1 = useRef<any>()
useEffect(() => {
if (!open) {
setSuccess(false)
setLoading(false)
setRepasswordValidateSuccess(false)
setNewPassword('')
setRePassword('')
setRePasswordError('')
}
_.delay(() => {
if (!open) {
setSuccess(false)
setLoading(false)
setRepasswordValidateSuccess(false)
setNewPassword('')
setRePassword('')
setRePasswordError('')
}
}, 1000)
}, [open])
useEffect(() => {
setRePasswordError('')
Expand Down Expand Up @@ -56,13 +59,12 @@ export default function SettingPasswordModal({ open, setOpen, profile }) {
new_password: newPassword,
confirm_new_password: rePassword,
})
console.log(res)
if (res) {
await profile.callApi(true)
setLoading(false)
setSuccess(true)
}
} catch (error) {
console.log(error)
setLoading(false)
}
}
Expand Down Expand Up @@ -117,7 +119,6 @@ export default function SettingPasswordModal({ open, setOpen, profile }) {
size='lg'
onClick={() => {
setOpen(false)
setSuccess(false)
}}>
{t('Continue')}
</FilledButton>
Expand Down

0 comments on commit 14d5809

Please sign in to comment.