import React, { useState, useEffect } from 'react'; import { Button } from './ui/button'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from './ui/card'; import { Badge } from './ui/badge'; import { Input } from './ui/input'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from './ui/select'; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger } from './ui/dialog'; import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle, SheetTrigger } from './ui/sheet'; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from './ui/table'; import { Progress } from './ui/progress'; import { Tabs, TabsContent, TabsList, TabsTrigger } from './ui/tabs'; import { Alert, AlertDescription } from './ui/alert'; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from './ui/accordion'; import { ArrowLeft, Download, BarChart3, MoreHorizontal, Users, Calendar, Clock, BookOpen, Award, Bell, Search, Filter, Eye, Mail, FileText, Play, MapPin, Video, FileQuestion, Activity, Building2, RefreshCw, ExternalLink, Plus, CheckCircle, AlertCircle, XCircle } from 'lucide-react'; // Types interface Programme { id: string; title: string; status: 'Active' | 'Upcoming' | 'Completed'; code: string; owner: string; version: number; description: string; goals: string[]; tags: string[]; structure: { preAssessment: ProgrammeItem[]; preLearning: ProgrammeItem[]; classroom: ProgrammeItem[]; postLearning: ProgrammeItem[]; }; } interface ProgrammeItem { id: string; type: 'Profiler' | 'Course' | 'Content' | 'Webinar' | 'OfflineSession'; title: string; duration?: string; dueDate?: string; venue?: string; room?: string; date?: string; capacity?: number; status?: 'Not Started' | 'In Progress' | 'Completed'; } interface Assignment { startDate: string; endDate: string; orgId: string; orgName: string; } interface ProgrammeCounts { learners: number; completionPct: number; courses: number; content: number; webinars: number; classes: number; } interface ProgrammeLearner { id: string; name: string; email: string; currentItem: { type: string; id: string; title: string; status: 'Not Started' | 'In-Progress' | 'Completed'; }; progressPct: number; nextItem?: { type: string; id: string; title: string; }; lastActivity: string; stage: 'Pre-assessment' | 'Pre-learning' | 'Classroom' | 'Post-learning'; cohort?: string; } interface ProgrammeEvent { id: string; programmeId: string; type: 'webinar' | 'class' | 'course_end' | 'content_end' | 'programme_end'; title: string; start: string; end: string; venue?: string; room?: string; } interface ProgrammeHRViewProps { programmeId: string; onBack: () => void; onAssignLearners: (programmeId: string) => void; onDownloadTracker: (programmeId: string) => void; onOpenAnalytics: (programmeId: string) => void; } // Mock data const mockProgramme: Programme = { id: 'prg_123', title: 'Executive Leadership Development Programme', status: 'Active', code: 'ELDP-2024', owner: 'Dr. Sarah Johnson', version: 2, description: 'A comprehensive leadership development programme designed to build strategic thinking, emotional intelligence, and decision-making capabilities for senior executives.', goals: [ 'Develop strategic thinking and planning capabilities', 'Enhance emotional intelligence and self-awareness', 'Build effective communication and influence skills', 'Master change management and innovation leadership' ], tags: ['Leadership', 'Executive', 'Strategic Thinking', 'Management'], structure: { preAssessment: [ { id: 'pa1', type: 'Profiler', title: 'Leadership Style Assessment', status: 'Completed' }, { id: 'pa2', type: 'Profiler', title: '360-Degree Feedback', status: 'In Progress' } ], preLearning: [ { id: 'pl1', type: 'Course', title: 'Strategic Thinking Fundamentals', duration: '4 hours', dueDate: '2024-01-15', status: 'Completed' }, { id: 'pl2', type: 'Content', title: 'Leadership in Crisis Webcast', duration: '45 mins', status: 'In Progress' }, { id: 'pl3', type: 'Webinar', title: 'Future of Leadership', date: '2024-01-20 10:00 AM AEDT', status: 'Not Started' } ], classroom: [ { id: 'c1', type: 'OfflineSession', title: 'Strategic Leadership Workshop', venue: 'Sydney Campus', room: 'Executive Suite A', date: '2024-02-05', capacity: 20 }, { id: 'c2', type: 'OfflineSession', title: 'Case Study Analysis', venue: 'Sydney Campus', room: 'Conference Room B', date: '2024-02-06', capacity: 20 } ], postLearning: [ { id: 'po1', type: 'Course', title: 'Advanced Decision Making', duration: '6 hours', dueDate: '2024-02-20', status: 'Not Started' }, { id: 'po2', type: 'Content', title: 'Leadership Reflection Journal', duration: '2 weeks', status: 'Not Started' } ] } }; const mockAssignment: Assignment = { startDate: '2024-01-01', endDate: '2024-03-31', orgId: 'org_123', orgName: 'Tech Solutions Pvt Ltd' }; const mockCounts: ProgrammeCounts = { learners: 28, completionPct: 64, courses: 2, content: 2, webinars: 1, classes: 2 }; const mockLearners: ProgrammeLearner[] = [ { id: 'l1', name: 'Sarah Chen', email: 'sarah.chen@company.com', currentItem: { type: 'Course', id: 'pl1', title: 'Strategic Thinking Fundamentals', status: 'In-Progress' }, progressPct: 75, nextItem: { type: 'Content', id: 'pl2', title: 'Leadership in Crisis Webcast' }, lastActivity: '2 hours ago', stage: 'Pre-learning', cohort: 'Cohort A' }, { id: 'l2', name: 'Michael Rodriguez', email: 'michael.r@company.com', currentItem: { type: 'Profiler', id: 'pa2', title: '360-Degree Feedback', status: 'In-Progress' }, progressPct: 45, nextItem: { type: 'Course', id: 'pl1', title: 'Strategic Thinking Fundamentals' }, lastActivity: '1 day ago', stage: 'Pre-assessment', cohort: 'Cohort A' }, { id: 'l3', name: 'Emma Thompson', email: 'emma.thompson@company.com', currentItem: { type: 'OfflineSession', id: 'c1', title: 'Strategic Leadership Workshop', status: 'Completed' }, progressPct: 89, nextItem: { type: 'Course', id: 'po1', title: 'Advanced Decision Making' }, lastActivity: '3 hours ago', stage: 'Classroom', cohort: 'Cohort B' } ]; const mockEvents: ProgrammeEvent[] = [ { id: 'e1', programmeId: 'prg_123', type: 'webinar', title: 'Future of Leadership', start: '2024-01-20T10:00:00', end: '2024-01-20T11:30:00' }, { id: 'e2', programmeId: 'prg_123', type: 'class', title: 'Strategic Leadership Workshop', start: '2024-02-05T09:00:00', end: '2024-02-05T17:00:00', venue: 'Sydney Campus', room: 'Executive Suite A' } ]; export const ProgrammeHRView: React.FC = ({ programmeId, onBack, onAssignLearners, onDownloadTracker, onOpenAnalytics }) => { const [activeTab, setActiveTab] = useState('overview'); const [loading, setLoading] = useState(true); const [searchTerm, setSearchTerm] = useState(''); const [statusFilter, setStatusFilter] = useState('all'); const [stageFilter, setStageFilter] = useState('all'); const [cohortFilter, setCohortFilter] = useState('all'); const [selectedLearner, setSelectedLearner] = useState(null); const [showLearnerDrawer, setShowLearnerDrawer] = useState(false); const [exporting, setExporting] = useState(false); // Simulate loading useEffect(() => { const timer = setTimeout(() => setLoading(false), 800); return () => clearTimeout(timer); }, []); const getTypeIcon = (type: string) => { switch (type) { case 'Course': return ; case 'Content': return ; case 'Webinar': return