From 63f6003e658c87e9a803b8591abfcb322d6a87ed Mon Sep 17 00:00:00 2001 From: Michael Hunteman Date: Tue, 15 Oct 2024 17:44:29 -0700 Subject: Toggle password visibility --- client/src/components/AdminLogin.tsx | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'client/src/components/AdminLogin.tsx') diff --git a/client/src/components/AdminLogin.tsx b/client/src/components/AdminLogin.tsx index bfc96d2..f1f676f 100644 --- a/client/src/components/AdminLogin.tsx +++ b/client/src/components/AdminLogin.tsx @@ -1,6 +1,14 @@ -import React from 'react'; +import React, { useState } from 'react'; import { useNavigate } from 'react-router-dom'; -import { Button, Paper, TextField, Typography } from '@mui/material'; +import { + Button, + Paper, + TextField, + Typography, + IconButton, + InputAdornment, +} from '@mui/material'; +import { Visibility, VisibilityOff } from '@mui/icons-material'; import { useForm } from 'react-hook-form'; import { useAppDispatch } from '../hooks'; import { setAdmin } from '../slices/auth/adminSlice'; @@ -14,6 +22,7 @@ function GuestLogin() { const dispatch = useAppDispatch(); const navigate = useNavigate(); const [login] = useLoginAdminMutation(); + const [showPassword, setShowPassword] = useState(false); const { register, @@ -49,6 +58,8 @@ function GuestLogin() { } }; + const handleClickShowPassword = () => setShowPassword((show) => !show); + return (
+ + {showPassword ? : } + + + ), + }} error={!!errors.password} helperText={errors.password?.message} required -- cgit v1.2.3