minor change
parent
efe2a8baf5
commit
fbd39f1eca
|
@ -213,16 +213,19 @@ export async function patchHandler(req: NextApiRequest) {
|
||||||
...parsedBody
|
...parsedBody
|
||||||
} = schemaEventTypeEditBodyParams.parse(body);
|
} = schemaEventTypeEditBodyParams.parse(body);
|
||||||
|
|
||||||
// validate children ownership
|
const validatedChildren =
|
||||||
|
parsedBody.teamId && parsedChildren
|
||||||
|
? parsedChildren.filter((child) => isUserMemberOfTeam(parsedBody.teamId, child.userId))
|
||||||
|
: [];
|
||||||
|
|
||||||
const data: Prisma.EventTypeUpdateArgs["data"] = {
|
const data: Prisma.EventTypeUpdateArgs["data"] = {
|
||||||
...parsedBody,
|
...parsedBody,
|
||||||
bookingLimits: bookingLimits === null ? Prisma.DbNull : bookingLimits,
|
bookingLimits: bookingLimits === null ? Prisma.DbNull : bookingLimits,
|
||||||
durationLimits: durationLimits === null ? Prisma.DbNull : durationLimits,
|
durationLimits: durationLimits === null ? Prisma.DbNull : durationLimits,
|
||||||
...(parsedChildren
|
...(validatedChildren
|
||||||
? {
|
? {
|
||||||
children: {
|
children: {
|
||||||
connect: parsedChildren.map((child) => ({ id: child.id })),
|
connect: validatedChildren.map((child) => ({ id: child.id })),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
: {}),
|
: {}),
|
||||||
|
|
|
@ -273,7 +273,6 @@ async function postHandler(req: NextApiRequest) {
|
||||||
...parsedBody
|
...parsedBody
|
||||||
} = schemaEventTypeCreateBodyParams.parse(body || {});
|
} = schemaEventTypeCreateBodyParams.parse(body || {});
|
||||||
|
|
||||||
// validate that these child event type owners are members of parent
|
|
||||||
const validatedChildren =
|
const validatedChildren =
|
||||||
parsedBody.teamId && parsedChildren
|
parsedBody.teamId && parsedChildren
|
||||||
? parsedChildren.filter((child) => isUserMemberOfTeam(parsedBody.teamId, child.userId))
|
? parsedChildren.filter((child) => isUserMemberOfTeam(parsedBody.teamId, child.userId))
|
||||||
|
|
Loading…
Reference in New Issue