Skip to content

Commit

Permalink
Merge branch 'main' into refactor/infinite-event-types
Browse files Browse the repository at this point in the history
  • Loading branch information
Udit-takkar authored Sep 17, 2024
2 parents 65da98f + 562309d commit bc2f5e9
Show file tree
Hide file tree
Showing 172 changed files with 3,204 additions and 2,074 deletions.
5 changes: 3 additions & 2 deletions apps/api/v1/pages/api/slots/_get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
isColdStart = false;
}

const { usernameList, ...rest } = req.query;
const { usernameList, isTeamEvent, ...rest } = req.query;
const parsedIsTeamEvent = String(isTeamEvent).toLowerCase() === "true";
let slugs = usernameList;
if (!Array.isArray(usernameList)) {
slugs = usernameList ? [usernameList] : undefined;
}
const input = getScheduleSchema.parse({ usernameList: slugs, ...rest });
const input = getScheduleSchema.parse({ usernameList: slugs, isTeamEvent: parsedIsTeamEvent, ...rest });
const timeZoneSupported = input.timeZone ? isSupportedTimeZone(input.timeZone) : false;
const availableSlots = await getAvailableSlots({ ctx: await createContext({ req, res }), input });
const slotsInProvidedTimeZone = timeZoneSupported
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export class CreateOrganizationAttributeOptionInput {
@IsString()
@IsNotEmpty()
readonly slug!: string;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,53 @@ import { UpdateOrganizationAttributeInput } from "@/modules/organizations/inputs
import { OrganizationAttributesRepository } from "@/modules/organizations/repositories/attributes/organization-attribute.repository";
import { Injectable } from "@nestjs/common";


@Injectable()
export class OrganizationAttributesService {
constructor(private readonly organizationAttributesRepository: OrganizationAttributesRepository) {}

async createOrganizationAttribute(organizationId: number, data: CreateOrganizationAttributeInput) {
const attribute = await this.organizationAttributesRepository.createOrganizationAttribute(organizationId, data);
const attribute = await this.organizationAttributesRepository.createOrganizationAttribute(
organizationId,
data
);
return attribute;
}

async getOrganizationAttribute(organizationId: number, attributeId: string) {
const attribute = await this.organizationAttributesRepository.getOrganizationAttribute(organizationId, attributeId);
const attribute = await this.organizationAttributesRepository.getOrganizationAttribute(
organizationId,
attributeId
);
return attribute;
}

async getOrganizationAttributes(organizationId: number, skip?: number, take?: number) {
const attributes = await this.organizationAttributesRepository.getOrganizationAttributes(organizationId, skip, take);
const attributes = await this.organizationAttributesRepository.getOrganizationAttributes(
organizationId,
skip,
take
);
return attributes;
}

async updateOrganizationAttribute(organizationId: number, attributeId: string, data: UpdateOrganizationAttributeInput) {
const attribute = await this.organizationAttributesRepository.updateOrganizationAttribute(organizationId, attributeId, data);
async updateOrganizationAttribute(
organizationId: number,
attributeId: string,
data: UpdateOrganizationAttributeInput
) {
const attribute = await this.organizationAttributesRepository.updateOrganizationAttribute(
organizationId,
attributeId,
data
);
return attribute;
}
}

async deleteOrganizationAttribute(organizationId: number, attributeId: string) {
const attribute = await this.organizationAttributesRepository.deleteOrganizationAttribute(organizationId, attributeId);
const attribute = await this.organizationAttributesRepository.deleteOrganizationAttribute(
organizationId,
attributeId
);
return attribute;
}

}
30 changes: 21 additions & 9 deletions apps/web/app/_utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ import { headers } from "next/headers";

import { constructGenericImage } from "@calcom/lib/OgImages";
import { IS_CALCOM, WEBAPP_URL, APP_NAME, SEO_IMG_OGIMG } from "@calcom/lib/constants";
import { truncateOnWord } from "@calcom/lib/text";
//@ts-expect-error no type definitions
import config from "@calcom/web/next-i18next.config";

import { preparePageMetadata } from "@lib/metadata";

const create = async (locale: string, ns: string) => {
const { _nextI18Next } = await serverSideTranslations(locale, [ns], config);

Expand All @@ -30,7 +29,8 @@ export const getFixedT = async (locale: string, ns = "common") => {

export const _generateMetadata = async (
getTitle: (t: TFunction<string, undefined>) => string,
getDescription: (t: TFunction<string, undefined>) => string
getDescription: (t: TFunction<string, undefined>) => string,
excludeAppNameFromTitle?: boolean
) => {
const h = headers();
const canonical = h.get("x-pathname") ?? "";
Expand All @@ -50,12 +50,24 @@ export const _generateMetadata = async (
description,
});

return preparePageMetadata({
title,
canonical,
image,
const titleSuffix = `| ${APP_NAME}`;
const displayedTitle =
title.includes(titleSuffix) || excludeAppNameFromTitle ? title : `${title} ${titleSuffix}`;

return {
title: title.length === 0 ? APP_NAME : displayedTitle,
description,
siteName: APP_NAME,
alternates: {
canonical,
},
openGraph: {
description: truncateOnWord(description, 158),
url: canonical,
type: "website",
siteName: APP_NAME,
title,
images: [image],
},
metadataBase,
});
};
};
7 changes: 5 additions & 2 deletions apps/web/app/future/[user]/[type]/embed/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ import { withAppDirSsr } from "app/WithAppDirSsr";
import withEmbedSsrAppDir from "app/WithEmbedSSR";
import { WithLayout } from "app/layoutHOC";

import LegacyPage from "~/users/views/users-type-public-view";
import { getServerSideProps, type PageProps } from "~/users/views/users-type-public-view.getServerSideProps";
import { getServerSideProps } from "@server/lib/[user]/[type]/getServerSideProps";

import LegacyPage, { type PageProps } from "~/users/views/users-type-public-view";

export { generateMetadata } from "../page";

const getData = withAppDirSsr<PageProps>(getServerSideProps);

Expand Down
7 changes: 3 additions & 4 deletions apps/web/app/future/[user]/[type]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ import { EventRepository } from "@calcom/lib/server/repository/event";

import { buildLegacyCtx } from "@lib/buildLegacyCtx";

import { getServerSideProps } from "@server/lib/[user]/[type]/getServerSideProps";

import type { PageProps as LegacyPageProps } from "~/users/views/users-type-public-view";
import LegacyPage from "~/users/views/users-type-public-view";
import {
getServerSideProps,
type PageProps as LegacyPageProps,
} from "~/users/views/users-type-public-view.getServerSideProps";

export const generateMetadata = async ({ params, searchParams }: PageProps) => {
const legacyCtx = buildLegacyCtx(headers(), cookies(), params, searchParams);
Expand Down
6 changes: 5 additions & 1 deletion apps/web/app/future/[user]/embed/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ import { withAppDirSsr } from "app/WithAppDirSsr";
import withEmbedSsrAppDir from "app/WithEmbedSSR";
import { WithLayout } from "app/layoutHOC";

import { getServerSideProps } from "@server/lib/[user]/getServerSideProps";

import type { PageProps as UserPageProps } from "~/users/views/users-public-view";
import LegacyPage from "~/users/views/users-public-view";
import { getServerSideProps, type UserPageProps } from "~/users/views/users-public-view.getServerSideProps";

export { generateMetadata } from "../page";

const getData = withAppDirSsr<UserPageProps>(getServerSideProps);

Expand Down
6 changes: 4 additions & 2 deletions apps/web/app/future/[user]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import { getLayout } from "@calcom/features/MainLayoutAppDir";

import { buildLegacyCtx } from "@lib/buildLegacyCtx";

import { getServerSideProps } from "@server/lib/[user]/getServerSideProps";

import type { PageProps as LegacyPageProps } from "~/users/views/users-public-view";
import LegacyPage from "~/users/views/users-public-view";
import { getServerSideProps, type UserPageProps } from "~/users/views/users-public-view.getServerSideProps";

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

const getData = withAppDirSsr<UserPageProps>(getServerSideProps);
const getData = withAppDirSsr<LegacyPageProps>(getServerSideProps);
export default WithLayout({ getLayout, getData, Page: LegacyPage })<"P">;
22 changes: 22 additions & 0 deletions apps/web/app/future/auth/verify-email-change/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { withAppDirSsr } from "app/WithAppDirSsr";
import { _generateMetadata } from "app/_utils";
import { WithLayout } from "app/layoutHOC";

import { getServerSideProps } from "@server/lib/auth/verify-email-change/getServerSideProps";

import type { PageProps } from "~/auth/verify-email-change-view";
import VerifyEmailChange from "~/auth/verify-email-change-view";

export const generateMetadata = async () => {
return await _generateMetadata(
() => "Verify email change",
() => ""
);
};

const getData = withAppDirSsr<PageProps>(getServerSideProps);
export default WithLayout({
getLayout: null,
Page: VerifyEmailChange,
getData,
});
7 changes: 4 additions & 3 deletions apps/web/app/future/auth/verify-email/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import VerifyEmailPage from "@pages/auth/verify-email";
import { _generateMetadata } from "app/_utils";
import { WithLayout } from "app/layoutHOC";

import VerifyEmailPage from "~/auth/verify-email-view";

export const generateMetadata = async () => {
return await _generateMetadata(
(t) => t("check_your_email"),
(t) => t("check_your_email")
() => "Verify email",
() => ""
);
};

Expand Down
42 changes: 40 additions & 2 deletions apps/web/app/future/auth/verify/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,49 @@
import VerifyPage from "@pages/auth/verify";
import { withAppDirSsr } from "app/WithAppDirSsr";
import type { PageProps as _PageProps } from "app/_types";
import { _generateMetadata } from "app/_utils";
import { WithLayout } from "app/layoutHOC";
import { z } from "zod";

import { StripeService } from "@calcom/lib/server/service/stripe";

import { getServerSideProps } from "@server/lib/auth/verify/getServerSideProps";

import type { PageProps } from "~/auth/verify-view";
import VerifyPage from "~/auth/verify-view";

const querySchema = z.object({
stripeCustomerId: z.string().optional(),
sessionId: z.string().optional(),
t: z.string().optional(),
});

export const generateMetadata = async ({ params, searchParams }: _PageProps) => {
const p = { ...params, ...searchParams };
const { sessionId, stripeCustomerId } = querySchema.parse(p);

if (!stripeCustomerId && !sessionId) {
return await _generateMetadata(
() => "Verify",
() => ""
);
}

const data = await StripeService.getCheckoutSession({
stripeCustomerId,
checkoutSessionId: sessionId,
});

const { hasPaymentFailed } = data;

return await _generateMetadata(
() =>
hasPaymentFailed ? "Your payment failed" : sessionId ? "Payment successful!" : `Verify your email`,
() => ""
);
};

export default WithLayout({
getLayout: null,
Page: VerifyPage,
getData: withAppDirSsr(getServerSideProps),
getData: withAppDirSsr<PageProps>(getServerSideProps),
})<"P">;
21 changes: 19 additions & 2 deletions apps/web/app/future/getting-started/[[...step]]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
import Page from "@pages/getting-started/[[...step]]";
import { withAppDirSsr } from "app/WithAppDirSsr";
import { _generateMetadata } from "app/_utils";
import { WithLayout } from "app/layoutHOC";

import { APP_NAME } from "@calcom/lib/constants";

import { getServerSideProps } from "@lib/getting-started/[[...step]]/getServerSideProps";

export default WithLayout({ getLayout: null, getData: withAppDirSsr(getServerSideProps), Page });
import type { PageProps } from "~/getting-started/[[...step]]/onboarding-view";
import Page from "~/getting-started/[[...step]]/onboarding-view";

export const generateMetadata = async () => {
return await _generateMetadata(
(t) => `${APP_NAME} - ${t("getting_started")}`,
() => "",
true
);
};

export default WithLayout({
getLayout: null,
getData: withAppDirSsr<PageProps>(getServerSideProps),
Page,
});
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const Page = async () => {
description={t("create_first_api_key_description", { appName: APP_NAME })}
CTA={<NewApiKeyButton />}
borderInShellHeader={true}>
<ApiKeysView />
<ApiKeysView isAppDir={true} />
</SettingsHeader>
);
};
Expand Down
5 changes: 0 additions & 5 deletions apps/web/app/future/settings/(settings)/teams/layout.tsx

This file was deleted.

Loading

0 comments on commit bc2f5e9

Please sign in to comment.