From 043b78c87b9f7c9fa910ef5d62ea5cedbac00cc9 Mon Sep 17 00:00:00 2001 From: "kody.low" Date: Tue, 31 Oct 2023 22:21:24 -0700 Subject: [PATCH] feat: confirm password field --- .../src/components/SetConfiguration.tsx | 23 +++++++++++++++++-- apps/guardian-ui/src/languages/en.json | 4 +++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/apps/guardian-ui/src/components/SetConfiguration.tsx b/apps/guardian-ui/src/components/SetConfiguration.tsx index fb5c54c3..26afb64d 100644 --- a/apps/guardian-ui/src/components/SetConfiguration.tsx +++ b/apps/guardian-ui/src/components/SetConfiguration.tsx @@ -51,6 +51,8 @@ export const SetConfiguration: React.FC = ({ next }: Props) => { const isHost = role === GuardianRole.Host; const [myName, setMyName] = useState(stateMyName); const [password, setPassword] = useState(statePassword); + const [confirmPassword, setConfirmPassword] = useState(''); + const [passwordsMatch, setPasswordsMatch] = useState(false); const [hostServerUrl, setHostServerUrl] = useState(''); const [defaultParams, setDefaultParams] = useState(); const [numPeers, setNumPeers] = useState( @@ -122,6 +124,10 @@ export const SetConfiguration: React.FC = ({ next }: Props) => { ) : Boolean(myName && password && hostServerUrl); + useEffect(() => { + setPasswordsMatch(password === confirmPassword); + }, [password, confirmPassword]); + const handleChangeFederationName = ( ev: React.ChangeEvent ) => { @@ -215,6 +221,19 @@ export const SetConfiguration: React.FC = ({ next }: Props) => { /> {t('set-config.admin-password-help')} + + {t('set-config.confirm-password')} + setConfirmPassword(ev.currentTarget.value)} + /> + + {passwordsMatch && password.length > 0 + ? 'Passwords match!' + : 'Passwords do not match!'} + + {!isHost && ( {t('set-config.join-federation')} @@ -318,8 +337,8 @@ export const SetConfiguration: React.FC = ({ next }: Props) => { )}