index.tsx 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import { MarketplaceContextProvider } from './context'
  2. import Description from './description'
  3. import IntersectionLine from './intersection-line'
  4. import SearchBoxWrapper from './search-box/search-box-wrapper'
  5. import PluginTypeSwitch from './plugin-type-switch'
  6. import ListWrapper from './list/list-wrapper'
  7. import type { SearchParams } from './types'
  8. import { getMarketplaceCollectionsAndPlugins } from './utils'
  9. import { TanstackQueryIniter } from '@/context/query-client'
  10. type MarketplaceProps = {
  11. locale: string
  12. searchBoxAutoAnimate?: boolean
  13. showInstallButton?: boolean
  14. shouldExclude?: boolean
  15. searchParams?: SearchParams
  16. pluginTypeSwitchClassName?: string
  17. intersectionContainerId?: string
  18. scrollContainerId?: string
  19. }
  20. const Marketplace = async ({
  21. locale,
  22. searchBoxAutoAnimate = true,
  23. showInstallButton = true,
  24. shouldExclude,
  25. searchParams,
  26. pluginTypeSwitchClassName,
  27. intersectionContainerId,
  28. scrollContainerId,
  29. }: MarketplaceProps) => {
  30. let marketplaceCollections: any = []
  31. let marketplaceCollectionPluginsMap = {}
  32. if (!shouldExclude) {
  33. const marketplaceCollectionsAndPluginsData = await getMarketplaceCollectionsAndPlugins()
  34. marketplaceCollections = marketplaceCollectionsAndPluginsData.marketplaceCollections
  35. marketplaceCollectionPluginsMap = marketplaceCollectionsAndPluginsData.marketplaceCollectionPluginsMap
  36. }
  37. return (
  38. <TanstackQueryIniter>
  39. <MarketplaceContextProvider
  40. searchParams={searchParams}
  41. shouldExclude={shouldExclude}
  42. scrollContainerId={scrollContainerId}
  43. >
  44. <Description locale={locale} />
  45. <IntersectionLine intersectionContainerId={intersectionContainerId} />
  46. <SearchBoxWrapper
  47. locale={locale}
  48. searchBoxAutoAnimate={searchBoxAutoAnimate}
  49. />
  50. <PluginTypeSwitch
  51. locale={locale}
  52. className={pluginTypeSwitchClassName}
  53. searchBoxAutoAnimate={searchBoxAutoAnimate}
  54. />
  55. <ListWrapper
  56. locale={locale}
  57. marketplaceCollections={marketplaceCollections}
  58. marketplaceCollectionPluginsMap={marketplaceCollectionPluginsMap}
  59. showInstallButton={showInstallButton}
  60. />
  61. </MarketplaceContextProvider>
  62. </TanstackQueryIniter>
  63. )
  64. }
  65. export default Marketplace