Skip to content

Instantly share code, notes, and snippets.

@imballinst
Last active July 21, 2019 13:09
Show Gist options
  • Save imballinst/75a20b045d4905f6efd4468fcd15e62b to your computer and use it in GitHub Desktop.
Save imballinst/75a20b045d4905f6efd4468fcd15e62b to your computer and use it in GitHub Desktop.
const handleSaveRole = async () => {
// ...
if (role.id) {
return api.getRolePermissions(state.jwt, role)
.then(response => api.deleteRolePermissions(state.jwt, response.data.items))
.then(() => api.addRolePermissionsToRole(state.jwt, role, state.roles))
.then(() => {
dispatch(["EDIT_ROLE", role]);
toast.success("Role saved.");
return role;
});
}
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment