forked from calcom/cal.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: app router - all sub-pages in
/apps
(calcom#16976)
* chore: apps/[slug] remove pages router * remove apps/[slug] pages from /future * chore: apps/installed remove pages router * chore: apps/installation remove pages router * remove Head element * fix metadata * fix test * fix another test * chore: apps/categories remove pages router * revert unneeded changes * update middleware * Remove <Head> * remove unused import and code * remove unused import and code again * fix * fix category page * add split icon * add /routing paths to middleware matcher * wip * remove HeadSeo from App.tsx * clean up head-seo test * add generateAppMetadata * use generateAppMetadata in apps/[slug] page * delete file * remove log * fix * fix * fix apps/installed pages * fix cateogires pages * fix * fix imports * wip * fix * fix * fix metadata * fix * redirect /apps/routing-forms to /routing * replace all usages of /apps/routing-forms to /routing * better naming * /routing -> /routing/forms * fix * fix * fix * fix * remove backPath as it is irrelevant when withoutMain is true * fix type checks * fix type check in apps/[slug] * refactors * fix * fix test * fix * fix * fix * Replace multiple leading slashes with a single slash * migrate routing-forms too * add re routing * fix * add redirection --------- Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com>
- Loading branch information
1 parent
12d8790
commit ead43c9
Showing
68 changed files
with
554 additions
and
561 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import type { PageProps as _PageProps } from "app/_types"; | ||
import { generateAppMetadata } from "app/_utils"; | ||
import { WithLayout } from "app/layoutHOC"; | ||
import { notFound } from "next/navigation"; | ||
import { z } from "zod"; | ||
|
||
import { AppRepository } from "@calcom/lib/server/repository/app"; | ||
import { isPrismaAvailableCheck } from "@calcom/prisma/is-prisma-available-check"; | ||
|
||
import { getStaticProps } from "@lib/apps/[slug]/getStaticProps"; | ||
|
||
import AppView from "~/apps/[slug]/slug-view"; | ||
|
||
const paramsSchema = z.object({ | ||
slug: z.string(), | ||
}); | ||
|
||
export const generateMetadata = async ({ params }: _PageProps) => { | ||
const p = paramsSchema.safeParse(params); | ||
|
||
if (!p.success) { | ||
return notFound(); | ||
} | ||
|
||
const props = await getStaticProps(p.data.slug); | ||
|
||
if (!props) { | ||
notFound(); | ||
} | ||
const { name, logo, description } = props.data; | ||
|
||
return await generateAppMetadata( | ||
{ slug: logo, name, description }, | ||
() => name, | ||
() => description | ||
); | ||
}; | ||
|
||
export const generateStaticParams = async () => { | ||
const isPrismaAvailable = await isPrismaAvailableCheck(); | ||
|
||
if (!isPrismaAvailable) { | ||
// Database is not available at build time. Make sure we fall back to building these pages on demand | ||
return []; | ||
} | ||
const appStore = await AppRepository.findAppStore(); | ||
return appStore.map(({ slug }) => ({ slug })); | ||
}; | ||
|
||
async function Page({ params }: _PageProps) { | ||
const p = paramsSchema.safeParse(params); | ||
|
||
if (!p.success) { | ||
return notFound(); | ||
} | ||
|
||
const props = await getStaticProps(p.data.slug); | ||
|
||
if (!props) { | ||
notFound(); | ||
} | ||
|
||
return <AppView {...props} />; | ||
} | ||
|
||
export default WithLayout({ getLayout: null, ServerPage: Page }); | ||
|
||
export const dynamic = "force-static"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import type { PageProps } from "app/_types"; | ||
import { _generateMetadata } from "app/_utils"; | ||
import { WithLayout } from "app/layoutHOC"; | ||
import { redirect } from "next/navigation"; | ||
import { z } from "zod"; | ||
|
||
import { AppCategories } from "@calcom/prisma/enums"; | ||
|
||
import { getStaticProps } from "@lib/apps/categories/[category]/getStaticProps"; | ||
|
||
import CategoryPage from "~/apps/categories/[category]/category-view"; | ||
|
||
const querySchema = z.object({ | ||
category: z.enum(Object.values(AppCategories) as [AppCategories, ...AppCategories[]]), | ||
}); | ||
|
||
export const generateMetadata = async () => { | ||
return await _generateMetadata( | ||
(t) => t("app_store"), | ||
(t) => t("app_store_description") | ||
); | ||
}; | ||
|
||
export const generateStaticParams = async () => { | ||
const paths = Object.keys(AppCategories); | ||
return paths.map((category) => ({ category })); | ||
}; | ||
|
||
async function Page({ params, searchParams }: PageProps) { | ||
const parsed = querySchema.safeParse({ ...params, ...searchParams }); | ||
if (!parsed.success) { | ||
redirect("/apps/categories/calendar"); | ||
} | ||
|
||
const props = await getStaticProps(parsed.data.category); | ||
|
||
return <CategoryPage {...props} />; | ||
} | ||
|
||
export default WithLayout({ getLayout: null, ServerPage: Page }); |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { PageProps } from "app/_types"; | ||
import { _generateMetadata } from "app/_utils"; | ||
import { WithLayout } from "app/layoutHOC"; | ||
import { redirect } from "next/navigation"; | ||
import { z } from "zod"; | ||
|
||
import { AppCategories } from "@calcom/prisma/enums"; | ||
|
||
import InstalledApps from "~/apps/installed/[category]/installed-category-view"; | ||
|
||
const querySchema = z.object({ | ||
category: z.nativeEnum(AppCategories), | ||
}); | ||
|
||
export const generateMetadata = async () => { | ||
return await _generateMetadata( | ||
(t) => t("installed_apps"), | ||
(t) => t("manage_your_connected_apps") | ||
); | ||
}; | ||
|
||
const InstalledAppsWrapper = async ({ params }: PageProps) => { | ||
const parsedParams = querySchema.safeParse(params); | ||
|
||
if (!parsedParams.success) { | ||
redirect("/apps/installed/calendar"); | ||
} | ||
|
||
return <InstalledApps category={parsedParams.data.category} />; | ||
}; | ||
|
||
export default WithLayout({ getLayout: null, ServerPage: InstalledAppsWrapper }); |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from "app/routing-forms/[...pages]/page"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from "app/routing-forms/page"; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.