Merge branch 'main' into teste2e-checkboxQuestion
commit
52fb3cf5ce
|
@ -3,7 +3,7 @@ import type { NextApiRequest, NextApiResponse } from "next";
|
||||||
import { HttpError } from "@calcom/lib/http-error";
|
import { HttpError } from "@calcom/lib/http-error";
|
||||||
import { defaultResponder } from "@calcom/lib/server";
|
import { defaultResponder } from "@calcom/lib/server";
|
||||||
import { createContext } from "@calcom/trpc/server/createContext";
|
import { createContext } from "@calcom/trpc/server/createContext";
|
||||||
import { viewerRouter } from "@calcom/trpc/server/routers/viewer/_router";
|
import { slotsRouter } from "@calcom/trpc/server/routers/viewer/slots/_router";
|
||||||
|
|
||||||
import { TRPCError } from "@trpc/server";
|
import { TRPCError } from "@trpc/server";
|
||||||
import { getHTTPStatusCodeFromError } from "@trpc/server/http";
|
import { getHTTPStatusCodeFromError } from "@trpc/server/http";
|
||||||
|
@ -11,10 +11,10 @@ import { getHTTPStatusCodeFromError } from "@trpc/server/http";
|
||||||
async function handler(req: NextApiRequest, res: NextApiResponse) {
|
async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||||
/** @see https://trpc.io/docs/server-side-calls */
|
/** @see https://trpc.io/docs/server-side-calls */
|
||||||
const ctx = await createContext({ req, res });
|
const ctx = await createContext({ req, res });
|
||||||
const caller = viewerRouter.createCaller(ctx);
|
const caller = slotsRouter.createCaller(ctx);
|
||||||
try {
|
try {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
return await caller.slots.getSchedule(req.query as any /* Let tRPC handle this */);
|
return await caller.getSchedule(req.query as any /* Let tRPC handle this */);
|
||||||
} catch (cause) {
|
} catch (cause) {
|
||||||
if (cause instanceof TRPCError) {
|
if (cause instanceof TRPCError) {
|
||||||
const statusCode = getHTTPStatusCodeFromError(cause);
|
const statusCode = getHTTPStatusCodeFromError(cause);
|
||||||
|
|
|
@ -7,7 +7,7 @@ import prisma from "@calcom/prisma";
|
||||||
import { UserPermissionRole } from "@calcom/prisma/enums";
|
import { UserPermissionRole } from "@calcom/prisma/enums";
|
||||||
import { TRPCError } from "@calcom/trpc/server";
|
import { TRPCError } from "@calcom/trpc/server";
|
||||||
import { createContext } from "@calcom/trpc/server/createContext";
|
import { createContext } from "@calcom/trpc/server/createContext";
|
||||||
import { viewerRouter } from "@calcom/trpc/server/routers/viewer/_router";
|
import { bookingsRouter } from "@calcom/trpc/server/routers/viewer/bookings/_router";
|
||||||
|
|
||||||
enum DirectAction {
|
enum DirectAction {
|
||||||
ACCEPT = "accept",
|
ACCEPT = "accept",
|
||||||
|
@ -55,13 +55,13 @@ async function handler(req: NextApiRequest, res: NextApiResponse<Response>) {
|
||||||
try {
|
try {
|
||||||
/** @see https://trpc.io/docs/server-side-calls */
|
/** @see https://trpc.io/docs/server-side-calls */
|
||||||
const ctx = await createContext({ req, res }, sessionGetter);
|
const ctx = await createContext({ req, res }, sessionGetter);
|
||||||
const caller = viewerRouter.createCaller({
|
const caller = bookingsRouter.createCaller({
|
||||||
...ctx,
|
...ctx,
|
||||||
req,
|
req,
|
||||||
res,
|
res,
|
||||||
user: { ...user, locale: user?.locale ?? "en" },
|
user: { ...user, locale: user?.locale ?? "en" },
|
||||||
});
|
});
|
||||||
await caller.bookings.confirm({
|
await caller.confirm({
|
||||||
bookingId: booking.id,
|
bookingId: booking.id,
|
||||||
recurringEventId: booking.recurringEventId || undefined,
|
recurringEventId: booking.recurringEventId || undefined,
|
||||||
confirmed: action === DirectAction.ACCEPT,
|
confirmed: action === DirectAction.ACCEPT,
|
||||||
|
|
|
@ -2,7 +2,7 @@ import type { NextApiRequest, NextApiResponse } from "next";
|
||||||
|
|
||||||
import { defaultResponder } from "@calcom/lib/server";
|
import { defaultResponder } from "@calcom/lib/server";
|
||||||
import { createContext } from "@calcom/trpc/server/createContext";
|
import { createContext } from "@calcom/trpc/server/createContext";
|
||||||
import { viewerRouter } from "@calcom/trpc/server/routers/viewer/_router";
|
import { apiKeysRouter } from "@calcom/trpc/server/routers/viewer/apiKeys/_router";
|
||||||
|
|
||||||
import checkSession from "../../_utils/auth";
|
import checkSession from "../../_utils/auth";
|
||||||
import getInstalledAppPath from "../../_utils/getInstalledAppPath";
|
import getInstalledAppPath from "../../_utils/getInstalledAppPath";
|
||||||
|
@ -15,9 +15,9 @@ export async function getHandler(req: NextApiRequest, res: NextApiResponse) {
|
||||||
const appType = appConfig.type;
|
const appType = appConfig.type;
|
||||||
|
|
||||||
const ctx = await createContext({ req, res });
|
const ctx = await createContext({ req, res });
|
||||||
const caller = viewerRouter.createCaller(ctx);
|
const caller = apiKeysRouter.createCaller(ctx);
|
||||||
|
|
||||||
const apiKey = await caller.apiKeys.create({
|
const apiKey = await caller.create({
|
||||||
note: "Cal.ai",
|
note: "Cal.ai",
|
||||||
expiresAt: null,
|
expiresAt: null,
|
||||||
appId: "cal-ai",
|
appId: "cal-ai",
|
||||||
|
|
Loading…
Reference in New Issue