'use client'; /** Right-hand dashboard column (like the reference design): * Tasks preview, shared files in this chat, and an Upcoming card. */ import { useEffect, useState } from 'react'; import Link from 'next/link'; import { useParams } from 'next/navigation'; import { CalendarDays, CheckCircle2, Circle, FileText, Flag, Paperclip, SquareKanban, Image as ImageIcon } from 'lucide-react'; import { api } from '@/lib/client/api'; import { Avatar, timeAgo } from './ui'; import { BOARD_BGS, dueMeta } from '@/lib/client/board-ui'; type BoardRow = { id: string; name: string; background: number; totalCards: number; doneCards: number }; type MyTask = { id: string; title: string; dueDate?: string | null; completedAt?: string | null; board: { id: string; name: string; background: number }; list: { name: string }; }; type FileRow = { id: string; fileName: string; fileUrl: string; fileType: string; size: number; createdAt: string; message: { sender: { id: string; name: string; avatarUrl?: string | null } }; }; type Holiday = { id: string; date: string; name: string }; function fileSize(bytes: number): string { if (bytes < 1048576) return `${(bytes / 1024).toFixed(0)} KB`; return `${(bytes / 1048576).toFixed(1)} MB`; } export default function OverviewPanel({ channelId, conversationId }: { channelId?: string; conversationId?: string }) { const { wsId } = useParams<{ wsId: string }>(); const [boards, setBoards] = useState([]); const [tasks, setTasks] = useState([]); const [files, setFiles] = useState([]); const [holidays, setHolidays] = useState([]); useEffect(() => { api<{ boards: BoardRow[] }>(`/api/workspaces/${wsId}/boards`).then((r) => setBoards(r.boards.slice(0, 1))).catch(() => {}); api<{ tasks: MyTask[] }>(`/api/workspaces/${wsId}/my-tasks`).then((r) => setTasks(r.tasks.filter((t) => !t.completedAt).slice(0, 4))).catch(() => {}); api<{ holidays: Holiday[] }>(`/api/workspaces/${wsId}/holidays`).then((r) => { const today = new Date().toISOString().slice(0, 10); setHolidays(r.holidays.filter((h) => h.date >= today).slice(0, 2)); }).catch(() => {}); }, [wsId]); useEffect(() => { const qs = channelId ? `channelId=${channelId}` : conversationId ? `conversationId=${conversationId}` : null; if (!qs) return; api<{ files: FileRow[] }>(`/api/resources?${qs}`).then((r) => setFiles(r.files.slice(0, 4))).catch(() => {}); }, [channelId, conversationId]); const board = boards[0]; return ( ); }