Added visibility toggle
This commit was merged in pull request #38.
This commit is contained in:
@@ -11,12 +11,18 @@ const VerifyPassword = () => {
|
|||||||
const [msgError, setMsgError] = useState("");
|
const [msgError, setMsgError] = useState("");
|
||||||
const [linkLoader, setLinkLoader] = useState(false);
|
const [linkLoader, setLinkLoader] = useState(false);
|
||||||
const [linkSuccess, setLinkSuccess] = useState(true);
|
const [linkSuccess, setLinkSuccess] = useState(true);
|
||||||
|
const [showPassword, setShowPassword] = useState(false);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const queryParams = new URLSearchParams(location?.search);
|
const queryParams = new URLSearchParams(location?.search);
|
||||||
const token = queryParams.get("passlink");
|
const token = queryParams.get("passlink");
|
||||||
const userApi = new usersService();
|
const userApi = new usersService();
|
||||||
|
|
||||||
|
// To Show and Hide Password
|
||||||
|
const togglePasswordVisibility = () => {
|
||||||
|
setShowPassword(!showPassword);
|
||||||
|
};
|
||||||
|
|
||||||
// little checker for the validity of the token
|
// little checker for the validity of the token
|
||||||
if (token?.length != 64) {
|
if (token?.length != 64) {
|
||||||
setLinkSuccess(false);
|
setLinkSuccess(false);
|
||||||
@@ -52,15 +58,13 @@ const VerifyPassword = () => {
|
|||||||
navigate("/login", { replace: true });
|
navigate("/login", { replace: true });
|
||||||
setLinkLoader(false);
|
setLinkLoader(false);
|
||||||
}, 2000);
|
}, 2000);
|
||||||
|
} else if (data && data?.status == "Invalid Request") {
|
||||||
|
setLinkLoader(false);
|
||||||
|
setLinkSuccess(false);
|
||||||
} else {
|
} else {
|
||||||
setLinkLoader(false);
|
setLinkLoader(false);
|
||||||
setMsgError("An error occurred");
|
setMsgError("An error occurred");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data && data?.status == "Invalid Request") {
|
|
||||||
setLinkLoader(false);
|
|
||||||
setLinkSuccess(false);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
setLinkLoader(false);
|
setLinkLoader(false);
|
||||||
setLinkSuccess(false);
|
setLinkSuccess(false);
|
||||||
@@ -122,7 +126,9 @@ const VerifyPassword = () => {
|
|||||||
onSubmit={completeReset}
|
onSubmit={completeReset}
|
||||||
msgErr={msgError}
|
msgErr={msgError}
|
||||||
loader={linkLoader}
|
loader={linkLoader}
|
||||||
onClick={() => navigate("/login")}
|
showPassword={showPassword}
|
||||||
|
onClick={togglePasswordVisibility}
|
||||||
|
navigateHandler={() => navigate("/login")}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<ErrorComponent onClick={() => navigate("/login")} />
|
<ErrorComponent onClick={() => navigate("/login")} />
|
||||||
@@ -139,6 +145,8 @@ export default VerifyPassword;
|
|||||||
|
|
||||||
const SuccessfulComponent = ({
|
const SuccessfulComponent = ({
|
||||||
onSubmit,
|
onSubmit,
|
||||||
|
navigateHandler,
|
||||||
|
showPassword,
|
||||||
onClick,
|
onClick,
|
||||||
password,
|
password,
|
||||||
confirmPassword,
|
confirmPassword,
|
||||||
@@ -155,8 +163,11 @@ const SuccessfulComponent = ({
|
|||||||
placeholder="● ● ● ● ● ●"
|
placeholder="● ● ● ● ● ●"
|
||||||
label="Password"
|
label="Password"
|
||||||
name="password"
|
name="password"
|
||||||
type="password"
|
type={showPassword ? "text" : "password"}
|
||||||
iconName="password"
|
onClick={onClick}
|
||||||
|
passIcon={
|
||||||
|
showPassword ? "show-password" : "hide-password"
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="mb-5">
|
<div className="mb-5">
|
||||||
@@ -167,7 +178,6 @@ const SuccessfulComponent = ({
|
|||||||
label="Confirm Password"
|
label="Confirm Password"
|
||||||
name="confirm_password"
|
name="confirm_password"
|
||||||
type="password"
|
type="password"
|
||||||
iconName="password"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{msgErr && (
|
{msgErr && (
|
||||||
@@ -190,7 +200,7 @@ const SuccessfulComponent = ({
|
|||||||
</div>
|
</div>
|
||||||
<div className="signin-area mb-3.5">
|
<div className="signin-area mb-3.5">
|
||||||
<button
|
<button
|
||||||
onClick={onClick}
|
onClick={navigateHandler}
|
||||||
type="button"
|
type="button"
|
||||||
className={`rounded-[0.475rem] mb-6 text-[15px] font-semibold text-[#009ef7] hover:text-white flex justify-center bg-[#f1faff] hover:bg-[#009ef7] transition-all duration-300 items-center py-[0.8875rem] px-[1.81rem] btn-login`}
|
className={`rounded-[0.475rem] mb-6 text-[15px] font-semibold text-[#009ef7] hover:text-white flex justify-center bg-[#f1faff] hover:bg-[#009ef7] transition-all duration-300 items-center py-[0.8875rem] px-[1.81rem] btn-login`}
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user