index.jsx 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. Copyright (C) 2025 QuantumNous
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Affero General Public License as
  5. published by the Free Software Foundation, either version 3 of the
  6. License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Affero General Public License for more details.
  11. You should have received a copy of the GNU Affero General Public License
  12. along with this program. If not, see <https://www.gnu.org/licenses/>.
  13. For commercial licensing, please contact support@quantumnous.com
  14. */
  15. import React from 'react';
  16. import CardPro from '../../common/ui/CardPro';
  17. import UsersTable from './UsersTable.jsx';
  18. import UsersActions from './UsersActions.jsx';
  19. import UsersFilters from './UsersFilters.jsx';
  20. import UsersDescription from './UsersDescription.jsx';
  21. import AddUserModal from './modals/AddUserModal.jsx';
  22. import EditUserModal from './modals/EditUserModal.jsx';
  23. import { useUsersData } from '../../../hooks/users/useUsersData';
  24. import { createCardProPagination } from '../../../helpers/utils';
  25. const UsersPage = () => {
  26. const usersData = useUsersData();
  27. const {
  28. // Modal state
  29. showAddUser,
  30. showEditUser,
  31. editingUser,
  32. setShowAddUser,
  33. closeAddUser,
  34. closeEditUser,
  35. refresh,
  36. // Form state
  37. formInitValues,
  38. setFormApi,
  39. searchUsers,
  40. loadUsers,
  41. activePage,
  42. pageSize,
  43. groupOptions,
  44. loading,
  45. searching,
  46. // Description state
  47. compactMode,
  48. setCompactMode,
  49. // Translation
  50. t,
  51. } = usersData;
  52. return (
  53. <>
  54. <AddUserModal
  55. refresh={refresh}
  56. visible={showAddUser}
  57. handleClose={closeAddUser}
  58. />
  59. <EditUserModal
  60. refresh={refresh}
  61. visible={showEditUser}
  62. handleClose={closeEditUser}
  63. editingUser={editingUser}
  64. />
  65. <CardPro
  66. type="type1"
  67. descriptionArea={
  68. <UsersDescription
  69. compactMode={compactMode}
  70. setCompactMode={setCompactMode}
  71. t={t}
  72. />
  73. }
  74. actionsArea={
  75. <div className="flex flex-col md:flex-row justify-between items-center gap-2 w-full">
  76. <UsersActions
  77. setShowAddUser={setShowAddUser}
  78. t={t}
  79. />
  80. <UsersFilters
  81. formInitValues={formInitValues}
  82. setFormApi={setFormApi}
  83. searchUsers={searchUsers}
  84. loadUsers={loadUsers}
  85. activePage={activePage}
  86. pageSize={pageSize}
  87. groupOptions={groupOptions}
  88. loading={loading}
  89. searching={searching}
  90. t={t}
  91. />
  92. </div>
  93. }
  94. paginationArea={createCardProPagination({
  95. currentPage: usersData.activePage,
  96. pageSize: usersData.pageSize,
  97. total: usersData.userCount,
  98. onPageChange: usersData.handlePageChange,
  99. onPageSizeChange: usersData.handlePageSizeChange,
  100. })}
  101. t={t}
  102. >
  103. <UsersTable {...usersData} />
  104. </CardPro>
  105. </>
  106. );
  107. };
  108. export default UsersPage;