added edity shot name
Deploy / deploy (push) Successful in 2m36s

This commit is contained in:
twotalesanimation
2026-05-21 18:16:54 +02:00
parent d39b968dcb
commit 32073fbe4c
2 changed files with 25 additions and 1 deletions
+12 -1
View File
@@ -197,6 +197,7 @@ export async function duplicateShot(sourceShotId: string) {
const updateShotSchema = z.object({
shotId: z.string().cuid(),
shotCode: z.string().min(1).max(120).regex(/^[A-Z0-9_]+$/i, "Alphanumeric and underscores only").optional(),
description: z.string().optional(),
status: z.nativeEnum(ShotStatus).optional(),
priority: z.nativeEnum(ShotPriority).optional(),
@@ -218,12 +219,22 @@ export async function updateShot(data: z.infer<typeof updateShotSchema>) {
}
const parsed = updateShotSchema.parse(data);
const { shotId, dueDate, artistId, ...rest } = parsed;
const { shotId, dueDate, artistId, shotCode, ...rest } = parsed;
// Check uniqueness if shotCode is being changed
if (shotCode) {
const existing = await db.shot.findFirst({
where: { projectId: (await db.shot.findUnique({ where: { id: shotId }, select: { projectId: true } }))!.projectId, shotCode, id: { not: shotId } },
select: { id: true },
});
if (existing) throw new Error(`Shot code "${shotCode}" is already used in this project.`);
}
const shot = await db.shot.update({
where: { id: shotId },
data: {
...rest,
...(shotCode ? { shotCode: shotCode.toUpperCase() } : {}),
dueDate: dueDate ? new Date(dueDate) : dueDate === null ? null : undefined,
artistId: artistId === "" ? null : artistId,
},