Skip to content

Commit 77168a5

Browse files
committed
wip
1 parent 550f34c commit 77168a5

5 files changed

Lines changed: 46 additions & 57 deletions

File tree

packages/app-store/_components/AppCard.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@ import Link from "next/link";
44
import { useAppContextWithSchema } from "@calcom/app-store/EventTypeAppContext";
55
import { useIsPlatform } from "@calcom/atoms/hooks/useIsPlatform";
66
import { useLocale } from "@calcom/lib/hooks/useLocale";
7-
import type { RouterOutputs } from "@calcom/trpc/react";
87
import classNames from "@calcom/ui/classNames";
98
import { Button } from "@calcom/ui/components/button";
109
import { Switch } from "@calcom/ui/components/form";
1110
import { Icon } from "@calcom/ui/components/icon";
1211
import { Section } from "@calcom/ui/components/section";
1312

14-
import type { CredentialOwner } from "../types";
13+
import type { AppCardApp } from "../types";
1514
import OmniInstallAppButton from "./OmniInstallAppButton";
1615

1716
export default function AppCard({
@@ -27,9 +26,7 @@ export default function AppCard({
2726
hideSettingsIcon = false,
2827
hideAppCardOptions = false,
2928
}: {
30-
app: RouterOutputs["viewer"]["apps"]["integrations"]["items"][number] & {
31-
credentialOwner?: CredentialOwner;
32-
};
29+
app: AppCardApp;
3330
description?: React.ReactNode;
3431
switchChecked?: boolean;
3532
switchOnClick?: (e: boolean) => void;

packages/app-store/_components/EventTypeAppCardInterface.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,15 @@ import type { GetAppData, SetAppData } from "@calcom/app-store/EventTypeAppConte
44
import EventTypeAppContext from "@calcom/app-store/EventTypeAppContext";
55
import { EventTypeAddonMap } from "@calcom/app-store/apps.browser.generated";
66
import type { EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";
7-
import type { RouterOutputs } from "@calcom/trpc/react";
87
import { ErrorBoundary } from "@calcom/ui/components/errorBoundary";
98

10-
import type { EventTypeAppCardComponentProps, CredentialOwner } from "../types";
9+
import type { EventTypeAppCardComponentProps, EventTypeAppCardApp } from "../types";
1110
import { DynamicComponent } from "./DynamicComponent";
1211

13-
export type EventTypeApp = RouterOutputs["viewer"]["apps"]["integrations"]["items"][number] & {
14-
credentialOwner?: CredentialOwner;
15-
};
16-
1712
export type EventTypeForAppCard = EventTypeAppCardComponentProps["eventType"];
1813

1914
export const EventTypeAppCard = (props: {
20-
app: EventTypeApp;
15+
app: EventTypeAppCardApp;
2116
eventType: EventTypeForAppCard;
2217
getAppData: GetAppData;
2318
setAppData: SetAppData;

packages/app-store/_components/eventTypeAppCardInterface.test.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import { render, screen } from "@testing-library/react";
2-
import type { CredentialOwner } from "types";
32
import { vi } from "vitest";
43

5-
import type { RouterOutputs } from "@calcom/trpc";
6-
4+
import type { EventTypeAppCardApp } from "../types";
75
import { DynamicComponent } from "./DynamicComponent";
86
import { EventTypeAppCard } from "./EventTypeAppCardInterface";
97

@@ -26,9 +24,7 @@ const mockProps = {
2624
name: "TestApp",
2725
slug: "testapp",
2826
credentialOwner: {},
29-
} as RouterOutputs["viewer"]["apps"]["integrations"]["items"][number] & {
30-
credentialOwner?: CredentialOwner;
31-
},
27+
} as EventTypeAppCardApp,
3228
eventType: {},
3329
getAppData: getAppDataMock,
3430
setAppData: setAppDataMock,

packages/app-store/types.d.ts

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import type React from "react";
22
import type { z } from "zod";
33

4-
import type { EventTypeFormMetadataSchema } from "@calcom/prisma/zod-utils";
5-
import type { RouterOutputs } from "@calcom/trpc/react";
4+
import type { EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";
65
import type { ButtonProps } from "@calcom/ui/components/button";
76

7+
import type { GetAppData, SetAppData } from "./EventTypeAppContext";
8+
89
export type IntegrationOAuthCallbackState = {
910
returnTo?: string;
1011
onErrorReturnTo: string;
@@ -22,10 +23,16 @@ export type CredentialOwner = {
2223
readOnly?: boolean;
2324
};
2425

25-
export type EventTypeAppCardApp = RouterOutputs["viewer"]["apps"]["integrations"]["items"][number] & {
26-
credentialOwner?: CredentialOwner;
27-
credentialIds?: number[];
28-
};
26+
/**
27+
* Domain-specific app type derived from the actual business logic return type
28+
* This ensures we have all the properties that the backend actually returns
29+
*/
30+
export type AppCardApp = ConnectedApps[number];
31+
32+
/**
33+
* For event type app cards, we use the same type since it includes all necessary properties
34+
*/
35+
export type EventTypeAppCardApp = AppCardApp;
2936

3037
type AppScript = { attrs?: Record<string, string> } & { src?: string; content?: string };
3138

@@ -45,36 +52,37 @@ export interface InstallAppButtonProps {
4552
onChanged?: () => unknown;
4653
disableInstall?: boolean;
4754
}
55+
/**
56+
* Domain-specific EventType interface for apps - independent of Prisma models
57+
*/
58+
export type AppEventType = {
59+
id: number;
60+
title: string;
61+
description?: string;
62+
teamId?: number;
63+
length: number;
64+
recurringEvent?: any; // Keep as any since this is JSON
65+
seatsPerTimeSlot?: number;
66+
team?: {
67+
id: number;
68+
name?: string;
69+
};
70+
schedulingType?: string;
71+
URL: string;
72+
};
73+
4874
export type EventTypeAppCardComponentProps = {
4975
// Limit what data should be accessible to apps
50-
eventType: Pick<
51-
z.infer<typeof EventTypeModel>,
52-
| "id"
53-
| "title"
54-
| "description"
55-
| "teamId"
56-
| "length"
57-
| "recurringEvent"
58-
| "seatsPerTimeSlot"
59-
| "team"
60-
| "schedulingType"
61-
> & {
62-
URL: string;
63-
};
76+
eventType: AppEventType;
6477
app: EventTypeAppCardApp;
6578
disabled?: boolean;
6679
LockedIcon?: JSX.Element | false;
67-
eventTypeFormMetadata?: z.infer<typeof EventTypeFormMetadataSchema>;
80+
eventTypeFormMetadata?: z.infer<typeof EventTypeMetaDataSchema>;
6881
};
6982

7083
export type EventTypeAppSettingsComponentProps = {
71-
// Limit what data should be accessible to apps\
72-
eventType: Pick<
73-
z.infer<typeof EventTypeModel>,
74-
"id" | "title" | "description" | "teamId" | "length" | "recurringEvent" | "seatsPerTimeSlot" | "team"
75-
> & {
76-
URL: string;
77-
};
84+
// Limit what data should be accessible to apps
85+
eventType: AppEventType;
7886
getAppData: GetAppData;
7987
setAppData: SetAppData;
8088
disabled?: boolean;
@@ -84,5 +92,3 @@ export type EventTypeAppSettingsComponentProps = {
8492
export type EventTypeAppCardComponent = React.FC<EventTypeAppCardComponentProps>;
8593

8694
export type EventTypeAppSettingsComponent = React.FC<EventTypeAppSettingsComponentProps>;
87-
88-
export type EventTypeModel = z.infer<typeof EventTypeModel>;

packages/features/apps/components/AppList.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useCallback, useState } from "react";
33
import { AppSettings } from "@calcom/app-store/_components/AppSettings";
44
import { InstallAppButton } from "@calcom/app-store/components";
55
import { getLocationFromApp, type EventLocationType } from "@calcom/app-store/locations";
6-
import type { CredentialOwner } from "@calcom/app-store/types";
6+
import type { AppCardApp } from "@calcom/app-store/types";
77
import AppListCard from "@calcom/features/apps/components/AppListCard";
88
import type { UpdateUsersDefaultConferencingAppParams } from "@calcom/features/apps/components/AppSetDefaultLinkDialog";
99
import { AppSetDefaultLinkDialog } from "@calcom/features/apps/components/AppSetDefaultLinkDialog";
@@ -13,6 +13,7 @@ import type {
1313
} from "@calcom/features/eventtypes/components/BulkEditDefaultForEventsModal";
1414
import { BulkEditDefaultForEventsModal } from "@calcom/features/eventtypes/components/BulkEditDefaultForEventsModal";
1515
import { isDelegationCredential } from "@calcom/lib/delegationCredential/clientAndServer";
16+
import type { ConnectedApps } from "@calcom/lib/getConnectedApps";
1617
import { useLocale } from "@calcom/lib/hooks/useLocale";
1718
import type { AppCategories } from "@calcom/prisma/enums";
1819
import { type RouterOutputs } from "@calcom/trpc";
@@ -33,7 +34,7 @@ export type HandleDisconnect = (credentialId: number, app: App["slug"], teamId?:
3334

3435
interface AppListProps {
3536
variant?: AppCategories;
36-
data: RouterOutputs["viewer"]["apps"]["integrations"];
37+
data: ConnectedApps;
3738
handleDisconnect: HandleDisconnect;
3839
listClassName?: string;
3940
defaultConferencingApp: RouterOutputs["viewer"]["apps"]["getUsersDefaultConferencingApp"];
@@ -69,13 +70,7 @@ export const AppList = ({
6970
showToast("Default app updated successfully", "success");
7071
}, []);
7172

72-
const ChildAppCard = ({
73-
item,
74-
}: {
75-
item: RouterOutputs["viewer"]["apps"]["integrations"]["items"][number] & {
76-
credentialOwner?: CredentialOwner;
77-
};
78-
}) => {
73+
const ChildAppCard = ({ item }: { item: AppCardApp }) => {
7974
const appSlug = item?.slug;
8075
const appIsDefault =
8176
appSlug === defaultConferencingApp?.appSlug ||

0 commit comments

Comments
 (0)