Initial commit

This commit is contained in:
twotalesanimation
2026-05-19 22:20:29 +02:00
commit 0fbe856dce
173 changed files with 38316 additions and 0 deletions
+94
View File
@@ -0,0 +1,94 @@
"use client";
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
import { cn, getInitials, formatRelativeDate } from "@/lib/utils";
import { ScrollArea } from "@/components/ui/scroll-area";
import {
Film,
MessageSquare,
CheckCircle2,
XCircle,
Upload,
Bell,
AtSign,
} from "lucide-react";
interface ActivityItem {
id: string;
type: string;
title: string;
message: string;
createdAt: Date;
user?: {
name: string | null;
image: string | null;
} | null;
}
interface RecentActivityProps {
activities: ActivityItem[];
}
const ACTIVITY_ICONS: Record<string, { icon: React.ElementType; color: string }> = {
VERSION_UPLOADED: { icon: Upload, color: "text-blue-400 bg-blue-500/10" },
FEEDBACK_ADDED: { icon: MessageSquare, color: "text-amber-400 bg-amber-500/10" },
SHOT_APPROVED: { icon: CheckCircle2, color: "text-emerald-400 bg-emerald-500/10" },
SHOT_REJECTED: { icon: XCircle, color: "text-red-400 bg-red-500/10" },
COMMENT_REPLY: { icon: MessageSquare, color: "text-purple-400 bg-purple-500/10" },
MENTION: { icon: AtSign, color: "text-primary bg-primary/10" },
REVISION_REQUESTED: { icon: Film, color: "text-orange-400 bg-orange-500/10" },
};
export function RecentActivity({ activities }: RecentActivityProps) {
if (activities.length === 0) {
return (
<div className="flex flex-col items-center justify-center py-10 text-zinc-500">
<Bell className="h-8 w-8 mb-3 opacity-30" />
<p className="text-sm">No recent activity</p>
</div>
);
}
return (
<ScrollArea className="h-full">
<div className="space-y-1 p-1">
{activities.map((item) => {
const cfg = ACTIVITY_ICONS[item.type] ?? { icon: Bell, color: "text-muted-foreground bg-muted/20" };
const Icon = cfg.icon;
return (
<div
key={item.id}
className="flex gap-3 px-2 py-2.5 rounded-lg hover:bg-secondary/30 transition-colors"
>
<div className={cn("p-1.5 rounded-md shrink-0 mt-0.5", cfg.color.split(" ")[1])}>
<Icon className={cn("h-3 w-3", cfg.color.split(" ")[0])} />
</div>
<div className="flex-1 min-w-0">
<p className="text-sm font-medium truncate">{item.title}</p>
<p className="text-xs text-muted-foreground line-clamp-2 mt-0.5">
{item.message}
</p>
</div>
<div className="flex flex-col items-end gap-1 shrink-0">
{item.user && (
<Avatar className="h-5 w-5">
{item.user.image && <AvatarImage src={item.user.image} />}
<AvatarFallback className="text-[8px]">
{getInitials(item.user.name)}
</AvatarFallback>
</Avatar>
)}
<span className="text-xs text-muted-foreground whitespace-nowrap">
{formatRelativeDate(item.createdAt)}
</span>
</div>
</div>
);
})}
</div>
</ScrollArea>
);
}
+319
View File
@@ -0,0 +1,319 @@
"use client";
import Link from "next/link";
import { format, addDays, startOfWeek, differenceInDays, parseISO } from "date-fns";
import { CalendarDays, AlertTriangle, Clock, Users, ExternalLink } from "lucide-react";
import { cn } from "@/lib/utils";
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
import { getInitials } from "@/lib/utils";
import { TASK_STATUS_CONFIG, TASK_TYPE_LABELS } from "@/components/tasks/TaskCard";
import { TaskStatus, TaskType } from "@prisma/client";
function toDate(val: string | null | undefined): Date | null {
if (!val) return null;
try {
return parseISO(val);
} catch {
return new Date(val);
}
}
interface ScheduleTask {
id: string;
title: string;
type: string;
status: string;
priority: string;
dueDate: string | null;
estimatedHours: number | null;
scheduledStartDate: string | null;
scheduledEndDate: string | null;
assignedArtistId: string | null;
assignedArtist: {
id: string;
name: string | null;
email: string;
image: string | null;
} | null;
shot: { shotCode: string } | null;
asset: { assetCode: string } | null;
project: { id: string; name: string; code: string };
}
interface ScheduleWidgetsProps {
scheduledTasks: ScheduleTask[];
artists: {
id: string;
name: string | null;
email: string;
image: string | null;
role: string;
}[];
}
function calcArtistLoad(
tasks: ScheduleTask[],
artistId: string,
weekStart: Date
): number {
const weekEnd = addDays(weekStart, 6);
const artistTasks = tasks.filter((t) => t.assignedArtistId === artistId);
let totalHours = 0;
for (const task of artistTasks) {
const start = toDate(task.scheduledStartDate);
const end = toDate(task.scheduledEndDate) ?? start;
if (!start || !end) continue;
// Check overlap with week
if (start > weekEnd || end < weekStart) continue;
const dur = Math.max(1, differenceInDays(end, start) + 1);
const hoursPerDay = (task.estimatedHours ?? 8) / dur;
// Count days in this week
let daysInWeek = 0;
for (let i = 0; i < 7; i++) {
const day = addDays(weekStart, i);
if (day >= start && day <= end) daysInWeek++;
}
totalHours += hoursPerDay * daysInWeek;
}
return totalHours;
}
export function ScheduleWidgets({
scheduledTasks,
artists,
}: ScheduleWidgetsProps) {
const today = new Date();
const weekStart = startOfWeek(today, { weekStartsOn: 1 });
const weekEnd = addDays(weekStart, 6);
// Tasks due this week
const dueThisWeek = scheduledTasks.filter((t) => {
const due = toDate(t.dueDate);
return due && due >= today && due <= weekEnd && t.status !== "DONE";
});
// Overloaded artists (> 40h this week = > 8h/day avg)
const artistLoads = artists.map((a) => ({
artist: a,
hours: calcArtistLoad(scheduledTasks, a.id, weekStart),
}));
const overloaded = artistLoads.filter((al) => al.hours > 40);
// Upcoming reviews
const upcomingReviews = scheduledTasks.filter(
(t) =>
t.status === "INTERNAL_REVIEW" || t.status === "CLIENT_REVIEW"
);
return (
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
{/* Due This Week */}
<div className="rounded-lg border border-zinc-800 bg-zinc-900 overflow-hidden">
<div className="flex items-center justify-between px-4 py-3 border-b border-zinc-800">
<div className="flex items-center gap-2">
<CalendarDays className="h-4 w-4 text-amber-400" />
<span className="text-sm font-medium text-zinc-200">
Due This Week
</span>
</div>
<span className="text-xs bg-zinc-800 text-zinc-400 px-2 py-0.5 rounded-full">
{dueThisWeek.length}
</span>
</div>
<div className="divide-y divide-zinc-800/60 max-h-52 overflow-y-auto">
{dueThisWeek.length === 0 ? (
<div className="px-4 py-6 text-center text-xs text-zinc-600">
No tasks due this week
</div>
) : (
dueThisWeek.slice(0, 6).map((task) => {
const code = task.shot?.shotCode ?? task.asset?.assetCode;
const cfg = TASK_STATUS_CONFIG[task.status as TaskStatus];
const StatusIcon = cfg.icon;
return (
<Link
key={task.id}
href={`/tasks/${task.id}`}
className="flex items-center gap-2.5 px-4 py-2.5 hover:bg-zinc-800/50 transition-colors"
>
<div className="flex-1 min-w-0">
<div className="flex items-center gap-1.5">
{code && (
<span className="text-[10px] font-mono text-zinc-500">
{code}
</span>
)}
<span className="text-xs text-zinc-300 truncate">
{task.title}
</span>
</div>
<div className="flex items-center gap-1.5 mt-0.5">
<span
className={cn(
"text-[10px]",
cfg.color.split(" ").find((c) => c.startsWith("text-"))
)}
>
{cfg.label}
</span>
{task.dueDate && (
<span className="text-[10px] text-zinc-600">
{format(toDate(task.dueDate)!, "EEE, MMM d")}
</span>
)}
</div>
</div>
{task.assignedArtist && (
<Avatar className="h-5 w-5 shrink-0">
<AvatarImage src={task.assignedArtist.image ?? undefined} />
<AvatarFallback className="text-[8px] bg-zinc-700">
{getInitials(
task.assignedArtist.name ?? task.assignedArtist.email
)}
</AvatarFallback>
</Avatar>
)}
</Link>
);
})
)}
</div>
</div>
{/* Artist Utilization */}
<div className="rounded-lg border border-zinc-800 bg-zinc-900 overflow-hidden">
<div className="flex items-center justify-between px-4 py-3 border-b border-zinc-800">
<div className="flex items-center gap-2">
<Users className="h-4 w-4 text-blue-400" />
<span className="text-sm font-medium text-zinc-200">
This Week
</span>
</div>
<Link
href="/schedule"
className="text-[10px] text-zinc-500 hover:text-amber-400 flex items-center gap-0.5 transition-colors"
>
Schedule <ExternalLink className="h-2.5 w-2.5" />
</Link>
</div>
<div className="divide-y divide-zinc-800/60 max-h-52 overflow-y-auto">
{artistLoads.length === 0 ? (
<div className="px-4 py-6 text-center text-xs text-zinc-600">
No scheduled work this week
</div>
) : (
artistLoads
.filter((al) => al.hours > 0)
.sort((a, b) => b.hours - a.hours)
.slice(0, 6)
.map(({ artist, hours }) => {
const pct = Math.min(100, (hours / 40) * 100);
const isOver = hours > 40;
return (
<div key={artist.id} className="px-4 py-2.5">
<div className="flex items-center gap-2 mb-1.5">
<Avatar className="h-5 w-5 shrink-0">
<AvatarImage src={artist.image ?? undefined} />
<AvatarFallback className="text-[8px] bg-zinc-700">
{getInitials(artist.name ?? artist.email)}
</AvatarFallback>
</Avatar>
<span className="text-xs text-zinc-300 flex-1 truncate">
{artist.name ?? artist.email.split("@")[0]}
</span>
<span
className={cn(
"text-[10px] font-medium",
isOver ? "text-orange-400" : "text-zinc-500"
)}
>
{Math.round(hours)}h
{isOver && " ⚠"}
</span>
</div>
<div className="h-1 bg-zinc-800 rounded-full overflow-hidden">
<div
className={cn(
"h-full rounded-full transition-all",
isOver ? "bg-orange-500" : "bg-blue-500"
)}
style={{ width: `${pct}%` }}
/>
</div>
</div>
);
})
)}
</div>
</div>
{/* Upcoming Reviews */}
<div className="rounded-lg border border-zinc-800 bg-zinc-900 overflow-hidden">
<div className="flex items-center justify-between px-4 py-3 border-b border-zinc-800">
<div className="flex items-center gap-2">
<Clock className="h-4 w-4 text-purple-400" />
<span className="text-sm font-medium text-zinc-200">
In Review
</span>
</div>
<span className="text-xs bg-zinc-800 text-zinc-400 px-2 py-0.5 rounded-full">
{upcomingReviews.length}
</span>
</div>
<div className="divide-y divide-zinc-800/60 max-h-52 overflow-y-auto">
{upcomingReviews.length === 0 ? (
<div className="px-4 py-6 text-center text-xs text-zinc-600">
Nothing in review
</div>
) : (
upcomingReviews.slice(0, 6).map((task) => {
const code = task.shot?.shotCode ?? task.asset?.assetCode;
const isClient = task.status === "CLIENT_REVIEW";
return (
<Link
key={task.id}
href={`/tasks/${task.id}`}
className="flex items-center gap-2.5 px-4 py-2.5 hover:bg-zinc-800/50 transition-colors"
>
<div
className={cn(
"w-1.5 h-1.5 rounded-full shrink-0",
isClient ? "bg-amber-400" : "bg-purple-400"
)}
/>
<div className="flex-1 min-w-0">
<div className="flex items-center gap-1.5">
{code && (
<span className="text-[10px] font-mono text-zinc-500">
{code}
</span>
)}
<span className="text-xs text-zinc-300 truncate">
{task.title}
</span>
</div>
<span
className={cn(
"text-[10px]",
isClient ? "text-amber-500" : "text-purple-500"
)}
>
{isClient ? "Client Review" : "Internal Review"}
</span>
</div>
</Link>
);
})
)}
</div>
</div>
</div>
);
}
+139
View File
@@ -0,0 +1,139 @@
"use client";
import Link from "next/link";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
import { cn, getInitials, formatRelativeDate } from "@/lib/utils";
import {
ArrowUpRight,
Clock,
CheckCircle2,
AlertCircle,
Film,
MessageSquare,
} from "lucide-react";
import type { ShotWithDetails } from "@/types";
interface ShotQueueProps {
shots: ShotWithDetails[];
projectId?: string;
title?: string;
}
const STATUS_STYLES: Record<string, string> = {
WAITING: "text-zinc-400",
IN_PROGRESS: "text-blue-400",
IN_REVIEW: "text-purple-400",
REVISIONS: "text-orange-400",
COMPLETE: "text-emerald-400",
};
const STATUS_ICONS: Record<string, React.ElementType> = {
WAITING: Clock,
IN_PROGRESS: Film,
IN_REVIEW: AlertCircle,
REVISIONS: AlertCircle,
COMPLETE: CheckCircle2,
};
const PRIORITY_DOT: Record<string, string> = {
LOW: "bg-zinc-500",
NORMAL: "bg-blue-500",
HIGH: "bg-amber-500",
URGENT: "bg-red-500",
};
export function ShotQueue({ shots, projectId, title = "Shot Queue" }: ShotQueueProps) {
if (shots.length === 0) {
return (
<div className="flex flex-col items-center justify-center py-10 text-muted-foreground">
<Film className="h-8 w-8 mb-3 opacity-30" />
<p className="text-sm">No shots yet</p>
</div>
);
}
return (
<div className="space-y-1">
{shots.map((shot) => {
const StatusIcon = STATUS_ICONS[shot.status] ?? Clock;
const latestVersion = shot.versions?.[0];
const openComments = shot.versions
?.reduce((sum, v) => sum + (v._count?.comments ?? 0), 0) ?? 0;
const href = projectId
? `/projects/${projectId}/shots/${shot.id}`
: `/projects/${(shot as any).projectId ?? "#"}/shots/${shot.id}`;
return (
<div
key={shot.id}
className="flex items-center gap-3 px-3 py-2.5 rounded-lg hover:bg-zinc-800 transition-colors group"
>
{/* Priority dot */}
<div
className={cn(
"w-2 h-2 rounded-full shrink-0",
PRIORITY_DOT[shot.priority] ?? "bg-zinc-500"
)}
title={shot.priority}
/>
{/* Shot code */}
<span className="font-mono text-xs text-muted-foreground w-32 shrink-0">
{shot.shotCode}
</span>
{/* Description / name */}
<span className="flex-1 text-sm truncate text-foreground/90">
{shot.description ?? shot.shotCode}
</span>
{/* Open comments */}
{openComments > 0 && (
<span className="flex items-center gap-1 text-xs text-amber-400 shrink-0">
<MessageSquare className="h-3 w-3" />
{openComments}
</span>
)}
{/* Status */}
<span
className={cn(
"flex items-center gap-1 text-xs shrink-0",
STATUS_STYLES[shot.status] ?? "text-muted-foreground"
)}
>
<StatusIcon className="h-3 w-3" />
<span className="hidden sm:inline">
{shot.status.replace("_", " ")}
</span>
</span>
{/* Artist */}
{shot.artist && (
<Avatar className="h-5 w-5 shrink-0">
{shot.artist.image && <img src={shot.artist.image} alt="" />}
<AvatarFallback className="text-[9px]">
{getInitials(shot.artist.name)}
</AvatarFallback>
</Avatar>
)}
{/* Open link */}
<Link href={href}>
<Button
variant="ghost"
size="icon-sm"
className="opacity-0 group-hover:opacity-100 transition-opacity"
>
<ArrowUpRight className="h-3.5 w-3.5" />
</Button>
</Link>
</div>
);
})}
</div>
);
}
+84
View File
@@ -0,0 +1,84 @@
"use client";
import { Card, CardContent } from "@/components/ui/card";
import { cn } from "@/lib/utils";
import {
Clock,
AlertCircle,
CheckCircle2,
XCircle,
TrendingUp,
} from "lucide-react";
import type { DashboardStats } from "@/types";
interface StatsCardsProps {
stats: DashboardStats;
}
export function StatsCards({ stats }: StatsCardsProps) {
const cards = [
{
label: "Awaiting Review",
value: stats.awaitingReview,
icon: Clock,
color: "text-amber-400",
bg: "bg-amber-500/10",
ring: "ring-amber-500/20",
},
{
label: "Needs Revisions",
value: stats.needsRevisions,
icon: AlertCircle,
color: "text-orange-400",
bg: "bg-orange-500/10",
ring: "ring-orange-500/20",
},
{
label: "Approved",
value: stats.approved,
icon: CheckCircle2,
color: "text-emerald-400",
bg: "bg-emerald-500/10",
ring: "ring-emerald-500/20",
},
{
label: "Overdue Tasks",
value: stats.tasksOverdue ?? stats.overdue,
icon: XCircle,
color: "text-red-400",
bg: "bg-red-500/10",
ring: "ring-red-500/20",
},
{
label: "Active Projects",
value: stats.activeProjects,
icon: TrendingUp,
color: "text-blue-400",
bg: "bg-blue-500/10",
ring: "ring-blue-500/20",
},
];
return (
<div className="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-4">
{cards.map((card) => {
const Icon = card.icon;
return (
<Card key={card.label}>
<CardContent className="p-4">
<div className="flex items-center justify-between mb-3">
<div className={cn("p-2 rounded-md", card.bg)}>
<Icon className={cn("h-4 w-4", card.color)} />
</div>
</div>
<p className="text-3xl font-bold text-white">
{card.value}
</p>
<p className="text-sm text-zinc-400 mt-0.5">{card.label}</p>
</CardContent>
</Card>
);
})}
</div>
);
}
+173
View File
@@ -0,0 +1,173 @@
"use client";
import Link from "next/link";
import { Badge } from "@/components/ui/badge";
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
import { cn, getInitials } from "@/lib/utils";
import {
CalendarDays,
Eye,
ListTodo,
AlertCircle,
CheckCircle2,
} from "lucide-react";
import { formatDistanceToNow } from "date-fns";
import { TASK_STATUS_CONFIG, TASK_TYPE_LABELS } from "@/components/tasks/TaskCard";
import { TaskStatus, TaskType } from "@prisma/client";
const PRIORITY_DOT: Record<string, string> = {
LOW: "bg-zinc-500",
NORMAL: "bg-blue-500",
HIGH: "bg-amber-500",
URGENT: "bg-red-500",
};
interface TaskRow {
id: string;
title: string;
type: TaskType;
status: TaskStatus;
priority: string;
dueDate: Date | null;
shot?: { shotCode: string } | null;
asset?: { assetCode: string } | null;
project: { id: string; name: string; code: string };
assignedArtist?: { id: string; name: string | null; email: string; image: string | null } | null;
}
function TaskRow({ task }: { task: TaskRow }) {
const cfg = TASK_STATUS_CONFIG[task.status];
const Icon = cfg.icon;
const contextCode = task.shot?.shotCode ?? task.asset?.assetCode;
const isOverdue =
task.dueDate &&
new Date(task.dueDate) < new Date() &&
task.status !== "DONE";
return (
<Link
href={`/tasks/${task.id}`}
className="flex items-center gap-3 px-3 py-2.5 rounded-lg hover:bg-zinc-800/60 transition-colors group"
>
<span
className={cn(
"w-1.5 h-1.5 rounded-full shrink-0",
PRIORITY_DOT[task.priority] ?? "bg-zinc-500"
)}
/>
<div className="flex-1 min-w-0">
<div className="flex items-center gap-2">
<span className="text-sm font-medium text-zinc-200 group-hover:text-amber-400 transition-colors truncate">
{task.title}
</span>
{contextCode && (
<span className="text-[10px] font-mono text-zinc-500 bg-zinc-800 px-1.5 py-0.5 rounded shrink-0">
{contextCode}
</span>
)}
</div>
<div className="flex items-center gap-2 mt-0.5">
<span className="text-[11px] text-zinc-500">{TASK_TYPE_LABELS[task.type]}</span>
<span className="text-[11px] text-zinc-700">·</span>
<span className="text-[11px] text-zinc-500">{task.project.code}</span>
</div>
</div>
<div className="flex items-center gap-2 shrink-0">
{task.assignedArtist && (
<Avatar className="h-5 w-5">
<AvatarFallback className="text-[8px] bg-zinc-700 text-zinc-300">
{getInitials(task.assignedArtist.name ?? task.assignedArtist.email)}
</AvatarFallback>
</Avatar>
)}
{task.dueDate && (
<span
className={cn(
"flex items-center gap-1 text-[10px]",
isOverdue ? "text-red-400" : "text-zinc-500"
)}
>
<CalendarDays className="h-3 w-3" />
{formatDistanceToNow(new Date(task.dueDate), { addSuffix: true })}
</span>
)}
<Badge
className={cn("text-[10px] border px-1.5 py-0 h-4 gap-1 shrink-0", cfg.color)}
>
<Icon className="h-2.5 w-2.5" />
{cfg.label}
</Badge>
</div>
</Link>
);
}
interface TaskWidgetsProps {
myTasks: TaskRow[];
reviewTasks: TaskRow[];
role: string;
}
export function TaskWidgets({ myTasks, reviewTasks, role }: TaskWidgetsProps) {
const isArtist = role === "ARTIST";
const showReview = !isArtist && reviewTasks.length > 0;
if (myTasks.length === 0 && reviewTasks.length === 0) return null;
return (
<div className={cn("grid gap-4", showReview ? "grid-cols-1 xl:grid-cols-2" : "grid-cols-1")}>
{/* My Tasks */}
{myTasks.length > 0 && (
<div className="rounded-xl border border-zinc-800 bg-zinc-900/60">
<div className="flex items-center justify-between px-4 py-3 border-b border-zinc-800">
<div className="flex items-center gap-2">
<ListTodo className="h-4 w-4 text-amber-400" />
<span className="text-sm font-semibold text-zinc-200">My Tasks</span>
<span className="text-xs text-zinc-600 bg-zinc-800 rounded-full px-2 py-0.5 font-mono">
{myTasks.length}
</span>
</div>
<Link
href="/tasks"
className="text-xs text-zinc-500 hover:text-amber-400 transition-colors"
>
View all
</Link>
</div>
<div className="divide-y divide-zinc-800/50">
{myTasks.map((task) => (
<TaskRow key={task.id} task={task} />
))}
</div>
</div>
)}
{/* Tasks In Review (supervisors/producers) */}
{showReview && (
<div className="rounded-xl border border-zinc-800 bg-zinc-900/60">
<div className="flex items-center justify-between px-4 py-3 border-b border-zinc-800">
<div className="flex items-center gap-2">
<Eye className="h-4 w-4 text-purple-400" />
<span className="text-sm font-semibold text-zinc-200">Needs Review</span>
<span className="text-xs text-zinc-600 bg-zinc-800 rounded-full px-2 py-0.5 font-mono">
{reviewTasks.length}
</span>
</div>
<Link
href="/tasks?status=INTERNAL_REVIEW"
className="text-xs text-zinc-500 hover:text-amber-400 transition-colors"
>
View all
</Link>
</div>
<div className="divide-y divide-zinc-800/50">
{reviewTasks.map((task) => (
<TaskRow key={task.id} task={task} />
))}
</div>
</div>
)}
</div>
);
}