fix: default to allcategories when search params is not from recommended (#2653)

This commit is contained in:
Rozstone
2024-03-02 17:11:25 +08:00
committed by GitHub
parent 444aba55dd
commit 2001483659
4 changed files with 349 additions and 15 deletions

View File

@@ -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<App | null>(null)
const [isShowCreateModal, setIsShowCreateModal] = React.useState(false)
@@ -112,6 +112,7 @@ const Apps: FC = () => {
list={categories}
value={currCategory}
onChange={setCurrCategory}
allCategoriesEn={allCategoriesEn}
/>
<div className="relative flex flex-1 mt-6 pb-6 flex-col overflow-auto bg-gray-100 shrink-0 grow">
<nav