fix: Update handlers and refactor code (#21686)
* fix: update safeCredentialSelect * Update credential.ts * Update * update
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type { PrismaClient } from "@calcom/prisma";
|
||||
import { safeCredentialSelect } from "@calcom/prisma/selects/credential";
|
||||
import type { TrpcSessionUser } from "@calcom/trpc/server/types";
|
||||
|
||||
import { TRPCError } from "@trpc/server";
|
||||
@@ -20,6 +21,7 @@ const getInCompleteBookingSettingsHandler = async (options: GetIncompleteBooking
|
||||
input,
|
||||
} = options;
|
||||
|
||||
const { user: _, ...safeCredentialSelectWithoutUser } = safeCredentialSelect;
|
||||
const [incompleteBookingActions, form] = await Promise.all([
|
||||
prisma.app_RoutingForms_IncompleteBookingActions.findMany({
|
||||
where: {
|
||||
@@ -67,7 +69,14 @@ const getInCompleteBookingSettingsHandler = async (options: GetIncompleteBooking
|
||||
in: [teamId, ...(orgQuery?.parentId ? [orgQuery.parentId] : [])],
|
||||
},
|
||||
},
|
||||
include: {
|
||||
select: {
|
||||
...safeCredentialSelectWithoutUser,
|
||||
user: {
|
||||
select: {
|
||||
email: true,
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
team: {
|
||||
select: {
|
||||
name: true,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { getAllDelegationCredentialsForUserByAppType } from "@calcom/lib/delegationCredential/server";
|
||||
import { UserRepository } from "@calcom/lib/server/repository/user";
|
||||
import { prisma } from "@calcom/prisma";
|
||||
import { safeCredentialSelect } from "@calcom/prisma/selects/credential";
|
||||
import type { TrpcSessionUser } from "@calcom/trpc/server/types";
|
||||
|
||||
import type { TAppCredentialsByTypeInputSchema } from "./appCredentialsByType.schema";
|
||||
@@ -16,6 +17,7 @@ type AppCredentialsByTypeOptions = {
|
||||
export const appCredentialsByTypeHandler = async ({ ctx, input }: AppCredentialsByTypeOptions) => {
|
||||
const { user } = ctx;
|
||||
const userAdminTeams = await UserRepository.getUserAdminTeams(ctx.user.id);
|
||||
const { user: _, ...safeCredentialSelectWithoutUser } = safeCredentialSelect;
|
||||
const userAdminTeamsIds = userAdminTeams?.teams?.map(({ team }) => team.id) ?? [];
|
||||
|
||||
const credentials = await prisma.credential.findMany({
|
||||
@@ -30,7 +32,8 @@ export const appCredentialsByTypeHandler = async ({ ctx, input }: AppCredentials
|
||||
],
|
||||
type: input.appType,
|
||||
},
|
||||
include: {
|
||||
select: {
|
||||
...safeCredentialSelectWithoutUser,
|
||||
user: {
|
||||
select: {
|
||||
name: true,
|
||||
|
||||
Reference in New Issue
Block a user