diff --git a/client/src/components/user-validate-pw-reset/user-validate-pw-reset.component.jsx b/client/src/components/user-validate-pw-reset/user-validate-pw-reset.component.jsx index 030338805..a6b05bd6d 100644 --- a/client/src/components/user-validate-pw-reset/user-validate-pw-reset.component.jsx +++ b/client/src/components/user-validate-pw-reset/user-validate-pw-reset.component.jsx @@ -1,15 +1,17 @@ import { LockOutlined } from "@ant-design/icons"; import { Button, Form, Input, Result, Typography } from "antd"; -import React from "react"; +import React, { useState, useEffect } from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; import { Link } from "react-router-dom"; import { createStructuredSelector } from "reselect"; import ImEXOnlineLogo from "../../assets/logo192.png"; +import { auth } from "../../firebase/firebase.utils"; import { validatePasswordResetStart } from "../../redux/user/user.actions"; import { selectPasswordReset } from "../../redux/user/user.selectors"; import AlertComponent from "../alert/alert.component"; import "./user-validate-pw-reset.styles.scss"; +import LoadingSpinner from "../loading-spinner/loading-spinner.component"; const mapStateToProps = createStructuredSelector({ passwordReset: selectPasswordReset, @@ -25,11 +27,34 @@ export function UserValidatePwReset({ oobCode, }) { const { t } = useTranslation(); - + const [codeValid, setCodeValid] = useState({ loading: true }); const handleFinish = (values) => { validatePasswordReset({ code: oobCode, password: values.password }); }; + useEffect(() => { + async function checkCodeValid() { + try { + const codeValid = await auth.checkActionCode(oobCode); + console.log("codeValid :>> ", codeValid); + setCodeValid({ loading: false, ...codeValid }); + } catch (error) { + console.log("error :>> ", error); + setCodeValid({ loading: false, ...error }); + } + } + checkCodeValid(); + }, [oobCode]); + + if (codeValid.loading) return ; + + if (codeValid.code) + return ( +
+ +
+ ); + if (passwordReset.success) return (