You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.tsx 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 { TanstackQueryInitializer } 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. showSearchParams?: boolean
  20. }
  21. const Marketplace = async ({
  22. locale,
  23. searchBoxAutoAnimate = true,
  24. showInstallButton = true,
  25. shouldExclude,
  26. searchParams,
  27. pluginTypeSwitchClassName,
  28. intersectionContainerId,
  29. scrollContainerId,
  30. showSearchParams = true,
  31. }: MarketplaceProps) => {
  32. let marketplaceCollections: any = []
  33. let marketplaceCollectionPluginsMap = {}
  34. if (!shouldExclude) {
  35. const marketplaceCollectionsAndPluginsData = await getMarketplaceCollectionsAndPlugins()
  36. marketplaceCollections = marketplaceCollectionsAndPluginsData.marketplaceCollections
  37. marketplaceCollectionPluginsMap = marketplaceCollectionsAndPluginsData.marketplaceCollectionPluginsMap
  38. }
  39. return (
  40. <TanstackQueryInitializer>
  41. <MarketplaceContextProvider
  42. searchParams={searchParams}
  43. shouldExclude={shouldExclude}
  44. scrollContainerId={scrollContainerId}
  45. showSearchParams={showSearchParams}
  46. >
  47. <Description locale={locale} />
  48. <IntersectionLine intersectionContainerId={intersectionContainerId} />
  49. <SearchBoxWrapper
  50. locale={locale}
  51. searchBoxAutoAnimate={searchBoxAutoAnimate}
  52. />
  53. <PluginTypeSwitch
  54. locale={locale}
  55. className={pluginTypeSwitchClassName}
  56. searchBoxAutoAnimate={searchBoxAutoAnimate}
  57. showSearchParams={showSearchParams}
  58. />
  59. <ListWrapper
  60. locale={locale}
  61. marketplaceCollections={marketplaceCollections}
  62. marketplaceCollectionPluginsMap={marketplaceCollectionPluginsMap}
  63. showInstallButton={showInstallButton}
  64. />
  65. </MarketplaceContextProvider>
  66. </TanstackQueryInitializer>
  67. )
  68. }
  69. export default Marketplace