Skip to content

Commit

Permalink
chore: EventTypeWebWrapper base pr (calcom#16550)
Browse files Browse the repository at this point in the history
* chore: EventTypeWebWrapper base pr

* fixup! chore: EventTypeWebWrapper base pr

* fixup! Merge branch 'main' into morgan/cal-4183-eventtypeatom-web-wrapper-base

* wip

* fix: error

* Event type atom wrapper handles app dir

* fixup! Merge branch 'main' into morgan/cal-4183-eventtypeatom-web-wrapper-base

* fixup! fixup! Merge branch 'main' into morgan/cal-4183-eventtypeatom-web-wrapper-base

* remove console log

* review comments

* fixup! review comments

* fixup! Merge branch 'main' into morgan/cal-4183-eventtypeatom-web-wrapper-base

---------

Co-authored-by: Somay Chauhan <[email protected]>
  • Loading branch information
ThyMinimalDev and SomayChauhan authored Sep 18, 2024
1 parent 3a5325f commit 2b43d9a
Show file tree
Hide file tree
Showing 9 changed files with 831 additions and 1,466 deletions.
6 changes: 3 additions & 3 deletions apps/web/app/future/event-types/[type]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { _generateMetadata } from "app/_utils";
import { WithLayout } from "app/layoutHOC";
import { cookies, headers } from "next/headers";

import { EventType } from "@calcom/atoms/monorepo";

import { buildLegacyCtx } from "@lib/buildLegacyCtx";
import { getServerSideProps } from "@lib/event-types/[type]/getServerSideProps";
import type { PageProps as EventTypePageProps } from "@lib/event-types/[type]/getServerSideProps";

import EventTypePageWrapper from "~/event-types/views/event-types-single-view";

export const generateMetadata = async ({ params, searchParams }: PageProps) => {
const legacyCtx = buildLegacyCtx(headers(), cookies(), params, searchParams);
const { eventType } = await getData(legacyCtx);
Expand All @@ -21,5 +21,5 @@ export const generateMetadata = async ({ params, searchParams }: PageProps) => {
};

const getData = withAppDirSsr(getServerSideProps);
const Page = (props: EventTypePageProps) => <EventTypePageWrapper {...props} isAppDir={true} />;
const Page = ({ type, ...rest }: EventTypePageProps) => <EventType {...rest} id={type} isAppDir={true} />;
export default WithLayout({ getLayout: null, getData, Page })<"P">;
33 changes: 3 additions & 30 deletions apps/web/modules/event-types/views/event-types-single-view.tsx
Original file line number Diff line number Diff line change
@@ -1,38 +1,11 @@
"use client";

import { EventType } from "@calcom/features/eventtypes/components/EventType";
import { EventTypeAppDir } from "@calcom/features/eventtypes/components/EventTypeAppDir";
import type { EventTypeSetupProps } from "@calcom/features/eventtypes/lib/types";

/* eslint-disable @typescript-eslint/no-empty-function */
// eslint-disable-next-line @calcom/eslint/deprecated-imports-next-router
import { trpc } from "@calcom/trpc/react";
import { EventType } from "@calcom/atoms/monorepo";

import type { PageProps } from "@lib/event-types/[type]/getServerSideProps";

const EventTypePageWrapper = (props: PageProps & { isAppDir?: boolean }) => {
const { data } = trpc.viewer.eventTypes.get.useQuery({ id: props.type });

if (!data) return null;

const eventType = data.eventType;

const { data: workflows } = trpc.viewer.workflows.getAllActiveWorkflows.useQuery({
eventType: {
id: props.type,
teamId: eventType.teamId,
userId: eventType.userId,
parent: eventType.parent,
metadata: eventType.metadata,
},
});

const propsData = {
...(data as EventTypeSetupProps),
allActiveWorkflows: workflows,
};

return props.isAppDir ? <EventTypeAppDir {...propsData} /> : <EventType {...propsData} />;
const EventTypePageWrapper = ({ type, ...rest }: PageProps) => {
return <EventType {...rest} id={type} isAppDir={false} />;
};

export default EventTypePageWrapper;
Loading

0 comments on commit 2b43d9a

Please sign in to comment.