Supervisor feature
Deploy / deploy (push) Successful in 2m40s

This commit is contained in:
twotalesanimation
2026-07-11 16:12:41 +02:00
parent e24fd8eda0
commit bb61813b04
4 changed files with 95 additions and 34 deletions
+17 -5
View File
@@ -1,7 +1,7 @@
"use client";
import { useState, useCallback, useRef, useEffect } from "react";
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
import { useQuery } from "@tanstack/react-query";
import { format } from "date-fns";
import { Plus, ChevronDown, ChevronRight, Image, MessageSquare, Loader2, Clapperboard } from "lucide-react";
import { Button } from "@/components/ui/button";
@@ -64,7 +64,8 @@ interface Props {
onNewDay: () => void;
onNewSetup: (dayId: string) => void;
onNewTake: (setupId: string) => void;
refreshToken?: number;
/** When set, auto-expands this day ID (e.g. after creation) */
expandDayId?: string | null;
}
export function TakeListPanel({
@@ -74,21 +75,21 @@ export function TakeListPanel({
onNewDay,
onNewSetup,
onNewTake,
refreshToken,
expandDayId,
}: Props) {
const [expandedDays, setExpandedDays] = useState<Set<string>>(new Set());
const [expandedSetups, setExpandedSetups] = useState<Set<string>>(new Set());
const autoExpandedRef = useRef(false);
const { data, isLoading } = useQuery<{ days: ShootDayWithSetups[] }>({
queryKey: ["shoot-log-days", projectId, refreshToken],
queryKey: ["shoot-log-days", projectId],
queryFn: async () => {
const res = await fetch(`/api/shoot-log/days?projectId=${projectId}`);
if (!res.ok) throw new Error("Failed to load days");
return res.json();
},
enabled: !!projectId,
staleTime: 30_000,
staleTime: 0,
});
const days = data?.days ?? [];
@@ -121,6 +122,17 @@ export function TakeListPanel({
}
}, [days]);
// Expand a specific day when requested (e.g. after creation)
useEffect(() => {
if (!expandDayId) return;
setExpandedDays((prev) => new Set([...prev, expandDayId]));
// Also expand the first setup within that day if present
const day = days.find((d) => d.id === expandDayId);
if (day?.setups[0]) {
setExpandedSetups((prev) => new Set([...prev, day.setups[0].id]));
}
}, [expandDayId]); // eslint-disable-line react-hooks/exhaustive-deps
const hasNotes = (take: TakeSummary) =>
!!(take.supervisorNotes || take.continuityNotes || take.vfxRequirements);