Adds custom inputs to eventTypes responses

This commit is contained in:
zomars
2022-10-14 15:52:09 -06:00
parent 11ffdccb4a
commit 25d3d12319
3 changed files with 6 additions and 3 deletions
+2 -1
View File
@@ -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(),
})
);
+1 -1
View File
@@ -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) };
}
+3 -1
View File
@@ -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) {