index.jsx 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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 { useIsMobile } from '../../../hooks/common/useIsMobile';
  25. import { createCardProPagination } from '../../../helpers/utils';
  26. const UsersPage = () => {
  27. const usersData = useUsersData();
  28. const isMobile = useIsMobile();
  29. const {
  30. // Modal state
  31. showAddUser,
  32. showEditUser,
  33. editingUser,
  34. setShowAddUser,
  35. closeAddUser,
  36. closeEditUser,
  37. refresh,
  38. // Form state
  39. formInitValues,
  40. setFormApi,
  41. searchUsers,
  42. loadUsers,
  43. activePage,
  44. pageSize,
  45. groupOptions,
  46. loading,
  47. searching,
  48. // Description state
  49. compactMode,
  50. setCompactMode,
  51. // Translation
  52. t,
  53. } = usersData;
  54. return (
  55. <>
  56. <AddUserModal
  57. refresh={refresh}
  58. visible={showAddUser}
  59. handleClose={closeAddUser}
  60. />
  61. <EditUserModal
  62. refresh={refresh}
  63. visible={showEditUser}
  64. handleClose={closeEditUser}
  65. editingUser={editingUser}
  66. />
  67. <CardPro
  68. type="type1"
  69. descriptionArea={
  70. <UsersDescription
  71. compactMode={compactMode}
  72. setCompactMode={setCompactMode}
  73. t={t}
  74. />
  75. }
  76. actionsArea={
  77. <div className="flex flex-col md:flex-row justify-between items-center gap-2 w-full">
  78. <UsersActions
  79. setShowAddUser={setShowAddUser}
  80. t={t}
  81. />
  82. <UsersFilters
  83. formInitValues={formInitValues}
  84. setFormApi={setFormApi}
  85. searchUsers={searchUsers}
  86. loadUsers={loadUsers}
  87. activePage={activePage}
  88. pageSize={pageSize}
  89. groupOptions={groupOptions}
  90. loading={loading}
  91. searching={searching}
  92. t={t}
  93. />
  94. </div>
  95. }
  96. paginationArea={createCardProPagination({
  97. currentPage: usersData.activePage,
  98. pageSize: usersData.pageSize,
  99. total: usersData.userCount,
  100. onPageChange: usersData.handlePageChange,
  101. onPageSizeChange: usersData.handlePageSizeChange,
  102. isMobile: isMobile,
  103. })}
  104. t={t}
  105. >
  106. <UsersTable {...usersData} />
  107. </CardPro>
  108. </>
  109. );
  110. };
  111. export default UsersPage;