SubscriptionsTable.jsx 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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, { useMemo } from 'react';
  16. import { Empty } from '@douyinfe/semi-ui';
  17. import CardTable from '../../common/ui/CardTable';
  18. import {
  19. IllustrationNoResult,
  20. IllustrationNoResultDark,
  21. } from '@douyinfe/semi-illustrations';
  22. import { getSubscriptionsColumns } from './SubscriptionsColumnDefs';
  23. const SubscriptionsTable = (subscriptionsData) => {
  24. const {
  25. plans,
  26. loading,
  27. compactMode,
  28. openEdit,
  29. setPlanEnabled,
  30. t,
  31. enableEpay,
  32. } = subscriptionsData;
  33. const columns = useMemo(() => {
  34. return getSubscriptionsColumns({
  35. t,
  36. openEdit,
  37. setPlanEnabled,
  38. enableEpay,
  39. });
  40. }, [t, openEdit, setPlanEnabled, enableEpay]);
  41. const tableColumns = useMemo(() => {
  42. return compactMode
  43. ? columns.map((col) => {
  44. if (col.dataIndex === 'operate') {
  45. const { fixed, ...rest } = col;
  46. return rest;
  47. }
  48. return col;
  49. })
  50. : columns;
  51. }, [compactMode, columns]);
  52. return (
  53. <CardTable
  54. columns={tableColumns}
  55. dataSource={plans}
  56. scroll={compactMode ? undefined : { x: 'max-content' }}
  57. pagination={false}
  58. hidePagination={true}
  59. loading={loading}
  60. rowKey={(row) => row?.plan?.id}
  61. empty={
  62. <Empty
  63. image={<IllustrationNoResult style={{ width: 150, height: 150 }} />}
  64. darkModeImage={
  65. <IllustrationNoResultDark style={{ width: 150, height: 150 }} />
  66. }
  67. description={t('暂无订阅套餐')}
  68. style={{ padding: 30 }}
  69. />
  70. }
  71. className='overflow-hidden'
  72. size='middle'
  73. />
  74. );
  75. };
  76. export default SubscriptionsTable;