Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a3859aa61b | |||
| 4cbb5d341c | |||
| 06a4122ebb | |||
| 842a8fe036 | |||
| 34af26dfbf |
@@ -542,4 +542,5 @@ For reference, the endpoints called by `VFXReviewConnector.jsx`:
|
||||
| Retry Export | `POST /api/ext/exports/{id}/retry` (E14) |
|
||||
| Regenerate Previews | `POST /api/ext/exports/{id}/regenerate-preview` |
|
||||
| Load QC Queue | `GET /api/ext/qc/queue?projectCode={PROJECT_CODE}` (E5) |
|
||||
| Build QC Review Session | `GET /api/ext/qc/queue?projectCode={PROJECT_CODE}` (E5): uses `scene`, `episode`, `seqTimecodeStart`, `handleHead`, `handleTail` |
|
||||
| QC Pass / QC Fail | `POST /api/ext/exports/{id}/qc` (E4) |
|
||||
|
||||
+1201
-15
File diff suppressed because it is too large
Load Diff
@@ -245,6 +245,7 @@ shot record, and submits it to the farm.
|
||||
|---|---|
|
||||
| **Urgent** | Priority 20 — claimable outside the render window, ahead of normal jobs |
|
||||
| **No preview** | Renders the EXRs but builds no preview, inheriting the previous export's MOV, review MP4 and thumbnail |
|
||||
| **Keep AEP** | Saves a reduced copy of the project in the export's version folder (see below) |
|
||||
|
||||
**No preview** exists for deliverables framed differently from the review —
|
||||
unscaled or un-punched-in EXRs. A preview rebuilt from those frames would be
|
||||
@@ -255,6 +256,37 @@ package still gets a MOV.
|
||||
Leave it unticked for an ordinary submission: the preview is what QC and the
|
||||
client review see.
|
||||
|
||||
#### Export AEP (Keep AEP)
|
||||
|
||||
With **Keep AEP** ticked (the default, remembered per machine), every export
|
||||
keeps a copy of the project it was queued from, so the exact comp behind a
|
||||
render can be reopened later:
|
||||
|
||||
```
|
||||
{version folder}/{shotCode}_cmp_TT_{version}.aep e.g. .../UNG_102_019_010/v005/UNG_102_019_010_cmp_TT_v005.aep
|
||||
```
|
||||
|
||||
- The copy is **reduced** to the exported comp and everything it uses (nested
|
||||
comps, footage, solids). Everything else in the project is dropped.
|
||||
- Nothing is collected. Plates and EXRs stay where they are and the copy links
|
||||
to them by path, so it stays a few MB.
|
||||
- It is saved after the export is submitted, into the same version folder the
|
||||
farm renders into. The worker only reads and clears `*.exr` files there, so
|
||||
the `.aep` is never touched. Re-queuing the same version overwrites it, just
|
||||
as the render overwrites the EXRs.
|
||||
- AE can only reduce the open project, so the panel does Save As, Reduce Project,
|
||||
Save, and then **reopens your project**. Your project was saved first and is
|
||||
never changed, but the reopen clears undo. Untick **Keep AEP** to skip it.
|
||||
- The copy is the project as it was when you queued. The farm still renders
|
||||
your working AEP, so a save made before the job starts goes into the render
|
||||
but not into the copy.
|
||||
- Reduce Project keeps only comps that are used as layers. An expression that
|
||||
points at a comp with `comp("Name")`, where that comp isn't nested anywhere,
|
||||
will break in the copy.
|
||||
|
||||
If the copy can't be saved, the export is still queued and the status line says
|
||||
`AEP not saved: …` with the reason.
|
||||
|
||||
---
|
||||
|
||||
## QC
|
||||
@@ -267,10 +299,63 @@ QC is per-export: a new export always needs new QC.
|
||||
|---|---|
|
||||
| **Load QC Queue** | Lists every export in `READY_FOR_QC` for the selected project, oldest first. Entries flagged with a warning count had a non-blocking validation warning worth a closer look. |
|
||||
| **Open Render** (or double-click) | Imports that export's actual EXR sequence into a `QC_{shot}_{version}` comp at full res and opens it. Re-selecting an already-imported shot just reopens the comp. |
|
||||
| **Compare Versions** | Opens the QC comp and stacks earlier versions of the shot under the export, one layer each (`v003`, `v002`…), lined up by EXR timecode (or frame number). Solo a layer to see that version, or set the top layer to **Difference** to see exactly what changed. With more than one earlier version, a dialog lets you untick the ones you don't need. Versions already in the comp are skipped. |
|
||||
| **Build QC Review Session** | Lays out the whole project's QC pass in one go. Every shot in the queue gets its `QC_{shot}_{version}` comp, and each scene gets an edit and a contact sheet. See *QC review session* below. |
|
||||
| **Notes** | Sent with the decision. Optional on pass; a fail with no notes asks for confirmation, because the artist only sees what you write here. |
|
||||
| **QC Pass** | Marks the version **ready for delivery** and nothing else — nothing is shared to the client, no approval state changes, no task moves. |
|
||||
| **QC Fail** | Sets the export to `QC_FAILED` and the comp task to **CHANGES**. The artist fixes and queues a new version; the old export is superseded. |
|
||||
|
||||
**Where Compare Versions looks:** next to the export's own render folder (resolved
|
||||
as for Open Render), in both on-disk layouts. That means farm version folders
|
||||
(`{shot}/v002/`, `{shot}/v003/`…) and the older flat folder with
|
||||
`{shot}_cmp_TT_{ver}.#####.exr` side by side. Only versions numbered below the
|
||||
export's are used. If earlier exports were written under a different root (see
|
||||
*More than one on-disk convention*), they won't be found.
|
||||
|
||||
### QC review session
|
||||
|
||||
**Build QC Review Session** loads the queue for the selected project. A dialog
|
||||
lists its scenes. Ctrl-click a scene to leave it out, or untick *Also import
|
||||
earlier versions*. Everything is built in one undo step, under
|
||||
`QC_SESSION_{project}` in the Project panel:
|
||||
|
||||
| Item | What it is |
|
||||
|---|---|
|
||||
| `{scene}/shots/QC_{shot}_{version}` | One comp per shot, reusing the comp from Open Render if there is one. The export sits on top, earlier versions under it (`v003`, `v002`…), and the shot's plates at the bottom, found as Build Shot finds them. **Only the export and the main plate (the longest) are switched on.** |
|
||||
| `{scene}/QC_EDIT_{scene}` | The scene's shot comps as one continuous edit. Each shot is cut to the edit, with the handles the render carries trimmed off, and has a layer marker with its name. |
|
||||
| `{scene}/QC_CONTACT_{scene}` | Every shot of the scene in a grid, each starting at its cut in, with its name under it. |
|
||||
| `_footage` | The EXR sequences it imported. Plates already in the project are reused, not imported again. |
|
||||
|
||||
A scene is the shot record's scene, which is not always the scene in the shot
|
||||
code. Episodic shows group by episode too (`UNG_109_SC013`), and standard ones
|
||||
by show (`DH2_VFX_SC033`). Shots run in sequence-timecode order when every shot
|
||||
in the scene has one, and in shot-code order otherwise. Only the newest queued
|
||||
version of a shot gets a comp; older queued versions appear as earlier versions
|
||||
in it.
|
||||
|
||||
Plates and earlier versions are lined up with the export by EXR timecode. A
|
||||
timecode more than a shot's length away is ignored, because a shot's elements
|
||||
can carry unrelated camera timecodes. The file frame number is used next, then
|
||||
the export's first frame. Exports from before handles were recorded have no
|
||||
handle count, so they play in full in the edit, and the status line counts them.
|
||||
|
||||
Running the button again adds anything new to the shot comps and rebuilds the
|
||||
scene edits and contact sheets from scratch. Don't do your own work in those
|
||||
two comps.
|
||||
|
||||
**Approving from the session.** QC Pass and QC Fail act on the shot in front of
|
||||
you, without finding it in the list:
|
||||
|
||||
- the `QC_{shot}_{version}` comp in the viewer, or
|
||||
- the shot layer (or its label) selected in a scene edit or contact sheet, or
|
||||
- with nothing selected in a scene edit, the shot under the playhead.
|
||||
|
||||
The confirmation names the shot, and a fail with notes is confirmed too when it
|
||||
came from the viewer. If a scene comp is active and no shot is picked, nothing
|
||||
is sent. Pick a shot, or switch to another comp to use the list selection. After
|
||||
a decision, that shot's comp and its layers in the scene comps are labelled
|
||||
**green** (pass) or **red** (fail).
|
||||
|
||||
Passing an export is what makes it eligible for a delivery package on the web
|
||||
app's **Pipeline → Deliveries** page.
|
||||
|
||||
|
||||
@@ -0,0 +1,196 @@
|
||||
"use server";
|
||||
|
||||
import { auth } from "@/auth";
|
||||
import { db } from "@/lib/db";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { z } from "zod";
|
||||
import { findShot, parseBoardText } from "@/lib/board-parse";
|
||||
|
||||
// The board is studio-internal. Anyone on staff can add and tick off lines;
|
||||
// it is a shared to-do list, not an approval surface.
|
||||
async function requireStaff() {
|
||||
const session = await auth();
|
||||
if (!session?.user) throw new Error("Unauthorized");
|
||||
if (session.user.role === "CLIENT") throw new Error("Insufficient permissions");
|
||||
return session.user;
|
||||
}
|
||||
|
||||
async function boardContext(projectId: string) {
|
||||
const [shots, users] = await Promise.all([
|
||||
db.shot.findMany({
|
||||
where: { projectId },
|
||||
select: { id: true, shotCode: true, clientCode: true },
|
||||
}),
|
||||
db.user.findMany({
|
||||
where: { isActive: true, role: { not: "CLIENT" } },
|
||||
select: { id: true, name: true, email: true },
|
||||
}),
|
||||
]);
|
||||
return { shots, users };
|
||||
}
|
||||
|
||||
const addSchema = z.object({
|
||||
projectId: z.string().cuid(),
|
||||
input: z.string().min(1).max(20000),
|
||||
group: z.string().max(100).optional(),
|
||||
});
|
||||
|
||||
/** Adds one line, or a pasted block of lines, to a project's board. */
|
||||
export async function addBoardItems(data: z.infer<typeof addSchema>) {
|
||||
const user = await requireStaff();
|
||||
const parsed = addSchema.parse(data);
|
||||
|
||||
const items = parseBoardText(parsed.input, {
|
||||
...(await boardContext(parsed.projectId)),
|
||||
group: parsed.group,
|
||||
});
|
||||
if (items.length === 0) return { success: true, added: 0, unmatched: [] as string[] };
|
||||
|
||||
const last = await db.boardItem.findFirst({
|
||||
where: { projectId: parsed.projectId },
|
||||
orderBy: { sortOrder: "desc" },
|
||||
select: { sortOrder: true },
|
||||
});
|
||||
const base = (last?.sortOrder ?? -1) + 1;
|
||||
|
||||
await db.boardItem.createMany({
|
||||
data: items.map((item, i) => ({
|
||||
projectId: parsed.projectId,
|
||||
shotId: item.shotId,
|
||||
code: item.code,
|
||||
text: item.text,
|
||||
group: item.group,
|
||||
assigneeId: item.assigneeId,
|
||||
waitingOn: item.waitingOn,
|
||||
sortOrder: base + i,
|
||||
createdById: user.id,
|
||||
})),
|
||||
});
|
||||
|
||||
revalidatePath("/board");
|
||||
return {
|
||||
success: true,
|
||||
added: items.length,
|
||||
unmatched: items.filter((i) => i.code && !i.shotId).map((i) => i.code as string),
|
||||
};
|
||||
}
|
||||
|
||||
const updateSchema = z.object({
|
||||
text: z.string().max(5000).optional(),
|
||||
code: z.string().max(100).nullable().optional(),
|
||||
group: z.string().max(100).optional(),
|
||||
assigneeId: z.string().cuid().nullable().optional(),
|
||||
waitingOn: z.string().max(500).nullable().optional(),
|
||||
});
|
||||
|
||||
export async function updateBoardItem(id: string, data: z.infer<typeof updateSchema>) {
|
||||
await requireStaff();
|
||||
const parsed = updateSchema.parse(data);
|
||||
const item = await db.boardItem.findUnique({ where: { id }, select: { projectId: true } });
|
||||
if (!item) throw new Error("Board item not found");
|
||||
|
||||
// Changing the code re-links the line; a code that matches nothing is kept
|
||||
// as a flag, exactly as when it was first typed.
|
||||
let link: { code: string | null; shotId: string | null } | undefined;
|
||||
if (parsed.code !== undefined) {
|
||||
const code = parsed.code?.trim() || null;
|
||||
const shot = code ? findShot(code, (await boardContext(item.projectId)).shots) : null;
|
||||
link = { code: shot?.shotCode ?? code?.toUpperCase() ?? null, shotId: shot?.id ?? null };
|
||||
}
|
||||
|
||||
await db.boardItem.update({
|
||||
where: { id },
|
||||
data: {
|
||||
...(parsed.text !== undefined && { text: parsed.text.trim() }),
|
||||
...(parsed.group !== undefined && { group: parsed.group.trim() }),
|
||||
...(parsed.assigneeId !== undefined && { assigneeId: parsed.assigneeId }),
|
||||
...(parsed.waitingOn !== undefined && { waitingOn: parsed.waitingOn?.trim() || null }),
|
||||
...link,
|
||||
},
|
||||
});
|
||||
|
||||
revalidatePath("/board");
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
export async function setBoardItemDone(id: string, done: boolean) {
|
||||
const user = await requireStaff();
|
||||
const item = await db.boardItem.update({
|
||||
where: { id },
|
||||
data: done ? { doneAt: new Date(), doneById: user.id } : { doneAt: null, doneById: null },
|
||||
select: { commentId: true },
|
||||
});
|
||||
// A line from pasted feedback is that client note: ticking it off resolves
|
||||
// the comment in the player too. (The comment may have been deleted there.)
|
||||
if (item.commentId) {
|
||||
const comment = await db.comment.updateMany({
|
||||
where: { id: item.commentId },
|
||||
data: { isResolved: done },
|
||||
});
|
||||
if (comment.count) {
|
||||
const c = await db.comment.findUnique({ where: { id: item.commentId }, select: { versionId: true } });
|
||||
if (c) revalidatePath(`/review/${c.versionId}`);
|
||||
}
|
||||
}
|
||||
revalidatePath("/board");
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
export async function deleteBoardItem(id: string) {
|
||||
await requireStaff();
|
||||
await db.boardItem.delete({ where: { id } });
|
||||
revalidatePath("/board");
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
const statusSchema = z.object({
|
||||
projectId: z.string().cuid(),
|
||||
status: z.string().max(2000),
|
||||
});
|
||||
|
||||
export async function setProjectBoardStatus(data: z.infer<typeof statusSchema>) {
|
||||
await requireStaff();
|
||||
const parsed = statusSchema.parse(data);
|
||||
const status = parsed.status.trim() || null;
|
||||
await db.project.update({
|
||||
where: { id: parsed.projectId },
|
||||
data: { boardStatus: status, boardStatusAt: status ? new Date() : null },
|
||||
});
|
||||
revalidatePath("/board");
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
const milestoneSchema = z.object({
|
||||
projectId: z.string().cuid(),
|
||||
label: z.string().min(1).max(200),
|
||||
date: z.string().min(1),
|
||||
});
|
||||
|
||||
export async function addMilestone(data: z.infer<typeof milestoneSchema>) {
|
||||
await requireStaff();
|
||||
const parsed = milestoneSchema.parse(data);
|
||||
const date = new Date(parsed.date);
|
||||
if (isNaN(date.getTime())) throw new Error("Invalid date");
|
||||
await db.projectMilestone.create({
|
||||
data: { projectId: parsed.projectId, label: parsed.label.trim(), date },
|
||||
});
|
||||
revalidatePath("/board");
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
export async function setMilestoneDone(id: string, done: boolean) {
|
||||
await requireStaff();
|
||||
await db.projectMilestone.update({
|
||||
where: { id },
|
||||
data: { doneAt: done ? new Date() : null },
|
||||
});
|
||||
revalidatePath("/board");
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
export async function deleteMilestone(id: string) {
|
||||
await requireStaff();
|
||||
await db.projectMilestone.delete({ where: { id } });
|
||||
revalidatePath("/board");
|
||||
return { success: true };
|
||||
}
|
||||
@@ -0,0 +1,253 @@
|
||||
"use server";
|
||||
|
||||
import { auth } from "@/auth";
|
||||
import { db } from "@/lib/db";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { z } from "zod";
|
||||
import { findShot, suggestShot, type BoardShot } from "@/lib/board-parse";
|
||||
import { parseFeedback, slateFrames, toPlayerFrame } from "@/lib/feedback-parse";
|
||||
import { updateTaskStatus } from "@/actions/tasks";
|
||||
|
||||
/** Comment.source for notes pasted from a client message */
|
||||
const SOURCE = "WHATSAPP";
|
||||
|
||||
async function requireStaff() {
|
||||
const session = await auth();
|
||||
if (!session?.user) throw new Error("Unauthorized");
|
||||
if (session.user.role === "CLIENT") throw new Error("Insufficient permissions");
|
||||
return session.user;
|
||||
}
|
||||
|
||||
/**
|
||||
* The shot a pasted code means: exact code or client alias first, then a code
|
||||
* the client shortened by dropping the show prefix ("113_018_040" for
|
||||
* "UNG_113_018_040") when exactly one shot ends with it.
|
||||
*/
|
||||
function resolveShot<T extends BoardShot>(code: string, shots: T[]): T | null {
|
||||
const exact = findShot(code, shots) as T | null;
|
||||
if (exact) return exact;
|
||||
const tail = `_${code.toUpperCase()}`;
|
||||
const hits = shots.filter((s) => s.shotCode.toUpperCase().endsWith(tail));
|
||||
return hits.length === 1 ? hits[0] : null;
|
||||
}
|
||||
|
||||
export interface FeedbackVersionOption {
|
||||
id: string;
|
||||
label: string;
|
||||
sent: boolean;
|
||||
sharedAt: string | null;
|
||||
taskId: string | null;
|
||||
taskStatus: string | null;
|
||||
/** The note's quoted frame converted for this version's media; null = no frame quoted */
|
||||
playerFrame: number | null;
|
||||
fromComp: boolean;
|
||||
}
|
||||
|
||||
export interface FeedbackPreviewNote {
|
||||
key: string;
|
||||
code: string;
|
||||
text: string;
|
||||
quotedFrame: number | null;
|
||||
shot: { id: string; shotCode: string } | null;
|
||||
suggestion: string | null;
|
||||
versions: FeedbackVersionOption[];
|
||||
defaultVersionId: string | null;
|
||||
}
|
||||
|
||||
export interface FeedbackPreview {
|
||||
rounds: { title: string; dueText: string | null; notes: FeedbackPreviewNote[] }[];
|
||||
ignored: string[];
|
||||
}
|
||||
|
||||
export async function previewFeedback(projectId: string, input: string): Promise<FeedbackPreview> {
|
||||
await requireStaff();
|
||||
z.string().cuid().parse(projectId);
|
||||
const parsed = parseFeedback(z.string().max(50000).parse(input));
|
||||
|
||||
const shots = await db.shot.findMany({
|
||||
where: { projectId },
|
||||
select: { id: true, shotCode: true, clientCode: true, frameStart: true },
|
||||
});
|
||||
|
||||
const matched = new Map<string, (typeof shots)[number] | null>();
|
||||
for (const r of parsed.rounds) for (const n of r.notes) {
|
||||
const code = n.codes[0];
|
||||
if (!matched.has(code)) matched.set(code, resolveShot(code, shots));
|
||||
}
|
||||
const shotIds = [...new Set([...matched.values()].filter(Boolean).map((s) => s!.id))];
|
||||
|
||||
// Recent versions per shot, whether hung off the shot or its task
|
||||
const versions = shotIds.length
|
||||
? await db.version.findMany({
|
||||
where: { OR: [{ shotId: { in: shotIds } }, { task: { shotId: { in: shotIds } } }] },
|
||||
orderBy: { createdAt: "desc" },
|
||||
select: {
|
||||
id: true,
|
||||
versionNumber: true,
|
||||
shotId: true,
|
||||
isClientVisible: true,
|
||||
sharedAt: true,
|
||||
frameCount: true,
|
||||
pictureStartFrame: true,
|
||||
task: { select: { id: true, status: true, shotId: true } },
|
||||
},
|
||||
})
|
||||
: [];
|
||||
const byShot = new Map<string, typeof versions>();
|
||||
for (const v of versions) {
|
||||
const sid = v.shotId ?? v.task?.shotId;
|
||||
if (!sid) continue;
|
||||
const list = byShot.get(sid) ?? [];
|
||||
if (list.length < 6) list.push(v);
|
||||
byShot.set(sid, list);
|
||||
}
|
||||
|
||||
let k = 0;
|
||||
return {
|
||||
ignored: parsed.ignored,
|
||||
rounds: parsed.rounds.map((r) => ({
|
||||
title: r.title,
|
||||
dueText: r.dueText,
|
||||
notes: r.notes.map((n) => {
|
||||
const code = n.codes[0];
|
||||
const shot = matched.get(code) ?? null;
|
||||
const options: FeedbackVersionOption[] = (shot ? byShot.get(shot.id) ?? [] : []).map((v) => {
|
||||
const conv = n.frame != null
|
||||
? toPlayerFrame(n.frame, {
|
||||
shotFrameStart: shot!.frameStart,
|
||||
pictureStart: slateFrames(v),
|
||||
frameCount: v.frameCount,
|
||||
})
|
||||
: null;
|
||||
return {
|
||||
id: v.id,
|
||||
label: `v${String(v.versionNumber).padStart(3, "0")}`,
|
||||
sent: v.isClientVisible,
|
||||
sharedAt: v.sharedAt?.toISOString() ?? null,
|
||||
taskId: v.task?.id ?? null,
|
||||
taskStatus: v.task?.status ?? null,
|
||||
playerFrame: conv?.frame ?? null,
|
||||
fromComp: conv?.fromComp ?? false,
|
||||
};
|
||||
});
|
||||
// The client is commenting on what they were sent
|
||||
const def = options.find((o) => o.sent) ?? options[0] ?? null;
|
||||
return {
|
||||
key: `n${k++}`,
|
||||
code: shot?.shotCode ?? code,
|
||||
text: n.text,
|
||||
quotedFrame: n.frame,
|
||||
shot: shot ? { id: shot.id, shotCode: shot.shotCode } : null,
|
||||
suggestion: shot ? null : suggestShot(code, shots)?.shotCode ?? null,
|
||||
versions: options,
|
||||
defaultVersionId: def?.id ?? null,
|
||||
};
|
||||
}),
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
const commitSchema = z.object({
|
||||
projectId: z.string().cuid(),
|
||||
rounds: z.array(z.object({
|
||||
title: z.string().max(200),
|
||||
dueAt: z.string().datetime().nullable(),
|
||||
notes: z.array(z.object({
|
||||
code: z.string().min(1).max(100),
|
||||
shotId: z.string().cuid().nullable(),
|
||||
text: z.string().min(1).max(5000),
|
||||
versionId: z.string().cuid().nullable(),
|
||||
frame: z.number().int().min(0).nullable(),
|
||||
setChanges: z.boolean(),
|
||||
})).min(1),
|
||||
})).min(1),
|
||||
});
|
||||
|
||||
/**
|
||||
* Saves pasted client feedback: one FeedbackRound per round, each note as a
|
||||
* player comment (tagged as client feedback) and a board line, and — where
|
||||
* ticked — the version's task moved to Changes.
|
||||
*/
|
||||
export async function commitFeedback(data: z.infer<typeof commitSchema>) {
|
||||
const user = await requireStaff();
|
||||
const parsed = commitSchema.parse(data);
|
||||
|
||||
const notes = parsed.rounds.flatMap((r) => r.notes);
|
||||
const versionIds = [...new Set(notes.map((n) => n.versionId).filter(Boolean) as string[])];
|
||||
const versions = await db.version.findMany({
|
||||
where: { id: { in: versionIds } },
|
||||
select: { id: true, fps: true, shotId: true, task: { select: { id: true, shotId: true, status: true, projectId: true } }, shot: { select: { projectId: true } } },
|
||||
});
|
||||
const vById = new Map(versions.map((v) => [v.id, v]));
|
||||
for (const n of notes) {
|
||||
if (!n.versionId) continue;
|
||||
const v = vById.get(n.versionId);
|
||||
const projectOk = v && (v.shot?.projectId ?? v.task?.projectId) === parsed.projectId;
|
||||
const shotOk = v && (v.shotId ?? v.task?.shotId) === n.shotId;
|
||||
if (!projectOk || !shotOk) throw new Error(`Version does not belong to ${n.code}`);
|
||||
}
|
||||
|
||||
const last = await db.boardItem.findFirst({
|
||||
where: { projectId: parsed.projectId },
|
||||
orderBy: { sortOrder: "desc" },
|
||||
select: { sortOrder: true },
|
||||
});
|
||||
let sort = (last?.sortOrder ?? -1) + 1;
|
||||
|
||||
let comments = 0;
|
||||
await db.$transaction(async (tx) => {
|
||||
for (const r of parsed.rounds) {
|
||||
const round = await tx.feedbackRound.create({
|
||||
data: {
|
||||
projectId: parsed.projectId,
|
||||
title: r.title.trim() || "Client feedback",
|
||||
dueAt: r.dueAt ? new Date(r.dueAt) : null,
|
||||
createdById: user.id,
|
||||
},
|
||||
});
|
||||
for (const n of r.notes) {
|
||||
const v = n.versionId ? vById.get(n.versionId)! : null;
|
||||
const frame = n.frame ?? 0;
|
||||
const comment = v
|
||||
? await tx.comment.create({
|
||||
data: {
|
||||
versionId: v.id,
|
||||
authorId: user.id,
|
||||
frameNumber: frame,
|
||||
timestamp: frame / v.fps,
|
||||
text: n.text.trim(),
|
||||
source: SOURCE,
|
||||
},
|
||||
select: { id: true },
|
||||
})
|
||||
: null;
|
||||
if (comment) comments++;
|
||||
await tx.boardItem.create({
|
||||
data: {
|
||||
projectId: parsed.projectId,
|
||||
shotId: n.shotId,
|
||||
code: n.code.toUpperCase(),
|
||||
text: n.text.trim(),
|
||||
roundId: round.id,
|
||||
commentId: comment?.id ?? null,
|
||||
sortOrder: sort++,
|
||||
createdById: user.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Outside the transaction: updateTaskStatus notifies the artist and
|
||||
// recalculates shot status, exactly as moving the task by hand does.
|
||||
const tasks = new Set<string>();
|
||||
for (const n of notes) {
|
||||
const task = n.versionId ? vById.get(n.versionId)?.task : null;
|
||||
if (n.setChanges && task && task.status !== "CHANGES") tasks.add(task.id);
|
||||
}
|
||||
for (const taskId of tasks) await updateTaskStatus(taskId, "CHANGES");
|
||||
|
||||
for (const id of versionIds) revalidatePath(`/review/${id}`);
|
||||
revalidatePath("/board");
|
||||
return { success: true, notes: notes.length, comments, tasksChanged: tasks.size };
|
||||
}
|
||||
@@ -0,0 +1,689 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useRef, useState, useTransition } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import Link from "next/link";
|
||||
import { differenceInCalendarDays, format, formatDistanceToNowStrict } from "date-fns";
|
||||
import {
|
||||
AlertTriangle,
|
||||
Check,
|
||||
ChevronDown,
|
||||
ChevronRight,
|
||||
Clock,
|
||||
Flag,
|
||||
Link2,
|
||||
MessageSquareText,
|
||||
Pencil,
|
||||
Plus,
|
||||
Trash2,
|
||||
X,
|
||||
} from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
|
||||
import { useToast } from "@/components/ui/use-toast";
|
||||
import { cn, getInitials } from "@/lib/utils";
|
||||
import {
|
||||
addBoardItems,
|
||||
addMilestone,
|
||||
deleteBoardItem,
|
||||
deleteMilestone,
|
||||
setBoardItemDone,
|
||||
setMilestoneDone,
|
||||
setProjectBoardStatus,
|
||||
updateBoardItem,
|
||||
} from "@/actions/board";
|
||||
import { FeedbackPasteDialog } from "./FeedbackPasteDialog";
|
||||
|
||||
type User = { id: string; name: string | null; email: string; image: string | null };
|
||||
|
||||
type BoardItem = {
|
||||
id: string;
|
||||
text: string;
|
||||
code: string | null;
|
||||
group: string;
|
||||
waitingOn: string | null;
|
||||
round: { id: string; title: string; dueAt: string | null } | null;
|
||||
/** The player comment a pasted-feedback line was saved as */
|
||||
comment: { versionId: string; frame: number } | null;
|
||||
doneAt: string | null;
|
||||
assignee: { id: string; name: string | null; image: string | null } | null;
|
||||
shot: {
|
||||
id: string;
|
||||
shotCode: string;
|
||||
status: string;
|
||||
latest: { id: string; versionNumber: number; approvalStatus: string; isClientVisible: boolean } | null;
|
||||
} | null;
|
||||
relinkTo: string | null;
|
||||
relinkIsExact: boolean;
|
||||
};
|
||||
|
||||
export type BoardProject = {
|
||||
id: string;
|
||||
name: string;
|
||||
code: string;
|
||||
status: string;
|
||||
boardStatus: string | null;
|
||||
boardStatusAt: string | null;
|
||||
shotTotal: number;
|
||||
shotComplete: number;
|
||||
milestones: { id: string; label: string; date: string; doneAt: string | null }[];
|
||||
items: BoardItem[];
|
||||
};
|
||||
|
||||
const SHOT_STATUS: Record<string, { label: string; color: string }> = {
|
||||
WAITING: { label: "Waiting", color: "bg-zinc-500/10 text-zinc-400 border-zinc-500/20" },
|
||||
IN_PROGRESS: { label: "In Progress", color: "bg-blue-500/10 text-blue-400 border-blue-500/20" },
|
||||
INTERNAL_REVIEW: { label: "Internal Review", color: "bg-purple-500/10 text-purple-400 border-purple-500/20" },
|
||||
READY_FOR_CLIENT: { label: "Ready for Client", color: "bg-cyan-500/10 text-cyan-400 border-cyan-500/20" },
|
||||
CLIENT_REVIEW: { label: "Client Review", color: "bg-indigo-500/10 text-indigo-400 border-indigo-500/20" },
|
||||
REVISIONS: { label: "Revisions", color: "bg-orange-500/10 text-orange-400 border-orange-500/20" },
|
||||
COMPLETE: { label: "Complete", color: "bg-green-500/10 text-green-400 border-green-500/20" },
|
||||
};
|
||||
|
||||
const APPROVAL: Record<string, { label: string; color: string }> = {
|
||||
PENDING_REVIEW: { label: "pending", color: "text-zinc-500" },
|
||||
APPROVED: { label: "approved", color: "text-green-400" },
|
||||
REJECTED: { label: "rejected", color: "text-red-400" },
|
||||
NEEDS_CHANGES: { label: "changes", color: "text-orange-400" },
|
||||
};
|
||||
|
||||
export function BoardClient({
|
||||
projects,
|
||||
users,
|
||||
who,
|
||||
}: {
|
||||
projects: BoardProject[];
|
||||
users: User[];
|
||||
who: string | null;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
|
||||
const filters = [
|
||||
{ key: null, label: "Everyone" },
|
||||
...users.map((u) => ({ key: u.id, label: u.name?.split(" ")[0] ?? u.email })),
|
||||
{ key: "none", label: "Unassigned" },
|
||||
];
|
||||
|
||||
return (
|
||||
<div className="p-4 md:p-8 max-w-5xl">
|
||||
<div className="mb-6 flex flex-wrap items-end justify-between gap-4">
|
||||
<div>
|
||||
<h1 className="text-3xl font-bold text-white">Board</h1>
|
||||
<p className="text-zinc-400 mt-1">{format(new Date(), "EEEE, d MMMM yyyy")}</p>
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-1 rounded-lg border border-zinc-800 bg-zinc-900 p-1">
|
||||
{filters.map((f) => (
|
||||
<button
|
||||
key={f.key ?? "all"}
|
||||
type="button"
|
||||
onClick={() => router.push(f.key ? `/board?who=${f.key}` : "/board")}
|
||||
className={cn(
|
||||
"rounded-md px-3 py-1 text-xs font-medium transition-colors",
|
||||
who === f.key ? "bg-amber-500/10 text-amber-400" : "text-zinc-400 hover:text-white",
|
||||
)}
|
||||
>
|
||||
{f.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{projects.length === 0 && (
|
||||
<p className="text-sm text-zinc-500">No active or on-hold projects.</p>
|
||||
)}
|
||||
|
||||
<div className="space-y-6">
|
||||
{projects.map((p) => (
|
||||
<ProjectSection key={p.id} project={p} users={users} who={who} />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function ProjectSection({ project, users, who }: { project: BoardProject; users: User[]; who: string | null }) {
|
||||
const [showDone, setShowDone] = useState(false);
|
||||
const [pasting, setPasting] = useState(false);
|
||||
|
||||
const visible = project.items.filter((i) =>
|
||||
who === null ? true : who === "none" ? !i.assignee : i.assignee?.id === who,
|
||||
);
|
||||
const open = visible.filter((i) => !i.doneAt);
|
||||
const done = visible.filter((i) => i.doneAt);
|
||||
// Pasted feedback stays together under its round, flags and all
|
||||
const rounds: { round: NonNullable<BoardItem["round"]>; items: BoardItem[] }[] = [];
|
||||
for (const item of open) {
|
||||
if (!item.round) continue;
|
||||
let r = rounds.find((x) => x.round.id === item.round!.id);
|
||||
if (!r) rounds.push((r = { round: item.round, items: [] }));
|
||||
r.items.push(item);
|
||||
}
|
||||
rounds.sort((a, b) => (a.round.dueAt ?? "9").localeCompare(b.round.dueAt ?? "9"));
|
||||
const loose = open.filter((i) => !i.round);
|
||||
const flagged = loose.filter((i) => i.code && !i.shot);
|
||||
const waiting = loose.filter((i) => i.waitingOn && !(i.code && !i.shot));
|
||||
const rest = loose.filter((i) => !flagged.includes(i) && !waiting.includes(i));
|
||||
|
||||
// Groups keep the order they were first typed in
|
||||
const groups: { name: string; items: BoardItem[] }[] = [];
|
||||
for (const item of rest) {
|
||||
let g = groups.find((x) => x.name === item.group);
|
||||
if (!g) groups.push((g = { name: item.group, items: [] }));
|
||||
g.items.push(item);
|
||||
}
|
||||
groups.sort((a, b) => (a.name === "" ? -1 : b.name === "" ? 1 : 0));
|
||||
|
||||
const pct = project.shotTotal ? Math.round((project.shotComplete / project.shotTotal) * 100) : 0;
|
||||
|
||||
return (
|
||||
<section className="rounded-xl border border-zinc-800 bg-zinc-900">
|
||||
<header className="flex flex-wrap items-center gap-x-3 gap-y-1 border-b border-zinc-800 px-4 py-3">
|
||||
<Link href={`/projects/${project.id}`} className="text-lg font-semibold text-white hover:text-amber-400">
|
||||
{project.name}
|
||||
</Link>
|
||||
<span className="text-xs text-zinc-500">{project.code}</span>
|
||||
{project.status === "ON_HOLD" && (
|
||||
<span className="rounded border border-yellow-500/20 bg-yellow-500/10 px-1.5 py-0.5 text-[10px] font-medium text-yellow-400">
|
||||
On hold
|
||||
</span>
|
||||
)}
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="ml-auto h-7"
|
||||
onClick={() => setPasting(true)}
|
||||
title="Paste a client's feedback message"
|
||||
>
|
||||
<MessageSquareText /> Paste feedback
|
||||
</Button>
|
||||
{project.shotTotal > 0 && (
|
||||
<div className="flex items-center gap-2 text-xs text-zinc-400">
|
||||
<div className="h-1.5 w-24 overflow-hidden rounded-full bg-zinc-800">
|
||||
<div className="h-full bg-green-500/70" style={{ width: `${pct}%` }} />
|
||||
</div>
|
||||
{project.shotComplete}/{project.shotTotal} shots complete
|
||||
</div>
|
||||
)}
|
||||
</header>
|
||||
|
||||
<div className="space-y-4 px-4 py-3">
|
||||
<StatusLine project={project} />
|
||||
<Milestones project={project} />
|
||||
|
||||
{rounds.map(({ round, items }) => (
|
||||
<RoundBlock key={round.id} round={round} count={items.length}>
|
||||
{items.map((i) => <ItemRow key={i.id} item={i} users={users} projectId={project.id} />)}
|
||||
</RoundBlock>
|
||||
))}
|
||||
{flagged.length > 0 && (
|
||||
<ItemBlock title="Flags" icon={<Flag className="h-3.5 w-3.5 text-red-400" />}>
|
||||
{flagged.map((i) => <ItemRow key={i.id} item={i} users={users} projectId={project.id} />)}
|
||||
</ItemBlock>
|
||||
)}
|
||||
{waiting.length > 0 && (
|
||||
<ItemBlock title="Waiting on" icon={<Clock className="h-3.5 w-3.5 text-amber-400" />}>
|
||||
{waiting.map((i) => <ItemRow key={i.id} item={i} users={users} projectId={project.id} />)}
|
||||
</ItemBlock>
|
||||
)}
|
||||
{groups.map((g) => (
|
||||
<ItemBlock key={g.name || "_"} title={g.name}>
|
||||
{g.items.map((i) => <ItemRow key={i.id} item={i} users={users} projectId={project.id} />)}
|
||||
</ItemBlock>
|
||||
))}
|
||||
|
||||
<QuickAdd projectId={project.id} />
|
||||
|
||||
{done.length > 0 && (
|
||||
<div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setShowDone(!showDone)}
|
||||
className="flex items-center gap-1 text-xs text-zinc-500 hover:text-zinc-300"
|
||||
>
|
||||
{showDone ? <ChevronDown className="h-3.5 w-3.5" /> : <ChevronRight className="h-3.5 w-3.5" />}
|
||||
Done this week ({done.length})
|
||||
</button>
|
||||
{showDone && (
|
||||
<div className="mt-1">
|
||||
{done.map((i) => <ItemRow key={i.id} item={i} users={users} projectId={project.id} />)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<FeedbackPasteDialog
|
||||
projectId={project.id}
|
||||
projectName={project.name}
|
||||
open={pasting}
|
||||
onOpenChange={setPasting}
|
||||
/>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
function RoundBlock({
|
||||
round,
|
||||
count,
|
||||
children,
|
||||
}: {
|
||||
round: NonNullable<BoardItem["round"]>;
|
||||
count: number;
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
const due = round.dueAt ? new Date(round.dueAt) : null;
|
||||
const late = due && due.getTime() < Date.now();
|
||||
const days = due ? differenceInCalendarDays(due, new Date()) : null;
|
||||
const when = due
|
||||
? days === 0 ? `today ${format(due, "HH:mm")}` : days === 1 ? `tomorrow ${format(due, "HH:mm")}` : format(due, "d MMM HH:mm")
|
||||
: null;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="mb-1 flex flex-wrap items-center gap-1.5 text-xs uppercase tracking-wider text-zinc-500">
|
||||
<MessageSquareText className="h-3.5 w-3.5 text-indigo-400" />
|
||||
{round.title}
|
||||
{when && (
|
||||
<span
|
||||
className={cn(
|
||||
"rounded px-1.5 py-px normal-case tracking-normal",
|
||||
late ? "bg-red-500/10 text-red-300" : days !== null && days <= 1 ? "bg-amber-500/10 text-amber-300" : "text-zinc-400",
|
||||
)}
|
||||
>
|
||||
{late ? "overdue · " : "due "}{when}
|
||||
</span>
|
||||
)}
|
||||
<span className="normal-case tracking-normal text-zinc-600">{count} open</span>
|
||||
</div>
|
||||
<div className="divide-y divide-zinc-800/60">{children}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function ItemBlock({ title, icon, children }: { title: string; icon?: React.ReactNode; children: React.ReactNode }) {
|
||||
return (
|
||||
<div>
|
||||
{title && (
|
||||
<div className="mb-1 flex items-center gap-1.5 text-xs uppercase tracking-wider text-zinc-500">
|
||||
{icon}
|
||||
{title}
|
||||
</div>
|
||||
)}
|
||||
<div className="divide-y divide-zinc-800/60">{children}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function useAction() {
|
||||
const router = useRouter();
|
||||
const { toast } = useToast();
|
||||
const [isPending, startTransition] = useTransition();
|
||||
const run = (fn: () => Promise<unknown>, after?: () => void) =>
|
||||
startTransition(async () => {
|
||||
try {
|
||||
await fn();
|
||||
after?.();
|
||||
router.refresh();
|
||||
} catch (e) {
|
||||
toast({ title: "Couldn't save", description: (e as Error).message, variant: "destructive" });
|
||||
}
|
||||
});
|
||||
return { run, isPending };
|
||||
}
|
||||
|
||||
// ── Status line ──────────────────────────────────────────────────────────────
|
||||
|
||||
function StatusLine({ project }: { project: BoardProject }) {
|
||||
const [editing, setEditing] = useState(false);
|
||||
const [value, setValue] = useState(project.boardStatus ?? "");
|
||||
const { run, isPending } = useAction();
|
||||
|
||||
const save = () =>
|
||||
run(() => setProjectBoardStatus({ projectId: project.id, status: value }), () => setEditing(false));
|
||||
|
||||
if (editing) {
|
||||
return (
|
||||
<div className="space-y-1.5">
|
||||
<textarea
|
||||
autoFocus
|
||||
value={value}
|
||||
onChange={(e) => setValue(e.target.value)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter" && !e.shiftKey) { e.preventDefault(); save(); }
|
||||
if (e.key === "Escape") { setValue(project.boardStatus ?? ""); setEditing(false); }
|
||||
}}
|
||||
rows={2}
|
||||
placeholder="Where things stand — e.g. Awaiting feedback on pick-ups"
|
||||
className="w-full resize-y rounded-lg border border-zinc-700 bg-zinc-950 px-3 py-2 text-sm text-white placeholder:text-zinc-600 focus:border-amber-500/50 focus:outline-none"
|
||||
/>
|
||||
<div className="flex gap-2">
|
||||
<Button size="sm" onClick={save} disabled={isPending}>Save</Button>
|
||||
<Button size="sm" variant="ghost" onClick={() => { setValue(project.boardStatus ?? ""); setEditing(false); }}>
|
||||
Cancel
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setEditing(true)}
|
||||
className="group block w-full text-left"
|
||||
>
|
||||
{project.boardStatus ? (
|
||||
<p className="whitespace-pre-wrap text-sm text-zinc-200">
|
||||
{project.boardStatus}
|
||||
{project.boardStatusAt && (
|
||||
<span className="ml-2 text-xs text-zinc-600">
|
||||
{formatDistanceToNowStrict(new Date(project.boardStatusAt), { addSuffix: true })}
|
||||
</span>
|
||||
)}
|
||||
<Pencil className="ml-2 inline h-3 w-3 text-zinc-600 opacity-0 group-hover:opacity-100" />
|
||||
</p>
|
||||
) : (
|
||||
<p className="text-sm text-zinc-600 group-hover:text-zinc-400">+ Add a status line</p>
|
||||
)}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
// ── Milestones ───────────────────────────────────────────────────────────────
|
||||
|
||||
function Milestones({ project }: { project: BoardProject }) {
|
||||
const [adding, setAdding] = useState(false);
|
||||
const [label, setLabel] = useState("");
|
||||
const [date, setDate] = useState("");
|
||||
const { run, isPending } = useAction();
|
||||
|
||||
const add = () => {
|
||||
if (!label.trim() || !date) return;
|
||||
// Noon keeps the calendar day stable across the studio/server time zones
|
||||
run(() => addMilestone({ projectId: project.id, label, date: `${date}T12:00:00` }), () => {
|
||||
setLabel("");
|
||||
setDate("");
|
||||
setAdding(false);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex flex-wrap items-center gap-1.5">
|
||||
{project.milestones.map((m) => <MilestoneChip key={m.id} m={m} />)}
|
||||
{adding ? (
|
||||
<div className="flex flex-wrap items-center gap-1.5">
|
||||
<input
|
||||
autoFocus
|
||||
value={label}
|
||||
onChange={(e) => setLabel(e.target.value)}
|
||||
onKeyDown={(e) => e.key === "Enter" && add()}
|
||||
placeholder="e.g. Final delivery"
|
||||
className="h-7 w-40 rounded-md border border-zinc-700 bg-zinc-950 px-2 text-xs text-white placeholder:text-zinc-600 focus:outline-none"
|
||||
/>
|
||||
<input
|
||||
type="date"
|
||||
value={date}
|
||||
onChange={(e) => setDate(e.target.value)}
|
||||
onKeyDown={(e) => e.key === "Enter" && add()}
|
||||
className="h-7 rounded-md border border-zinc-700 bg-zinc-950 px-2 text-xs text-white [color-scheme:dark] focus:outline-none"
|
||||
/>
|
||||
<Button size="sm" className="h-7" onClick={add} disabled={isPending || !label.trim() || !date}>Add</Button>
|
||||
<Button size="sm" variant="ghost" className="h-7" onClick={() => setAdding(false)}>Cancel</Button>
|
||||
</div>
|
||||
) : (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setAdding(true)}
|
||||
className="flex h-7 items-center gap-1 rounded-md px-2 text-xs text-zinc-600 hover:bg-zinc-800 hover:text-zinc-300"
|
||||
>
|
||||
<Plus className="h-3 w-3" /> Date
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function MilestoneChip({ m }: { m: BoardProject["milestones"][number] }) {
|
||||
const { run } = useAction();
|
||||
const days = differenceInCalendarDays(new Date(m.date), new Date());
|
||||
const done = !!m.doneAt;
|
||||
const late = !done && days < 0;
|
||||
const soon = !done && days >= 0 && days <= 7;
|
||||
const when = done ? "done" : days === 0 ? "today" : days === 1 ? "tomorrow" : days > 0 ? `in ${days}d` : `${-days}d late`;
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
"group flex h-7 items-center gap-1.5 rounded-md border px-2 text-xs",
|
||||
done ? "border-zinc-800 text-zinc-600" :
|
||||
late ? "border-red-500/30 bg-red-500/10 text-red-300" :
|
||||
soon ? "border-amber-500/30 bg-amber-500/10 text-amber-300" :
|
||||
"border-zinc-700 text-zinc-300",
|
||||
)}
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
title={done ? "Mark not done" : "Mark done"}
|
||||
onClick={() => run(() => setMilestoneDone(m.id, !done))}
|
||||
className={cn(
|
||||
"flex h-3.5 w-3.5 items-center justify-center rounded-sm border",
|
||||
done ? "border-green-500/50 bg-green-500/20 text-green-400" : "border-current opacity-60 hover:opacity-100",
|
||||
)}
|
||||
>
|
||||
{done && <Check className="h-2.5 w-2.5" />}
|
||||
</button>
|
||||
<span className={cn(done && "line-through")}>{m.label}</span>
|
||||
<span className="opacity-70">{format(new Date(m.date), "d MMM")}</span>
|
||||
<span className="font-medium">· {when}</span>
|
||||
<button
|
||||
type="button"
|
||||
title="Remove"
|
||||
onClick={() => { if (confirm(`Remove "${m.label}"?`)) run(() => deleteMilestone(m.id)); }}
|
||||
className="hidden text-zinc-500 hover:text-red-400 group-hover:block"
|
||||
>
|
||||
<X className="h-3 w-3" />
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// ── Items ────────────────────────────────────────────────────────────────────
|
||||
|
||||
function ItemRow({ item, users, projectId }: { item: BoardItem; users: User[]; projectId: string }) {
|
||||
const [editing, setEditing] = useState(false);
|
||||
const { run, isPending } = useAction();
|
||||
const done = !!item.doneAt;
|
||||
const flagged = !!item.code && !item.shot;
|
||||
|
||||
if (editing) return <ItemEditor item={item} users={users} onClose={() => setEditing(false)} />;
|
||||
|
||||
const st = item.shot ? SHOT_STATUS[item.shot.status] : null;
|
||||
const v = item.shot?.latest;
|
||||
|
||||
return (
|
||||
<div className={cn("group flex items-start gap-2.5 py-1.5", isPending && "opacity-50")}>
|
||||
<button
|
||||
type="button"
|
||||
title={done ? "Mark not done" : "Mark done"}
|
||||
onClick={() => run(() => setBoardItemDone(item.id, !done))}
|
||||
className={cn(
|
||||
"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded border",
|
||||
done ? "border-green-500/50 bg-green-500/20 text-green-400" : "border-zinc-600 hover:border-zinc-400",
|
||||
)}
|
||||
>
|
||||
{done && <Check className="h-3 w-3" />}
|
||||
</button>
|
||||
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="flex flex-wrap items-center gap-x-2 gap-y-1 text-sm">
|
||||
{item.shot && (
|
||||
<Link
|
||||
href={`/projects/${projectId}/shots/${item.shot.id}`}
|
||||
className="font-mono text-xs text-amber-400 hover:underline"
|
||||
>
|
||||
{item.shot.shotCode}
|
||||
</Link>
|
||||
)}
|
||||
{flagged && (
|
||||
<span className="flex items-center gap-1 font-mono text-xs text-red-400" title="Not a shot in this project">
|
||||
<AlertTriangle className="h-3 w-3" />
|
||||
{item.code}
|
||||
</span>
|
||||
)}
|
||||
{st && !done && (
|
||||
<span className={cn("rounded border px-1.5 py-px text-[10px] font-medium", st.color)}>{st.label}</span>
|
||||
)}
|
||||
{v && !done && (
|
||||
<Link href={`/review/${v.id}`} className="text-[11px] text-zinc-500 hover:text-zinc-300">
|
||||
v{String(v.versionNumber).padStart(3, "0")}{" "}
|
||||
<span className={APPROVAL[v.approvalStatus]?.color}>{APPROVAL[v.approvalStatus]?.label}</span>
|
||||
{v.isClientVisible && <span className="text-indigo-400"> · sent</span>}
|
||||
</Link>
|
||||
)}
|
||||
<span className={cn("text-zinc-200", done && "text-zinc-600 line-through")}>{item.text}</span>
|
||||
{item.comment && (
|
||||
<Link
|
||||
href={`/review/${item.comment.versionId}`}
|
||||
className="text-[11px] text-indigo-400/80 hover:text-indigo-300"
|
||||
title="Open the note in the player"
|
||||
>
|
||||
note @ F{item.comment.frame}
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{(item.waitingOn || (flagged && !done)) && (
|
||||
<div className="mt-1 flex flex-wrap items-center gap-2 text-xs">
|
||||
{item.waitingOn && (
|
||||
<span className="flex items-center gap-1 rounded bg-amber-500/10 px-1.5 py-0.5 text-amber-300">
|
||||
<Clock className="h-3 w-3" /> Waiting on {item.waitingOn}
|
||||
</span>
|
||||
)}
|
||||
{flagged && !done && (
|
||||
item.relinkTo ? (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => run(() => updateBoardItem(item.id, { code: item.relinkTo }))}
|
||||
className="flex items-center gap-1 text-zinc-400 hover:text-amber-400"
|
||||
>
|
||||
<Link2 className="h-3 w-3" />
|
||||
{item.relinkIsExact ? `${item.relinkTo} exists now. Link it` : `Did you mean ${item.relinkTo}?`}
|
||||
</button>
|
||||
) : (
|
||||
<span className="text-zinc-500">Not a shot in this project</span>
|
||||
)
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{item.assignee && (
|
||||
<span className="flex shrink-0 items-center gap-1.5 text-xs text-zinc-400" title={item.assignee.name ?? ""}>
|
||||
<Avatar className="h-5 w-5">
|
||||
{item.assignee.image && <AvatarImage src={item.assignee.image} />}
|
||||
<AvatarFallback className="text-[9px]">{getInitials(item.assignee.name)}</AvatarFallback>
|
||||
</Avatar>
|
||||
<span className="hidden sm:inline">{item.assignee.name?.split(" ")[0]}</span>
|
||||
</span>
|
||||
)}
|
||||
|
||||
<div className="flex shrink-0 gap-0.5 opacity-100 md:opacity-0 md:group-hover:opacity-100">
|
||||
<button type="button" title="Edit" onClick={() => setEditing(true)} className="rounded p-1 text-zinc-500 hover:bg-zinc-800 hover:text-white">
|
||||
<Pencil className="h-3.5 w-3.5" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
title="Delete"
|
||||
onClick={() => { if (confirm("Delete this line?")) run(() => deleteBoardItem(item.id)); }}
|
||||
className="rounded p-1 text-zinc-500 hover:bg-zinc-800 hover:text-red-400"
|
||||
>
|
||||
<Trash2 className="h-3.5 w-3.5" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function ItemEditor({ item, users, onClose }: { item: BoardItem; users: User[]; onClose: () => void }) {
|
||||
const [code, setCode] = useState(item.shot?.shotCode ?? item.code ?? "");
|
||||
const [text, setText] = useState(item.text);
|
||||
const [assigneeId, setAssigneeId] = useState(item.assignee?.id ?? "");
|
||||
const [waitingOn, setWaitingOn] = useState(item.waitingOn ?? "");
|
||||
const [group, setGroup] = useState(item.group);
|
||||
const { run, isPending } = useAction();
|
||||
|
||||
const save = () =>
|
||||
run(
|
||||
() => updateBoardItem(item.id, { code, text, assigneeId: assigneeId || null, waitingOn, group }),
|
||||
onClose,
|
||||
);
|
||||
|
||||
const field = "h-8 rounded-md border border-zinc-700 bg-zinc-950 px-2 text-xs text-white placeholder:text-zinc-600 focus:border-amber-500/50 focus:outline-none";
|
||||
|
||||
return (
|
||||
<div
|
||||
className="my-1 grid grid-cols-1 gap-2 rounded-lg border border-zinc-700 bg-zinc-950/50 p-2 sm:grid-cols-[10rem_1fr]"
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter") { e.preventDefault(); save(); }
|
||||
if (e.key === "Escape") onClose();
|
||||
}}
|
||||
>
|
||||
<input value={code} onChange={(e) => setCode(e.target.value)} placeholder="Shot code" className={cn(field, "font-mono")} />
|
||||
<input autoFocus value={text} onChange={(e) => setText(e.target.value)} placeholder="Note" className={field} />
|
||||
<select value={assigneeId} onChange={(e) => setAssigneeId(e.target.value)} className={field}>
|
||||
<option value="">Unassigned</option>
|
||||
{users.map((u) => <option key={u.id} value={u.id}>{u.name ?? u.email}</option>)}
|
||||
</select>
|
||||
<input value={waitingOn} onChange={(e) => setWaitingOn(e.target.value)} placeholder="Waiting on (blank = not blocked)" className={field} />
|
||||
<input value={group} onChange={(e) => setGroup(e.target.value)} placeholder="Heading (optional)" className={field} />
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button size="sm" variant="ghost" onClick={onClose}>Cancel</Button>
|
||||
<Button size="sm" onClick={save} disabled={isPending}>Save</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function QuickAdd({ projectId }: { projectId: string }) {
|
||||
const [value, setValue] = useState("");
|
||||
const ref = useRef<HTMLTextAreaElement>(null);
|
||||
const { toast } = useToast();
|
||||
const { run, isPending } = useAction();
|
||||
|
||||
// Grow with pasted blocks
|
||||
useEffect(() => {
|
||||
const el = ref.current;
|
||||
if (!el) return;
|
||||
el.style.height = "auto";
|
||||
el.style.height = `${Math.min(el.scrollHeight, 320)}px`;
|
||||
}, [value]);
|
||||
|
||||
const submit = () => {
|
||||
if (!value.trim()) return;
|
||||
run(async () => {
|
||||
const res = await addBoardItems({ projectId, input: value });
|
||||
if (res.unmatched.length) {
|
||||
toast({
|
||||
title: `${res.unmatched.length} code${res.unmatched.length === 1 ? "" : "s"} not in this project`,
|
||||
description: `${res.unmatched.join(", ")}: flagged on the board.`,
|
||||
});
|
||||
}
|
||||
}, () => setValue(""));
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<textarea
|
||||
ref={ref}
|
||||
value={value}
|
||||
onChange={(e) => setValue(e.target.value)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter" && !e.shiftKey) { e.preventDefault(); submit(); }
|
||||
}}
|
||||
rows={1}
|
||||
disabled={isPending}
|
||||
placeholder="Add a line, e.g. SHOT_CODE finalise (Chris) wait: client GFX, or paste a list"
|
||||
className="w-full resize-none rounded-lg border border-dashed border-zinc-700 bg-transparent px-3 py-2 text-sm text-white placeholder:text-zinc-600 focus:border-solid focus:border-amber-500/50 focus:outline-none"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,342 @@
|
||||
"use client";
|
||||
|
||||
import { useState, useTransition } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { format } from "date-fns";
|
||||
import { AlertTriangle, ArrowLeft, Link2, MessageSquareText } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
||||
import { useToast } from "@/components/ui/use-toast";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { parseDue } from "@/lib/feedback-parse";
|
||||
import { commitFeedback, previewFeedback, type FeedbackPreview, type FeedbackPreviewNote } from "@/actions/feedback";
|
||||
|
||||
type NoteState = {
|
||||
include: boolean;
|
||||
text: string;
|
||||
versionId: string | null;
|
||||
/** Typed frame; null = use the selected version's converted frame */
|
||||
frame: string | null;
|
||||
setChanges: boolean;
|
||||
};
|
||||
type RoundState = { title: string; due: string; notes: Record<string, NoteState> };
|
||||
|
||||
const LOCAL_DT = "yyyy-MM-dd'T'HH:mm";
|
||||
|
||||
function initialState(preview: FeedbackPreview): RoundState[] {
|
||||
return preview.rounds.map((r) => {
|
||||
const due = parseDue(r.dueText);
|
||||
return {
|
||||
title: r.title || `Feedback ${format(new Date(), "d MMM")}`,
|
||||
due: due ? format(due, LOCAL_DT) : "",
|
||||
notes: Object.fromEntries(
|
||||
r.notes.map((n) => [
|
||||
n.key,
|
||||
{ include: true, text: n.text, versionId: n.defaultVersionId, frame: null, setChanges: true },
|
||||
]),
|
||||
),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export function FeedbackPasteDialog({
|
||||
projectId,
|
||||
projectName,
|
||||
open,
|
||||
onOpenChange,
|
||||
}: {
|
||||
projectId: string;
|
||||
projectName: string;
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const { toast } = useToast();
|
||||
const [input, setInput] = useState("");
|
||||
const [preview, setPreview] = useState<FeedbackPreview | null>(null);
|
||||
const [rounds, setRounds] = useState<RoundState[]>([]);
|
||||
const [isPending, startTransition] = useTransition();
|
||||
|
||||
const reset = () => {
|
||||
setInput("");
|
||||
setPreview(null);
|
||||
setRounds([]);
|
||||
};
|
||||
|
||||
const read = (text: string) =>
|
||||
startTransition(async () => {
|
||||
try {
|
||||
const p = await previewFeedback(projectId, text);
|
||||
if (p.rounds.length === 0) {
|
||||
toast({ title: "No shot notes found", description: "Each note needs to start with a shot code.", variant: "destructive" });
|
||||
return;
|
||||
}
|
||||
setPreview(p);
|
||||
setRounds(initialState(p));
|
||||
} catch (e) {
|
||||
toast({ title: "Couldn't read feedback", description: (e as Error).message, variant: "destructive" });
|
||||
}
|
||||
});
|
||||
|
||||
// Accepting a suggested code rewrites the paste and reads it again, so
|
||||
// everything downstream (versions, frames) comes from the real shot.
|
||||
const applySuggestion = (code: string, suggestion: string) => {
|
||||
const next = input.split(code).join(suggestion);
|
||||
setInput(next);
|
||||
read(next);
|
||||
};
|
||||
|
||||
const updateNote = (ri: number, key: string, patch: Partial<NoteState>) =>
|
||||
setRounds((rs) => rs.map((r, i) => (i === ri ? { ...r, notes: { ...r.notes, [key]: { ...r.notes[key], ...patch } } } : r)));
|
||||
|
||||
const frameFor = (n: FeedbackPreviewNote, s: NoteState): number | null => {
|
||||
if (s.frame !== null) return s.frame.trim() === "" ? null : Number(s.frame);
|
||||
return n.versions.find((v) => v.id === s.versionId)?.playerFrame ?? null;
|
||||
};
|
||||
|
||||
const included = preview
|
||||
? preview.rounds.flatMap((r, ri) => r.notes.filter((n) => rounds[ri]?.notes[n.key]?.include && rounds[ri].notes[n.key].text.trim()))
|
||||
: [];
|
||||
|
||||
const save = () => {
|
||||
if (!preview) return;
|
||||
const payload = preview.rounds
|
||||
.map((r, ri) => {
|
||||
const rs = rounds[ri];
|
||||
return {
|
||||
title: rs.title,
|
||||
dueAt: rs.due ? new Date(rs.due).toISOString() : null,
|
||||
notes: r.notes
|
||||
.filter((n) => rs.notes[n.key].include && rs.notes[n.key].text.trim())
|
||||
.map((n) => {
|
||||
const s = rs.notes[n.key];
|
||||
const frame = frameFor(n, s);
|
||||
return {
|
||||
code: n.code,
|
||||
shotId: n.shot?.id ?? null,
|
||||
text: s.text.trim(),
|
||||
versionId: n.shot ? s.versionId : null,
|
||||
frame: frame != null && Number.isFinite(frame) && frame >= 0 ? Math.floor(frame) : null,
|
||||
setChanges: !!s.versionId && s.setChanges,
|
||||
};
|
||||
}),
|
||||
};
|
||||
})
|
||||
.filter((r) => r.notes.length > 0);
|
||||
if (payload.length === 0) return;
|
||||
|
||||
startTransition(async () => {
|
||||
try {
|
||||
const res = await commitFeedback({ projectId, rounds: payload });
|
||||
toast({
|
||||
title: `${res.notes} note${res.notes === 1 ? "" : "s"} logged`,
|
||||
description: `${res.comments} in the player · ${res.tasksChanged} task${res.tasksChanged === 1 ? "" : "s"} moved to Changes`,
|
||||
});
|
||||
reset();
|
||||
onOpenChange(false);
|
||||
router.refresh();
|
||||
} catch (e) {
|
||||
toast({ title: "Couldn't save feedback", description: (e as Error).message, variant: "destructive" });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const field = "rounded-md border border-zinc-700 bg-zinc-950 px-2 text-xs text-white placeholder:text-zinc-600 focus:border-amber-500/50 focus:outline-none";
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={(o) => { if (!o) reset(); onOpenChange(o); }}>
|
||||
<DialogContent className="max-h-[90vh] max-w-4xl overflow-y-auto">
|
||||
<DialogHeader>
|
||||
<DialogTitle className="flex items-center gap-2">
|
||||
<MessageSquareText className="h-4 w-4 text-amber-400" />
|
||||
Paste client feedback · {projectName}
|
||||
</DialogTitle>
|
||||
<DialogDescription>
|
||||
{preview
|
||||
? "Check where each note will go. Notes are saved in the player as client feedback and added to the board."
|
||||
: "Paste the message as it arrived. Each note should start with a shot code; a line like “FEEDBACK 113 DUE Oct 7 12:00 PM” starts a round."}
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
{!preview ? (
|
||||
<div className="space-y-3">
|
||||
<textarea
|
||||
autoFocus
|
||||
value={input}
|
||||
onChange={(e) => setInput(e.target.value)}
|
||||
rows={12}
|
||||
placeholder={"FEEDBACK 113 DUE Oct 7, 2026 12:00 PM\nUNG_113_008_040 The screen is partially peeking under the mask\nUNG_113_018_050 At frame 1018, the mask is still slipping"}
|
||||
className={cn(field, "w-full resize-y py-2 font-mono text-[13px] leading-relaxed")}
|
||||
/>
|
||||
<div className="flex justify-end">
|
||||
<Button onClick={() => read(input)} disabled={isPending || !input.trim()}>
|
||||
{isPending ? "Reading…" : "Read feedback"}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div className="space-y-5">
|
||||
{preview.ignored.length > 0 && (
|
||||
<p className="text-xs text-zinc-500">
|
||||
Skipped (no shot code): {preview.ignored.map((l) => `“${l}”`).join(", ")}
|
||||
</p>
|
||||
)}
|
||||
|
||||
{preview.rounds.map((r, ri) => {
|
||||
const rs = rounds[ri];
|
||||
if (!rs) return null;
|
||||
return (
|
||||
<div key={ri} className="space-y-2">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<input
|
||||
value={rs.title}
|
||||
onChange={(e) => setRounds((all) => all.map((x, i) => (i === ri ? { ...x, title: e.target.value } : x)))}
|
||||
className={cn(field, "h-8 w-56 text-sm font-medium")}
|
||||
/>
|
||||
<span className="text-xs text-zinc-500">due</span>
|
||||
<input
|
||||
type="datetime-local"
|
||||
value={rs.due}
|
||||
onChange={(e) => setRounds((all) => all.map((x, i) => (i === ri ? { ...x, due: e.target.value } : x)))}
|
||||
className={cn(field, "h-8 [color-scheme:dark]")}
|
||||
/>
|
||||
{r.dueText && !rs.due && (
|
||||
<span className="text-xs text-amber-400">Couldn’t read “{r.dueText}”, set it by hand</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="overflow-x-auto rounded-lg border border-zinc-800">
|
||||
<table className="w-full text-xs">
|
||||
<thead className="bg-zinc-950 text-left uppercase tracking-wider text-zinc-500">
|
||||
<tr>
|
||||
<th className="w-8 px-2 py-2" />
|
||||
<th className="px-2 py-2">Shot</th>
|
||||
<th className="px-2 py-2">Note</th>
|
||||
<th className="px-2 py-2">Version</th>
|
||||
<th className="px-2 py-2">Frame</th>
|
||||
<th className="px-2 py-2" title="Move the task to Changes">Changes</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="divide-y divide-zinc-800">
|
||||
{r.notes.map((n) => {
|
||||
const s = rs.notes[n.key];
|
||||
const v = n.versions.find((x) => x.id === s.versionId) ?? null;
|
||||
const frame = frameFor(n, s);
|
||||
return (
|
||||
<tr key={n.key} className={cn("align-top", !s.include && "opacity-40")}>
|
||||
<td className="px-2 py-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={s.include}
|
||||
onChange={(e) => updateNote(ri, n.key, { include: e.target.checked })}
|
||||
className="mt-1 accent-amber-500"
|
||||
/>
|
||||
</td>
|
||||
<td className="whitespace-nowrap px-2 py-2 font-mono">
|
||||
{n.shot ? (
|
||||
<span className="text-amber-400">{n.shot.shotCode}</span>
|
||||
) : (
|
||||
<div className="space-y-1">
|
||||
<span className="flex items-center gap-1 text-red-400">
|
||||
<AlertTriangle className="h-3 w-3" /> {n.code}
|
||||
</span>
|
||||
{n.suggestion ? (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => applySuggestion(n.code, n.suggestion!)}
|
||||
className="flex items-center gap-1 font-sans text-zinc-400 hover:text-amber-400"
|
||||
>
|
||||
<Link2 className="h-3 w-3" /> Use {n.suggestion}
|
||||
</button>
|
||||
) : (
|
||||
<span className="block font-sans text-zinc-500">Not in project; flag only</span>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</td>
|
||||
<td className="min-w-[16rem] px-2 py-2">
|
||||
<textarea
|
||||
value={s.text}
|
||||
onChange={(e) => updateNote(ri, n.key, { text: e.target.value })}
|
||||
rows={Math.min(5, Math.max(1, Math.ceil(s.text.length / 60)))}
|
||||
className={cn(field, "w-full resize-y py-1 leading-snug")}
|
||||
/>
|
||||
</td>
|
||||
<td className="px-2 py-2">
|
||||
{n.versions.length > 0 ? (
|
||||
<select
|
||||
value={s.versionId ?? ""}
|
||||
onChange={(e) => updateNote(ri, n.key, { versionId: e.target.value || null, frame: null })}
|
||||
className={cn(field, "h-7")}
|
||||
>
|
||||
{n.versions.map((o) => (
|
||||
<option key={o.id} value={o.id}>
|
||||
{o.label}
|
||||
{o.sent ? ` · sent${o.sharedAt ? " " + format(new Date(o.sharedAt), "d MMM") : ""}` : " · not sent"}
|
||||
</option>
|
||||
))}
|
||||
<option value="">Board only</option>
|
||||
</select>
|
||||
) : (
|
||||
<span className="text-zinc-500">{n.shot ? "No versions; board only" : "—"}</span>
|
||||
)}
|
||||
{v && !v.sent && <span className="mt-1 block text-amber-400/80">Not sent to client</span>}
|
||||
</td>
|
||||
<td className="px-2 py-2">
|
||||
{s.versionId ? (
|
||||
<>
|
||||
<input
|
||||
inputMode="numeric"
|
||||
value={s.frame ?? (frame != null ? String(frame) : "")}
|
||||
onChange={(e) => updateNote(ri, n.key, { frame: e.target.value.replace(/\D/g, "") })}
|
||||
placeholder="0"
|
||||
className={cn(field, "h-7 w-16 font-mono")}
|
||||
/>
|
||||
{n.quotedFrame != null && s.frame === null && v && (
|
||||
<span className="mt-1 block whitespace-nowrap text-zinc-500">
|
||||
{v.fromComp ? `comp ${n.quotedFrame}` : `as quoted`}
|
||||
</span>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<span className="text-zinc-600">—</span>
|
||||
)}
|
||||
</td>
|
||||
<td className="px-2 py-2 text-center">
|
||||
{v?.taskId ? (
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={s.setChanges}
|
||||
disabled={v.taskStatus === "CHANGES"}
|
||||
title={v.taskStatus === "CHANGES" ? "Already in Changes" : "Move the task to Changes"}
|
||||
onChange={(e) => updateNote(ri, n.key, { setChanges: e.target.checked })}
|
||||
className="mt-1 accent-amber-500"
|
||||
/>
|
||||
) : (
|
||||
<span className="text-zinc-600">—</span>
|
||||
)}
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
|
||||
<div className="flex flex-wrap items-center justify-between gap-2">
|
||||
<Button variant="ghost" onClick={() => setPreview(null)} disabled={isPending}>
|
||||
<ArrowLeft /> Edit paste
|
||||
</Button>
|
||||
<Button onClick={save} disabled={isPending || included.length === 0}>
|
||||
{isPending ? "Saving…" : `Save ${included.length} note${included.length === 1 ? "" : "s"}`}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
import { auth } from "@/auth";
|
||||
import { db } from "@/lib/db";
|
||||
import { redirect } from "next/navigation";
|
||||
import { suggestShot } from "@/lib/board-parse";
|
||||
import { BoardClient, type BoardProject } from "./BoardClient";
|
||||
|
||||
export const metadata = { title: "Board" };
|
||||
|
||||
// Done lines stay visible this long so "what did we get through" is answerable
|
||||
const DONE_WINDOW_MS = 7 * 86400000;
|
||||
|
||||
export default async function BoardPage({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams: Promise<{ who?: string }>;
|
||||
}) {
|
||||
const session = await auth();
|
||||
if (!session?.user) redirect("/login");
|
||||
if (session.user.role === "CLIENT") redirect("/dashboard");
|
||||
|
||||
const { who } = await searchParams;
|
||||
const doneSince = new Date(Date.now() - DONE_WINDOW_MS);
|
||||
|
||||
const [projects, users] = await Promise.all([
|
||||
db.project.findMany({
|
||||
where: { status: { in: ["ACTIVE", "ON_HOLD"] } },
|
||||
orderBy: [{ status: "asc" }, { name: "asc" }],
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
code: true,
|
||||
status: true,
|
||||
boardStatus: true,
|
||||
boardStatusAt: true,
|
||||
milestones: { orderBy: { date: "asc" } },
|
||||
boardItems: {
|
||||
where: { OR: [{ doneAt: null }, { doneAt: { gte: doneSince } }] },
|
||||
orderBy: { sortOrder: "asc" },
|
||||
include: {
|
||||
assignee: { select: { id: true, name: true, image: true } },
|
||||
round: { select: { id: true, title: true, dueAt: true } },
|
||||
shot: {
|
||||
select: {
|
||||
id: true,
|
||||
shotCode: true,
|
||||
status: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
db.user.findMany({
|
||||
where: { isActive: true, role: { not: "CLIENT" } },
|
||||
select: { id: true, name: true, email: true, image: true },
|
||||
orderBy: { name: "asc" },
|
||||
}),
|
||||
]);
|
||||
|
||||
const projectIds = projects.map((p) => p.id);
|
||||
|
||||
// Latest version per linked shot — versions hang off the shot or its task
|
||||
const linkedShotIds = [...new Set(projects.flatMap((p) => p.boardItems.map((i) => i.shotId).filter(Boolean) as string[]))];
|
||||
const latestByShot = new Map<string, { id: string; versionNumber: number; approvalStatus: string; isClientVisible: boolean }>();
|
||||
if (linkedShotIds.length) {
|
||||
const versions = await db.version.findMany({
|
||||
where: { OR: [{ shotId: { in: linkedShotIds } }, { task: { shotId: { in: linkedShotIds } } }] },
|
||||
orderBy: { createdAt: "desc" },
|
||||
select: {
|
||||
id: true, versionNumber: true, approvalStatus: true, isClientVisible: true,
|
||||
shotId: true, task: { select: { shotId: true } },
|
||||
},
|
||||
});
|
||||
for (const v of versions) {
|
||||
const sid = v.shotId ?? v.task?.shotId;
|
||||
if (sid && !latestByShot.has(sid)) latestByShot.set(sid, v);
|
||||
}
|
||||
}
|
||||
|
||||
// Pasted-feedback lines link to the comment they were saved as
|
||||
const commentIds = projects.flatMap((p) => p.boardItems.map((i) => i.commentId).filter(Boolean) as string[]);
|
||||
const commentVersion = new Map(
|
||||
(commentIds.length
|
||||
? await db.comment.findMany({ where: { id: { in: commentIds } }, select: { id: true, versionId: true, frameNumber: true } })
|
||||
: []
|
||||
).map((c) => [c.id, c]),
|
||||
);
|
||||
const shotCounts = await db.shot.groupBy({
|
||||
by: ["projectId", "status"],
|
||||
where: { projectId: { in: projectIds } },
|
||||
_count: { _all: true },
|
||||
});
|
||||
|
||||
// Lines whose code did not match a shot when typed: the shot may exist now,
|
||||
// or there may be an obvious near-miss (DH2_004_100 → DH2_VFX_004_100).
|
||||
const flaggedProjects = projects.filter((p) => p.boardItems.some((i) => i.code && !i.shotId));
|
||||
const shotsByProject = new Map(
|
||||
await Promise.all(
|
||||
flaggedProjects.map(async (p) => [
|
||||
p.id,
|
||||
await db.shot.findMany({
|
||||
where: { projectId: p.id },
|
||||
select: { id: true, shotCode: true, clientCode: true },
|
||||
}),
|
||||
] as const),
|
||||
),
|
||||
);
|
||||
|
||||
const data: BoardProject[] = projects.map((p) => {
|
||||
const counts = shotCounts.filter((c) => c.projectId === p.id);
|
||||
const shots = shotsByProject.get(p.id) ?? [];
|
||||
return {
|
||||
id: p.id,
|
||||
name: p.name,
|
||||
code: p.code,
|
||||
status: p.status,
|
||||
boardStatus: p.boardStatus,
|
||||
boardStatusAt: p.boardStatusAt?.toISOString() ?? null,
|
||||
shotTotal: counts.reduce((n, c) => n + c._count._all, 0),
|
||||
shotComplete: counts.find((c) => c.status === "COMPLETE")?._count._all ?? 0,
|
||||
milestones: p.milestones.map((m) => ({
|
||||
id: m.id,
|
||||
label: m.label,
|
||||
date: m.date.toISOString(),
|
||||
doneAt: m.doneAt?.toISOString() ?? null,
|
||||
})),
|
||||
items: p.boardItems.map((i) => {
|
||||
const v = i.shot ? latestByShot.get(i.shot.id) : undefined;
|
||||
const nowMatches = !i.shotId && i.code
|
||||
? shots.find((s) => s.shotCode.toUpperCase() === i.code!.toUpperCase())
|
||||
: undefined;
|
||||
const suggestion = !i.shotId && i.code && !nowMatches ? suggestShot(i.code, shots) : null;
|
||||
return {
|
||||
id: i.id,
|
||||
text: i.text,
|
||||
code: i.code,
|
||||
group: i.group,
|
||||
waitingOn: i.waitingOn,
|
||||
round: i.round ? { id: i.round.id, title: i.round.title, dueAt: i.round.dueAt?.toISOString() ?? null } : null,
|
||||
comment: i.commentId && commentVersion.has(i.commentId)
|
||||
? { versionId: commentVersion.get(i.commentId)!.versionId, frame: commentVersion.get(i.commentId)!.frameNumber }
|
||||
: null,
|
||||
doneAt: i.doneAt?.toISOString() ?? null,
|
||||
assignee: i.assignee,
|
||||
shot: i.shot
|
||||
? {
|
||||
id: i.shot.id,
|
||||
shotCode: i.shot.shotCode,
|
||||
status: i.shot.status,
|
||||
latest: v
|
||||
? {
|
||||
id: v.id,
|
||||
versionNumber: v.versionNumber,
|
||||
approvalStatus: v.approvalStatus,
|
||||
isClientVisible: v.isClientVisible,
|
||||
}
|
||||
: null,
|
||||
}
|
||||
: null,
|
||||
// Shot created since the line was typed: offer to link it
|
||||
relinkTo: nowMatches?.shotCode ?? suggestion?.shotCode ?? null,
|
||||
relinkIsExact: !!nowMatches,
|
||||
};
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
return <BoardClient projects={data} users={users} who={who ?? null} />;
|
||||
}
|
||||
@@ -1130,6 +1130,8 @@ export function ShotStatusClient({
|
||||
const [expandedGroups, setExpandedGroups] = useState<Set<string>>(new Set());
|
||||
const [groupMode, setGroupMode] = useState<"flat" | "scene" | "group">("flat");
|
||||
const [selectedIds, setSelectedIds] = useState<Set<string>>(new Set());
|
||||
// Statuses picked from the summary badges; empty shows every shot.
|
||||
const [statusFilter, setStatusFilter] = useState<Set<string>>(new Set());
|
||||
|
||||
// Which sections were open is restored before the scroll position: until
|
||||
// they are, the page is shorter and the saved offset would not fit.
|
||||
@@ -1141,6 +1143,7 @@ export function ShotStatusClient({
|
||||
useEffect(() => {
|
||||
if (!selectedProjectId) return;
|
||||
setExpandRestored(false);
|
||||
setStatusFilter(new Set());
|
||||
const mode = (readStored(`shotStatus:${selectedProjectId}:groupMode`) ?? "flat") as "flat" | "scene" | "group";
|
||||
setGroupMode(mode);
|
||||
setExpandedEpisodes(new Set(readStoredList(`shotStatus:${selectedProjectId}:episodeExpand`) ?? []));
|
||||
@@ -1235,6 +1238,22 @@ export function ShotStatusClient({
|
||||
|
||||
const clearSelection = () => setSelectedIds(new Set());
|
||||
|
||||
const toggleStatusFilter = (status: string) => {
|
||||
const next = new Set(statusFilter);
|
||||
next.has(status) ? next.delete(status) : next.add(status);
|
||||
setStatusFilter(next);
|
||||
// Bulk actions must never reach shots the filter has hidden.
|
||||
if (next.size > 0) {
|
||||
setSelectedIds((prev) => {
|
||||
const kept = new Set<string>();
|
||||
for (const s of shots) if (prev.has(s.id) && next.has(s.status)) kept.add(s.id);
|
||||
return kept;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const visibleShots = statusFilter.size > 0 ? shots.filter((s) => statusFilter.has(s.status)) : shots;
|
||||
|
||||
const handleBulkDueDate = async (date: string, includeTasks: boolean) => {
|
||||
try {
|
||||
const result = await bulkUpdateDueDates([...selectedIds], date, includeTasks);
|
||||
@@ -1320,7 +1339,7 @@ export function ShotStatusClient({
|
||||
const episodeGroups: [string, ShotRow[]][] = isEpisodic
|
||||
? (() => {
|
||||
const map = new Map<string, ShotRow[]>();
|
||||
for (const shot of shots) {
|
||||
for (const shot of visibleShots) {
|
||||
const key = shot.episode ?? "(No Episode)";
|
||||
if (!map.has(key)) map.set(key, []);
|
||||
map.get(key)!.push(shot);
|
||||
@@ -1332,7 +1351,7 @@ export function ShotStatusClient({
|
||||
const sceneGroups: [string, ShotRow[]][] = !isEpisodic && groupMode === "scene"
|
||||
? (() => {
|
||||
const map = new Map<string, ShotRow[]>();
|
||||
for (const shot of shots) {
|
||||
for (const shot of visibleShots) {
|
||||
const key = shot.scene || "(No Scene)";
|
||||
if (!map.has(key)) map.set(key, []);
|
||||
map.get(key)!.push(shot);
|
||||
@@ -1344,7 +1363,7 @@ export function ShotStatusClient({
|
||||
const shotGroupGroups: [string, string, ShotRow[]][] = !isEpisodic && groupMode === "group"
|
||||
? (() => {
|
||||
const map = new Map<string, [string, ShotRow[]]>();
|
||||
for (const shot of shots) {
|
||||
for (const shot of visibleShots) {
|
||||
const id = shot.shotGroup?.id ?? "";
|
||||
const name = shot.shotGroup?.name ?? "(No Group)";
|
||||
if (!map.has(id)) map.set(id, [name, []]);
|
||||
@@ -1437,16 +1456,45 @@ export function ShotStatusClient({
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
{selectionCount === 0 ? (
|
||||
<>
|
||||
<span className="text-xs text-zinc-500 self-center">{shots.length} shots total</span>
|
||||
<span className="text-xs text-zinc-500 self-center">
|
||||
{statusFilter.size > 0 ? `${visibleShots.length} of ${shots.length} shots` : `${shots.length} shots total`}
|
||||
</span>
|
||||
{Object.entries(STATUS_CONFIG).map(([key, cfg]) => {
|
||||
const count = statusCounts[key] ?? 0;
|
||||
if (!count) return null;
|
||||
const active = statusFilter.has(key);
|
||||
return (
|
||||
<Badge key={key} className={cn("gap-1 text-xs", cfg.color)}>
|
||||
{count} {cfg.label}
|
||||
</Badge>
|
||||
<button
|
||||
key={key}
|
||||
type="button"
|
||||
onClick={() => toggleStatusFilter(key)}
|
||||
aria-pressed={active}
|
||||
title={active ? `Stop filtering by ${cfg.label}` : `Show only ${cfg.label}`}
|
||||
className="rounded-full"
|
||||
>
|
||||
<Badge
|
||||
className={cn(
|
||||
"gap-1 text-xs cursor-pointer",
|
||||
cfg.color,
|
||||
statusFilter.size > 0 && !active && "opacity-40 hover:opacity-70",
|
||||
active && "ring-1 ring-current"
|
||||
)}
|
||||
>
|
||||
{count} {cfg.label}
|
||||
</Badge>
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
{statusFilter.size > 0 && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setStatusFilter(new Set())}
|
||||
className="flex items-center gap-1 text-xs text-zinc-500 hover:text-zinc-300 transition-colors"
|
||||
>
|
||||
<X className="h-3 w-3" />
|
||||
Clear filter
|
||||
</button>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<div className="flex items-center gap-3 rounded-lg border border-blue-500/30 bg-blue-500/10 px-4 py-2">
|
||||
@@ -1669,7 +1717,7 @@ export function ShotStatusClient({
|
||||
) : (
|
||||
<div className="overflow-x-auto">
|
||||
<ShotTable
|
||||
shots={shots}
|
||||
shots={visibleShots}
|
||||
canManage={canManage}
|
||||
projectId={selectedProjectId!}
|
||||
selectedIds={selectedIds}
|
||||
|
||||
@@ -46,6 +46,8 @@ interface Comment {
|
||||
timestamp: number;
|
||||
text: string;
|
||||
isResolved: boolean;
|
||||
/** "WHATSAPP" = client feedback sent by message and logged by the studio */
|
||||
source?: string | null;
|
||||
createdAt: string;
|
||||
/** This reviewer wrote it, so they can change or remove it. Set by the API. */
|
||||
canEdit?: boolean;
|
||||
@@ -660,7 +662,9 @@ export default function ClientReviewPage({
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
<span className="text-xs text-zinc-300 font-medium">
|
||||
{comment.author.name ?? comment.author.email.split("@")[0]}
|
||||
{comment.source === "WHATSAPP"
|
||||
? "Client feedback"
|
||||
: comment.author.name ?? comment.author.email.split("@")[0]}
|
||||
</span>
|
||||
<span className="ml-auto font-mono text-xs text-amber-400/80">
|
||||
{frameToTimecode(comment.frameNumber, version.fps)}
|
||||
|
||||
@@ -342,8 +342,18 @@ function CommentThread({
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="flex items-center gap-2 flex-wrap">
|
||||
<span className="text-xs font-medium">
|
||||
{comment.author?.name ?? comment.author?.email ?? "Deleted User"}
|
||||
{comment.source === "WHATSAPP"
|
||||
? "Client feedback"
|
||||
: comment.author?.name ?? comment.author?.email ?? "Deleted User"}
|
||||
</span>
|
||||
{comment.source === "WHATSAPP" && (
|
||||
<span
|
||||
className="rounded border border-indigo-500/20 bg-indigo-500/10 px-1 py-px text-[10px] text-indigo-400"
|
||||
title={`Pasted from WhatsApp by ${comment.author?.name ?? comment.author?.email ?? "someone"}`}
|
||||
>
|
||||
via {comment.author?.name?.split(" ")[0] ?? "WhatsApp"}
|
||||
</span>
|
||||
)}
|
||||
<button
|
||||
className="font-mono text-xs text-primary/80 hover:text-primary hover:underline"
|
||||
onClick={() => onJumpToFrame(comment.frameNumber)}
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
ChevronLeft,
|
||||
ChevronRight,
|
||||
ListTodo,
|
||||
NotebookPen,
|
||||
CalendarRange,
|
||||
BarChart2,
|
||||
ListVideo,
|
||||
@@ -32,6 +33,7 @@ import { useMobileNav } from '@/components/layout/MobileNav';
|
||||
const navItems = [
|
||||
{ href: '/dashboard', label: 'Dashboard', icon: LayoutDashboard },
|
||||
{ href: '/projects', label: 'Projects', icon: FolderOpen },
|
||||
{ href: '/board', label: 'Board', icon: NotebookPen, hideForClient: true },
|
||||
{ href: '/shot-status', label: 'Shot Status', icon: BarChart2, hideForClient: true },
|
||||
{ href: '/playlist', label: 'Playlist', icon: ListVideo, hideForClient: true },
|
||||
{ href: '/tasks', label: 'My Tasks', icon: ListTodo, hideForClient: true },
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { parseBoardLine, parseBoardText, suggestShot } from "./board-parse";
|
||||
|
||||
const shots = [
|
||||
{ id: "s1", shotCode: "DH2_VFX_027_090" },
|
||||
{ id: "s2", shotCode: "DH2_VFX_005_010" },
|
||||
{ id: "s3", shotCode: "DH2_VFX_004_100" },
|
||||
{ id: "s4", shotCode: "UNG_117_023_010", clientCode: "EP17_VFX_003" },
|
||||
];
|
||||
const users = [
|
||||
{ id: "u1", name: "Chris Pinto", email: "chris@example.com" },
|
||||
{ id: "u2", name: "Michelle Pinto", email: "michelle@example.com" },
|
||||
];
|
||||
const ctx = { shots, users };
|
||||
|
||||
describe("parseBoardLine", () => {
|
||||
it("links the shot and assigns from (NAME)", () => {
|
||||
expect(parseBoardLine("DH2_VFX_027_090 finalise (CHRIS)", ctx)).toEqual({
|
||||
text: "finalise",
|
||||
code: "DH2_VFX_027_090",
|
||||
shotId: "s1",
|
||||
assigneeId: "u1",
|
||||
waitingOn: null,
|
||||
group: "",
|
||||
});
|
||||
});
|
||||
|
||||
it("matches codes case-insensitively and by client alias", () => {
|
||||
expect(parseBoardLine("dh2_vfx_027_090 x", ctx).shotId).toBe("s1");
|
||||
const alias = parseBoardLine("EP17_VFX_003 warp fix", ctx);
|
||||
expect(alias.shotId).toBe("s4");
|
||||
expect(alias.code).toBe("UNG_117_023_010");
|
||||
});
|
||||
|
||||
it("keeps an unknown code as typed for flagging", () => {
|
||||
const r = parseBoardLine("DH2_004_100 not on our tracker?", ctx);
|
||||
expect(r.code).toBe("DH2_004_100");
|
||||
expect(r.shotId).toBeNull();
|
||||
expect(r.text).toBe("not on our tracker?");
|
||||
});
|
||||
|
||||
it("assigns from @name and keeps the rest of a parenthesised group", () => {
|
||||
expect(parseBoardLine("DH2_VFX_005_010 gfx @michelle", ctx).assigneeId).toBe("u2");
|
||||
const r = parseBoardLine("(MICHELLE ROTO) Maagie shot", ctx);
|
||||
expect(r.assigneeId).toBe("u2");
|
||||
expect(r.text).toBe("ROTO Maagie shot");
|
||||
});
|
||||
|
||||
it("leaves parentheses that are not a user alone", () => {
|
||||
const r = parseBoardLine("DH2_VFX_005_010 track (90% done)", ctx);
|
||||
expect(r.assigneeId).toBeNull();
|
||||
expect(r.text).toBe("track (90% done)");
|
||||
});
|
||||
|
||||
it("splits off what the line is waiting on", () => {
|
||||
const r = parseBoardLine(
|
||||
"DH2_VFX_005_010 gfx required for update (MICHELLE) wait: client GFX ADH_GFX_005_020",
|
||||
ctx,
|
||||
);
|
||||
expect(r.shotId).toBe("s2");
|
||||
expect(r.waitingOn).toBe("client GFX ADH_GFX_005_020");
|
||||
expect(r.text).toBe("gfx required for update");
|
||||
expect(parseBoardLine("x waiting on: grade", ctx).waitingOn).toBe("grade");
|
||||
// no colon → prose
|
||||
expect(parseBoardLine("awaiting gfx", ctx).waitingOn).toBeNull();
|
||||
});
|
||||
|
||||
it("takes a note with no shot code", () => {
|
||||
const r = parseBoardLine("- Deposit received", ctx);
|
||||
expect(r).toMatchObject({ text: "Deposit received", code: null, shotId: null });
|
||||
});
|
||||
});
|
||||
|
||||
describe("parseBoardText", () => {
|
||||
it("groups lines under headings and skips blanks", () => {
|
||||
const items = parseBoardText(
|
||||
"DH2_VFX_027_090 finalise (CHRIS)\n\nWATER DROPS:\nDH2_VFX_005_010 still do (CHRIS)\nDH2_VFX_004_100\n",
|
||||
ctx,
|
||||
);
|
||||
expect(items.map((i) => [i.code, i.group, i.text])).toEqual([
|
||||
["DH2_VFX_027_090", "", "finalise"],
|
||||
["DH2_VFX_005_010", "WATER DROPS", "still do"],
|
||||
["DH2_VFX_004_100", "WATER DROPS", ""],
|
||||
]);
|
||||
});
|
||||
|
||||
it("treats an all-caps line without a code as a heading", () => {
|
||||
const items = parseBoardText("FLAGS\nDH2_004_100 not on our tracker?", ctx);
|
||||
expect(items).toHaveLength(1);
|
||||
expect(items[0].group).toBe("FLAGS");
|
||||
});
|
||||
|
||||
it("never treats a single typed line as a heading", () => {
|
||||
expect(parseBoardText("CALL CLIENT", ctx)).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe("suggestShot", () => {
|
||||
it("suggests the shot with the same prefix and numbers", () => {
|
||||
expect(suggestShot("DH2_004_100", shots)?.id).toBe("s3");
|
||||
});
|
||||
|
||||
it("does not guess between several candidates", () => {
|
||||
const dup = [...shots, { id: "s5", shotCode: "DH2_GFX_004_100" }];
|
||||
expect(suggestShot("DH2_004_100", dup)).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,171 @@
|
||||
/**
|
||||
* Turns lines typed (or pasted) onto the daily board into board items.
|
||||
*
|
||||
* The board replaces a shared doc, so the input is whatever someone would
|
||||
* have typed there:
|
||||
*
|
||||
* WATER DROPS:
|
||||
* DH2_VFX_027_210 still do (CHRIS)
|
||||
* DH2_VFX_005_010 gfx required for update @michelle wait: client GFX ADH_GFX_005_020
|
||||
*
|
||||
* - The first shot-code-shaped token is the line's shot. It is matched against
|
||||
* the project's shot codes and client aliases; a code that matches nothing
|
||||
* is kept as typed so the board can flag it.
|
||||
* - `(NAME)` or `@name` assigns the line when NAME is a user's first or full
|
||||
* name. A parenthesised group can carry more than the name — "(MICHELLE
|
||||
* ROTO)" assigns Michelle and keeps "ROTO" in the text.
|
||||
* - `wait: …` (also `waiting on:`, `blocked by:`) marks what the line is
|
||||
* blocked on. The colon is required so prose like "awaiting gfx" stays text.
|
||||
* - A line with no shot code that ends in ":" or is all capitals is a heading;
|
||||
* the lines after it are grouped under it.
|
||||
*/
|
||||
|
||||
export interface BoardShot {
|
||||
id: string;
|
||||
shotCode: string;
|
||||
clientCode?: string | null;
|
||||
}
|
||||
|
||||
export interface BoardUser {
|
||||
id: string;
|
||||
name: string | null;
|
||||
email: string;
|
||||
}
|
||||
|
||||
export interface ParsedBoardLine {
|
||||
text: string;
|
||||
/** The shot code as typed (canonical shotCode when it matched); null = no code on the line */
|
||||
code: string | null;
|
||||
shotId: string | null;
|
||||
assigneeId: string | null;
|
||||
waitingOn: string | null;
|
||||
group: string;
|
||||
}
|
||||
|
||||
// Three or more underscore-separated segments, starting with a letter:
|
||||
// DH2_VFX_027_090, UNG_117_023_010, ADH_GFX_005_020.
|
||||
export const CODE_RE = /\b[A-Za-z][A-Za-z0-9]*(?:_[A-Za-z0-9]+){2,}\b/;
|
||||
const WAIT_RE = /\b(?:wait(?:ing)?(?:\s+(?:on|for))?|blocked(?:\s+(?:on|by))?)\s*:\s*(.*)$/i;
|
||||
const BULLET_RE = /^(?:[-*•–]|\d+[.)])\s+/;
|
||||
|
||||
export function findShot(code: string, shots: BoardShot[]): BoardShot | null {
|
||||
const c = code.toUpperCase();
|
||||
return (
|
||||
shots.find((s) => s.shotCode.toUpperCase() === c) ??
|
||||
shots.find((s) => s.clientCode?.trim().toUpperCase() === c) ??
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* A likely intended shot for a code that matched nothing — same leading
|
||||
* segment and same numeric segments, so "DH2_004_100" suggests
|
||||
* "DH2_VFX_004_100". Only a unique candidate is suggested.
|
||||
*/
|
||||
export function suggestShot(code: string, shots: BoardShot[]): BoardShot | null {
|
||||
const sig = (c: string) => {
|
||||
const parts = c.toUpperCase().split("_");
|
||||
return `${parts[0]}|${parts.filter((p) => /^\d+$/.test(p)).join("_")}`;
|
||||
};
|
||||
const want = sig(code);
|
||||
if (want.endsWith("|")) return null; // no numeric segments to go on
|
||||
const hits = shots.filter((s) => sig(s.shotCode) === want);
|
||||
return hits.length === 1 ? hits[0] : null;
|
||||
}
|
||||
|
||||
function userNames(u: BoardUser): string[] {
|
||||
const names = [u.email.split("@")[0]];
|
||||
if (u.name) {
|
||||
names.push(u.name);
|
||||
names.push(u.name.split(/\s+/)[0]);
|
||||
}
|
||||
return names.map((n) => n.toLowerCase());
|
||||
}
|
||||
|
||||
function findUser(word: string, users: BoardUser[]): BoardUser | null {
|
||||
const w = word.toLowerCase();
|
||||
const hits = users.filter((u) => userNames(u).includes(w));
|
||||
return hits.length === 1 ? hits[0] : null;
|
||||
}
|
||||
|
||||
function isHeading(line: string): boolean {
|
||||
if (CODE_RE.test(line)) return false;
|
||||
if (line.endsWith(":")) return true;
|
||||
const letters = line.replace(/[^A-Za-z]/g, "");
|
||||
return letters.length >= 3 && letters === letters.toUpperCase();
|
||||
}
|
||||
|
||||
export function parseBoardLine(
|
||||
raw: string,
|
||||
ctx: { shots: BoardShot[]; users: BoardUser[] },
|
||||
group = "",
|
||||
): ParsedBoardLine {
|
||||
let line = raw.trim().replace(BULLET_RE, "");
|
||||
|
||||
let waitingOn: string | null = null;
|
||||
const wait = WAIT_RE.exec(line);
|
||||
if (wait) {
|
||||
waitingOn = wait[1].trim() || null;
|
||||
line = line.slice(0, wait.index);
|
||||
}
|
||||
|
||||
let code: string | null = null;
|
||||
let shotId: string | null = null;
|
||||
const codeMatch = CODE_RE.exec(line);
|
||||
if (codeMatch) {
|
||||
const shot = findShot(codeMatch[0], ctx.shots);
|
||||
code = shot?.shotCode ?? codeMatch[0].toUpperCase();
|
||||
shotId = shot?.id ?? null;
|
||||
line = line.slice(0, codeMatch.index) + line.slice(codeMatch.index + codeMatch[0].length);
|
||||
}
|
||||
|
||||
let assigneeId: string | null = null;
|
||||
// (NAME …) — first word a user's name; the rest of the group stays as text
|
||||
line = line.replace(/\(([^)]*)\)/g, (whole, inner: string) => {
|
||||
if (assigneeId) return whole;
|
||||
const words = inner.trim().split(/\s+/);
|
||||
// Full name first ("Chris Pinto"), then first word
|
||||
const full = findUser(words.slice(0, 2).join(" "), ctx.users);
|
||||
const user = full ?? findUser(words[0] ?? "", ctx.users);
|
||||
if (!user) return whole;
|
||||
assigneeId = user.id;
|
||||
const rest = words.slice(full ? 2 : 1).join(" ");
|
||||
return rest ? ` ${rest} ` : " ";
|
||||
});
|
||||
line = line.replace(/@([A-Za-z][\w.-]*)/g, (whole, name: string) => {
|
||||
if (assigneeId) return whole;
|
||||
const user = findUser(name, ctx.users);
|
||||
if (!user) return whole;
|
||||
assigneeId = user.id;
|
||||
return " ";
|
||||
});
|
||||
|
||||
const text = line
|
||||
.replace(/\s+/g, " ")
|
||||
.replace(/^[\s:\-–,.]+|[\s:\-–,]+$/g, "")
|
||||
.trim();
|
||||
|
||||
return { text, code, shotId, assigneeId, waitingOn, group };
|
||||
}
|
||||
|
||||
/** Every non-blank line of `input` as a board item, headings applied as groups. */
|
||||
export function parseBoardText(
|
||||
input: string,
|
||||
ctx: { shots: BoardShot[]; users: BoardUser[]; group?: string },
|
||||
): ParsedBoardLine[] {
|
||||
const out: ParsedBoardLine[] = [];
|
||||
let group = ctx.group ?? "";
|
||||
const lines = input.split(/\r?\n/).map((l) => l.trim()).filter(Boolean);
|
||||
for (const raw of lines) {
|
||||
const line = raw.replace(BULLET_RE, "");
|
||||
// A single line is always an item — someone typing "Deposit received"
|
||||
// into the quick-add box means a note, not a heading.
|
||||
if (lines.length > 1 && isHeading(line)) {
|
||||
group = line.replace(/:$/, "").trim();
|
||||
continue;
|
||||
}
|
||||
const parsed = parseBoardLine(line, ctx, group);
|
||||
if (parsed.text || parsed.code || parsed.waitingOn) out.push(parsed);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { parseDue, parseFeedback, slateFrames, toPlayerFrame } from "./feedback-parse";
|
||||
|
||||
describe("parseFeedback", () => {
|
||||
it("splits rounds and notes from the doc's own format", () => {
|
||||
const { rounds, ignored } = parseFeedback(`FEEDBACK 117 DUE Oct 7, 2026 12:00 PM
|
||||
UNG_117_023_010 The screen comp starts warping, slightly expanding and contracting in the second half of the shot.
|
||||
UNG_117_024_010 48fps @ 200% Done Dineo seems slightly too small
|
||||
|
||||
FEEDBACK 113 DUE Oct 7, 2026 12:00 PM
|
||||
UNG_113_008_040 The screen is partially peeking under the mask on OZ
|
||||
UNG_113_018_050 At frame 1018, the mask is still slipping`);
|
||||
expect(ignored).toEqual([]);
|
||||
expect(rounds.map((r) => [r.title, r.dueText, r.notes.length])).toEqual([
|
||||
["FEEDBACK 117", "Oct 7, 2026 12:00 PM", 2],
|
||||
["FEEDBACK 113", "Oct 7, 2026 12:00 PM", 2],
|
||||
]);
|
||||
expect(rounds[1].notes[1]).toEqual({
|
||||
codes: ["UNG_113_018_050"],
|
||||
text: "At frame 1018, the mask is still slipping",
|
||||
frame: 1018,
|
||||
});
|
||||
expect(rounds[0].notes[1].frame).toBeNull();
|
||||
});
|
||||
|
||||
it("joins wrapped lines onto the note above, even ones mentioning changes or due", () => {
|
||||
const { rounds } = parseFeedback(`UNG_108_004_030 Comp needs work.
|
||||
Visible matte edge on left of "Top Story" banner.
|
||||
lighting changes, due to the grade`);
|
||||
expect(rounds).toHaveLength(1);
|
||||
expect(rounds[0].title).toBe("");
|
||||
expect(rounds[0].notes[0].text).toBe(
|
||||
'Comp needs work. Visible matte edge on left of "Top Story" banner. lighting changes, due to the grade',
|
||||
);
|
||||
});
|
||||
|
||||
it("strips WhatsApp prefixes and formatting, and keeps preamble aside", () => {
|
||||
const { rounds, ignored } = parseFeedback(`[07/10/2026, 09:12] Stephen Abbott: Hi team, notes below
|
||||
[07/10/2026, 09:13] Stephen Abbott: *UNG_113_031_010* As the camera pans the screen comp seems to shrink`);
|
||||
expect(rounds[0].title).toBe("");
|
||||
expect(rounds[0].notes[0].codes).toEqual(["UNG_113_031_010"]);
|
||||
expect(rounds[0].notes[0].text).toBe("As the camera pans the screen comp seems to shrink");
|
||||
expect(ignored).toEqual(["Hi team, notes below"]);
|
||||
|
||||
const plain = parseFeedback("Morning!\nUNG_113_031_010 shrink");
|
||||
expect(plain.ignored).toEqual(["Morning!"]);
|
||||
});
|
||||
|
||||
it("gives one note per shot when several codes lead the line", () => {
|
||||
const { rounds } = parseFeedback("UNG_113_032_034 / UNG_113_032_036, UNG_113_032_038 same matte fix");
|
||||
expect(rounds[0].notes.map((n) => [n.codes[0], n.text])).toEqual([
|
||||
["UNG_113_032_034", "same matte fix"],
|
||||
["UNG_113_032_036", "same matte fix"],
|
||||
["UNG_113_032_038", "same matte fix"],
|
||||
]);
|
||||
});
|
||||
|
||||
it("accepts codes without the show prefix and upper-cases them", () => {
|
||||
const { rounds } = parseFeedback("- 113_018_040: hard blue edge, fr 1004");
|
||||
expect(rounds[0].notes[0]).toMatchObject({ codes: ["113_018_040"], text: "hard blue edge, fr 1004", frame: 1004 });
|
||||
});
|
||||
});
|
||||
|
||||
describe("parseDue", () => {
|
||||
const now = new Date(2026, 9, 7, 8, 0);
|
||||
|
||||
it("reads a full date and time", () => {
|
||||
const d = parseDue("Oct 7, 2026 12:00 PM", now)!;
|
||||
expect([d.getFullYear(), d.getMonth(), d.getDate(), d.getHours()]).toEqual([2026, 9, 7, 12]);
|
||||
});
|
||||
|
||||
it("fills in the year", () => {
|
||||
const d = parseDue("7 Oct 16:00", now)!;
|
||||
expect([d.getFullYear(), d.getMonth(), d.getDate(), d.getHours()]).toEqual([2026, 9, 7, 16]);
|
||||
});
|
||||
|
||||
it("returns null for what it cannot read", () => {
|
||||
expect(parseDue("end of day", now)).toBeNull();
|
||||
expect(parseDue(null, now)).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("slateFrames", () => {
|
||||
it("uses the recorded slate, else 1 for pipeline previews, else 0", () => {
|
||||
expect(slateFrames({ pictureStartFrame: 2, frameCount: 120 })).toBe(2);
|
||||
expect(slateFrames({ pictureStartFrame: 0, frameCount: 120 })).toBe(0);
|
||||
expect(slateFrames({ pictureStartFrame: null, frameCount: 120 })).toBe(1);
|
||||
expect(slateFrames({ pictureStartFrame: null, frameCount: null })).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe("toPlayerFrame", () => {
|
||||
it("maps a comp frame through the shot start and slate", () => {
|
||||
expect(toPlayerFrame(1018, { shotFrameStart: 1001, pictureStart: 1, frameCount: 120 })).toEqual({
|
||||
frame: 18,
|
||||
fromComp: true,
|
||||
});
|
||||
});
|
||||
|
||||
it("assumes the house 1001 start when the shot has none", () => {
|
||||
expect(toPlayerFrame(1018, { shotFrameStart: null, pictureStart: 1, frameCount: 120 }).frame).toBe(18);
|
||||
expect(toPlayerFrame(1018, { shotFrameStart: 0, pictureStart: 0, frameCount: null }).frame).toBe(17);
|
||||
});
|
||||
|
||||
it("takes a small number as the player's own frame", () => {
|
||||
expect(toPlayerFrame(40, { shotFrameStart: 1001, pictureStart: 1, frameCount: 120 })).toEqual({
|
||||
frame: 40,
|
||||
fromComp: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps the frame inside the picture", () => {
|
||||
expect(toPlayerFrame(1500, { shotFrameStart: 1001, pictureStart: 1, frameCount: 100 }).frame).toBe(100);
|
||||
expect(toPlayerFrame(500, { shotFrameStart: null, pictureStart: 0, frameCount: 100 }).frame).toBe(99);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,180 @@
|
||||
/**
|
||||
* Client feedback pasted from WhatsApp (or an email, or the old doc) split
|
||||
* into rounds and per-shot notes.
|
||||
*
|
||||
* [07/10/2026, 09:12] Stephen: FEEDBACK 113 DUE Oct 7, 2026 12:00 PM
|
||||
* UNG_113_018_040 there is a hard blue edge on her finger,
|
||||
* along her thumb, which is not in the OCF
|
||||
* UNG_113_018_050 At frame 1018, the mask is still slipping
|
||||
*
|
||||
* - A line that starts with a shot code starts a note. Several codes before
|
||||
* the text ("UNG_113_032_034 / UNG_113_032_036 same fix") give one note per
|
||||
* shot. Lines without a code continue the note above them — WhatsApp
|
||||
* messages wrap.
|
||||
* - A line with no code that names feedback/notes/a round, mentions a due
|
||||
* date, or ends in ":" starts a new round. "DUE …" is split off as the
|
||||
* round's due text; turning it into a date is left to the browser
|
||||
* (parseDue) so "12:00 PM" means the studio's noon, not the server's.
|
||||
* - WhatsApp's copy prefix ("[07/10, 09:12] Name: ") and bold, italic
|
||||
* and strike markers are stripped.
|
||||
*
|
||||
* Codes are kept as typed; matching them to shots is the server's job.
|
||||
*/
|
||||
|
||||
export interface FeedbackNote {
|
||||
codes: string[];
|
||||
text: string;
|
||||
/** Frame number as the client quoted it ("at frame 1018"); null = none given */
|
||||
frame: number | null;
|
||||
}
|
||||
|
||||
export interface FeedbackRoundDraft {
|
||||
title: string;
|
||||
dueText: string | null;
|
||||
notes: FeedbackNote[];
|
||||
}
|
||||
|
||||
export interface ParsedFeedback {
|
||||
rounds: FeedbackRoundDraft[];
|
||||
/** Lines before any note that were not a round header ("Hi team") */
|
||||
ignored: string[];
|
||||
}
|
||||
|
||||
// "[07/10/2026, 09:12]" / "[9:12 AM, 10/7/2026]" then "Sender Name: "
|
||||
const WHATSAPP_PREFIX = /^\[[^\]]*\d[^\]]*\]\s*(?:[^:]{1,60}:\s)?/;
|
||||
const BULLET = /^(?:[-*•–]|\d+[.)])\s+/;
|
||||
// One code: underscore-joined segments. Clients sometimes drop the show
|
||||
// prefix ("113_018_050"), so two segments are enough here.
|
||||
const CODE = "[A-Za-z0-9]+(?:_[A-Za-z0-9]+)+";
|
||||
const LEADING_CODES = new RegExp(`^(${CODE})((?:\\s*(?:,|/|&|\\+|and)?\\s*${CODE})*)`, "i");
|
||||
const HEADER_START = /^(feedback|notes|round|comments)\b/i;
|
||||
const DUE = /\bdue\b[:\s]*(.*)$/i;
|
||||
const DUE_WITH_DATE = /\bdue\b[:\s]+\S*\d/i;
|
||||
const FRAME = /\b(?:frames?|fr\.?|frm)\s*#?\s*(\d{1,6})\b/i;
|
||||
|
||||
function clean(line: string): string {
|
||||
return line
|
||||
.replace(WHATSAPP_PREFIX, "")
|
||||
.replace(/[*~]/g, "") // *bold*, ~strike~
|
||||
// _italic_ only around whole words: shot codes are full of underscores
|
||||
.replace(/(^|\s)_([^_\s][^_]*?)_(?=[\s.,!?]|$)/g, "$1$2")
|
||||
.replace(BULLET, "")
|
||||
.trim();
|
||||
}
|
||||
|
||||
// Strict on purpose: a wrapped note line ("lighting changes, due to the
|
||||
// grade") must continue the note, not start a round.
|
||||
function isHeader(line: string): boolean {
|
||||
if (HEADER_START.test(line)) return true;
|
||||
return line.length <= 60 && (line.endsWith(":") || DUE_WITH_DATE.test(line));
|
||||
}
|
||||
|
||||
export function parseFeedback(input: string): ParsedFeedback {
|
||||
const rounds: FeedbackRoundDraft[] = [];
|
||||
const ignored: string[] = [];
|
||||
let round: FeedbackRoundDraft | null = null;
|
||||
let note: FeedbackNote[] | null = null; // the note (one per code) being continued
|
||||
|
||||
const startRound = (title: string, dueText: string | null) => {
|
||||
round = { title, dueText, notes: [] };
|
||||
rounds.push(round);
|
||||
note = null;
|
||||
};
|
||||
|
||||
for (const raw of input.split(/\r?\n/)) {
|
||||
const line = clean(raw);
|
||||
if (!line) continue;
|
||||
|
||||
const lead = LEADING_CODES.exec(line);
|
||||
if (lead) {
|
||||
const codes = (lead[0].match(new RegExp(CODE, "g")) ?? []).map((c) => c.toUpperCase());
|
||||
const text = line.slice(lead[0].length).replace(/^[\s:\-–,.]+/, "").trim();
|
||||
if (!round) startRound("", null);
|
||||
note = codes.map((code) => ({ codes: [code], text, frame: null }));
|
||||
round!.notes.push(...note);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isHeader(line)) {
|
||||
const due = DUE.exec(line);
|
||||
const title = (due ? line.slice(0, due.index) : line).replace(/[\s:\-–]+$/, "").trim();
|
||||
startRound(title, due?.[1].trim() || null);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (note) {
|
||||
for (const n of note as FeedbackNote[]) n.text = n.text ? `${n.text} ${line}` : line;
|
||||
} else {
|
||||
ignored.push(line);
|
||||
}
|
||||
}
|
||||
|
||||
for (const r of rounds as FeedbackRoundDraft[]) {
|
||||
for (const n of r.notes) {
|
||||
const f = FRAME.exec(n.text);
|
||||
n.frame = f ? Number(f[1]) : null;
|
||||
}
|
||||
}
|
||||
|
||||
return { rounds: rounds.filter((r) => r.notes.length > 0), ignored };
|
||||
}
|
||||
|
||||
/**
|
||||
* The round's due time from the text the client wrote ("Oct 7, 2026 12:00 PM",
|
||||
* "7 Oct 12:00", "Friday" is not attempted). Run in the browser so the time is
|
||||
* read in the studio's zone. A date without a year takes `now`'s year.
|
||||
*/
|
||||
export function parseDue(dueText: string | null, now = new Date()): Date | null {
|
||||
if (!dueText) return null;
|
||||
const text = dueText.replace(/\b(at|@)\b/gi, " ").replace(/\s+/g, " ").trim();
|
||||
// V8's Date parser accepts almost anything ("end of day 2026"); insist on
|
||||
// a month name or a numeric date before handing it over.
|
||||
if (!/\b(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[a-z]*\b|\d{1,2}[/.-]\d{1,2}/i.test(text)) return null;
|
||||
const direct = new Date(text);
|
||||
if (!isNaN(direct.getTime()) && /\d{4}/.test(text)) return direct;
|
||||
const withYear = new Date(`${text} ${now.getFullYear()}`);
|
||||
if (!isNaN(withYear.getTime())) return withYear;
|
||||
// "7 Oct 12:00" → move the year before the time so Date can read it
|
||||
const m = /^(.*?)(\d{1,2}:\d{2}\s*(?:am|pm)?)$/i.exec(text);
|
||||
if (m) {
|
||||
const d = new Date(`${m[1].trim()} ${now.getFullYear()} ${m[2]}`);
|
||||
if (!isNaN(d.getTime())) return d;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** First comp frame by house convention, for shots with no frameStart recorded */
|
||||
export const HOUSE_FRAME_START = 1001;
|
||||
|
||||
/**
|
||||
* Slate frames before the picture in a version's review media. Recorded on
|
||||
* newer versions; otherwise pipeline previews (the ones that record an EXR
|
||||
* frameCount) open with a 1-frame slate and other uploads with none.
|
||||
* Version.duration is not stored, so the length-based inference in
|
||||
* lib/handles.ts is not available here.
|
||||
*/
|
||||
export function slateFrames(v: { pictureStartFrame: number | null; frameCount: number | null }): number {
|
||||
if (v.pictureStartFrame != null && v.pictureStartFrame >= 0) return v.pictureStartFrame;
|
||||
return v.frameCount != null ? 1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* The player frame (0-based, in the review media) for a frame the client
|
||||
* quoted. Clients read the burned-in comp frame (1001-based), so a quote at
|
||||
* or past the shot's first frame is mapped through it and the slate; a
|
||||
* smaller number is taken as the player's own counter.
|
||||
*/
|
||||
export function toPlayerFrame(
|
||||
quoted: number,
|
||||
opts: { shotFrameStart: number | null; pictureStart: number; frameCount: number | null },
|
||||
): { frame: number; fromComp: boolean } {
|
||||
const { pictureStart, frameCount } = opts;
|
||||
const compStart = opts.shotFrameStart && opts.shotFrameStart > 0 ? opts.shotFrameStart : HOUSE_FRAME_START;
|
||||
const last = frameCount && frameCount > 0 ? pictureStart + frameCount - 1 : null;
|
||||
const clamp = (f: number, min: number) => Math.max(min, last != null ? Math.min(last, f) : f);
|
||||
|
||||
if (quoted >= compStart) {
|
||||
return { frame: clamp(quoted - compStart + pictureStart, pictureStart), fromComp: true };
|
||||
}
|
||||
return { frame: clamp(quoted, 0), fromComp: false };
|
||||
}
|
||||
@@ -147,7 +147,7 @@ export async function getQCQueue(filter: QCQueueFilter) {
|
||||
orderBy: { statusChangedAt: "asc" }, // oldest first — nothing should sit in QC
|
||||
take: limit,
|
||||
include: {
|
||||
shot: { select: { id: true, shotCode: true, episode: true, scene: true, project: { select: { code: true, name: true } } } },
|
||||
shot: { select: { id: true, shotCode: true, episode: true, scene: true, seqTimecodeStart: true, project: { select: { code: true, name: true } } } },
|
||||
validations: { where: { status: { in: ["FAIL", "WARN"] } }, select: { checkName: true, status: true, message: true } },
|
||||
},
|
||||
});
|
||||
@@ -167,6 +167,11 @@ export async function getQCQueue(filter: QCQueueFilter) {
|
||||
frameStart: e.frameStart,
|
||||
frameEnd: e.frameEnd,
|
||||
fps: e.fps,
|
||||
// The panel's QC session cuts each shot into a scene edit: in edit order,
|
||||
// with the handles the render carries trimmed off. Null on old exports.
|
||||
seqTimecodeStart: e.shot.seqTimecodeStart,
|
||||
handleHead: e.handleHead,
|
||||
handleTail: e.handleTail,
|
||||
deliveryMovPath: e.deliveryMovPath,
|
||||
thumbnailUrl: e.thumbnailKey ? `/api/files/${e.thumbnailKey}` : null,
|
||||
previewUrl: e.previewMovKey ? `/api/files/${e.previewMovKey}` : null,
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
-- Daily board: the day-to-day tracker that used to live in a shared doc,
|
||||
-- now linked to shots. Board items are notes, not tasks, so nothing here
|
||||
-- feeds shot status.
|
||||
ALTER TABLE "projects" ADD COLUMN "boardStatus" TEXT;
|
||||
ALTER TABLE "projects" ADD COLUMN "boardStatusAt" TIMESTAMP(3);
|
||||
|
||||
CREATE TABLE "board_items" (
|
||||
"id" TEXT NOT NULL,
|
||||
"projectId" TEXT NOT NULL,
|
||||
"shotId" TEXT,
|
||||
"code" TEXT,
|
||||
"text" TEXT NOT NULL,
|
||||
"group" TEXT NOT NULL DEFAULT '',
|
||||
"assigneeId" TEXT,
|
||||
"waitingOn" TEXT,
|
||||
"sortOrder" INTEGER NOT NULL DEFAULT 0,
|
||||
"doneAt" TIMESTAMP(3),
|
||||
"doneById" TEXT,
|
||||
"createdById" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "board_items_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
CREATE TABLE "project_milestones" (
|
||||
"id" TEXT NOT NULL,
|
||||
"projectId" TEXT NOT NULL,
|
||||
"label" TEXT NOT NULL,
|
||||
"date" TIMESTAMP(3) NOT NULL,
|
||||
"doneAt" TIMESTAMP(3),
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "project_milestones_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
CREATE INDEX "board_items_projectId_doneAt_idx" ON "board_items"("projectId", "doneAt");
|
||||
CREATE INDEX "board_items_shotId_idx" ON "board_items"("shotId");
|
||||
CREATE INDEX "project_milestones_projectId_date_idx" ON "project_milestones"("projectId", "date");
|
||||
|
||||
ALTER TABLE "board_items" ADD CONSTRAINT "board_items_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "projects"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
ALTER TABLE "board_items" ADD CONSTRAINT "board_items_shotId_fkey" FOREIGN KEY ("shotId") REFERENCES "shots"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
ALTER TABLE "board_items" ADD CONSTRAINT "board_items_assigneeId_fkey" FOREIGN KEY ("assigneeId") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
ALTER TABLE "project_milestones" ADD CONSTRAINT "project_milestones_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "projects"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,22 @@
|
||||
-- Client feedback pasted from WhatsApp: rounds group the notes on the board,
|
||||
-- and each note is saved as a player comment tagged with its source.
|
||||
ALTER TABLE "comments" ADD COLUMN "source" TEXT;
|
||||
|
||||
CREATE TABLE "feedback_rounds" (
|
||||
"id" TEXT NOT NULL,
|
||||
"projectId" TEXT NOT NULL,
|
||||
"title" TEXT NOT NULL,
|
||||
"dueAt" TIMESTAMP(3),
|
||||
"createdById" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "feedback_rounds_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
ALTER TABLE "board_items" ADD COLUMN "roundId" TEXT;
|
||||
ALTER TABLE "board_items" ADD COLUMN "commentId" TEXT;
|
||||
|
||||
CREATE INDEX "feedback_rounds_projectId_idx" ON "feedback_rounds"("projectId");
|
||||
|
||||
ALTER TABLE "feedback_rounds" ADD CONSTRAINT "feedback_rounds_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "projects"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
ALTER TABLE "board_items" ADD CONSTRAINT "board_items_roundId_fkey" FOREIGN KEY ("roundId") REFERENCES "feedback_rounds"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
@@ -262,6 +262,7 @@ model User {
|
||||
createdShootDays ShootDay[] @relation("ShootDayCreator")
|
||||
createdTakes Take[] @relation("TakeCreator")
|
||||
uploadedTakeAttachments TakeAttachment[] @relation("TakeAttachmentUploader")
|
||||
assignedBoardItems BoardItem[] @relation("BoardItemAssignee")
|
||||
|
||||
@@map("users")
|
||||
}
|
||||
@@ -382,6 +383,15 @@ model Project {
|
||||
deliveryPackages DeliveryPackage[]
|
||||
deliveryRequests DeliveryRequest[]
|
||||
|
||||
/// The one-line "where are we" on the daily board ("Official bid sent",
|
||||
/// "Awaiting feedback on pick-ups"). Free text on purpose: it is what the
|
||||
/// producer would have typed at the top of the project's section in the doc.
|
||||
boardStatus String? @db.Text
|
||||
boardStatusAt DateTime?
|
||||
boardItems BoardItem[]
|
||||
milestones ProjectMilestone[]
|
||||
feedbackRounds FeedbackRound[]
|
||||
|
||||
@@map("projects")
|
||||
}
|
||||
|
||||
@@ -487,6 +497,7 @@ model Shot {
|
||||
loggedTakes Take[] @relation("TakeToShot")
|
||||
exports Export[]
|
||||
deliveryRequestLines DeliveryRequestLine[]
|
||||
boardItems BoardItem[]
|
||||
|
||||
@@unique([projectId, shotCode])
|
||||
@@map("shots")
|
||||
@@ -602,6 +613,10 @@ model Comment {
|
||||
timestamp Float
|
||||
text String @db.Text
|
||||
isResolved Boolean @default(false)
|
||||
/// Where the note came from when it was not typed in the player. "WHATSAPP"
|
||||
/// = client feedback pasted from a message; `authorId` is then whoever
|
||||
/// logged it, not who said it, and the player labels it client feedback.
|
||||
source String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@ -1255,6 +1270,80 @@ model DeliveryRequestLine {
|
||||
@@map("delivery_request_lines")
|
||||
}
|
||||
|
||||
/// A line on the daily board — the day-to-day to-do the team used to keep in
|
||||
/// a shared doc ("DH2_VFX_027_090 finalise (CHRIS)"). Deliberately not a Task:
|
||||
/// tasks are the pipeline's one-per-shot work items whose state drives shot
|
||||
/// status, and a note like "finalise" or "awaiting gfx" must not move a shot
|
||||
/// back to IN_PROGRESS or notify anyone.
|
||||
///
|
||||
/// `code` is the shot code as typed. When it matches a shot, `shotId` links it
|
||||
/// and the board shows the shot's live status; when it does not, the line is a
|
||||
/// flag ("not on our tracker?") until the shot exists or the code is fixed.
|
||||
model BoardItem {
|
||||
id String @id @default(cuid())
|
||||
projectId String
|
||||
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
||||
shotId String?
|
||||
shot Shot? @relation(fields: [shotId], references: [id], onDelete: SetNull)
|
||||
code String?
|
||||
text String @db.Text
|
||||
/// Heading the line sits under on the board ("WATER DROPS"); "" = none
|
||||
group String @default("")
|
||||
assigneeId String?
|
||||
assignee User? @relation("BoardItemAssignee", fields: [assigneeId], references: [id], onDelete: SetNull)
|
||||
/// What the line is blocked on ("client GFX ADH_GFX_013_010"); null = not blocked
|
||||
waitingOn String?
|
||||
/// Set when the line came from pasted client feedback: the round it belongs
|
||||
/// to, and the player comment it was saved as. Ticking the line off
|
||||
/// resolves that comment.
|
||||
roundId String?
|
||||
round FeedbackRound? @relation(fields: [roundId], references: [id], onDelete: SetNull)
|
||||
commentId String?
|
||||
sortOrder Int @default(0)
|
||||
doneAt DateTime?
|
||||
doneById String?
|
||||
createdById String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@index([projectId, doneAt])
|
||||
@@index([shotId])
|
||||
@@map("board_items")
|
||||
}
|
||||
|
||||
/// One batch of client feedback as it arrived ("FEEDBACK 113 DUE Oct 7 12:00
|
||||
/// PM"). Its notes are saved as player comments and as board lines; the round
|
||||
/// is what groups them on the board under one due time.
|
||||
model FeedbackRound {
|
||||
id String @id @default(cuid())
|
||||
projectId String
|
||||
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
||||
title String
|
||||
dueAt DateTime?
|
||||
createdById String
|
||||
createdAt DateTime @default(now())
|
||||
items BoardItem[]
|
||||
|
||||
@@index([projectId])
|
||||
@@map("feedback_rounds")
|
||||
}
|
||||
|
||||
/// A dated project milestone — batch deliveries, picture locks, shoot start,
|
||||
/// colour & mix review. Episode due dates stay in EpisodeDueDate because the
|
||||
/// shot-status board keys off them; these are the dates around the work.
|
||||
model ProjectMilestone {
|
||||
id String @id @default(cuid())
|
||||
projectId String
|
||||
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
||||
label String
|
||||
date DateTime
|
||||
doneAt DateTime?
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
@@index([projectId, date])
|
||||
@@map("project_milestones")
|
||||
}
|
||||
|
||||
model SketchTemplate {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
|
||||
@@ -64,6 +64,8 @@ export interface CommentWithReplies {
|
||||
timestamp: number;
|
||||
text: string;
|
||||
isResolved: boolean;
|
||||
/** "WHATSAPP" = client feedback pasted from a message; author is who logged it */
|
||||
source?: string | null;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
author: {
|
||||
|
||||
Reference in New Issue
Block a user