10000 chore: Remove Pages Router / Use App Router - `/workflows` (#16519) · calcom/cal.com@ce9df65 · GitHub
[go: up one dir, main page]

Skip to content

Commit

Permalink
chore: Remove Pages Router / Use App Router - /workflows (#16519)
Browse files Browse the repository at this point in the history
* /workflows: Remove Pages Router / Render App Router

* fix

* unneeded changes

* disable server side fetching for now

* revert unneeded changes
  • Loading branch information
hbjORbj authored Dec 11, 2024
1 parent fc6e39c commit ce9df65
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 91 deletions.
1 change: 0 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,6 @@ APP_ROUTER_APPS_CATEGORIES_ENABLED=0
APP_ROUTER_APPS_CATEGORIES_CATEGORY_ENABLED=0
APP_ROUTER_BOOKING_ENABLED=0
APP_ROUTER_BOOKINGS_STATUS_ENABLED=0
APP_ROUTER_WORKFLOWS_ENABLED=0
APP_ROUTER_GETTING_STARTED_STEP_ENABLED=0
APP_ROUTER_VIDEO_ENABLED=0
APP_ROUTER_TEAM_ENABLED=0
Expand Down
1 change: 0 additions & 1 deletion apps/web/abTest/middlewareFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const ROUTES: [URLPattern, boolean][] = [
["/auth/error", process.env.APP_ROUTER_AUTH_ERROR_ENABLED === "1"] as const,
["/auth/platform/:path*", process.env.APP_ROUTER_AUTH_PLATFORM_ENABLED === "1"] as const,
["/auth/oauth2/:path*", process.env.APP_ROUTER_AUTH_OAUTH2_ENABLED === "1"] as const,
["/workflows/:path*", process.env.APP_ROUTER_WORKFLOWS_ENABLED === "1"] as const,
["/getting-started/:step", process.env.APP_ROUTER_GETTING_STARTED_STEP_ENABLED === "1"] as const,
["/bookings/:status", process.env.APP_ROUTER_BOOKINGS_STATUS_ENABLED === "1"] as const,
["/booking/:path*", process.env.APP_ROUTER_BOOKING_ENABLED === "1"] as const,
Expand Down
36 changes: 0 additions & 36 deletions apps/web/app/future/workflows/page.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { WithLayout } from "app/layoutHOC";
import { notFound } from "next/navigation";
import { z } from "zod";

import { getServerSessionForAppDir } from "@calcom/feature-auth/lib/get-server-session-for-app-dir";
// import { getServerSessionForAppDir } from "@calcom/feature-auth/lib/get-server-session-for-app-dir";
import LegacyPage from "@calcom/features/ee/workflows/pages/workflow";
import { WorkflowRepository } from "@calcom/lib/server/repository/workflow";

Expand All @@ -21,7 +21,7 @@ export const generateMetadata = async ({ params, searchParams }: PageProps) => {
const workflow = await WorkflowRepository.getById({ id: +parsed.data.workflow });

return await _generateMetadata(
() => (workflow && workflow.name ? workflow.name : "Untitled"),
(t) => (workflow && workflow.name ? workflow.name : t("untitled")),
() => ""
);
};
Expand All @@ -30,31 +30,33 @@ export const generateStaticParams = () => [];

const Page = async ({ params, searchParams }: PageProps) => {
// FIXME: Refactor me once next-auth endpoint is migrated to App Router
const session = await getServerSessionForAppDir();
const user = session?.user;
// const session = await getServerSessionForAppDir();
// const user = session?.user;
const parsed = querySchema.safeParse({ ...params, ...searchParams });
if (!parsed.success) {
notFound();
}

const workflow = await WorkflowRepository.getById({ id: +parsed.data.workflow });
let verifiedEmails, verifiedNumbers;
try {
verifiedEmails = await WorkflowRepository.getVerifiedEmails({
userEmail: user?.email ?? null,
userId: user?.id ?? null,
teamId: workflow?.team?.id,
});
} catch (err) {}
try {
verifiedNumbers = await WorkflowRepository.getVerifiedNumbers({
userId: user?.id ?? null,
teamId: workflow?.team?.id,
});
} catch (err) {}
// const workflow = await WorkflowRepository.getById({ id: +parsed.data.workflow });
// let verifiedEmails, verifiedNumbers;
// try {
// verifiedEmails = await WorkflowRepository.getVerifiedEmails({
// userEmail: user?.email ?? null,
// userId: user?.id ?? null,
// teamId: workflow?.team?.id,
// });
// } catch (err) {}
// try {
// verifiedNumbers = await WorkflowRepository.getVerifiedNumbers({
// userId: user?.id ?? null,
// teamId: workflow?.team?.id,
// });
// } catch (err) {}

return (
<LegacyPage workflowData={workflow} verifiedEmails={verifiedEmails} verifiedNumbers={verifiedNumbers} />
<LegacyPage
// workflowData={workflow} verifiedEmails={verifiedEmails} verifiedNumbers={verifiedNumbers}
/>
);
};

Expand Down
40 changes: 40 additions & 0 deletions apps/web/app/workflows/page.tsx
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 { getServerSessionForAppDir } from "@calcom/feature-auth/lib/get-server-session-for-app-dir";
// import { getTeamsFiltersFromQuery } from "@calcom/features/filters/lib/getTeamsFiltersFromQuery";
// import { WorkflowRepository } from "@calcom/lib/server/repository/workflow";
import LegacyPage from "@calcom/features/ee/workflows/pages/index";

export const generateMetadata = async () =>
await _generateMetadata(
(t) => t("workflows"),
(t) => t("workflows_to_automate_notifications")
);

const Page = async ({ params, searchParams }: PageProps) => {
// FIXME: Refactor me once next-auth endpoint is migrated to App Router
// const session = await getServerSessionForAppDir();
// const user = session?.user;

// const filters = getTeamsFiltersFromQuery({ ...searchParams, ...params });

// let filteredList;
// try {
// filteredList = await WorkflowRepository.getFilteredList({
// userId: user?.id,
// input: {
// filters,
// },
// });
// } catch (err) {}

return (
<LegacyPage
// filteredList={filteredList}
/>
);
};

export default WithLayout({ getLayout: null, ServerPage: Page })<"P">;
1 change: 0 additions & 1 deletion apps/web/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ export const config = {
"/apps/categories/:category/",
"/future/apps/categories/:category/",
"/workflows/:path*",
"/future/workflows/:path*",
"/getting-started/:step/",
"/future/getting-started/:step/",
"/apps",
Expand Down
21 changes: 0 additions & 2 D7AE 1 deletions apps/web/pages/workflows/[workflow].tsx

This file was deleted.

9 changes: 0 additions & 9 deletions apps/web/pages/workflows/index.tsx

This file was deleted.

1 change: 1 addition & 0 deletions apps/web/public/static/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"second_one": "{{count}} second",
"second_other": "{{count}} seconds",
"upgrade_now": "Upgrade now",
"untitled": "Untitled",
"accept_invitation": "Accept Invitation",
"max_characters": "Max. Characters",
"min_characters": "Min. Characters",
Expand Down
1 change: 0 additions & 1 deletion apps/web/scripts/vercel-app-router-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ checkRoute "$APP_ROUTER_AUTH_SAML_ENABLED" app/future/auth/saml-idp
checkRoute "$APP_ROUTER_AUTH_ERROR_ENABLED" app/future/auth/error
checkRoute "$APP_ROUTER_AUTH_PLATFORM_ENABLED" app/future/auth/platform
checkRoute "$APP_ROUTER_AUTH_OAUTH2_ENABLED" app/future/auth/oauth2
checkRoute "$APP_ROUTER_WORKFLOWS_ENABLED" app/future/workflows
checkRoute "$APP_ROUTER_GETTING_STARTED_STEP_ENABLED" app/future/getting-started
checkRoute "$APP_ROUTER_BOOKINGS_STATUS_ENABLED" app/future/bookings
checkRoute "$APP_ROUTER_BOOKING_ENABLED" app/future/booking
Expand Down
1 change: 0 additions & 1 deletion turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@
"APP_ROUTER_BOOKINGS_STATUS_ENABLED",
"APP_ROUTER_EVENT_TYPES_ENABLED",
"APP_ROUTER_GETTING_STARTED_STEP_ENABLED",
"APP_ROUTER_WORKFLOWS_ENABLED",
"APP_ROUTER_VIDEO_ENABLED",
"APP_ROUTER_AUTH_FORGOT_PASSWORD_ENABLED",
"APP_ROUTER_AUTH_LOGIN_ENABLED",
Expand Down

0 comments on commit ce9df65

Please sign in to comment.
0