Commit ba7ade4d by t0ng7u

💄 refactor: Users table UI & state handling

Summary of changes
1. UI clean-up
   • Removed all `prefixIcon` props from `Tag` components in `UsersColumnDefs.js`.
   • Corrected i18n string in invite info (`${t('邀请人')}: …`).

2. “Statistics” column overhaul
   • Added a Switch (enable / disable) and quota Progress bar, mirroring the Tokens table design.
   • Moved enable / disable action out of the “More” dropdown; user status is now toggled directly via the Switch.
   • Disabled the Switch for deleted (注销) users.
   • Restored column title to “Statistics” to avoid duplication.

3. State consistency / refresh
   • Updated `manageUser` in `useUsersData.js` to:
     – set `loading` while processing actions;
     – update users list immutably (new objects & array) to trigger React re-render.

4. Imports / plumbing
   • Added `Progress` and `Switch` to UI imports in `UsersColumnDefs.js`.

These changes streamline the user table’s appearance, align interaction patterns with the token table, and ensure immediate visual feedback after user status changes.
parent 7ff1921f
......@@ -121,30 +121,36 @@ export const useUsersData = () => {
// Manage user operations (promote, demote, enable, disable, delete)
const manageUser = async (userId, action, record) => {
// Trigger loading state to force table re-render
setLoading(true);
const res = await API.post('/api/user/manage', {
id: userId,
action,
});
const { success, message } = res.data;
if (success) {
showSuccess('操作成功完成!');
let user = res.data.data;
let newUsers = [...users];
if (action === 'delete') {
// Mark as deleted
const index = newUsers.findIndex(u => u.id === userId);
if (index > -1) {
newUsers[index].DeletedAt = new Date();
const user = res.data.data;
// Create a new array and new object to ensure React detects changes
const newUsers = users.map((u) => {
if (u.id === userId) {
if (action === 'delete') {
return { ...u, DeletedAt: new Date() };
}
return { ...u, status: user.status, role: user.role };
}
} else {
// Update status and role
record.status = user.status;
record.role = user.role;
}
return u;
});
setUsers(newUsers);
} else {
showError(message);
}
setLoading(false);
};
// Handle page change
......
......@@ -390,7 +390,6 @@
"已封禁": "Banned",
"搜索用户的 ID,用户名,显示名称,以及邮箱地址 ...": "Search user ID, username, display name, and email address...",
"用户名": "Username",
"统计信息": "Statistics",
"用户角色": "User Role",
"未绑定邮箱地址": "Email not bound",
"请求次数": "Number of Requests",
......@@ -1483,6 +1482,7 @@
"剩余": "Remaining",
"已用": "Used",
"调用": "Calls",
"调用次数": "Call Count",
"邀请": "Invitations",
"收益": "Earnings",
"无邀请人": "No Inviter",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment