feat: verify_only field on SoloTask, PATCH route saves verify_only

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Janpeter Visser 2026-05-01 12:50:50 +02:00
parent daa1c77498
commit f33903d207
3 changed files with 24 additions and 8 deletions

View file

@ -82,6 +82,7 @@ export default async function SoloProductPage({ params }: Props) {
priority: t.priority,
sort_order: t.sort_order,
status: t.status as SoloTask['status'],
verify_only: t.verify_only,
story_id: t.story.id,
story_code: t.story.code,
story_title: t.story.title,

View file

@ -14,10 +14,15 @@ const patchSchema = z
.object({
status: z.enum(PATCHABLE_TASK_STATUS as [string, ...string[]]).optional(),
implementation_plan: z.string().optional(),
verify_only: z.boolean().optional(),
})
.refine((data) => data.status !== undefined || data.implementation_plan !== undefined, {
message: 'Geef minimaal status of implementation_plan mee',
})
.refine(
(data) =>
data.status !== undefined ||
data.implementation_plan !== undefined ||
data.verify_only !== undefined,
{ message: 'Geef minimaal status, implementation_plan of verify_only mee' },
)
export async function PATCH(
request: Request,
@ -83,12 +88,19 @@ export async function PATCH(
}
}
// Combine simple field writes (plan, verify_only) into one update call
const simpleData: { implementation_plan?: string; verify_only?: boolean } = {}
if (parsed.data.implementation_plan !== undefined)
simpleData.implementation_plan = parsed.data.implementation_plan
if (parsed.data.verify_only !== undefined)
simpleData.verify_only = parsed.data.verify_only
const updated = await prisma.$transaction(async (tx) => {
const planUpdate = parsed.data.implementation_plan !== undefined
const simpleUpdate = Object.keys(simpleData).length > 0
? await tx.task.update({
where: { id },
data: { implementation_plan: parsed.data.implementation_plan },
select: { id: true, status: true, implementation_plan: true },
data: simpleData,
select: { id: true, status: true, implementation_plan: true, verify_only: true },
})
: null
@ -98,12 +110,13 @@ export async function PATCH(
id: result.task.id,
status: result.task.status,
implementation_plan: result.task.implementation_plan,
verify_only: simpleUpdate?.verify_only,
}
}
if (planUpdate) return planUpdate
if (simpleUpdate) return simpleUpdate
// Should not reach here — patchSchema rejects bodies without status or implementation_plan.
// Should not reach here — patchSchema rejects bodies without recognized fields.
throw new Error('Geen wijzigingen')
})
@ -111,5 +124,6 @@ export async function PATCH(
id: updated.id,
status: taskStatusToApi(updated.status),
implementation_plan: updated.implementation_plan,
...(updated.verify_only !== undefined && { verify_only: updated.verify_only }),
})
}

View file

@ -25,6 +25,7 @@ export interface SoloTask {
priority: number
sort_order: number
status: 'TO_DO' | 'IN_PROGRESS' | 'REVIEW' | 'DONE'
verify_only: boolean
story_id: string
story_code: string | null
story_title: string