feat(shots): previous/next shot navigation on the shot page
Deploy / deploy (push) Successful in 3m26s

Prev/next buttons beside the breadcrumb walk the project's shot list in
the same order as the Shots tab. The ordering now lives in
lib/shot-order.ts, shared by the project page and the shot API.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
twotalesanimation
2026-10-13 07:45:24 +02:00
parent d7e37de18f
commit 0aedc4b1fa
4 changed files with 117 additions and 15 deletions
+29 -1
View File
@@ -1,6 +1,7 @@
import { NextRequest, NextResponse } from "next/server";
import { auth } from "@/auth";
import { db } from "@/lib/db";
import { sortShotsForList } from "@/lib/shot-order";
export async function GET(
req: NextRequest,
@@ -38,9 +39,35 @@ export async function GET(
const project = await db.project.findUnique({
where: { id: shot.projectId },
select: { name: true },
select: {
name: true,
projectType: true,
shots: {
orderBy: { createdAt: "asc" },
select: {
id: true,
shotCode: true,
episode: true,
scene: true,
shotNumber: true,
shotGroup: { select: { name: true } },
},
},
},
});
// Neighbours in the project page's shot list order, for prev/next navigation
const orderedShots = project ? sortShotsForList(project.shots, project.projectType) : [];
const shotIndex = orderedShots.findIndex((s) => s.id === shotId);
const neighbour = (i: number) =>
shotIndex >= 0 && orderedShots[i] ? { id: orderedShots[i].id, shotCode: orderedShots[i].shotCode } : null;
const shotNav = {
prev: neighbour(shotIndex - 1),
next: neighbour(shotIndex + 1),
position: shotIndex + 1,
total: orderedShots.length,
};
const [tasks, artists] = await Promise.all([
db.task.findMany({
where: { shotId },
@@ -99,6 +126,7 @@ export async function GET(
return NextResponse.json({
shot: shotSerialized,
projectName: project?.name ?? "",
shotNav,
canApprove,
canInternallyApprove: ["ADMIN", "PRODUCER", "SUPERVISOR"].includes(session.user.role as string),
tasks,