Adds custom inputs to eventTypes responses
This commit is contained in:
1 parent
11ffdccb4a
commit
25d3d12319
3 files changed
+6
-3
No files matched your search
@@ -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