diff --git a/apps/web/pages/v2/apps/installed/[category].tsx b/apps/web/pages/v2/apps/installed/[category].tsx index cca605e990..a9c85eff34 100644 --- a/apps/web/pages/v2/apps/installed/[category].tsx +++ b/apps/web/pages/v2/apps/installed/[category].tsx @@ -1,4 +1,4 @@ -import { useRouter } from "next/router"; +import { GetStaticPaths, GetStaticProps, InferGetStaticPropsType } from "next"; import z from "zod"; import { InstallAppButton } from "@calcom/app-store/components"; @@ -177,12 +177,8 @@ const querySchema = z.object({ category: z.nativeEnum(InstalledAppVariants), }); -export default function InstalledApps() { +export default function InstalledApps({ category }: InferGetStaticPropsType) { const { t } = useLocale(); - const router = useRouter(); - const { category } = router.isReady - ? querySchema.parse(router.query) - : { category: InstalledAppVariants.calendar as const }; return ( @@ -202,3 +198,25 @@ export default function InstalledApps() { ); } + +export const getStaticProps: GetStaticProps = (ctx) => { + const params = querySchema.safeParse(ctx.params); + + if (!params.success) return { notFound: true }; + + return { + props: { + category: params.data.category, + }, + }; +}; + +export const getStaticPaths: GetStaticPaths = () => { + return { + paths: Object.values(InstalledAppVariants).map((category) => ({ + params: { category }, + locale: "en", + })), + fallback: "blocking", + }; +};