Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

Commit

Permalink
fix: Remove credentials and some ts fixes (calcom#11794)
Browse files Browse the repository at this point in the history
  • Loading branch information
emrysal authored Oct 10, 2023
1 parent 778485b commit 150dc3a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 30 deletions.
16 changes: 8 additions & 8 deletions packages/app-store/server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Prisma } from "@prisma/client";
import type { TFunction } from "next-i18next";

import type { CredentialDataWithTeamName } from "@calcom/app-store/utils";
import { defaultVideoAppCategories } from "@calcom/app-store/utils";
import getEnabledAppsFromCredentials from "@calcom/lib/apps/getEnabledAppsFromCredentials";
import { prisma } from "@calcom/prisma";
Expand All @@ -21,11 +21,11 @@ export async function getLocationGroupedOptions(
disabled?: boolean;
icon?: string;
slug?: string;
credential?: CredentialDataWithTeamName;
}[]
> = {};

let idToSearchObject = {};
// don't default to {}, when you do TS no longer determines the right types.
let idToSearchObject: Prisma.CredentialWhereInput;

if ("teamId" in userOrTeamId) {
const teamId = userOrTeamId.teamId;
Expand Down Expand Up @@ -84,11 +84,11 @@ export async function getLocationGroupedOptions(
: app.categories[0] || app.category;
if (!groupByCategory) groupByCategory = AppCategories.conferencing;

for (const credential of app.credentials) {
const label = `${app.locationOption.label} ${
credential.team?.name ? `(${credential.team.name})` : ""
}`;
const option = { ...app.locationOption, label, icon: app.logo, slug: app.slug, credential };
for (const { teamName } of app.credentials.map((credential) => ({
teamName: credential.team?.name,
}))) {
const label = `${app.locationOption.label} ${teamName ? `(${teamName})` : ""}`;
const option = { ...app.locationOption, label, icon: app.logo, slug: app.slug };
if (apps[groupByCategory]) {
apps[groupByCategory] = [...apps[groupByCategory], option];
} else {
Expand Down
23 changes: 1 addition & 22 deletions packages/lib/getEventTypeById.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { CAL_URL } from "@calcom/lib/constants";
import { getTranslation } from "@calcom/lib/server/i18n";
import type { PrismaClient } from "@calcom/prisma";
import type { Credential } from "@calcom/prisma/client";
import { SchedulingType, MembershipRole, AppCategories } from "@calcom/prisma/enums";
import { SchedulingType, MembershipRole } from "@calcom/prisma/enums";
import { customInputSchema, EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";

import { TRPCError } from "@trpc/server";
Expand Down Expand Up @@ -230,27 +230,6 @@ export default async function getEventTypeById({
}
}

const credentials = await prisma.credential.findMany({
where: {
userId,
app: {
enabled: true,
categories: {
hasSome: [AppCategories.conferencing, AppCategories.video, AppCategories.payment],
},
},
},
select: {
id: true,
type: true,
key: true,
userId: true,
teamId: true,
appId: true,
invalid: true,
},
});

const { locations, metadata, ...restEventType } = rawEventType;
const newMetadata = EventTypeMetaDataSchema.parse(metadata || {}) || {};
const apps = newMetadata?.apps || {};
Expand Down

0 comments on commit 150dc3a

Please sign in to comment.