* remove barrel export for client * fix more imports * remove server barrel * remove more barrel exporst and fix tssconfig * fix types * fix imports for removed barrels * fig ssg createserverside helpers * restore lock * new yarn lock * remove barel exports * remove barrel * replace client with react in tsconfig * fix yarn lock * Update exports for trpc to not be types * add ENDPOINTS export to the correct location * other exports fixes lost due to barrel * fix client error export * more imports --------- Co-authored-by: hbjORbj <sldisek783@gmail.com> Co-authored-by: Keith Williams <keithwillcode@gmail.com>
51 lines
1.2 KiB
TypeScript
51 lines
1.2 KiB
TypeScript
import { getSerializableForm } from "@calcom/app-store/routing-forms/lib/getSerializableForm";
|
|
import { handleResponse } from "@calcom/app-store/routing-forms/lib/handleResponse";
|
|
import type { PrismaClient } from "@calcom/prisma";
|
|
|
|
import { TRPCError } from "@trpc/server";
|
|
|
|
import type { TResponseInputSchema } from "./response.schema";
|
|
|
|
interface ResponseHandlerOptions {
|
|
ctx: {
|
|
prisma: PrismaClient;
|
|
};
|
|
input: TResponseInputSchema;
|
|
}
|
|
export const responseHandler = async ({ ctx, input }: ResponseHandlerOptions) => {
|
|
const { prisma } = ctx;
|
|
const { formId, response, formFillerId, chosenRouteId = null, isPreview = false } = input;
|
|
const form = await prisma.app_RoutingForms_Form.findFirst({
|
|
where: {
|
|
id: formId,
|
|
},
|
|
include: {
|
|
team: {
|
|
select: {
|
|
parentId: true,
|
|
},
|
|
},
|
|
user: {
|
|
select: {
|
|
id: true,
|
|
email: true,
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
if (!form) {
|
|
throw new TRPCError({
|
|
code: "NOT_FOUND",
|
|
});
|
|
}
|
|
|
|
const serializableForm = await getSerializableForm({
|
|
form,
|
|
});
|
|
|
|
return handleResponse({ response, form: serializableForm, formFillerId, chosenRouteId, isPreview });
|
|
};
|
|
|
|
export default responseHandler;
|