|
|
|
@@ -3,9 +3,11 @@ import PropTypes from "prop-types"; |
|
|
|
import { useFormik } from 'formik'; |
|
|
|
import { useTranslation } from 'react-i18next'; |
|
|
|
import { useDispatch } from "react-redux"; |
|
|
|
// import * as Yup from 'yup'; |
|
|
|
import DiligLogo from "../../assets/images/logo_horizontal_black.png"; |
|
|
|
import * as Yup from 'yup'; |
|
|
|
// import i18next from 'i18next'; |
|
|
|
import HrLogo from "../../assets/images/hrcenter.png"; |
|
|
|
|
|
|
|
import { |
|
|
|
Box, |
|
|
|
Container, |
|
|
|
@@ -23,19 +25,11 @@ import { BASE_PAGE } from '../../constants/pages'; |
|
|
|
import { NavLink } from 'react-router-dom'; |
|
|
|
import { resetPassword } from '../../store/actions/login/loginActions'; |
|
|
|
|
|
|
|
// const resetPasswordValidationSchema = Yup.object().shape({ |
|
|
|
// email: Yup.string() |
|
|
|
// .required(i18next.t('forgotPassword.emailRequired')) |
|
|
|
// .email(i18next.t('forgotPassword.emailFormat')), |
|
|
|
// }); |
|
|
|
function getQueryVariable(variable) { |
|
|
|
var query = window.location.search.substring(1); |
|
|
|
// console.log(query)//"app=article&act=news_content&aid=160990" |
|
|
|
var vars = query.split("&"); |
|
|
|
// console.log(vars) //[ 'app=article', 'act=news_content', 'aid=160990' ] |
|
|
|
for (var i = 0; i < vars.length; i++) { |
|
|
|
var pair = vars[i].split("="); |
|
|
|
// console.log(pair)//[ 'app', 'article' ][ 'act', 'news_content' ][ 'aid', '160990' ] |
|
|
|
if (pair[0] == variable) { return pair[1]; } |
|
|
|
} |
|
|
|
return (false); |
|
|
|
@@ -52,16 +46,19 @@ const ResetPasswordPage = ({ history }) => { |
|
|
|
const handleClickShowConfirmPassword = () => setShowConfirmPassword(!showConfirmPassword); |
|
|
|
const handleMouseDownConfirmPassword = () => setShowConfirmPassword(!showConfirmPassword); |
|
|
|
|
|
|
|
const resetPasswordValidationSchema = Yup.object().shape({ |
|
|
|
password: Yup.string().required(t("login.passwordRequired")), |
|
|
|
confirmPassword: Yup.string().required(t("login.passwordRequired")) |
|
|
|
.oneOf([Yup.ref('password'), null], t('login.passwordDontMatch')) |
|
|
|
}); |
|
|
|
|
|
|
|
const handleSubmit = (values) => { |
|
|
|
const password = values.password; |
|
|
|
const confirmPassword = values.confirmPassword; |
|
|
|
console.log(password); |
|
|
|
console.log(confirmPassword); |
|
|
|
if (password === confirmPassword) |
|
|
|
// const confirmPassword = values.confirmPassword; |
|
|
|
// if (password === confirmPassword) |
|
|
|
{ |
|
|
|
const code = getQueryVariable('token'), |
|
|
|
email = getQueryVariable('email'); |
|
|
|
email = getQueryVariable('email'); |
|
|
|
dispatch( |
|
|
|
resetPassword({ |
|
|
|
code, |
|
|
|
@@ -87,7 +84,7 @@ const ResetPasswordPage = ({ history }) => { |
|
|
|
password: '', |
|
|
|
confirmPassword: '', |
|
|
|
}, |
|
|
|
// validationSchema: resetPasswordValidationSchema, |
|
|
|
validationSchema: resetPasswordValidationSchema, |
|
|
|
onSubmit: handleSubmit, |
|
|
|
validateOnBlur: true, |
|
|
|
enableReinitialize: true, |
|
|
|
@@ -113,10 +110,10 @@ const ResetPasswordPage = ({ history }) => { |
|
|
|
> |
|
|
|
<img src={HrLogo} className="login-logo" /> |
|
|
|
<Typography variant="h5" sx={{ m: 2, mt: 3 }}> |
|
|
|
{t("login.forgotYourPassword")} |
|
|
|
{t("login.resetYourPassword")} |
|
|
|
</Typography> |
|
|
|
<Typography variant="p"> |
|
|
|
{t("login.forgotYourPasswordHelpText")} |
|
|
|
{t("login.resetYourPasswordHelpText")} |
|
|
|
</Typography> |
|
|
|
<Box |
|
|
|
component="form" |
|
|
|
@@ -191,6 +188,9 @@ const ResetPasswordPage = ({ history }) => { |
|
|
|
{t('login.forgotYourPasswordBackLink')} |
|
|
|
</Link> |
|
|
|
</Grid> |
|
|
|
<div className="flex-center"> |
|
|
|
<img src={DiligLogo} style={{ margin: "70px auto 0px auto" }} /> |
|
|
|
</div> |
|
|
|
</Box> |
|
|
|
</Box> |
|
|
|
</Container> |