|
1 | 1 | import type { ActionFunctionArgs } from "@remix-run/server-runtime"; |
2 | 2 | import { json } from "@remix-run/server-runtime"; |
3 | | -import { truncateSync } from "fs"; |
4 | 3 | import { z } from "zod"; |
5 | 4 | import { prisma } from "~/db.server"; |
| 5 | +import { scheduleUniqWhereClause, scheduleWhereClause } from "~/models/schedules.server"; |
6 | 6 | import { ViewSchedulePresenter } from "~/presenters/v3/ViewSchedulePresenter.server"; |
7 | 7 | import { authenticateApiRequest } from "~/services/apiAuth.server"; |
8 | 8 |
|
@@ -34,21 +34,21 @@ export async function action({ request, params }: ActionFunctionArgs) { |
34 | 34 |
|
35 | 35 | try { |
36 | 36 | const existingSchedule = await prisma.taskSchedule.findFirst({ |
37 | | - where: { |
38 | | - friendlyId: parsedParams.data.scheduleId, |
39 | | - projectId: authenticationResult.environment.projectId, |
40 | | - }, |
| 37 | + where: scheduleWhereClause( |
| 38 | + authenticationResult.environment.projectId, |
| 39 | + parsedParams.data.scheduleId |
| 40 | + ), |
41 | 41 | }); |
42 | 42 |
|
43 | 43 | if (!existingSchedule) { |
44 | 44 | return json({ error: "Schedule not found" }, { status: 404 }); |
45 | 45 | } |
46 | 46 |
|
47 | 47 | await prisma.taskSchedule.update({ |
48 | | - where: { |
49 | | - friendlyId: parsedParams.data.scheduleId, |
50 | | - projectId: authenticationResult.environment.projectId, |
51 | | - }, |
| 48 | + where: scheduleUniqWhereClause( |
| 49 | + authenticationResult.environment.projectId, |
| 50 | + parsedParams.data.scheduleId |
| 51 | + ), |
52 | 52 | data: { |
53 | 53 | active: true, |
54 | 54 | }, |
|
0 commit comments