Adds custom inputs to eventTypes responses
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import { _EventTypeModel as EventType } from "@calcom/prisma/zod";
|
||||
import { _EventTypeCustomInputModel, _EventTypeModel as EventType } from "@calcom/prisma/zod";
|
||||
|
||||
import { Frequency } from "@lib/types";
|
||||
|
||||
@@ -116,5 +116,6 @@ export const schemaEventTypeReadPublic = EventType.pick({
|
||||
)
|
||||
.nullable(),
|
||||
metadata: jsonSchema.nullable(),
|
||||
customInputs: _EventTypeCustomInputModel.array().optional(),
|
||||
})
|
||||
);
|
||||
|
||||
@@ -36,7 +36,7 @@ import { schemaQueryIdParseInt } from "@lib/validations/shared/queryIdTransformP
|
||||
export async function getHandler(req: NextApiRequest) {
|
||||
const { prisma, query } = req;
|
||||
const { id } = schemaQueryIdParseInt.parse(query);
|
||||
const event_type = await prisma.eventType.findUnique({ where: { id } });
|
||||
const event_type = await prisma.eventType.findUnique({ where: { id }, include: { customInputs: true } });
|
||||
return { event_type: schemaEventTypeReadPublic.parse(event_type) };
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,9 @@ import { schemaQuerySingleOrMultipleUserIds } from "@lib/validations/shared/quer
|
||||
*/
|
||||
async function getHandler(req: NextApiRequest) {
|
||||
const { userId, isAdmin, prisma } = req;
|
||||
const args: Prisma.EventTypeFindManyArgs = isAdmin ? {} : { where: { userId } };
|
||||
const args: Prisma.EventTypeFindManyArgs = isAdmin
|
||||
? {}
|
||||
: { where: { userId }, include: { customInputs: true } };
|
||||
/** Only admins can query other users */
|
||||
if (!isAdmin && req.query.userId) throw new HttpError({ statusCode: 401, message: "ADMIN required" });
|
||||
if (isAdmin && req.query.userId) {
|
||||
|
||||
Reference in New Issue
Block a user