diff --git a/src/app/dashboard/(admin)/admin/(settings)/settings/account/_component.tsx/password.tsx b/src/app/dashboard/(admin)/admin/(settings)/settings/account/_component.tsx/password.tsx index ae6a8f408..7b858f80c 100644 --- a/src/app/dashboard/(admin)/admin/(settings)/settings/account/_component.tsx/password.tsx +++ b/src/app/dashboard/(admin)/admin/(settings)/settings/account/_component.tsx/password.tsx @@ -2,6 +2,7 @@ import { zodResolver } from "@hookform/resolvers/zod"; import axios from "axios"; +import { Eye, EyeOff } from "lucide-react"; import { useSession } from "next-auth/react"; import { useState } from "react"; import { useForm } from "react-hook-form"; @@ -13,6 +14,8 @@ import { toast } from "~/components/ui/use-toast"; import { cn } from "~/lib/utils"; import { passwordSchema, type PasswordFormData } from "./schema"; +type PasswordField = "current" | "new" | "confirmNew"; + const Password = () => { const { data } = useSession(); @@ -29,6 +32,12 @@ const Password = () => { mode: "all", }); + const [showPassword, setShowPassword] = useState({ + current: false, + new: false, + confirmNew: false, + }); + const submitHandler = async (values: PasswordFormData) => { try { setIsPending(true); @@ -59,6 +68,13 @@ const Password = () => { } }; + const togglePasswordVisibility = (field: PasswordField) => { + setShowPassword((previousState) => ({ + ...previousState, + [field]: !previousState[field], + })); + }; + return (
@@ -76,16 +92,26 @@ const Password = () => { -
+
+ togglePasswordVisibility("current")} + > + {showPassword.current ? ( + + ) : ( + + )} +
{errors.currentPassword && ( @@ -99,16 +125,22 @@ const Password = () => { -
+
+ togglePasswordVisibility("new")} + > + {showPassword.new ? : } +
{errors.newPassword && ( @@ -122,16 +154,26 @@ const Password = () => { -
+
+ togglePasswordVisibility("confirmNew")} + > + {showPassword.confirmNew ? ( + + ) : ( + + )} +
{errors.confirmPassword && (