| }) | }) | ||||
| }, [activeTab, tagFilterValue, keywords, collectionList]) | }, [activeTab, tagFilterValue, keywords, collectionList]) | ||||
| const [currentProvider, setCurrentProvider] = useState<Collection | undefined>() | |||||
| const [currentProviderId, setCurrentProviderId] = useState<string | undefined>() | |||||
| const currentProvider = useMemo<Collection | undefined>(() => { | |||||
| return filteredCollectionList.find(collection => collection.id === currentProviderId) | |||||
| }, [currentProviderId, filteredCollectionList]) | |||||
| const { data: pluginList } = useInstalledPluginList() | const { data: pluginList } = useInstalledPluginList() | ||||
| const invalidateInstalledPluginList = useInvalidateInstalledPluginList() | const invalidateInstalledPluginList = useInvalidateInstalledPluginList() | ||||
| const currentPluginDetail = useMemo(() => { | const currentPluginDetail = useMemo(() => { | ||||
| > | > | ||||
| <div className={cn( | <div className={cn( | ||||
| 'sticky top-0 z-20 flex flex-wrap items-center justify-between gap-y-2 bg-background-body px-12 pb-2 pt-4 leading-[56px]', | 'sticky top-0 z-20 flex flex-wrap items-center justify-between gap-y-2 bg-background-body px-12 pb-2 pt-4 leading-[56px]', | ||||
| currentProvider && 'pr-6', | |||||
| currentProviderId && 'pr-6', | |||||
| )}> | )}> | ||||
| <TabSliderNew | <TabSliderNew | ||||
| value={activeTab} | value={activeTab} | ||||
| onChange={(state) => { | onChange={(state) => { | ||||
| setActiveTab(state) | setActiveTab(state) | ||||
| if (state !== activeTab) | if (state !== activeTab) | ||||
| setCurrentProvider(undefined) | |||||
| setCurrentProviderId(undefined) | |||||
| }} | }} | ||||
| options={options} | options={options} | ||||
| /> | /> | ||||
| {filteredCollectionList.map(collection => ( | {filteredCollectionList.map(collection => ( | ||||
| <div | <div | ||||
| key={collection.id} | key={collection.id} | ||||
| onClick={() => setCurrentProvider(collection)} | |||||
| onClick={() => setCurrentProviderId(collection.id)} | |||||
| > | > | ||||
| <Card | <Card | ||||
| className={cn( | className={cn( | ||||
| 'cursor-pointer border-[1.5px] border-transparent', | 'cursor-pointer border-[1.5px] border-transparent', | ||||
| currentProvider?.id === collection.id && 'border-components-option-card-option-selected-border', | |||||
| currentProviderId === collection.id && 'border-components-option-card-option-selected-border', | |||||
| )} | )} | ||||
| hideCornerMark | hideCornerMark | ||||
| payload={{ | payload={{ | ||||
| {currentProvider && !currentProvider.plugin_id && ( | {currentProvider && !currentProvider.plugin_id && ( | ||||
| <ProviderDetail | <ProviderDetail | ||||
| collection={currentProvider} | collection={currentProvider} | ||||
| onHide={() => setCurrentProvider(undefined)} | |||||
| onHide={() => setCurrentProviderId(undefined)} | |||||
| onRefreshData={refetch} | onRefreshData={refetch} | ||||
| /> | /> | ||||
| )} | )} | ||||
| <PluginDetailPanel | <PluginDetailPanel | ||||
| detail={currentPluginDetail} | detail={currentPluginDetail} | ||||
| onUpdate={() => invalidateInstalledPluginList()} | onUpdate={() => invalidateInstalledPluginList()} | ||||
| onHide={() => setCurrentProvider(undefined)} | |||||
| onHide={() => setCurrentProviderId(undefined)} | |||||
| /> | /> | ||||
| </> | </> | ||||
| ) | ) |