import { useState } from "react";
import { Card, CardContent } from "@/components/ui/card";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { motion } from "framer-motion";
const stagesList = [
"Design",
"Manufacturing",
"Inspection & Assembly",
"Trial",
"Sample Validation",
"Pilot Run",
"Handover"
];
export default function ProjectManagementApp() {
const [projects, setProjects] = useState([]);
const [name, setName] = useState("");
const [number, setNumber] = useState("");
const addProject = () => {
if (!name || !number) return;
const stages = {};
stagesList.forEach(stage => {
stages[stage] = {
plannedStart: "",
plannedEnd: "",
actualStart: "",
actualEnd: "",
issue: "",
status: "On Time"
};
});
setProjects([...projects, { id: Date.now(), name, number, stages, movements: [] }]);
setName("");
setNumber("");
};
const updateStage = (id, stage, field, value) => {
setProjects(projects.map(p => {
if (p.id !== id) return p;
const updated = { ...p.stages[stage], [field]: value };
if (updated.actualEnd && updated.plannedEnd && updated.actualEnd > updated.plannedEnd) {
updated.status = "Delay";
} else {
updated.status = "On Time";
}
return {
...p,
stages: { ...p.stages, [stage]: updated },
movements: [...p.movements, `${stage} moved on ${new Date().toLocaleDateString()}`]
};
}));
};
return (
Ultimate CEO Dashboard
{/* Add Project */}
setName(e.target.value)} />
setNumber(e.target.value)} />
{/* Planned vs Actual Gantt */}
Planned vs Actual Gantt
{projects.map(project => (
{project.name}
{stagesList.map(stage => {
const s = project.stages[stage];
if (!s.plannedStart || !s.plannedEnd) return null;
const planned = (new Date(s.plannedEnd) - new Date(s.plannedStart)) / (1000*60*60*24);
const actual = s.actualEnd && s.actualStart
? (new Date(s.actualEnd) - new Date(s.actualStart)) / (1000*60*60*24)
: 0;
return (
);
})}
))}
{/* Alerts */}
Alerts
{projects.map(p => {
const delayed = Object.values(p.stages).some(s => s.status === "Delay");
return delayed && ⚠ {p.name} is delayed
;
})}
{/* Visual Bird View */}
Visual Bird Eye View
{projects.map(p => (
{p.name}
{p.movements.slice(-3).join(" → ")}
))}
{/* Project Details */}
{projects.map(project => (
{project.name}
{stagesList.map(stage => {
const s = project.stages[stage];
const color = s.status === "Delay" ? "bg-black text-white" : "bg-green-200";
return (
{stage}
updateStage(project.id,stage,"plannedStart",e.target.value)} />
updateStage(project.id,stage,"plannedEnd",e.target.value)} />
updateStage(project.id,stage,"actualStart",e.target.value)} />
updateStage(project.id,stage,"actualEnd",e.target.value)} />
updateStage(project.id,stage,"issue",e.target.value)} />
);
})}
))}
);
}