Skip to content

Commit

Permalink
Refined User State Selection Form
Browse files Browse the repository at this point in the history
- Cancel button is diabled if user.invitePending is true.
- Dialog does not close on background click nor escape key press.
- This is to prevent the user from closing the dialog before they have made a selection.
  • Loading branch information
hawkishpolicy committed Dec 30, 2024
1 parent 4d9ea65 commit af52494
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions frontend/src/components/Register/UpdateUserStateForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const UpdateStateForm: React.FC<{
const [values, setValues] = useState<UpdateStateFormValues>(defaultValues);
const [errorRequestMessage, setErrorRequestMessage] = useState<string>('');
const [isLoading, setIsLoading] = useState<boolean>(false);
const { apiPut } = useAuthContext();
const { apiPut, user } = useAuthContext();

const handleChange = (event: SelectChangeEvent) => {
setValues((values: any) => ({
Expand Down Expand Up @@ -63,7 +63,16 @@ export const UpdateStateForm: React.FC<{
};

return (
<StyledDialog open={open} onClose={onClose} maxWidth="xs" fullWidth>
<StyledDialog
open={open}
onClose={(event, reason) => {
if (reason !== 'backdropClick' && reason !== 'escapeKeyDown') {
onClose();
}
}}
maxWidth="xs"
fullWidth
>
<DialogTitle id="form-dialog-title">Update State Information</DialogTitle>
<DialogContent>
{errorRequestMessage && (
Expand Down Expand Up @@ -92,7 +101,11 @@ export const UpdateStateForm: React.FC<{
</Select>
</DialogContent>
<DialogActions>
<Button variant="outlined" onClick={onClose}>
<Button
variant="outlined"
onClick={onClose}
disabled={user?.invitePending === true}
>
Cancel
</Button>
<Button
Expand Down

0 comments on commit af52494

Please sign in to comment.