2025-07-19 00:32:56 +08:00
|
|
|
import React from 'react';
|
|
|
|
|
import CardPro from '../../common/ui/CardPro';
|
|
|
|
|
import UsersTable from './UsersTable.jsx';
|
|
|
|
|
import UsersActions from './UsersActions.jsx';
|
|
|
|
|
import UsersFilters from './UsersFilters.jsx';
|
|
|
|
|
import UsersDescription from './UsersDescription.jsx';
|
|
|
|
|
import AddUserModal from './modals/AddUserModal.jsx';
|
|
|
|
|
import EditUserModal from './modals/EditUserModal.jsx';
|
|
|
|
|
import { useUsersData } from '../../../hooks/users/useUsersData';
|
|
|
|
|
|
|
|
|
|
const UsersPage = () => {
|
|
|
|
|
const usersData = useUsersData();
|
|
|
|
|
|
|
|
|
|
const {
|
|
|
|
|
// Modal state
|
|
|
|
|
showAddUser,
|
|
|
|
|
showEditUser,
|
|
|
|
|
editingUser,
|
|
|
|
|
setShowAddUser,
|
|
|
|
|
closeAddUser,
|
|
|
|
|
closeEditUser,
|
|
|
|
|
refresh,
|
|
|
|
|
|
|
|
|
|
// Form state
|
|
|
|
|
formInitValues,
|
|
|
|
|
setFormApi,
|
|
|
|
|
searchUsers,
|
|
|
|
|
loadUsers,
|
|
|
|
|
activePage,
|
|
|
|
|
pageSize,
|
|
|
|
|
groupOptions,
|
|
|
|
|
loading,
|
|
|
|
|
searching,
|
|
|
|
|
|
|
|
|
|
// Description state
|
|
|
|
|
compactMode,
|
|
|
|
|
setCompactMode,
|
|
|
|
|
|
|
|
|
|
// Translation
|
|
|
|
|
t,
|
|
|
|
|
} = usersData;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<AddUserModal
|
|
|
|
|
refresh={refresh}
|
|
|
|
|
visible={showAddUser}
|
|
|
|
|
handleClose={closeAddUser}
|
|
|
|
|
/>
|
🏗️ refactor: complete table module architecture unification and cleanup
BREAKING CHANGE: Removed standalone user edit routes and intermediate export files
## Major Refactoring
- Decompose 673-line monolithic UsersTable.js into 8 specialized components
- Extract column definitions to UsersColumnDefs.js with render functions
- Create dedicated UsersActions.jsx for action buttons
- Create UsersFilters.jsx for search and filtering logic
- Create UsersDescription.jsx for description area
- Extract all data management logic to useUsersData.js hook
- Move AddUser.js and EditUser.js to users/modals/ folder as modal components
- Create 4 new confirmation modal components (Promote, Demote, EnableDisable, Delete)
- Implement pure UsersTable.jsx component for table rendering only
- Create main container component users/index.jsx to compose all subcomponents
## Import Path Optimization
- Remove 6 intermediate re-export files: ChannelsTable.js, TokensTable.js, RedemptionsTable.js, UsageLogsTable.js, MjLogsTable.js, TaskLogsTable.js
- Update all pages to import directly from module folders (e.g., '../../components/table/tokens')
- Standardize naming convention: all pages import as XxxTable while internal components use XxxPage
## Route Cleanup
- Remove obsolete EditUser imports and routes from App.js (/console/user/edit, /console/user/edit/:id)
- Delete original monolithic files: UsersTable.js, AddUser.js, EditUser.js
## Architecture Benefits
- Unified modular pattern across all table modules (tokens, redemptions, users, channels, logs)
- Consistent file organization and naming conventions
- Better separation of concerns and maintainability
- Enhanced reusability and testability
- Eliminated unnecessary intermediate layers
- Improved import clarity and performance
All existing functionality preserved with significantly improved code organization.
2025-07-19 00:44:09 +08:00
|
|
|
|
2025-07-19 00:32:56 +08:00
|
|
|
<EditUserModal
|
|
|
|
|
refresh={refresh}
|
|
|
|
|
visible={showEditUser}
|
|
|
|
|
handleClose={closeEditUser}
|
|
|
|
|
editingUser={editingUser}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<CardPro
|
|
|
|
|
type="type1"
|
|
|
|
|
descriptionArea={
|
|
|
|
|
<UsersDescription
|
|
|
|
|
compactMode={compactMode}
|
|
|
|
|
setCompactMode={setCompactMode}
|
|
|
|
|
t={t}
|
|
|
|
|
/>
|
|
|
|
|
}
|
|
|
|
|
actionsArea={
|
|
|
|
|
<div className="flex flex-col md:flex-row justify-between items-center gap-2 w-full">
|
|
|
|
|
<UsersActions
|
|
|
|
|
setShowAddUser={setShowAddUser}
|
|
|
|
|
t={t}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<UsersFilters
|
|
|
|
|
formInitValues={formInitValues}
|
|
|
|
|
setFormApi={setFormApi}
|
|
|
|
|
searchUsers={searchUsers}
|
|
|
|
|
loadUsers={loadUsers}
|
|
|
|
|
activePage={activePage}
|
|
|
|
|
pageSize={pageSize}
|
|
|
|
|
groupOptions={groupOptions}
|
|
|
|
|
loading={loading}
|
|
|
|
|
searching={searching}
|
|
|
|
|
t={t}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
<UsersTable {...usersData} />
|
|
|
|
|
</CardPro>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default UsersPage;
|