PricingSidebar.jsx 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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 { Button } from '@douyinfe/semi-ui';
  17. import PricingGroups from '../filter/PricingGroups';
  18. import PricingQuotaTypes from '../filter/PricingQuotaTypes';
  19. import PricingEndpointTypes from '../filter/PricingEndpointTypes';
  20. import PricingVendors from '../filter/PricingVendors';
  21. import PricingDisplaySettings from '../filter/PricingDisplaySettings';
  22. import { resetPricingFilters } from '../../../../helpers/utils';
  23. import { usePricingFilterCounts } from '../../../../hooks/model-pricing/usePricingFilterCounts';
  24. const PricingSidebar = ({
  25. showWithRecharge,
  26. setShowWithRecharge,
  27. currency,
  28. setCurrency,
  29. handleChange,
  30. setActiveKey,
  31. showRatio,
  32. setShowRatio,
  33. viewMode,
  34. setViewMode,
  35. filterGroup,
  36. setFilterGroup,
  37. handleGroupClick,
  38. filterQuotaType,
  39. setFilterQuotaType,
  40. filterEndpointType,
  41. setFilterEndpointType,
  42. filterVendor,
  43. setFilterVendor,
  44. currentPage,
  45. setCurrentPage,
  46. tokenUnit,
  47. setTokenUnit,
  48. loading,
  49. t,
  50. ...categoryProps
  51. }) => {
  52. const {
  53. quotaTypeModels,
  54. endpointTypeModels,
  55. vendorModels,
  56. groupCountModels,
  57. } = usePricingFilterCounts({
  58. models: categoryProps.models,
  59. filterGroup,
  60. filterQuotaType,
  61. filterEndpointType,
  62. filterVendor,
  63. searchValue: categoryProps.searchValue,
  64. });
  65. const handleResetFilters = () =>
  66. resetPricingFilters({
  67. handleChange,
  68. setShowWithRecharge,
  69. setCurrency,
  70. setShowRatio,
  71. setViewMode,
  72. setFilterGroup,
  73. setFilterQuotaType,
  74. setFilterEndpointType,
  75. setFilterVendor,
  76. setCurrentPage,
  77. setTokenUnit,
  78. });
  79. return (
  80. <div className="p-4">
  81. <div className="flex items-center justify-between mb-6">
  82. <div className="text-lg font-semibold text-gray-800">
  83. {t('筛选')}
  84. </div>
  85. <Button
  86. theme="outline"
  87. type='tertiary'
  88. onClick={handleResetFilters}
  89. className="text-gray-500 hover:text-gray-700"
  90. >
  91. {t('重置')}
  92. </Button>
  93. </div>
  94. <PricingDisplaySettings
  95. showWithRecharge={showWithRecharge}
  96. setShowWithRecharge={setShowWithRecharge}
  97. currency={currency}
  98. setCurrency={setCurrency}
  99. showRatio={showRatio}
  100. setShowRatio={setShowRatio}
  101. viewMode={viewMode}
  102. setViewMode={setViewMode}
  103. tokenUnit={tokenUnit}
  104. setTokenUnit={setTokenUnit}
  105. loading={loading}
  106. t={t}
  107. />
  108. <PricingVendors
  109. filterVendor={filterVendor}
  110. setFilterVendor={setFilterVendor}
  111. models={vendorModels}
  112. allModels={categoryProps.models}
  113. loading={loading}
  114. t={t}
  115. />
  116. <PricingGroups
  117. filterGroup={filterGroup}
  118. setFilterGroup={handleGroupClick}
  119. usableGroup={categoryProps.usableGroup}
  120. groupRatio={categoryProps.groupRatio}
  121. models={groupCountModels}
  122. loading={loading}
  123. t={t}
  124. />
  125. <PricingQuotaTypes
  126. filterQuotaType={filterQuotaType}
  127. setFilterQuotaType={setFilterQuotaType}
  128. models={quotaTypeModels}
  129. loading={loading}
  130. t={t}
  131. />
  132. <PricingEndpointTypes
  133. filterEndpointType={filterEndpointType}
  134. setFilterEndpointType={setFilterEndpointType}
  135. models={endpointTypeModels}
  136. allModels={categoryProps.models}
  137. loading={loading}
  138. t={t}
  139. />
  140. </div>
  141. );
  142. };
  143. export default PricingSidebar;