Force refresh of user after save to avoid modal (#3180) (#3187)

* Force refresh of user after save to avoid modal (#3180)

* Update src/user/UsersTabs.tsx

Co-authored-by: Jon Koops <jonkoops@gmail.com>

* Update src/user/UsersTabs.tsx

Co-authored-by: Jon Koops <jonkoops@gmail.com>

* Update src/user/UsersTabs.tsx

Co-authored-by: Jon Koops <jonkoops@gmail.com>

Co-authored-by: Jon Koops <jonkoops@gmail.com>
This commit is contained in:
kris2kris 2022-08-25 09:02:14 +02:00 committed by GitHub
parent 0b509131cc
commit 8c9917ddff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -46,6 +46,8 @@ const UsersTabs = () => {
const [user, setUser] = useState<UserRepresentation>();
const [bruteForced, setBruteForced] = useState<BruteForced>();
const [addedGroups, setAddedGroups] = useState<GroupRepresentation[]>([]);
const [refreshCount, setRefreshCount] = useState(0);
const refresh = () => setRefreshCount((count) => count + 1);
useFetch(
async () => {
@ -72,7 +74,7 @@ const UsersTabs = () => {
setBruteForced(bruteForced);
user && setupForm(user);
},
[user?.username]
[user?.username, refreshCount]
);
const setupForm = (user: UserRepresentation) => {
@ -90,6 +92,7 @@ const UsersTabs = () => {
if (id) {
await adminClient.users.update({ id }, user);
addAlert(t("userSaved"), AlertVariant.success);
refresh();
} else {
const createdUser = await adminClient.users.create(user);