import React, { useState, useMemo } from 'react'; import { Button, Space, message, Card } from 'antd'; import AdvancedGanttChart from './AdvancedGanttChart'; import { GanttTask, ColumnConfig } from '../../types/advanced-gantt.types'; import { useAppSelector } from '../../hooks/useAppSelector'; import { holidayPresets, workingDayPresets } from './TimelineMarkers'; // Enhanced sample data with more realistic project structure const generateSampleTasks = (): GanttTask[] => { const baseDate = new Date(2024, 11, 1); // December 1, 2024 return [ // Project Phase 1: Planning & Design { id: 'project-1', name: '🚀 Web Platform Development', startDate: new Date(2024, 11, 1), endDate: new Date(2025, 2, 31), progress: 45, type: 'project', status: 'in-progress', priority: 'high', color: '#1890ff', hasChildren: true, isExpanded: true, level: 0, }, { id: 'planning-phase', name: '📋 Planning & Analysis Phase', startDate: new Date(2024, 11, 1), endDate: new Date(2024, 11, 20), progress: 85, type: 'project', status: 'in-progress', priority: 'high', parent: 'project-1', color: '#52c41a', hasChildren: true, isExpanded: true, level: 1, }, { id: 'requirements-analysis', name: 'Requirements Gathering & Analysis', startDate: new Date(2024, 11, 1), endDate: new Date(2024, 11, 8), progress: 100, type: 'task', status: 'completed', priority: 'high', parent: 'planning-phase', assignee: { id: 'user-1', name: 'Alice Johnson', avatar: 'https://ui-avatars.com/api/?name=Alice+Johnson&background=1890ff&color=fff', }, tags: ['research', 'documentation'], level: 2, }, { id: 'technical-architecture', name: 'Technical Architecture Design', startDate: new Date(2024, 11, 8), endDate: new Date(2024, 11, 18), progress: 75, type: 'task', status: 'in-progress', priority: 'high', parent: 'planning-phase', assignee: { id: 'user-2', name: 'Bob Smith', avatar: 'https://ui-avatars.com/api/?name=Bob+Smith&background=52c41a&color=fff', }, dependencies: ['requirements-analysis'], tags: ['architecture', 'design'], level: 2, }, { id: 'ui-ux-design', name: 'UI/UX Design & Prototyping', startDate: new Date(2024, 11, 10), endDate: new Date(2024, 11, 20), progress: 60, type: 'task', status: 'in-progress', priority: 'medium', parent: 'planning-phase', assignee: { id: 'user-3', name: 'Carol Davis', avatar: 'https://ui-avatars.com/api/?name=Carol+Davis&background=faad14&color=fff', }, dependencies: ['requirements-analysis'], tags: ['design', 'prototype'], level: 2, }, { id: 'milestone-planning-complete', name: '🎯 Planning Phase Complete', startDate: new Date(2024, 11, 20), endDate: new Date(2024, 11, 20), progress: 0, type: 'milestone', status: 'not-started', priority: 'critical', parent: 'planning-phase', dependencies: ['technical-architecture', 'ui-ux-design'], level: 2, }, // Development Phase { id: 'development-phase', name: '⚡ Development Phase', startDate: new Date(2024, 11, 21), endDate: new Date(2025, 1, 28), progress: 35, type: 'project', status: 'in-progress', priority: 'high', parent: 'project-1', color: '#722ed1', hasChildren: true, isExpanded: true, level: 1, }, { id: 'backend-development', name: 'Backend API Development', startDate: new Date(2024, 11, 21), endDate: new Date(2025, 1, 15), progress: 45, type: 'task', status: 'in-progress', priority: 'high', parent: 'development-phase', assignee: { id: 'user-4', name: 'David Wilson', avatar: 'https://ui-avatars.com/api/?name=David+Wilson&background=722ed1&color=fff', }, dependencies: ['milestone-planning-complete'], tags: ['backend', 'api'], level: 2, }, { id: 'frontend-development', name: 'Frontend React Application', startDate: new Date(2025, 0, 5), endDate: new Date(2025, 1, 25), progress: 25, type: 'task', status: 'in-progress', priority: 'high', parent: 'development-phase', assignee: { id: 'user-5', name: 'Eva Brown', avatar: 'https://ui-avatars.com/api/?name=Eva+Brown&background=ff7a45&color=fff', }, dependencies: ['backend-development'], tags: ['frontend', 'react'], level: 2, }, { id: 'database-setup', name: 'Database Schema & Migration', startDate: new Date(2024, 11, 21), endDate: new Date(2025, 0, 10), progress: 80, type: 'task', status: 'in-progress', priority: 'medium', parent: 'development-phase', assignee: { id: 'user-6', name: 'Frank Miller', avatar: 'https://ui-avatars.com/api/?name=Frank+Miller&background=13c2c2&color=fff', }, dependencies: ['milestone-planning-complete'], tags: ['database', 'migration'], level: 2, }, // Testing Phase { id: 'testing-phase', name: '🧪 Testing & QA Phase', startDate: new Date(2025, 2, 1), endDate: new Date(2025, 2, 20), progress: 0, type: 'project', status: 'not-started', priority: 'high', parent: 'project-1', color: '#fa8c16', hasChildren: true, isExpanded: false, level: 1, }, { id: 'unit-testing', name: 'Unit Testing Implementation', startDate: new Date(2025, 2, 1), endDate: new Date(2025, 2, 10), progress: 0, type: 'task', status: 'not-started', priority: 'high', parent: 'testing-phase', assignee: { id: 'user-7', name: 'Grace Lee', avatar: 'https://ui-avatars.com/api/?name=Grace+Lee&background=fa8c16&color=fff', }, dependencies: ['frontend-development'], tags: ['testing', 'unit'], level: 2, }, { id: 'integration-testing', name: 'Integration & E2E Testing', startDate: new Date(2025, 2, 8), endDate: new Date(2025, 2, 18), progress: 0, type: 'task', status: 'not-started', priority: 'high', parent: 'testing-phase', assignee: { id: 'user-8', name: 'Henry Clark', avatar: 'https://ui-avatars.com/api/?name=Henry+Clark&background=eb2f96&color=fff', }, dependencies: ['unit-testing'], tags: ['testing', 'integration'], level: 2, }, { id: 'milestone-beta-ready', name: '🎯 Beta Release Ready', startDate: new Date(2025, 2, 20), endDate: new Date(2025, 2, 20), progress: 0, type: 'milestone', status: 'not-started', priority: 'critical', parent: 'testing-phase', dependencies: ['integration-testing'], level: 2, }, // Deployment Phase { id: 'deployment-phase', name: '🚀 Deployment & Launch', startDate: new Date(2025, 2, 21), endDate: new Date(2025, 2, 31), progress: 0, type: 'project', status: 'not-started', priority: 'critical', parent: 'project-1', color: '#f5222d', hasChildren: true, isExpanded: false, level: 1, }, { id: 'production-deployment', name: 'Production Environment Setup', startDate: new Date(2025, 2, 21), endDate: new Date(2025, 2, 25), progress: 0, type: 'task', status: 'not-started', priority: 'critical', parent: 'deployment-phase', assignee: { id: 'user-9', name: 'Ivy Taylor', avatar: 'https://ui-avatars.com/api/?name=Ivy+Taylor&background=f5222d&color=fff', }, dependencies: ['milestone-beta-ready'], tags: ['deployment', 'production'], level: 2, }, { id: 'go-live', name: 'Go Live & Monitoring', startDate: new Date(2025, 2, 26), endDate: new Date(2025, 2, 31), progress: 0, type: 'task', status: 'not-started', priority: 'critical', parent: 'deployment-phase', assignee: { id: 'user-10', name: 'Jack Anderson', avatar: 'https://ui-avatars.com/api/?name=Jack+Anderson&background=2f54eb&color=fff', }, dependencies: ['production-deployment'], tags: ['launch', 'monitoring'], level: 2, }, { id: 'milestone-project-complete', name: '🎉 Project Launch Complete', startDate: new Date(2025, 2, 31), endDate: new Date(2025, 2, 31), progress: 0, type: 'milestone', status: 'not-started', priority: 'critical', parent: 'deployment-phase', dependencies: ['go-live'], level: 2, }, ]; }; // Enhanced column configuration const sampleColumns: ColumnConfig[] = [ { field: 'name', title: 'Task / Phase Name', width: 300, minWidth: 200, resizable: true, sortable: true, fixed: true, editor: 'text' }, { field: 'assignee', title: 'Assignee', width: 150, minWidth: 120, resizable: true, sortable: true, fixed: true }, { field: 'startDate', title: 'Start Date', width: 120, minWidth: 100, resizable: true, sortable: true, fixed: true, editor: 'date' }, { field: 'endDate', title: 'End Date', width: 120, minWidth: 100, resizable: true, sortable: true, fixed: true, editor: 'date' }, { field: 'duration', title: 'Duration', width: 80, minWidth: 60, resizable: true, sortable: false, fixed: true, align: 'center' }, { field: 'progress', title: 'Progress', width: 120, minWidth: 100, resizable: true, sortable: true, fixed: true, editor: 'number' }, { field: 'status', title: 'Status', width: 100, minWidth: 80, resizable: true, sortable: true, fixed: true, editor: 'select', editorOptions: [ { value: 'not-started', label: 'Not Started' }, { value: 'in-progress', label: 'In Progress' }, { value: 'completed', label: 'Completed' }, { value: 'on-hold', label: 'On Hold' }, { value: 'overdue', label: 'Overdue' }, ] }, { field: 'priority', title: 'Priority', width: 100, minWidth: 80, resizable: true, sortable: true, fixed: true, editor: 'select', editorOptions: [ { value: 'low', label: 'Low' }, { value: 'medium', label: 'Medium' }, { value: 'high', label: 'High' }, { value: 'critical', label: 'Critical' }, ] }, ]; const AdvancedGanttDemo: React.FC = () => { const [tasks, setTasks] = useState(generateSampleTasks()); const [selectedTasks, setSelectedTasks] = useState([]); const themeMode = useAppSelector(state => state.themeReducer.mode); const handleTaskUpdate = (taskId: string, updates: Partial) => { setTasks(prevTasks => prevTasks.map(task => task.id === taskId ? { ...task, ...updates } : task ) ); message.success(`Task "${tasks.find(t => t.id === taskId)?.name}" updated`); }; const handleTaskMove = (taskId: string, newDates: { start: Date; end: Date }) => { setTasks(prevTasks => prevTasks.map(task => task.id === taskId ? { ...task, startDate: newDates.start, endDate: newDates.end } : task ) ); message.info(`Task moved: ${newDates.start.toLocaleDateString()} - ${newDates.end.toLocaleDateString()}`); }; const handleProgressChange = (taskId: string, progress: number) => { setTasks(prevTasks => prevTasks.map(task => task.id === taskId ? { ...task, progress } : task ) ); message.info(`Progress updated: ${Math.round(progress)}%`); }; const handleSelectionChange = (selection: any) => { setSelectedTasks(selection.selectedTasks); }; const resetToSampleData = () => { setTasks(generateSampleTasks()); setSelectedTasks([]); message.info('Gantt chart reset to sample data'); }; const addSampleTask = () => { const newTask: GanttTask = { id: `task-${Date.now()}`, name: `New Task ${tasks.length + 1}`, startDate: new Date(), endDate: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000), // +7 days progress: 0, type: 'task', status: 'not-started', priority: 'medium', level: 0, }; setTasks(prev => [...prev, newTask]); message.success('New task added'); }; const deleteSelectedTasks = () => { if (selectedTasks.length === 0) { message.warning('No tasks selected'); return; } setTasks(prev => prev.filter(task => !selectedTasks.includes(task.id))); setSelectedTasks([]); message.success(`${selectedTasks.length} task(s) deleted`); }; const taskStats = useMemo(() => { const total = tasks.length; const completed = tasks.filter(t => t.status === 'completed').length; const inProgress = tasks.filter(t => t.status === 'in-progress').length; const overdue = tasks.filter(t => t.status === 'overdue').length; const avgProgress = tasks.reduce((sum, t) => sum + t.progress, 0) / total; return { total, completed, inProgress, overdue, avgProgress }; }, [tasks]); return (
{/* Header */}

🚀 Advanced Gantt Chart Demo

Professional Gantt chart with draggable tasks, virtual scrolling, holiday markers, and performance optimizations for modern project management.

{/* Project Statistics */}
Total Tasks
{taskStats.total}
Completed
{taskStats.completed}
In Progress
{taskStats.inProgress}
Avg Progress
{Math.round(taskStats.avgProgress)}%
{/* Gantt Chart */}
{/* Feature List */}

✨ Advanced Features Demonstrated

Performance & UX

  • • Virtual scrolling for 1000+ tasks
  • • Smooth 60fps drag & drop
  • • Debounced updates
  • • Memory-optimized rendering
  • • Responsive design

Gantt Features

  • • Draggable task bars
  • • Resizable task duration
  • • Progress editing
  • • Multi-level hierarchy
  • • Task dependencies

Timeline & Markers

  • • Weekend & holiday markers
  • • Working day indicators
  • • Today line
  • • Multi-tier timeline
  • • Zoom levels (Year/Month/Week/Day)

Grid Features

  • • Fixed columns layout
  • • Inline editing
  • • Column resizing
  • • Multi-select
  • • Hierarchical tree view

UI/UX

  • • Dark/Light theme support
  • • Tailwind CSS styling
  • • Consistent with Worklenz
  • • Accessibility features
  • • Mobile responsive

Architecture

  • • Modern React patterns
  • • TypeScript safety
  • • Optimized performance
  • • Enterprise features
  • • Best practices 2025
); }; export default AdvancedGanttDemo;