2022-10-13 18:30:48 +00:00
|
|
|
import type { Prisma } from "@prisma/client";
|
|
|
|
import type { NextApiRequest } from "next";
|
|
|
|
|
|
|
|
import { defaultResponder } from "@calcom/lib/server";
|
|
|
|
|
2022-11-25 13:56:58 +00:00
|
|
|
import { schemaEventTypeCustomInputPublic } from "~/lib/validations/event-type-custom-input";
|
2022-10-13 18:30:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @swagger
|
|
|
|
* /custom-inputs:
|
|
|
|
* get:
|
|
|
|
* summary: Find all eventTypeCustomInputs
|
|
|
|
* tags:
|
|
|
|
* - custom-inputs
|
|
|
|
* responses:
|
|
|
|
* 200:
|
|
|
|
* description: OK
|
|
|
|
* 401:
|
|
|
|
* description: Authorization information is missing or invalid.
|
|
|
|
* 404:
|
|
|
|
* description: No eventTypeCustomInputs were found
|
|
|
|
*/
|
|
|
|
async function getHandler(req: NextApiRequest) {
|
|
|
|
const { userId, isAdmin, prisma } = req;
|
|
|
|
const args: Prisma.EventTypeCustomInputFindManyArgs = isAdmin ? {} : { where: { eventType: { userId } } };
|
|
|
|
const data = await prisma.eventTypeCustomInput.findMany(args);
|
|
|
|
return { event_type_custom_inputs: data.map((v) => schemaEventTypeCustomInputPublic.parse(v)) };
|
|
|
|
}
|
|
|
|
|
|
|
|
export default defaultResponder(getHandler);
|