feat: payments tab for event types atom (#16892)
* update translations * add payments tab to event types platform * payments tab for event types platform wrapper * update event types props * fix icon * add stripe form * update event type platform wrapper * testing EventTypeAppCard component * update atoms module * add endpoint to get app integration based on slug * input dtos for atoms app integration endpoint * update platform libraries * add queries for app integration endpoint * chore: fixup * custom hook to get app integration * export TeamsQuery type to use for platform * update props for stripe atom * update payments tab * update platform libraries in local (temperory) * fix merge conflicts * fixup * resolve merge conflicts * fixup * Update package.json * update platform libraries * fix imports * resolve merge conflicts * more import paths fixes * fixup * cleanup comments * include payments tab * resolve merge conflicts * fixup * Update package.json * revert yarn.lock * Update yarn.lock --------- Co-authored-by: Somay Chauhan <[email protected]> Co-authored-by: Morgan <[email protected]>
This commit is contained in:
22 files changed
+396
-13
No files matched your search
@@ -28,7 +28,7 @@
|
||||
"dependencies": {
|
||||
"@calcom/platform-constants": "*",
|
||||
"@calcom/platform-enums": "*",
|
||||
"@calcom/platform-libraries": "npm:@calcom/[email protected]7",
|
||||
"@calcom/platform-libraries": "npm:@calcom/[email protected]8",
|
||||
"@calcom/platform-libraries-0.0.2": "npm:@calcom/[email protected]",
|
||||
"@calcom/platform-types": "*",
|
||||
"@calcom/platform-utils": "*",
|
||||
|
||||
@@ -2,6 +2,7 @@ import { EventTypesModule_2024_06_14 } from "@/ee/event-types/event-types_2024_0
|
||||
import { SchedulesRepository_2024_06_11 } from "@/ee/schedules/schedules_2024_06_11/schedules.repository";
|
||||
import { AtomsController } from "@/modules/atoms/controllers/atoms.controller";
|
||||
import { EventTypesAtomService } from "@/modules/atoms/services/event-types-atom.service";
|
||||
import { CredentialsRepository } from "@/modules/credentials/credentials.repository";
|
||||
import { MembershipsRepository } from "@/modules/memberships/memberships.repository";
|
||||
import { OrganizationsModule } from "@/modules/organizations/organizations.module";
|
||||
import { PrismaModule } from "@/modules/prisma/prisma.module";
|
||||
@@ -14,6 +15,7 @@ import { Module } from "@nestjs/common";
|
||||
providers: [
|
||||
EventTypesAtomService,
|
||||
MembershipsRepository,
|
||||
CredentialsRepository,
|
||||
UsersRepository,
|
||||
UsersService,
|
||||
SchedulesRepository_2024_06_11,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { API_VERSIONS_VALUES } from "@/lib/api-versions";
|
||||
import { EventTypesAppInput } from "@/modules/atoms/inputs/event-types-app.input";
|
||||
import { EventTypesAtomService } from "@/modules/atoms/services/event-types-atom.service";
|
||||
import { GetUser } from "@/modules/auth/decorators/get-user/get-user.decorator";
|
||||
import { ApiAuthGuard } from "@/modules/auth/guards/api-auth/api-auth.guard";
|
||||
@@ -13,6 +14,7 @@ import {
|
||||
VERSION_NEUTRAL,
|
||||
Patch,
|
||||
Body,
|
||||
Query,
|
||||
} from "@nestjs/common";
|
||||
import { ApiTags as DocsTags, ApiExcludeController as DocsExcludeController } from "@nestjs/swagger";
|
||||
|
||||
@@ -50,6 +52,26 @@ export class AtomsController {
|
||||
};
|
||||
}
|
||||
|
||||
@Get("event-types-app/:appSlug")
|
||||
@Version(VERSION_NEUTRAL)
|
||||
@UseGuards(ApiAuthGuard)
|
||||
async getAtomEventTypeApp(
|
||||
@GetUser() user: UserWithProfile,
|
||||
@Param("appSlug") appSlug: string,
|
||||
@Query() queryParams: EventTypesAppInput
|
||||
): Promise<ApiResponse<unknown>> {
|
||||
const { teamId } = queryParams;
|
||||
|
||||
const app = await this.eventTypesService.getEventTypesAppIntegration(appSlug, user.id, user.name, teamId);
|
||||
|
||||
return {
|
||||
status: SUCCESS_STATUS,
|
||||
data: {
|
||||
app,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@Patch("event-types/:eventTypeId")
|
||||
@Version(VERSION_NEUTRAL)
|
||||
@UseGuards(ApiAuthGuard)
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Transform } from "class-transformer";
|
||||
import { IsNumber, IsOptional } from "class-validator";
|
||||
|
||||
export class EventTypesAppInput {
|
||||
@Transform(({ value }: { value: string }) => value && parseInt(value))
|
||||
@IsNumber()
|
||||
@IsOptional()
|
||||
teamId?: number;
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
import { EventTypesService_2024_06_14 } from "@/ee/event-types/event-types_2024_06_14/services/event-types.service";
|
||||
import { CredentialsRepository } from "@/modules/credentials/credentials.repository";
|
||||
import { MembershipsRepository } from "@/modules/memberships/memberships.repository";
|
||||
import { OrganizationsTeamsRepository } from "@/modules/organizations/repositories/organizations-teams.repository";
|
||||
import { OrganizationsEventTypesService } from "@/modules/organizations/services/event-types/organizations-event-types.service";
|
||||
import { PrismaReadService } from "@/modules/prisma/prisma-read.service";
|
||||
import { PrismaWriteService } from "@/modules/prisma/prisma-write.service";
|
||||
@@ -12,13 +14,33 @@ import {
|
||||
TUpdateEventTypeInputSchema,
|
||||
systemBeforeFieldEmail,
|
||||
getEventTypeById,
|
||||
getEnabledAppsFromCredentials,
|
||||
getAppFromSlug,
|
||||
MembershipRole,
|
||||
} from "@calcom/platform-libraries";
|
||||
import type {
|
||||
App,
|
||||
CredentialDataWithTeamName,
|
||||
LocationOption,
|
||||
TeamQuery,
|
||||
CredentialOwner,
|
||||
TDependencyData,
|
||||
CredentialPayload,
|
||||
} from "@calcom/platform-libraries";
|
||||
import { PrismaClient } from "@calcom/prisma/client";
|
||||
|
||||
type EnabledAppType = App & {
|
||||
credential: CredentialDataWithTeamName;
|
||||
credentials: CredentialDataWithTeamName[];
|
||||
locationOption: LocationOption | null;
|
||||
};
|
||||
|
||||
@Injectable()
|
||||
export class EventTypesAtomService {
|
||||
constructor(
|
||||
private readonly membershipsRepository: MembershipsRepository,
|
||||
private readonly credentialsRepository: CredentialsRepository,
|
||||
private readonly organizationsTeamsRepository: OrganizationsTeamsRepository,
|
||||
private readonly usersService: UsersService,
|
||||
private readonly dbWrite: PrismaWriteService,
|
||||
private readonly dbRead: PrismaReadService,
|
||||
@@ -146,4 +168,110 @@ export class EventTypesAtomService {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async getEventTypesAppIntegration(slug: string, userId: number, userName: string | null, teamId?: number) {
|
||||
let credentials = await this.credentialsRepository.getAllUserCredentialsById(userId);
|
||||
let userTeams: TeamQuery[] = [];
|
||||
if (teamId) {
|
||||
const teamsQuery = await this.organizationsTeamsRepository.getUserTeamsById(userId);
|
||||
// If a team is a part of an org then include those apps
|
||||
// Don't want to iterate over these parent teams
|
||||
const filteredTeams: TeamQuery[] = [];
|
||||
const parentTeams: TeamQuery[] = [];
|
||||
// Only loop and grab parent teams if a teamId was given. If not then all teams will be queried
|
||||
if (teamId) {
|
||||
teamsQuery.forEach((team) => {
|
||||
if (team?.parent) {
|
||||
const { parent, ...filteredTeam } = team;
|
||||
filteredTeams.push(filteredTeam);
|
||||
// Only add parent team if it's not already in teamsQuery
|
||||
if (!teamsQuery.some((t) => t.id === parent.id)) {
|
||||
parentTeams.push(parent);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
userTeams = [...teamsQuery, ...parentTeams];
|
||||
const teamAppCredentials: CredentialPayload[] = userTeams.flatMap((teamApp) => {
|
||||
return teamApp.credentials ? teamApp.credentials.flat() : [];
|
||||
});
|
||||
if (teamId) {
|
||||
credentials = teamAppCredentials;
|
||||
} else {
|
||||
credentials = credentials.concat(teamAppCredentials);
|
||||
}
|
||||
}
|
||||
const enabledApps = await getEnabledAppsFromCredentials(credentials, {
|
||||
where: { slug },
|
||||
});
|
||||
const apps = await Promise.all(
|
||||
enabledApps
|
||||
.filter(({ ...app }) => app.slug === slug)
|
||||
.map(
|
||||
async ({
|
||||
credentials: _,
|
||||
credential,
|
||||
key: _2 /* don't leak to frontend */,
|
||||
...app
|
||||
}: EnabledAppType) => {
|
||||
const userCredentialIds = credentials
|
||||
.filter((c) => c.appId === app.slug && !c.teamId)
|
||||
.map((c) => c.id);
|
||||
const invalidCredentialIds = credentials
|
||||
.filter((c) => c.appId === app.slug && c.invalid)
|
||||
.map((c) => c.id);
|
||||
const teams = await Promise.all(
|
||||
credentials
|
||||
.filter((c) => c.appId === app.slug && c.teamId)
|
||||
.map(async (c) => {
|
||||
const team = userTeams.find((team) => team.id === c.teamId);
|
||||
if (!team) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
teamId: team.id,
|
||||
name: team.name,
|
||||
logoUrl: team.logoUrl,
|
||||
credentialId: c.id,
|
||||
isAdmin:
|
||||
team.members[0].role === MembershipRole.ADMIN ||
|
||||
team.members[0].role === MembershipRole.OWNER,
|
||||
};
|
||||
})
|
||||
);
|
||||
const isSetupAlready = credential && app.categories.includes("payment") ? true : undefined;
|
||||
let dependencyData: TDependencyData = [];
|
||||
if (app.dependencies?.length) {
|
||||
dependencyData = app.dependencies.map((dependency) => {
|
||||
const dependencyInstalled = enabledApps.some(
|
||||
(dbAppIterator: EnabledAppType) =>
|
||||
dbAppIterator.credentials.length && dbAppIterator.slug === dependency
|
||||
);
|
||||
// If the app marked as dependency is simply deleted from the codebase,
|
||||
// we can have the situation where App is marked installed in DB but we couldn't get the app.
|
||||
const dependencyName = getAppFromSlug(dependency)?.name;
|
||||
return { name: dependencyName, installed: dependencyInstalled };
|
||||
});
|
||||
}
|
||||
const credentialOwner: CredentialOwner = {
|
||||
name: userName,
|
||||
teamId,
|
||||
};
|
||||
return {
|
||||
...app,
|
||||
...(teams.length && {
|
||||
credentialOwner,
|
||||
}),
|
||||
userCredentialIds,
|
||||
invalidCredentialIds,
|
||||
teams,
|
||||
isInstalled: !!userCredentialIds.length || !!teams.length || app.isGlobal,
|
||||
isSetupAlready,
|
||||
...(app.dependencies && { dependencyData }),
|
||||
};
|
||||
}
|
||||
)
|
||||
);
|
||||
return apps[0];
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import { Injectable } from "@nestjs/common";
|
||||
import { Prisma } from "@prisma/client";
|
||||
|
||||
import { APPS_TYPE_ID_MAPPING } from "@calcom/platform-constants";
|
||||
import { credentialForCalendarServiceSelect } from "@calcom/platform-libraries";
|
||||
|
||||
@Injectable()
|
||||
export class CredentialsRepository {
|
||||
@@ -65,6 +66,18 @@ export class CredentialsRepository {
|
||||
});
|
||||
}
|
||||
|
||||
async getAllUserCredentialsById(userId: number) {
|
||||
return await this.dbRead.prisma.credential.findMany({
|
||||
where: {
|
||||
userId,
|
||||
},
|
||||
select: credentialForCalendarServiceSelect,
|
||||
orderBy: {
|
||||
id: "asc",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async getUserCredentialById(userId: number, credentialId: number, type: string) {
|
||||
return await this.dbRead.prisma.credential.findUnique({
|
||||
where: {
|
||||
|
||||
@@ -4,6 +4,8 @@ import { PrismaReadService } from "@/modules/prisma/prisma-read.service";
|
||||
import { PrismaWriteService } from "@/modules/prisma/prisma-write.service";
|
||||
import { Injectable } from "@nestjs/common";
|
||||
|
||||
import { credentialForCalendarServiceSelect } from "@calcom/platform-libraries";
|
||||
|
||||
@Injectable()
|
||||
export class OrganizationsTeamsRepository {
|
||||
constructor(private readonly dbRead: PrismaReadService, private readonly dbWrite: PrismaWriteService) {}
|
||||
@@ -119,4 +121,53 @@ export class OrganizationsTeamsRepository {
|
||||
|
||||
return team.members.map((member) => member.userId);
|
||||
}
|
||||
|
||||
async getUserTeamsById(userId: number) {
|
||||
const userTeams = await this.dbRead.prisma.team.findMany({
|
||||
where: {
|
||||
members: {
|
||||
some: {
|
||||
userId,
|
||||
accepted: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
credentials: {
|
||||
select: credentialForCalendarServiceSelect,
|
||||
},
|
||||
name: true,
|
||||
logoUrl: true,
|
||||
members: {
|
||||
where: {
|
||||
userId,
|
||||
},
|
||||
select: {
|
||||
role: true,
|
||||
},
|
||||
},
|
||||
parent: {
|
||||
select: {
|
||||
id: true,
|
||||
credentials: {
|
||||
select: credentialForCalendarServiceSelect,
|
||||
},
|
||||
name: true,
|
||||
logoUrl: true,
|
||||
members: {
|
||||
where: {
|
||||
userId,
|
||||
},
|
||||
select: {
|
||||
role: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return userTeams;
|
||||
}
|
||||
}
|
||||
@@ -1387,6 +1387,8 @@
|
||||
"event_limit_tab_description": "How often you can be booked",
|
||||
"event_advanced_tab_description": "Calendar settings & more...",
|
||||
"event_advanced_tab_title": "Advanced",
|
||||
"event_payments_tab_title": "Payments",
|
||||
"event_payments_tab_description": "Set up payments for event",
|
||||
"event_setup_multiple_duration_error": "Event Setup: Multiple durations requires at least 1 option.",
|
||||
"event_setup_multiple_duration_default_error": "Event Setup: Please select a valid default duration.",
|
||||
"event_setup_booking_limits_error": "Booking limits must be in ascending order. [day, week, month, year]",
|
||||
|
||||
@@ -3,6 +3,7 @@ import Link from "next/link";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { useAppContextWithSchema } from "@calcom/app-store/EventTypeAppContext";
|
||||
import { useIsPlatform } from "@calcom/atoms/monorepo";
|
||||
import { classNames } from "@calcom/lib";
|
||||
import type { RouterOutputs } from "@calcom/trpc/react";
|
||||
import { Switch, Badge, Avatar, Button, Icon } from "@calcom/ui";
|
||||
@@ -39,6 +40,7 @@ export default function AppCard({
|
||||
const { t } = useTranslation();
|
||||
const [animationRef] = useAutoAnimate<HTMLDivElement>();
|
||||
const { setAppData, LockedIcon, disabled: managedDisabled } = useAppContextWithSchema();
|
||||
const isPlatform = useIsPlatform();
|
||||
|
||||
return (
|
||||
<div
|
||||
@@ -128,7 +130,7 @@ export default function AppCard({
|
||||
{app?.isInstalled && switchChecked ? (
|
||||
app.isSetupAlready === undefined || app.isSetupAlready ? (
|
||||
<div className="relative p-4 pt-5 text-sm [&_input]:mb-0 [&_input]:leading-4">
|
||||
{!hideSettingsIcon && (
|
||||
{!hideSettingsIcon && !isPlatform && (
|
||||
<Link href={`/apps/${app.slug}/setup`} className="absolute right-4 top-4">
|
||||
<Icon name="settings" className="text-default h-4 w-4" aria-hidden="true" />
|
||||
</Link>
|
||||
|
||||
@@ -10,9 +10,15 @@ import { ErrorBoundary } from "@calcom/ui";
|
||||
import type { EventTypeAppCardComponentProps, CredentialOwner } from "../types";
|
||||
import { DynamicComponent } from "./DynamicComponent";
|
||||
|
||||
export type EventTypeApp = RouterOutputs["viewer"]["integrations"]["items"][number] & {
|
||||
credentialOwner?: CredentialOwner;
|
||||
};
|
||||
|
||||
export type EventTypeForAppCard = EventTypeAppCardComponentProps["eventType"];
|
||||
|
||||
export const EventTypeAppCard = (props: {
|
||||
app: RouterOutputs["viewer"]["integrations"]["items"][number] & { credentialOwner?: CredentialOwner };
|
||||
eventType: EventTypeAppCardComponentProps["eventType"];
|
||||
app: EventTypeApp;
|
||||
eventType: EventTypeForAppCard;
|
||||
getAppData: GetAppData;
|
||||
setAppData: SetAppData;
|
||||
// For event type apps, get these props from shouldLockDisableProps
|
||||
|
||||
@@ -12,7 +12,7 @@ import type { CredentialPayload } from "@calcom/types/Credential";
|
||||
|
||||
export * from "./_utils/getEventTypeAppData";
|
||||
|
||||
type LocationOption = {
|
||||
export type LocationOption = {
|
||||
label: string;
|
||||
value: EventLocationType["type"];
|
||||
icon?: string;
|
||||
|
||||
@@ -42,6 +42,7 @@ const tabs = [
|
||||
"workflows",
|
||||
"webhooks",
|
||||
"ai",
|
||||
"payments",
|
||||
] as const;
|
||||
|
||||
export type EventTypeSetup = RouterOutputs["viewer"]["eventTypes"]["get"]["eventType"];
|
||||
|
||||
@@ -153,4 +153,5 @@ export type TabMap = {
|
||||
team?: React.ReactNode;
|
||||
webhooks?: React.ReactNode;
|
||||
workflows?: React.ReactNode;
|
||||
payments?: React.ReactNode;
|
||||
};
|
||||
@@ -2,6 +2,8 @@ import type { FC } from "react";
|
||||
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { Button } from "@calcom/ui";
|
||||
import type { IconName } from "@calcom/ui";
|
||||
import type { ButtonColor } from "@calcom/ui";
|
||||
|
||||
import type { OnCheckErrorType, UseCheckProps } from "../../hooks/connect/useCheck";
|
||||
import { useCheck } from "../../hooks/stripe/useCheck";
|
||||
@@ -10,6 +12,9 @@ import { AtomsWrapper } from "../../src/components/atoms-wrapper";
|
||||
import { cn } from "../../src/lib/utils";
|
||||
|
||||
type StripeConnectProps = {
|
||||
icon?: IconName;
|
||||
color?: ButtonColor;
|
||||
isClickable?: boolean;
|
||||
className?: string;
|
||||
label: string;
|
||||
alreadyConnectedLabel: string;
|
||||
@@ -22,6 +27,9 @@ type StripeConnectProps = {
|
||||
};
|
||||
|
||||
export const StripeConnect: FC<Partial<StripeConnectProps>> = ({
|
||||
icon,
|
||||
color,
|
||||
isClickable,
|
||||
label,
|
||||
className,
|
||||
loadingLabel,
|
||||
@@ -54,9 +62,9 @@ export const StripeConnect: FC<Partial<StripeConnectProps>> = ({
|
||||
return (
|
||||
<AtomsWrapper>
|
||||
<Button
|
||||
StartIcon="calendar"
|
||||
color="primary"
|
||||
disabled={isDisabled}
|
||||
StartIcon={!!icon ? icon : "credit-card"}
|
||||
color={!!color ? color : "primary"}
|
||||
disabled={isClickable ? false : isDisabled}
|
||||
className={cn(
|
||||
"",
|
||||
className,
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { SUCCESS_STATUS } from "@calcom/platform-constants";
|
||||
import type { App, CredentialDataWithTeamName, LocationOption } from "@calcom/platform-libraries-1.2.3";
|
||||
import type { ApiResponse } from "@calcom/platform-types";
|
||||
|
||||
import { useAtomsContext } from "../../hooks/useAtomsContext";
|
||||
import http from "../../lib/http";
|
||||
|
||||
type EnabledAppType = App & {
|
||||
credential: CredentialDataWithTeamName;
|
||||
credentials: CredentialDataWithTeamName[];
|
||||
userCredentialIds: number[];
|
||||
locationOption: LocationOption | null;
|
||||
};
|
||||
|
||||
export const QUERY_KEY = "use-event-app-integration";
|
||||
export const useAtomsEventTypeById = (appSlug: string | null) => {
|
||||
const pathname = `/atoms/event-types-app/${appSlug}`;
|
||||
const { isInit, accessToken } = useAtomsContext();
|
||||
|
||||
return useQuery({
|
||||
queryKey: [QUERY_KEY, appSlug],
|
||||
queryFn: () => {
|
||||
return http?.get<ApiResponse<{ app: EnabledAppType }>>(pathname).then((res) => {
|
||||
if (res.data.status === SUCCESS_STATUS) {
|
||||
return res.data.data;
|
||||
}
|
||||
throw new Error(res.data.error.message);
|
||||
});
|
||||
},
|
||||
enabled: !!appSlug && isInit && !!accessToken,
|
||||
});
|
||||
};
|
||||
@@ -171,6 +171,14 @@ function getNavigation({ length, multipleDuration, t, tabs, url, onClick, curren
|
||||
icon: "sliders-vertical",
|
||||
info: `event_advanced_tab_description`,
|
||||
});
|
||||
tabs.includes("payments") &&
|
||||
tabsNavigation.push({
|
||||
name: "event_payments_tab_title",
|
||||
onClick: () => onClick("payments"),
|
||||
href: `${url}?tabName=payments`,
|
||||
icon: "credit-card",
|
||||
info: `event_payments_tab_description`,
|
||||
});
|
||||
|
||||
return tabsNavigation;
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
import { EventTypeAppCard } from "@calcom/app-store/_components/EventTypeAppCardInterface";
|
||||
import type {
|
||||
EventTypeApp,
|
||||
EventTypeForAppCard,
|
||||
} from "@calcom/app-store/_components/EventTypeAppCardInterface";
|
||||
import type { EventTypeAppsList } from "@calcom/app-store/utils";
|
||||
import type { EventTypeSetupProps } from "@calcom/features/eventtypes/lib/types";
|
||||
import useAppsData from "@calcom/lib/hooks/useAppsData";
|
||||
import { EmptyScreen } from "@calcom/ui";
|
||||
|
||||
import { StripeConnect } from "../../connect/stripe/StripeConnect";
|
||||
import { useCheck } from "../../hooks/stripe/useCheck";
|
||||
import { useAtomsEventTypeById } from "../hooks/useAtomEventTypeAppIntegration";
|
||||
|
||||
const EventPaymentsTabPlatformWrapper = ({ eventType }: { eventType: EventTypeSetupProps["eventType"] }) => {
|
||||
const { allowConnect, checked } = useCheck({});
|
||||
const isStripeConnected = !checked || !allowConnect;
|
||||
|
||||
return (
|
||||
<div>
|
||||
{!isStripeConnected ? (
|
||||
<EmptyScreen
|
||||
Icon="grid-3x3"
|
||||
headline="Stripe not connected"
|
||||
description="You need to connect Stripe to use this feature. Pleae click on the button below to connect."
|
||||
buttonRaw={
|
||||
<StripeConnect
|
||||
label="Connect to Stripe"
|
||||
loadingLabel="Connect to Stripe"
|
||||
alreadyConnectedLabel="Connect to Stripe"
|
||||
isClickable={true}
|
||||
color="secondary"
|
||||
redir={window.location.href}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<StripeAppCard eventType={eventType} />
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const StripeAppCard = ({ eventType }: { eventType: EventTypeSetupProps["eventType"] }) => {
|
||||
const { getAppDataGetter, getAppDataSetter, eventTypeFormMetadata } = useAppsData();
|
||||
const { data: stripeData, isLoading } = useAtomsEventTypeById("stripe");
|
||||
|
||||
const transformedAppData = {
|
||||
...stripeData?.app,
|
||||
logo: `https://app.cal.com${stripeData?.app.logo}`,
|
||||
};
|
||||
|
||||
if (isLoading || !stripeData) return null;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<EventTypeAppCard
|
||||
getAppData={getAppDataGetter(transformedAppData.slug as EventTypeAppsList)}
|
||||
setAppData={getAppDataSetter(
|
||||
transformedAppData.slug as EventTypeAppsList,
|
||||
transformedAppData.categories as string[],
|
||||
transformedAppData.userCredentialIds && (transformedAppData.userCredentialIds[0] as number)
|
||||
)}
|
||||
key={transformedAppData.slug}
|
||||
app={transformedAppData as EventTypeApp}
|
||||
eventType={eventType as unknown as EventTypeForAppCard}
|
||||
eventTypeFormMetadata={eventTypeFormMetadata}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default EventPaymentsTabPlatformWrapper;
|
||||
@@ -22,6 +22,7 @@ import { usePlatformTabsNavigations } from "../hooks/usePlatformTabsNavigations"
|
||||
import EventAdvancedPlatformWrapper from "./EventAdvancedPlatformWrapper";
|
||||
import EventAvailabilityTabPlatformWrapper from "./EventAvailabilityTabPlatformWrapper";
|
||||
import EventLimitsTabPlatformWrapper from "./EventLimitsTabPlatformWrapper";
|
||||
import EventPaymentsTabPlatformWrapper from "./EventPaymentsTabPlatformWrapper";
|
||||
import EventRecurringTabPlatformWrapper from "./EventRecurringTabPlatformWrapper";
|
||||
import SetupTab from "./EventSetupTabPlatformWrapper";
|
||||
import EventTeamAssignmentTabPlatformWrapper from "./EventTeamAssignmentTabPlatformWrapper";
|
||||
@@ -42,7 +43,7 @@ export type EventTypePlatformWrapperProps = {
|
||||
};
|
||||
|
||||
const EventType = ({
|
||||
tabs = ["setup", "availability", "team", "limits", "advanced", "recurring"],
|
||||
tabs = ["setup", "availability", "team", "limits", "advanced", "recurring", "payments"],
|
||||
onSuccess,
|
||||
onError,
|
||||
onDeleteSuccess,
|
||||
@@ -151,7 +152,7 @@ const EventType = ({
|
||||
) : (
|
||||
<></>
|
||||
),
|
||||
|
||||
payments: tabs.includes("payments") ? <EventPaymentsTabPlatformWrapper eventType={eventType} /> : <></>,
|
||||
limits: tabs.includes("limits") ? <EventLimitsTabPlatformWrapper eventType={eventType} /> : <></>,
|
||||
instant: <></>,
|
||||
recurring: tabs.includes("recurring") ? (
|
||||
|
||||
@@ -35,7 +35,7 @@ export const useCheck = ({ onCheckError, initialData, onCheckSuccess }: UseCheck
|
||||
?.get<ApiResponse<{ checked: boolean; allowConnect: boolean }>>(`/stripe/check`)
|
||||
.then(({ data: responseBody }) => {
|
||||
if (responseBody.status === SUCCESS_STATUS) {
|
||||
onCheckSuccess();
|
||||
onCheckSuccess?.();
|
||||
return { status: SUCCESS_STATUS, data: { allowConnect: false, checked: true } };
|
||||
}
|
||||
onCheckError?.(responseBody);
|
||||
|
||||
@@ -98,7 +98,7 @@ export default function Bookings(props: { calUsername: string; calEmail: string
|
||||
customClassNames={{ atomsWrapper: "!w-[50vw] !m-auto" }}
|
||||
allowDelete={true}
|
||||
id={eventTypeId}
|
||||
tabs={["setup", "limits", "recurring", "advanced", "availability", "team"]}
|
||||
tabs={["setup", "limits", "recurring", "advanced", "availability", "team", "payments"]}
|
||||
onSuccess={(eventType) => {
|
||||
setEventTypeId(null);
|
||||
refetch();
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import type { TDependencyData } from "@calcom/app-store/_appRegistry";
|
||||
import { getCalendar } from "@calcom/app-store/_utils/getCalendar";
|
||||
import { CalendarService } from "@calcom/app-store/applecalendar/lib";
|
||||
import { CalendarService as IcsFeedCalendarService } from "@calcom/app-store/ics-feedcalendar/lib";
|
||||
import type { CredentialOwner } from "@calcom/app-store/types";
|
||||
import { getAppFromSlug } from "@calcom/app-store/utils";
|
||||
import type { CredentialDataWithTeamName, LocationOption } from "@calcom/app-store/utils";
|
||||
import { getBookingForReschedule } from "@calcom/features/bookings/lib/get-booking";
|
||||
import getBookingInfo from "@calcom/features/bookings/lib/getBookingInfo";
|
||||
import handleCancelBooking from "@calcom/features/bookings/lib/handleCancelBooking";
|
||||
@@ -9,15 +13,21 @@ import { getPublicEvent } from "@calcom/features/eventtypes/lib/getPublicEvent";
|
||||
import { handleCreatePhoneCall } from "@calcom/features/handleCreatePhoneCall";
|
||||
import handleMarkNoShow from "@calcom/features/handleMarkNoShow";
|
||||
import * as instantMeetingMethods from "@calcom/features/instant-meeting/handleInstantMeeting";
|
||||
import getEnabledAppsFromCredentials from "@calcom/lib/apps/getEnabledAppsFromCredentials";
|
||||
import getAllUserBookings from "@calcom/lib/bookings/getAllUserBookings";
|
||||
import { symmetricEncrypt, symmetricDecrypt } from "@calcom/lib/crypto";
|
||||
import { getTranslation } from "@calcom/lib/server/i18n";
|
||||
import { MembershipRole } from "@calcom/prisma/enums";
|
||||
import { credentialForCalendarServiceSelect } from "@calcom/prisma/selects/credential";
|
||||
import type { TeamQuery } from "@calcom/trpc/server/routers/loggedInViewer/integrations.handler";
|
||||
import { updateHandler as updateScheduleHandler } from "@calcom/trpc/server/routers/viewer/availability/schedule/update.handler";
|
||||
import { getAvailableSlots } from "@calcom/trpc/server/routers/viewer/slots/util";
|
||||
import {
|
||||
createNewUsersConnectToOrgIfExists,
|
||||
sendSignupToOrganizationEmail,
|
||||
} from "@calcom/trpc/server/routers/viewer/teams/inviteMember/utils";
|
||||
import type { App } from "@calcom/types/App";
|
||||
import type { CredentialPayload } from "@calcom/types/Credential";
|
||||
|
||||
export { slugify } from "@calcom/lib/slugify";
|
||||
export { getBookingForReschedule };
|
||||
@@ -150,3 +160,15 @@ export { ErrorCode } from "@calcom/lib/errorCodes";
|
||||
|
||||
export { IcsFeedCalendarService };
|
||||
export { validateCustomEventName } from "@calcom/core/event";
|
||||
export { getEnabledAppsFromCredentials };
|
||||
export type { App };
|
||||
export type { CredentialDataWithTeamName };
|
||||
export type { LocationOption };
|
||||
export type { TeamQuery };
|
||||
export type { CredentialOwner };
|
||||
export type { TDependencyData };
|
||||
export type { CredentialPayload };
|
||||
|
||||
export { getAppFromSlug };
|
||||
export { credentialForCalendarServiceSelect };
|
||||
export { MembershipRole };
|
||||
@@ -23,7 +23,7 @@ type IntegrationsOptions = {
|
||||
input: TIntegrationsInputSchema;
|
||||
};
|
||||
|
||||
type TeamQuery = Prisma.TeamGetPayload<{
|
||||
export type TeamQuery = Prisma.TeamGetPayload<{
|
||||
select: {
|
||||
id: true;
|
||||
credentials: {
|
||||
|
||||
Reference in new issue
Block a user