Files
calendar/packages/trpc/server/routers/viewer/teams/roundRobin/roundRobinManualReassign.handler.ts
Benny JooandGitHub ff38d6c7db refactor: Remove circular deps between @calcom/lib and @calcom/features [1] (#24399)
* add eslint config

* migrate autoLock to features

* migrate teamService to features

* migrate userCreationService

* migrate insights services to features

* migrate ProfileRepository

* update imports

* migrate filter segmen tests

* migrate filter segment repository

* migrate getBusyTimes

* migrate getLocaleFromRequest

* refactor csvUtils

* make filename clearer

* migrate getLuckyUser integration test

* migrate autoLock test to features

* wip

* refactors

* migrate useBookerUrl

* migrate more

* wip

* Migrate eventTypeRepository

* membership repository

* update imports

* update imports

* migrate

* move organization repository

* update imports

* update imports

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix tests

* fix type checks

* fix

* fix

* migrate

* update imports

* fix tests

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix
2025-10-13 12:01:02 -03:00

40 lines
1.3 KiB
TypeScript

import { roundRobinManualReassignment } from "@calcom/features/ee/round-robin/roundRobinManualReassignment";
import { BookingRepository } from "@calcom/features/bookings/repositories/BookingRepository";
import { prisma } from "@calcom/prisma";
import type { TrpcSessionUser } from "@calcom/trpc/server/types";
import { TRPCError } from "@trpc/server";
import type { TRoundRobinManualReassignInputSchema } from "./roundRobinManualReassign.schema";
type RoundRobinManualReassignOptions = {
ctx: {
user: NonNullable<TrpcSessionUser>;
};
input: TRoundRobinManualReassignInputSchema;
};
export const roundRobinManualReassignHandler = async ({ ctx, input }: RoundRobinManualReassignOptions) => {
const { bookingId, teamMemberId, reassignReason } = input;
// Check if user has access to change booking
const bookingRepo = new BookingRepository(prisma);
const isAllowed = await bookingRepo.doesUserIdHaveAccessToBooking({ userId: ctx.user.id, bookingId });
if (!isAllowed) {
throw new TRPCError({ code: "FORBIDDEN", message: "You do not have permission" });
}
await roundRobinManualReassignment({
bookingId,
newUserId: teamMemberId,
orgId: ctx.user.organizationId,
reassignReason,
reassignedById: ctx.user.id,
});
return { success: true };
};
export default roundRobinManualReassignHandler;