PricingSidebar.jsx 3.9 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 PricingTags from '../filter/PricingTags';
  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. filterTag,
  45. setFilterTag,
  46. currentPage,
  47. setCurrentPage,
  48. tokenUnit,
  49. setTokenUnit,
  50. loading,
  51. t,
  52. ...categoryProps
  53. }) => {
  54. const {
  55. quotaTypeModels,
  56. endpointTypeModels,
  57. vendorModels,
  58. tagModels,
  59. groupCountModels,
  60. } = usePricingFilterCounts({
  61. models: categoryProps.models,
  62. filterGroup,
  63. filterQuotaType,
  64. filterEndpointType,
  65. filterVendor,
  66. filterTag,
  67. searchValue: categoryProps.searchValue,
  68. });
  69. const handleResetFilters = () =>
  70. resetPricingFilters({
  71. handleChange,
  72. setShowWithRecharge,
  73. setCurrency,
  74. setShowRatio,
  75. setViewMode,
  76. setFilterGroup,
  77. setFilterQuotaType,
  78. setFilterEndpointType,
  79. setFilterVendor,
  80. setFilterTag,
  81. setCurrentPage,
  82. setTokenUnit,
  83. });
  84. return (
  85. <div className="p-2">
  86. <div className="flex items-center justify-between mb-6">
  87. <div className="text-lg font-semibold text-gray-800">
  88. {t('筛选')}
  89. </div>
  90. <Button
  91. theme="outline"
  92. type='tertiary'
  93. onClick={handleResetFilters}
  94. className="text-gray-500 hover:text-gray-700"
  95. >
  96. {t('重置')}
  97. </Button>
  98. </div>
  99. <PricingVendors
  100. filterVendor={filterVendor}
  101. setFilterVendor={setFilterVendor}
  102. models={vendorModels}
  103. allModels={categoryProps.models}
  104. loading={loading}
  105. t={t}
  106. />
  107. <PricingTags
  108. filterTag={filterTag}
  109. setFilterTag={setFilterTag}
  110. models={tagModels}
  111. allModels={categoryProps.models}
  112. loading={loading}
  113. t={t}
  114. />
  115. <PricingGroups
  116. filterGroup={filterGroup}
  117. setFilterGroup={handleGroupClick}
  118. usableGroup={categoryProps.usableGroup}
  119. groupRatio={categoryProps.groupRatio}
  120. models={groupCountModels}
  121. loading={loading}
  122. t={t}
  123. />
  124. <PricingQuotaTypes
  125. filterQuotaType={filterQuotaType}
  126. setFilterQuotaType={setFilterQuotaType}
  127. models={quotaTypeModels}
  128. loading={loading}
  129. t={t}
  130. />
  131. <PricingEndpointTypes
  132. filterEndpointType={filterEndpointType}
  133. setFilterEndpointType={setFilterEndpointType}
  134. models={endpointTypeModels}
  135. allModels={categoryProps.models}
  136. loading={loading}
  137. t={t}
  138. />
  139. </div>
  140. );
  141. };
  142. export default PricingSidebar;