index.jsx 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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 RedemptionsTable from './RedemptionsTable.jsx';
  18. import RedemptionsActions from './RedemptionsActions.jsx';
  19. import RedemptionsFilters from './RedemptionsFilters.jsx';
  20. import RedemptionsDescription from './RedemptionsDescription.jsx';
  21. import EditRedemptionModal from './modals/EditRedemptionModal';
  22. import { useRedemptionsData } from '../../../hooks/redemptions/useRedemptionsData';
  23. import { useIsMobile } from '../../../hooks/common/useIsMobile';
  24. import { createCardProPagination } from '../../../helpers/utils';
  25. const RedemptionsPage = () => {
  26. const redemptionsData = useRedemptionsData();
  27. const isMobile = useIsMobile();
  28. const {
  29. // Edit state
  30. showEdit,
  31. editingRedemption,
  32. closeEdit,
  33. refresh,
  34. // Actions state
  35. selectedKeys,
  36. setEditingRedemption,
  37. setShowEdit,
  38. batchCopyRedemptions,
  39. batchDeleteRedemptions,
  40. // Filters state
  41. formInitValues,
  42. setFormApi,
  43. searchRedemptions,
  44. loading,
  45. searching,
  46. // UI state
  47. compactMode,
  48. setCompactMode,
  49. // Translation
  50. t,
  51. } = redemptionsData;
  52. return (
  53. <>
  54. <EditRedemptionModal
  55. refresh={refresh}
  56. editingRedemption={editingRedemption}
  57. visiable={showEdit}
  58. handleClose={closeEdit}
  59. />
  60. <CardPro
  61. type="type1"
  62. descriptionArea={
  63. <RedemptionsDescription
  64. compactMode={compactMode}
  65. setCompactMode={setCompactMode}
  66. t={t}
  67. />
  68. }
  69. actionsArea={
  70. <div className="flex flex-col md:flex-row justify-between items-center gap-2 w-full">
  71. <RedemptionsActions
  72. selectedKeys={selectedKeys}
  73. setEditingRedemption={setEditingRedemption}
  74. setShowEdit={setShowEdit}
  75. batchCopyRedemptions={batchCopyRedemptions}
  76. batchDeleteRedemptions={batchDeleteRedemptions}
  77. t={t}
  78. />
  79. <div className="w-full md:w-full lg:w-auto order-1 md:order-2">
  80. <RedemptionsFilters
  81. formInitValues={formInitValues}
  82. setFormApi={setFormApi}
  83. searchRedemptions={searchRedemptions}
  84. loading={loading}
  85. searching={searching}
  86. t={t}
  87. />
  88. </div>
  89. </div>
  90. }
  91. paginationArea={createCardProPagination({
  92. currentPage: redemptionsData.activePage,
  93. pageSize: redemptionsData.pageSize,
  94. total: redemptionsData.tokenCount,
  95. onPageChange: redemptionsData.handlePageChange,
  96. onPageSizeChange: redemptionsData.handlePageSizeChange,
  97. isMobile: isMobile,
  98. t: redemptionsData.t,
  99. })}
  100. t={redemptionsData.t}
  101. >
  102. <RedemptionsTable {...redemptionsData} />
  103. </CardPro>
  104. </>
  105. );
  106. };
  107. export default RedemptionsPage;