Skip to content

Commit 8461b82

Browse files
authored
fix: Update handlers and refactor code (calcom#21686)
* fix: update safeCredentialSelect * Update credential.ts * Update * update
1 parent 07ffc3f commit 8461b82

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

packages/app-store/routing-forms/trpc/getIncompleteBookingSettings.handler.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { PrismaClient } from "@calcom/prisma";
2+
import { safeCredentialSelect } from "@calcom/prisma/selects/credential";
23
import type { TrpcSessionUser } from "@calcom/trpc/server/types";
34

45
import { TRPCError } from "@trpc/server";
@@ -20,6 +21,7 @@ const getInCompleteBookingSettingsHandler = async (options: GetIncompleteBooking
2021
input,
2122
} = options;
2223

24+
const { user: _, ...safeCredentialSelectWithoutUser } = safeCredentialSelect;
2325
const [incompleteBookingActions, form] = await Promise.all([
2426
prisma.app_RoutingForms_IncompleteBookingActions.findMany({
2527
where: {
@@ -67,7 +69,14 @@ const getInCompleteBookingSettingsHandler = async (options: GetIncompleteBooking
6769
in: [teamId, ...(orgQuery?.parentId ? [orgQuery.parentId] : [])],
6870
},
6971
},
70-
include: {
72+
select: {
73+
...safeCredentialSelectWithoutUser,
74+
user: {
75+
select: {
76+
email: true,
77+
name: true,
78+
},
79+
},
7180
team: {
7281
select: {
7382
name: true,

packages/trpc/server/routers/viewer/apps/appCredentialsByType.handler.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { getAllDelegationCredentialsForUserByAppType } from "@calcom/lib/delegationCredential/server";
22
import { UserRepository } from "@calcom/lib/server/repository/user";
33
import { prisma } from "@calcom/prisma";
4+
import { safeCredentialSelect } from "@calcom/prisma/selects/credential";
45
import type { TrpcSessionUser } from "@calcom/trpc/server/types";
56

67
import type { TAppCredentialsByTypeInputSchema } from "./appCredentialsByType.schema";
@@ -16,6 +17,7 @@ type AppCredentialsByTypeOptions = {
1617
export const appCredentialsByTypeHandler = async ({ ctx, input }: AppCredentialsByTypeOptions) => {
1718
const { user } = ctx;
1819
const userAdminTeams = await UserRepository.getUserAdminTeams(ctx.user.id);
20+
const { user: _, ...safeCredentialSelectWithoutUser } = safeCredentialSelect;
1921
const userAdminTeamsIds = userAdminTeams?.teams?.map(({ team }) => team.id) ?? [];
2022

2123
const credentials = await prisma.credential.findMany({
@@ -30,7 +32,8 @@ export const appCredentialsByTypeHandler = async ({ ctx, input }: AppCredentials
3032
],
3133
type: input.appType,
3234
},
33-
include: {
35+
select: {
36+
...safeCredentialSelectWithoutUser,
3437
user: {
3538
select: {
3639
name: true,

0 commit comments

Comments
 (0)