import React, { useState } from "react"; import { base44 } from "@/api/base44Client"; import { useQuery } from "@tanstack/react-query"; import { Link, useNavigate } from "react-router-dom"; import { createPageUrl } from "@/utils"; import { Button } from "@/components/ui/button"; import { Card, CardHeader, CardTitle, CardContent } from "@/components/ui/card"; import { Users, Building2, UserPlus, TrendingUp, MapPin, Calendar, DollarSign, Award, Target, BarChart3, Shield, Leaf } from "lucide-react"; import StatsCard from "../components/staff/StatsCard"; import EcosystemWheel from "../components/dashboard/EcosystemWheel"; import QuickMetrics from "../components/dashboard/QuickMetrics"; import PageHeader from "../components/common/PageHeader"; export default function Dashboard() { const navigate = useNavigate(); const [selectedLayer, setSelectedLayer] = useState(null); const { data: staff, isLoading: loadingStaff } = useQuery({ queryKey: ['staff'], queryFn: () => base44.entities.Staff.list('-created_date'), initialData: [], }); const { data: events, isLoading: loadingEvents } = useQuery({ queryKey: ['events'], queryFn: () => base44.entities.Event.list('-date'), initialData: [], }); const recentStaff = staff.slice(0, 6); const uniqueDepartments = [...new Set(staff.map(s => s.department).filter(Boolean))]; const uniqueLocations = [...new Set(staff.map(s => s.hub_location).filter(Boolean))]; // Calculate key metrics const totalFillRate = 97; const totalSpend = 2.3; const overallScore = "A+"; const activeEvents = events.filter(e => e.status === "Active" || e.status === "Confirmed").length; const completionRate = events.length > 0 ? Math.round((events.filter(e => e.status === "Completed").length / events.length) * 100) : 0; const ecosystemLayers = [ { name: "Buyer(Procurements)", icon: DollarSign, color: "from-[#0A39DF] to-[#1C323E]", metrics: { fillRate: "97%", spend: "$2.3M", score: "A+" }, route: "ProcurementDashboard" }, { name: "Enterprises (Operator)", icon: Target, color: "from-emerald-500 to-emerald-700", metrics: { coverage: "94%", incidents: "2", satisfaction: "4.8/5" }, route: "OperatorDashboard" }, { name: "Sectors (Execution)", icon: Building2, color: "from-purple-500 to-purple-700", metrics: { active: activeEvents, revenue: "$1.8M", growth: "+12%" }, route: "OperatorDashboard" }, { name: "Partner", icon: Users, color: "from-pink-500 to-pink-700", metrics: { total: "45", retention: "92%", nps: "8.5" }, route: "Business" }, { name: "Approved Vendor", icon: Award, color: "from-amber-500 to-amber-700", metrics: { partners: "12", rating: "4.7/5", compliance: "98%" }, route: "VendorDashboard" }, { name: "Workforce", icon: UserPlus, color: "from-[#0A39DF] to-[#0A39DF]/80", metrics: { total: staff.length, active: staff.filter(s => s.check_in).length, trained: "89%" }, route: "WorkforceDashboard" } ]; return (
Interactive puzzle showing how each layer connects • Hover to see metrics • Click to explore
Recent additions and active workers
{member.position}