can add scenarios and it mostly works

This commit is contained in:
Kyle Corbitt
2023-06-23 20:00:46 -07:00
parent c497b74208
commit 8534477236
13 changed files with 278 additions and 68 deletions

View File

@@ -15,6 +15,34 @@ export const scenariosRouter = createTRPCRouter({
});
}),
create: publicProcedure
.input(
z.object({
experimentId: z.string(),
})
)
.mutation(async ({ input }) => {
const maxSortIndex =
(
await prisma.testScenario.aggregate({
where: {
experimentId: input.experimentId,
},
_max: {
sortIndex: true,
},
})
)._max.sortIndex ?? 0;
const newScenario = await prisma.testScenario.create({
data: {
experimentId: input.experimentId,
sortIndex: maxSortIndex + 1,
variableValues: {},
},
});
}),
replaceWithValues: publicProcedure
.input(
z.object({