feat(deliveries): delivery requests and upload/share evidence
Deploy / deploy (push) Successful in 5m17s
Deploy / deploy (push) Successful in 5m17s
A built package used to become DELIVERED on one click with nothing behind it, and nothing recorded what a client had asked for. - Marking delivered is now two recorded steps: Record upload (the link on the client's portal, contents confirmed) then Share link (who it was sent to). The second is refused until the first is on record. - Delivery requests log a client's ask by episode, pasted shot codes or a Shot Status selection. A line closes only when its shot goes out with evidence after the request was logged; a request can otherwise only be cancelled with a reason. - Delivered Outside Pipeline takes an upload link and recipient, required for shots on an open request. - The dashboard gains an Awaiting delivery section listing open requests and built packages the client does not have yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { db } from "@/lib/db";
|
||||
import { getConfigNumber } from "@/lib/render-pipeline/config";
|
||||
import { listMachines } from "@/lib/render-pipeline/machines";
|
||||
import { handoffStage, type HandoffStage } from "@/lib/render-pipeline/delivery-handoff";
|
||||
import type { ExportStatus, Prisma } from "@prisma/client";
|
||||
|
||||
/**
|
||||
@@ -596,6 +597,72 @@ export async function getRecentDeliveries(limit = 5): Promise<DeliverySummary[]>
|
||||
});
|
||||
}
|
||||
|
||||
export interface AwaitingDelivery {
|
||||
id: string;
|
||||
packageNumber: number;
|
||||
name: string;
|
||||
projectCode: string;
|
||||
episode: string;
|
||||
itemCount: number;
|
||||
stage: HandoffStage;
|
||||
/** When the folder was ready to go — the clock the client is waiting on. */
|
||||
builtAt: Date;
|
||||
severity: "normal" | "warning" | "critical";
|
||||
}
|
||||
|
||||
/**
|
||||
* Built packages the client does not have yet.
|
||||
*
|
||||
* A READY package is the easiest thing in the pipeline to believe is done: the
|
||||
* folder exists and every file verified, but nothing has left the building.
|
||||
* It stays listed until the upload location and the person it was shared with
|
||||
* are both on record, and gets louder the longer that takes.
|
||||
*/
|
||||
export async function getAwaitingDelivery(): Promise<AwaitingDelivery[]> {
|
||||
const rows = await db.deliveryPackage.findMany({
|
||||
where: {
|
||||
kind: "EXR_DELIVERY",
|
||||
status: "READY",
|
||||
project: { status: { in: ["ACTIVE", "ON_HOLD"] } },
|
||||
},
|
||||
orderBy: { builtAt: "asc" },
|
||||
select: {
|
||||
id: true,
|
||||
packageNumber: true,
|
||||
name: true,
|
||||
kind: true,
|
||||
status: true,
|
||||
episode: true,
|
||||
createdAt: true,
|
||||
builtAt: true,
|
||||
uploadedAt: true,
|
||||
project: { select: { code: true } },
|
||||
_count: { select: { items: true } },
|
||||
},
|
||||
});
|
||||
|
||||
const day = 24 * 3600_000;
|
||||
return rows.flatMap((row) => {
|
||||
const stage = handoffStage(row);
|
||||
if (!stage) return [];
|
||||
const builtAt = row.builtAt ?? row.createdAt;
|
||||
const age = Date.now() - builtAt.getTime();
|
||||
return [
|
||||
{
|
||||
id: row.id,
|
||||
packageNumber: row.packageNumber,
|
||||
name: row.name,
|
||||
projectCode: row.project.code,
|
||||
episode: row.episode,
|
||||
itemCount: row._count.items,
|
||||
stage,
|
||||
builtAt,
|
||||
severity: age >= 2 * day ? "critical" : age >= day ? "warning" : "normal",
|
||||
},
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
export interface CourtSide {
|
||||
count: number;
|
||||
items: { id: string; shotCode: string; label: string; href: string }[];
|
||||
|
||||
Reference in New Issue
Block a user