| | |
| | | InputAdornment, |
| | | IconButton, |
| | | } from '@mui/material'; |
| | | import { updateUserInfo } from '@/api/auth'; |
| | | import { requestResetPassword } from '@/api/auth'; |
| | | import Visibility from '@mui/icons-material/Visibility'; |
| | | import VisibilityOff from '@mui/icons-material/VisibilityOff'; |
| | | |
| | |
| | | } |
| | | }, [userInfo, setValue]) |
| | | |
| | | const onSubmit = (data) => { |
| | | console.log(data); |
| | | return false; |
| | | |
| | | const onSubmit = (params) => { |
| | | setLoading(true); |
| | | updateUserInfo({ id: userInfo.id, ...data }).then(res => { |
| | | requestResetPassword(params).then(res => { |
| | | setLoading(false); |
| | | const { code, msg, data } = res; |
| | | if (code === 200) { |
| | | notify(msg, { type: 'success', messageArgs: { _: msg } }); |
| | | reset(); |
| | | } else if (code === 10001) { |
| | | setError('oldPassword', { |
| | | message: msg, |
| | | }); |
| | | } else { |
| | | notify(msg, { type: 'error', messageArgs: { _: msg } }); |
| | | setError('oldPassword', { |
| | | type: 'server', // make no sense |
| | | message: res.msg, |
| | | }); |
| | | } |
| | | }).catch((error) => { |
| | | setLoading(false); |
| | |
| | | rules={{ |
| | | required: translate('ra.validation.required'), |
| | | pattern: { |
| | | value: /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{6,13}$/, |
| | | value: /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d\.]{6,13}$/, |
| | | message: translate('page.settings.resetPwd.tip.pwdInputLimit'), |
| | | }, |
| | | validate: (value) => { |