diff --git a/packages/ui/v2/core/apps/AllApps.tsx b/packages/ui/v2/core/apps/AllApps.tsx index 44bfbaecb1..8da15525b2 100644 --- a/packages/ui/v2/core/apps/AllApps.tsx +++ b/packages/ui/v2/core/apps/AllApps.tsx @@ -38,13 +38,95 @@ export function useShouldShowArrows() { type AllAppsPropsType = { apps: (App & { credentials: Credential[] | undefined })[] }; -export default function AllApps({ apps }: AllAppsPropsType) { +interface CategoryTabProps { + selectedCategory: string | null; + categories: string[]; +} + +function CategoryTab({ selectedCategory, categories }: CategoryTabProps) { const { t } = useLocale(); const router = useRouter(); + const { ref, calculateScroll, leftVisible, rightVisible } = useShouldShowArrows(); + const handleLeft = () => { + if (ref.current) { + ref.current.scrollLeft -= 100; + } + }; + + const handleRight = () => { + if (ref.current) { + ref.current.scrollLeft += 100; + } + }; + return ( +
+

+ {t("explore_apps", { + category: + (selectedCategory && selectedCategory[0].toUpperCase() + selectedCategory.slice(1)) || + t("all_apps"), + })} +

+ {leftVisible && ( + + )} + + {rightVisible && ( + + )} +
+ ); +} + +export default function AllApps({ apps }: AllAppsPropsType) { + const router = useRouter(); const [selectedCategory, setSelectedCategory] = useState(null); const [appsContainerRef] = useAutoAnimate(); - const { ref, calculateScroll, leftVisible, rightVisible } = useShouldShowArrows(); + const categories = apps .map((app) => app.category) .filter((cat, pos, self) => { @@ -61,65 +143,7 @@ export default function AllApps({ apps }: AllAppsPropsType) { return (
-
-

- {t("explore_apps", { - category: - (selectedCategory && selectedCategory[0].toUpperCase() + selectedCategory.slice(1)) || - t("all_apps"), - })} -

- {leftVisible && ( -
-
- -
-
-
- )} -
    calculateScroll(e)} - ref={ref}> -
  • { - router.replace(router.asPath.split("?")[0], undefined, { shallow: true }); - }} - className={classNames( - selectedCategory === null ? "bg-gray-900 text-gray-50" : "bg-gray-50 text-gray-900", - "rounded-md px-4 py-2.5 text-sm font-medium hover:cursor-pointer hover:bg-gray-900 hover:text-gray-50" - )}> - {t("all_apps")} -
  • - {categories.map((cat, pos) => ( -
  • { - if (selectedCategory === cat) { - router.replace(router.asPath.split("?")[0], undefined, { shallow: true }); - } else { - router.replace(router.asPath.split("?")[0] + `?category=${cat}`, undefined, { - shallow: true, - }); - } - }} - className={classNames( - selectedCategory === cat ? "bg-gray-900 text-gray-50" : "bg-gray-50 text-gray-900", - "rounded-md px-4 py-2.5 text-sm font-medium hover:cursor-pointer hover:bg-gray-900 hover:text-gray-50" - )}> - {cat[0].toUpperCase() + cat.slice(1)} -
  • - ))} -
- {rightVisible && ( -
-
-
- -
-
- )} -
+