* trpc procedures an middleware refactor * allow use sessionMiddleware without a req object * sync with the new tRPC structure * tRPC refactor on routing form app * import Prisma from @prisma/client * Lazy load apps from appstore * remove unrelated changes * Add types for PaymentService * type fixes * Merge branch 'main' into roae85/cal-1514-set-the-user-session-only-on-the * fix typo * remove console.log * remove explicit types from apstore object * linter fixes --------- Co-authored-by: Keith Williams <keithwillcode@gmail.com> Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
38 lines
840 B
TypeScript
38 lines
840 B
TypeScript
import type { PrismaClient } from "@prisma/client";
|
|
|
|
import type { TrpcSessionUser } from "@calcom/trpc/server/trpc";
|
|
|
|
import { getSerializableForm } from "../lib/getSerializableForm";
|
|
|
|
interface FormsHandlerOptions {
|
|
ctx: {
|
|
prisma: PrismaClient;
|
|
user: NonNullable<TrpcSessionUser>;
|
|
};
|
|
}
|
|
|
|
export const formsHandler = async ({ ctx }: FormsHandlerOptions) => {
|
|
const { prisma, user } = ctx;
|
|
const forms = await prisma.app_RoutingForms_Form.findMany({
|
|
where: {
|
|
userId: user.id,
|
|
},
|
|
orderBy: {
|
|
createdAt: "desc",
|
|
},
|
|
include: {
|
|
_count: {
|
|
select: {
|
|
responses: true,
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
const serializableForms = [];
|
|
for (let i = 0; i < forms.length; i++) {
|
|
serializableForms.push(await getSerializableForm(forms[i]));
|
|
}
|
|
return serializableForms;
|
|
};
|