* Initial commit * routingForm to Booking a particular team member working * Happy path working * Fixes * Fix router query params forwarding * Add basicConfig within app * Tests * More tests * Update packages/app-store/routing-forms/components/SingleForm.tsx Co-authored-by: Omar López <zomars@me.com> --------- Co-authored-by: Omar López <zomars@me.com> Co-authored-by: Benny Joo <sldisek783@gmail.com>
31 lines
948 B
TypeScript
31 lines
948 B
TypeScript
import { TRPCError } from "@trpc/server";
|
|
import type { TrpcSessionUser } from "@calcom/trpc/server/trpc";
|
|
|
|
import type { TGetAttributesForTeamInputSchema } from "./getAttributesForTeam.schema";
|
|
import { getAttributesForTeam } from "../lib/getAttributes";
|
|
import { MembershipRepository } from "@calcom/lib/server/repository/membership";
|
|
|
|
type GetAttributesForTeamHandlerOptions = {
|
|
ctx: {
|
|
user: NonNullable<TrpcSessionUser>;
|
|
};
|
|
input: TGetAttributesForTeamInputSchema;
|
|
};
|
|
|
|
export default async function getAttributesForTeamHandler({
|
|
ctx,
|
|
input,
|
|
}: GetAttributesForTeamHandlerOptions) {
|
|
const { teamId } = input;
|
|
const { user } = ctx;
|
|
const isMemberOfTeam = await MembershipRepository.findFirstByUserIdAndTeamId({ userId: user.id, teamId });
|
|
|
|
if (!isMemberOfTeam) {
|
|
throw new TRPCError({
|
|
code: "NOT_FOUND",
|
|
message: "You are not a member of this team",
|
|
});
|
|
}
|
|
|
|
return getAttributesForTeam({ teamId });
|
|
} |