Fix overwriting users column when saving event types (#7445)

* Only overwrite user column when present

* Clean up
pull/7453/head
Joe Au-Yeung 2023-03-01 12:16:04 -05:00 committed by GitHub
parent a6cd173910
commit 7b1ced914b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 8 deletions

View File

@ -74,11 +74,33 @@ export const createUsersFixture = (page: Page, workerInfo: WorkerInfo) => {
});
await prisma.eventType.create({
data: {
owner: {
connect: {
id: _user.id,
},
},
users: {
connect: {
id: _user.id,
},
},
title: "30 mins",
slug: "30-mins",
length: 30,
},
});
await prisma.eventType.create({
data: {
users: {
connect: {
id: _user.id,
},
},
owner: {
connect: {
id: _user.id,
},
},
title: "Paid",
slug: "paid",
length: 30,
@ -92,6 +114,11 @@ export const createUsersFixture = (page: Page, workerInfo: WorkerInfo) => {
id: _user.id,
},
},
owner: {
connect: {
id: _user.id,
},
},
title: "Opt in",
slug: "opt-in",
requiresConfirmation: true,
@ -298,13 +325,6 @@ const createUser = async (
},
}
: undefined,
eventTypes: {
create: {
title: "30 min",
slug: "30-min",
length: 30,
},
},
};
};

View File

@ -604,7 +604,7 @@ export const eventTypesRouter = router({
};
}
if (users) {
if (users.length) {
data.users = {
set: [],
connect: users.map((userId: number) => ({ id: userId })),