chore: [app-router-migration 16]: migrate routing forms page (#13015)
Co-authored-by: Benny Joo <[email protected]>
This commit is contained in:
1 parent
dd7673b1f9
commit
bdd1d3a99d
29 files changed
+665
-333
No files matched your search
@@ -1,3 +1,5 @@
|
||||
"use client";
|
||||
|
||||
import type { GetServerSidePropsContext } from "next";
|
||||
|
||||
import { getAppWithMetadata } from "@calcom/app-store/_appRegistry";
|
||||
@@ -48,7 +50,6 @@ function getRoute(appName: string, pages: string[]) {
|
||||
}
|
||||
const mainPage = pages[0];
|
||||
const appPage = routingConfig.layoutHandler || (routingConfig[mainPage] as AppPageType);
|
||||
|
||||
if (!appPage) {
|
||||
return {
|
||||
notFound: true,
|
||||
@@ -60,7 +61,7 @@ function getRoute(appName: string, pages: string[]) {
|
||||
const AppPage: AppPageType["default"] = function AppPage(props) {
|
||||
const appName = props.appName;
|
||||
const params = useParamsWithFallback();
|
||||
const pages = (params.pages || []) as string[];
|
||||
const pages = Array.isArray(params.pages) ? params.pages : params.pages?.split("/") ?? [];
|
||||
const route = getRoute(appName, pages);
|
||||
|
||||
const componentProps = {
|
||||
@@ -87,18 +88,22 @@ AppPage.isBookingPage = ({ router }) => {
|
||||
return !!isBookingPage;
|
||||
};
|
||||
|
||||
AppPage.getLayout = (page, router) => {
|
||||
const route = getRoute(router.query.slug as string, router.query.pages as string[]);
|
||||
export const getLayout: NonNullable<(typeof AppPage)["getLayout"]> = (page) => {
|
||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||
const { slug, pages } = useParamsWithFallback();
|
||||
const route = getRoute(slug as string, pages as string[]);
|
||||
|
||||
if (route.notFound) {
|
||||
return null;
|
||||
}
|
||||
if (!route.Component.getLayout) {
|
||||
return page;
|
||||
}
|
||||
return route.Component.getLayout(page, router);
|
||||
return route.Component.getLayout(page);
|
||||
};
|
||||
|
||||
AppPage.PageWrapper = PageWrapper;
|
||||
AppPage.getLayout = getLayout;
|
||||
|
||||
export default AppPage;
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import type { AppProps as NextAppProps } from "next/app";
|
||||
import { redirect } from "next/navigation";
|
||||
import { redirect, useRouter } from "next/navigation";
|
||||
|
||||
import { AddNewTeamsForm } from "@calcom/features/ee/organizations/components";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
@@ -22,8 +21,11 @@ const AddNewTeamsPage = () => {
|
||||
);
|
||||
};
|
||||
|
||||
AddNewTeamsPage.getLayout = (page: React.ReactElement, router: NextAppProps["router"]) => (
|
||||
<>
|
||||
AddNewTeamsPage.getLayout = (page: React.ReactElement) => {
|
||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||
const router = useRouter();
|
||||
|
||||
return (
|
||||
<WizardLayout
|
||||
currentStep={5}
|
||||
maxSteps={5}
|
||||
@@ -32,8 +34,8 @@ AddNewTeamsPage.getLayout = (page: React.ReactElement, router: NextAppProps["rou
|
||||
}}>
|
||||
{page}
|
||||
</WizardLayout>
|
||||
</>
|
||||
);
|
||||
);
|
||||
};
|
||||
|
||||
AddNewTeamsPage.PageWrapper = PageWrapper;
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
"use client";
|
||||
|
||||
import type { AppProps as NextAppProps } from "next/app";
|
||||
import { redirect } from "next/navigation";
|
||||
import { redirect, useRouter } from "next/navigation";
|
||||
|
||||
import { AddNewOrgAdminsForm } from "@calcom/features/ee/organizations/components";
|
||||
import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { Meta, WizardLayout, WizardLayoutAppDir } from "@calcom/ui";
|
||||
|
||||
@@ -25,16 +25,23 @@ const OnboardTeamMembersPage = () => {
|
||||
);
|
||||
};
|
||||
|
||||
OnboardTeamMembersPage.getLayout = (page: React.ReactElement, router: NextAppProps["router"]) => (
|
||||
<WizardLayout
|
||||
currentStep={4}
|
||||
maxSteps={5}
|
||||
isOptionalCallback={() => {
|
||||
router.push(`/settings/organizations/${router.query.id}/add-teams`);
|
||||
}}>
|
||||
{page}
|
||||
</WizardLayout>
|
||||
);
|
||||
OnboardTeamMembersPage.getLayout = (page: React.ReactElement) => {
|
||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||
const router = useRouter();
|
||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||
const query = useCompatSearchParams();
|
||||
|
||||
return (
|
||||
<WizardLayout
|
||||
currentStep={4}
|
||||
maxSteps={5}
|
||||
isOptionalCallback={() => {
|
||||
router.push(`/settings/organizations/${query.get("id")}/add-teams`);
|
||||
}}>
|
||||
{page}
|
||||
</WizardLayout>
|
||||
);
|
||||
};
|
||||
|
||||
export const buildWrappedOnboardTeamMembersPage = (
|
||||
id: string | string[] | undefined,
|
||||
|
||||
Reference in new issue
Block a user