From 2001483659fc27d529be1760bdf55e5694da9566 Mon Sep 17 00:00:00 2001 From: Rozstone <42225395+wststone@users.noreply.github.com> Date: Sat, 2 Mar 2024 17:11:25 +0800 Subject: [PATCH] fix: default to allcategories when search params is not from recommended (#2653) --- web/app/components/explore/app-list/index.tsx | 13 +- web/app/components/explore/category.tsx | 25 +- .../share/chat/welcome/massive-component.tsx | 4 +- web/test/mocks/categories.ts | 322 ++++++++++++++++++ 4 files changed, 349 insertions(+), 15 deletions(-) create mode 100644 web/test/mocks/categories.ts diff --git a/web/app/components/explore/app-list/index.tsx b/web/app/components/explore/app-list/index.tsx index 9031bb6299..058aa541c3 100644 --- a/web/app/components/explore/app-list/index.tsx +++ b/web/app/components/explore/app-list/index.tsx @@ -26,7 +26,8 @@ const Apps: FC = () => { const { isCurrentWorkspaceManager } = useAppContext() const router = useRouter() const { hasEditPermission } = useContext(ExploreContext) - const allCategoriesEn = t('explore.apps.allCategories') + const allCategoriesEn = t('explore.apps.allCategories', { lng: 'en' }) + const [currCategory, setCurrCategory] = useTabSearchParams({ defaultTab: allCategoriesEn, }) @@ -47,11 +48,10 @@ const Apps: FC = () => { }, ) - const currList = (() => { - if (currCategory === allCategoriesEn) - return allList - return allList.filter(item => item.category === currCategory) - })() + const currList + = currCategory === allCategoriesEn + ? allList + : allList.filter(item => item.category === currCategory) const [currApp, setCurrApp] = React.useState(null) const [isShowCreateModal, setIsShowCreateModal] = React.useState(false) @@ -112,6 +112,7 @@ const Apps: FC = () => { list={categories} value={currCategory} onChange={setCurrCategory} + allCategoriesEn={allCategoriesEn} />