Skip to content

Commit

Permalink
feat: confirm password field
Browse files Browse the repository at this point in the history
  • Loading branch information
Kodylow committed Nov 1, 2023
1 parent 64b7c25 commit f7c6837
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
23 changes: 21 additions & 2 deletions apps/guardian-ui/src/components/SetConfiguration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ export const SetConfiguration: React.FC<Props> = ({ 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<ConfigGenParams>();
const [numPeers, setNumPeers] = useState(
Expand Down Expand Up @@ -122,6 +124,10 @@ export const SetConfiguration: React.FC<Props> = ({ next }: Props) => {
)
: Boolean(myName && password && hostServerUrl);

useEffect(() => {
setPasswordsMatch(password === confirmPassword);
}, [password, confirmPassword]);

const handleChangeFederationName = (
ev: React.ChangeEvent<HTMLInputElement>
) => {
Expand Down Expand Up @@ -215,6 +221,19 @@ export const SetConfiguration: React.FC<Props> = ({ next }: Props) => {
/>
<FormHelperText>{t('set-config.admin-password-help')}</FormHelperText>
</FormControl>
<FormControl>
<FormLabel>{t('set-config.confirm-password')}</FormLabel>
<Input
type='password'
value={confirmPassword}
onChange={(ev) => setConfirmPassword(ev.currentTarget.value)}
/>
<FormHelperText>
{passwordsMatch && password.length > 0
? 'Passwords match!'
: 'Passwords do not match!'}
</FormHelperText>
</FormControl>
{!isHost && (
<FormControl>
<FormLabel>{t('set-config.join-federation')}</FormLabel>
Expand Down Expand Up @@ -318,8 +337,8 @@ export const SetConfiguration: React.FC<Props> = ({ next }: Props) => {
)}
<div>
<Button
isDisabled={!isValid}
onClick={isValid ? handleNext : undefined}
isDisabled={!isValid || !passwordsMatch}
onClick={isValid && passwordsMatch ? handleNext : undefined}
leftIcon={<Icon as={ArrowRightIcon} />}
mt={4}
>
Expand Down
4 changes: 3 additions & 1 deletion apps/guardian-ui/src/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@
"guardian-name-help": "This name will be shown to other Guardians",
"admin-password": "Admin password",
"admin-password-help": "You'll need this every time you visit this page.",
"confirm-password": "Confirm password",
"confirm-password-help": "You'll need this every time you visit this page.",
"join-federation": "Join Federation link",
"join-federation-help": "Ask the person who created the Federation for a link, and paste it here.",
"federation-settings": "Federation settings",
Expand All @@ -100,7 +102,7 @@
"error-valid-max": "Please input a number of at most {{max}}.",
"error-valid-min-max": "Please input a number between {{min}} and {{max}}.",
"meta-fields": "Meta fields",
"meta-fields-description": "Additional configuration sent to fedimint clients. See <docs>documentation</docs> or more information.",
"meta-fields-description": "Additional configuration sent to fedimint clients. See <docs>documentation</docs> for more information.",
"meta-fields-key": "Meta key",
"meta-fields-value": "Value",
"meta-fields-add-another": "Add another"
Expand Down

0 comments on commit f7c6837

Please sign in to comment.