Skip to content

Commit

Permalink
feat: disables save button on user permissions until any permission i…
Browse files Browse the repository at this point in the history
…s changed (#306)
  • Loading branch information
emi-hi authored May 27, 2024
1 parent c403ed1 commit 53f2b12
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions frontend/src/users/UsersContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const UsersContainer = (props) => {
const [messageSeverity, setMessageSeverity] = useState("");
const [userToDelete, setUserToDelete] = useState("");
const [openDialog, setOpenDialog] = useState(false);
const [saveButtonEnabled, setSaveButtonEnabled] = useState(false);
const axios = useAxios();

const handleAddNewUser = () => {
Expand Down Expand Up @@ -56,6 +57,7 @@ const UsersContainer = (props) => {
userToChange.user_permissions[permissionType] = checked;
}),
);
setSaveButtonEnabled(true)
}, []);

const handleDeleteUserClick = (idir) => {
Expand Down Expand Up @@ -139,6 +141,7 @@ const UsersContainer = (props) => {
setMessage={setMessage}
newUser={newUser}
handleXClick={handleDeleteUserClick}
saveButtonEnabled={saveButtonEnabled}
/>
</div>
);
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/users/components/UsersPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const UsersPage = (props) => {
newUser,
setMessage,
handleXClick,
saveButtonEnabled
} = props;

const userRow = (user) => {
Expand Down Expand Up @@ -171,6 +172,7 @@ const UsersPage = (props) => {
className="button-dark-blue"
startIcon={<SaveIcon />}
onClick={handleSubmitUserUpdates}
disabled={!saveButtonEnabled}
>
Save
</Button>
Expand Down

0 comments on commit 53f2b12

Please sign in to comment.