feat(delivery): record shots delivered outside the render pipeline
Deploy / deploy (push) Successful in 3m34s
Deploy / deploy (push) Successful in 3m34s
Shots delivered by hand before the pipeline have no Export, so they could never appear in a DeliveryPackage and the dashboard countdown showed them as not delivered. Add Shot.manualDeliveredAt/ById/Note, a "Delivered Outside Pipeline" bulk action on Shot Status (mark with the real date, or clear), a badge on marked shots, and count them in the countdown alongside DELIVERED EXR packages. The real date keeps the weekly rate honest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -32,7 +32,7 @@ import { Button } from "@/components/ui/button";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
|
||||
import { cn, getInitials } from "@/lib/utils";
|
||||
import { updateShotNotes, bulkUpdateDueDates, bulkAssignArtist, bulkDeleteShots, toggleKeyShot, toggleScaledShot } from "@/actions/shots";
|
||||
import { updateShotNotes, bulkUpdateDueDates, bulkAssignArtist, bulkDeleteShots, bulkSetManualDelivery, toggleKeyShot, toggleScaledShot } from "@/actions/shots";
|
||||
import { previewMovReview, buildMovReview } from "@/actions/deliveries";
|
||||
import { useToast } from "@/components/ui/use-toast";
|
||||
import {
|
||||
@@ -54,6 +54,7 @@ import {
|
||||
Clapperboard,
|
||||
Scaling,
|
||||
UserPlus,
|
||||
PackageCheck,
|
||||
} from "lucide-react";
|
||||
import { format } from "date-fns";
|
||||
import { shotThumbnail } from "@/lib/shot-thumbnail";
|
||||
@@ -73,6 +74,8 @@ type ShotRow = {
|
||||
description: string | null;
|
||||
isKeyShot: boolean;
|
||||
isScaled: boolean;
|
||||
manualDeliveredAt: Date | string | null;
|
||||
manualDeliveryNote: string | null;
|
||||
shotVersion: string | null;
|
||||
artist: { id: string; name: string | null; image: string | null; email: string } | null;
|
||||
shotGroup: { id: string; name: string } | null;
|
||||
@@ -352,6 +355,128 @@ function BulkAssignArtistDialog({
|
||||
);
|
||||
}
|
||||
|
||||
// ── ManualDeliveryDialog ──────────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* Record shots as delivered outside the render pipeline — the ones sent by
|
||||
* hand before packages existed, which have no Export to put in a package.
|
||||
*
|
||||
* The date asked for is when the frames went out, not today: the delivery
|
||||
* countdown's weekly rate reads it, so a backfill stamped with today's date
|
||||
* would claim a week nobody had.
|
||||
*/
|
||||
function ManualDeliveryDialog({
|
||||
open,
|
||||
onClose,
|
||||
onApply,
|
||||
count,
|
||||
}: {
|
||||
open: boolean;
|
||||
onClose: () => void;
|
||||
onApply: (deliveredOn: string | null, note: string) => Promise<void>;
|
||||
count: number;
|
||||
}) {
|
||||
const [date, setDate] = useState("");
|
||||
const [note, setNote] = useState("");
|
||||
const [clearing, setClearing] = useState(false);
|
||||
const [isPending, startTransition] = useTransition();
|
||||
|
||||
useEffect(() => {
|
||||
if (open) {
|
||||
setDate("");
|
||||
setNote("");
|
||||
setClearing(false);
|
||||
}
|
||||
}, [open]);
|
||||
|
||||
const handleApply = () => {
|
||||
if (!clearing && !date) return;
|
||||
startTransition(async () => {
|
||||
await onApply(clearing ? null : date, note);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={(o) => { if (!o && !isPending) onClose(); }}>
|
||||
<DialogContent className="sm:max-w-sm">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Delivered Outside Pipeline</DialogTitle>
|
||||
</DialogHeader>
|
||||
|
||||
<p className="text-sm text-zinc-400 -mt-1">
|
||||
Applying to <span className="text-white font-medium">{count}</span>{" "}
|
||||
shot{count !== 1 ? "s" : ""}
|
||||
</p>
|
||||
|
||||
<div className="space-y-4 pt-1">
|
||||
<div className="space-y-2.5">
|
||||
<label className="flex items-center gap-2.5 cursor-pointer">
|
||||
<input
|
||||
type="radio"
|
||||
name="manual-delivery-mode"
|
||||
checked={!clearing}
|
||||
onChange={() => setClearing(false)}
|
||||
className="accent-blue-500 cursor-pointer"
|
||||
/>
|
||||
<span className="text-sm text-zinc-200">Mark as delivered</span>
|
||||
</label>
|
||||
<label className="flex items-center gap-2.5 cursor-pointer">
|
||||
<input
|
||||
type="radio"
|
||||
name="manual-delivery-mode"
|
||||
checked={clearing}
|
||||
onChange={() => setClearing(true)}
|
||||
className="accent-blue-500 cursor-pointer"
|
||||
/>
|
||||
<span className="text-sm text-zinc-200">Clear manual delivery</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
{!clearing && (
|
||||
<>
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-medium text-zinc-400">Date the shots went out</label>
|
||||
<input
|
||||
type="date"
|
||||
value={date}
|
||||
max={format(new Date(), "yyyy-MM-dd")}
|
||||
onChange={(e) => setDate(e.target.value)}
|
||||
className="w-full rounded-md border border-zinc-700 bg-zinc-900 px-3 py-2 text-sm text-zinc-100 [color-scheme:dark] focus:border-zinc-500 focus:outline-none focus:ring-1 focus:ring-zinc-500"
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-medium text-zinc-400">Note (optional)</label>
|
||||
<Textarea
|
||||
value={note}
|
||||
onChange={(e) => setNote(e.target.value)}
|
||||
placeholder="e.g. Aspera upload, turnover 3"
|
||||
className="min-h-[56px] text-sm resize-none bg-zinc-900 border-zinc-700 focus:border-zinc-500 text-zinc-200 placeholder:text-zinc-600"
|
||||
rows={2}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
<p className="text-xs text-zinc-500">
|
||||
For shots sent by hand before the render pipeline. They count as delivered on the
|
||||
dashboard; no package is created and nothing is sent.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<DialogFooter className="mt-2">
|
||||
<Button variant="ghost" onClick={onClose} disabled={isPending}>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button onClick={handleApply} disabled={(!clearing && !date) || isPending}>
|
||||
{isPending && <Loader2 className="h-3.5 w-3.5 mr-1.5 animate-spin" />}
|
||||
{clearing ? "Clear" : "Mark delivered"}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
function BulkDeleteDialog({
|
||||
open,
|
||||
onClose,
|
||||
@@ -811,6 +936,15 @@ function ShotTable({
|
||||
Scaled
|
||||
</span>
|
||||
)}
|
||||
{shot.manualDeliveredAt && (
|
||||
<span
|
||||
title={shot.manualDeliveryNote ?? "Delivered outside the render pipeline"}
|
||||
className="flex items-center gap-1 rounded-full border border-emerald-500/30 bg-emerald-500/10 px-1.5 py-0.5 text-[10px] font-medium text-emerald-300 shrink-0"
|
||||
>
|
||||
<PackageCheck className="h-2.5 w-2.5" />
|
||||
Delivered {format(new Date(shot.manualDeliveredAt), "d MMM")}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
{shot.description && (
|
||||
<p className="text-xs text-zinc-500 mt-0.5 truncate max-w-[200px]">
|
||||
@@ -951,6 +1085,7 @@ export function ShotStatusClient({
|
||||
const [assignDialogOpen, setAssignDialogOpen] = useState(false);
|
||||
const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);
|
||||
const [movReviewDialogOpen, setMovReviewDialogOpen] = useState(false);
|
||||
const [manualDeliveryDialogOpen, setManualDeliveryDialogOpen] = useState(false);
|
||||
|
||||
const toggleEpisode = (ep: string) =>
|
||||
setExpandedEpisodes((prev) => {
|
||||
@@ -1050,6 +1185,23 @@ export function ShotStatusClient({
|
||||
}
|
||||
};
|
||||
|
||||
const handleManualDelivery = async (deliveredOn: string | null, note: string) => {
|
||||
try {
|
||||
const result = await bulkSetManualDelivery([...selectedIds], deliveredOn, note);
|
||||
const n = `${result.updated} shot${result.updated !== 1 ? "s" : ""}`;
|
||||
toast({ title: deliveredOn ? `${n} marked delivered` : `Manual delivery cleared on ${n}` });
|
||||
setManualDeliveryDialogOpen(false);
|
||||
clearSelection();
|
||||
router.refresh();
|
||||
} catch (e) {
|
||||
toast({
|
||||
title: "Failed to update delivery",
|
||||
description: e instanceof Error ? e.message : undefined,
|
||||
variant: "destructive",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const handleBulkDelete = async () => {
|
||||
try {
|
||||
const result = await bulkDeleteShots([...selectedIds]);
|
||||
@@ -1232,6 +1384,10 @@ export function ShotStatusClient({
|
||||
<Clapperboard className="h-3.5 w-3.5 mr-2" />
|
||||
Build MOV Review Package
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={() => setManualDeliveryDialogOpen(true)}>
|
||||
<PackageCheck className="h-3.5 w-3.5 mr-2" />
|
||||
Delivered Outside Pipeline
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem
|
||||
onClick={() => setDeleteDialogOpen(true)}
|
||||
@@ -1446,6 +1602,14 @@ export function ShotStatusClient({
|
||||
count={selectionCount}
|
||||
/>
|
||||
|
||||
{/* Manual (pre-pipeline) delivery dialog */}
|
||||
<ManualDeliveryDialog
|
||||
open={manualDeliveryDialogOpen}
|
||||
onClose={() => setManualDeliveryDialogOpen(false)}
|
||||
onApply={handleManualDelivery}
|
||||
count={selectionCount}
|
||||
/>
|
||||
|
||||
{/* Bulk delete dialog */}
|
||||
<BulkDeleteDialog
|
||||
open={deleteDialogOpen}
|
||||
|
||||
Reference in New Issue
Block a user