"use client"; import { useRouter, usePathname, useSearchParams } from "next/navigation"; import { PendingLink } from "@/components/ui/pending-link"; import { Badge, Card, CardContent } from "poyraz-ui/atoms"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "poyraz-ui/molecules"; import { Bar, BarChart, CartesianGrid, ResponsiveContainer, Tooltip, XAxis, YAxis, Line, LineChart } from "recharts"; import { CheckCircle2, Wallet, FolderKanban, Activity, Users } from "lucide-react"; export type DashboardData = { metrics: { netProfit: number; activeProjectsCount: number; completedTasksCount: number; avgMood: string; financeTrend: { date: string; income: number; expense: number }[]; moodTrend: { date: string; mood: number; energy: number }[]; }; projects: { id: string; status: string; name: string; created_at: string }[]; clients: { id: string; name: string; company_name: string; created_at: string }[]; range: string; }; type DashboardClientProps = { data: DashboardData; }; export function DashboardClient({ data }: DashboardClientProps) { const router = useRouter(); const pathname = usePathname(); const searchParams = useSearchParams(); const handleRangeChange = (newRange: string) => { const params = new URLSearchParams(searchParams.toString()); params.set("range", newRange); router.push(`${pathname}?${params.toString()}`); }; const { netProfit, activeProjectsCount, completedTasksCount, avgMood, financeTrend, moodTrend } = data.metrics; // Format dates for Recharts using local timezone const incomeTrendData = (financeTrend || []).map(f => ({ name: new Date(f.date).toLocaleDateString("tr-TR", { month: "short", day: "numeric" }), income: f.income, expense: f.expense })); const moodTrendData = (moodTrend || []).map(l => ({ date: new Date(l.date).toLocaleDateString("tr-TR", { month: "short", day: "numeric" }), mood: l.mood, energy: l.energy, })); // Format currency const formatCurrency = (val: number) => { return new Intl.NumberFormat("tr-TR", { style: "currency", currency: "USD", maximumFractionDigits: 0, }).format(val); }; return (
İş performansını, gelirlerini ve günlük durumunu takip et.
{label}
{project.name}
{new Date(project.created_at).toLocaleDateString("tr-TR", { month: "short", day: "numeric" })}
{client.name}
{client.company_name || "Bireysel"}
{label}
{value}