Skip to content

Commit c2a6280

Browse files
bimakwLinkinStars
andauthored
fix: add feedback after successfully adding a user in admin panel (#1462)
## Summary - Show success toast notification after user is added - Refresh user list and navigate to 'normal' filter on page 1 to display the newly added user ## Problem When adding a user in Admin -> Users, the page had no feedback after submission (as reported in #1457). **Root cause:** The code only refreshed the user list if the current filter was "all" or "staff", but the default filter is "normal". Additionally, there was no success toast notification. ## Solution 1. Added toast notification to confirm successful user creation 2. After adding user, navigate to "normal" filter page 1 and refresh the list so the new user is visible ## Test plan 1. Go to Admin -> Users 2. Click "Add User" 3. Submit user information 4. ✅ Success toast should appear 5. ✅ Page should navigate to "normal" filter 6. ✅ Newly added user should be visible in the list Fixes #1457 --------- Co-authored-by: LinkinStars <linkinstar@foxmail.com>
1 parent 5940877 commit c2a6280

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

i18n/en_US.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2383,6 +2383,7 @@ ui:
23832383
user_normal: This user is already normal.
23842384
user_suspended: This user has been suspended.
23852385
user_deleted: This user has been deleted.
2386+
user_added: User has been added successfully.
23862387
badge_activated: This badge has been activated.
23872388
badge_inactivated: This badge has been inactivated.
23882389
users_deleted: These users have been deleted.

ui/src/pages/Admin/Users/index.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,14 @@ const Users: FC = () => {
109109
return new Promise((resolve, reject) => {
110110
addUsers(userModel)
111111
.then(() => {
112-
if (/all|staff/.test(curFilter) && curPage === 1) {
113-
refreshUsers();
114-
}
112+
toastStore.getState().show({
113+
msg: t('user_added', { keyPrefix: 'messages' }),
114+
variant: 'success',
115+
});
116+
urlSearchParams.set('filter', 'normal');
117+
urlSearchParams.delete('page');
118+
setUrlSearchParams(urlSearchParams);
119+
refreshUsers();
115120
resolve(true);
116121
})
117122
.catch((e) => {

ui/src/pages/SideNavLayout/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const Index: FC = () => {
3838
<Outlet />
3939
</div>
4040
</div>
41-
<div className="d-flex justify-content-center">
41+
<div className="d-flex justify-content-center px-0 px-md-4">
4242
<div className="main-mx-with">
4343
<Footer />
4444
</div>

0 commit comments

Comments
 (0)