97bde083ca
- Rename team.ts to teamService.ts - Rename TeamService.test.ts to teamService.test.ts - Rename TeamService.alternative.test.ts to teamService.alternative.test.ts - Update all import statements across codebase to reference new file names This change improves consistency with the codebase naming conventions while maintaining all existing functionality. Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
23 lines
670 B
TypeScript
23 lines
670 B
TypeScript
import { isTeamOwner } from "@calcom/lib/server/queries/teams";
|
|
import { TeamService } from "@calcom/lib/server/service/teamService";
|
|
|
|
import { TRPCError } from "@trpc/server";
|
|
|
|
import type { TrpcSessionUser } from "../../../types";
|
|
import type { TDeleteInputSchema } from "./delete.schema";
|
|
|
|
type DeleteOptions = {
|
|
ctx: {
|
|
user: NonNullable<TrpcSessionUser>;
|
|
};
|
|
input: TDeleteInputSchema;
|
|
};
|
|
|
|
export const deleteHandler = async ({ ctx, input }: DeleteOptions) => {
|
|
if (!(await isTeamOwner(ctx.user?.id, input.teamId))) throw new TRPCError({ code: "UNAUTHORIZED" });
|
|
|
|
return await TeamService.delete({ id: input.teamId });
|
|
};
|
|
|
|
export default deleteHandler;
|