* perf: Slim down loggedInViewer some more * Move locationOptions to apps router * Moved calVideo related handlers to separate router * Moved calendar related handlers to separate router * Rename * Moved deleteCredential to new router * Moved updateProfile to me router * fix unit test * fix e2e test * tweak * missing --------- Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com> Co-authored-by: unknown <adhabal2002@gmail.com>
31 lines
902 B
TypeScript
31 lines
902 B
TypeScript
import { getConnectedDestinationCalendarsAndEnsureDefaultsInDb } from "@calcom/lib/getConnectedDestinationCalendars";
|
|
import { prisma } from "@calcom/prisma";
|
|
import type { TrpcSessionUser } from "@calcom/trpc/server/types";
|
|
|
|
import type { TConnectedCalendarsInputSchema } from "./connectedCalendars.schema";
|
|
|
|
type ConnectedCalendarsOptions = {
|
|
ctx: {
|
|
user: NonNullable<TrpcSessionUser>;
|
|
};
|
|
input: TConnectedCalendarsInputSchema;
|
|
};
|
|
|
|
export const connectedCalendarsHandler = async ({ ctx, input }: ConnectedCalendarsOptions) => {
|
|
const { user } = ctx;
|
|
const onboarding = input?.onboarding || false;
|
|
|
|
const { connectedCalendars, destinationCalendar } =
|
|
await getConnectedDestinationCalendarsAndEnsureDefaultsInDb({
|
|
user,
|
|
onboarding,
|
|
eventTypeId: input?.eventTypeId ?? null,
|
|
prisma,
|
|
});
|
|
|
|
return {
|
|
connectedCalendars,
|
|
destinationCalendar,
|
|
};
|
|
};
|