Files
mrp/client/src/modules/gantt/GanttPage.tsx

50 lines
1.6 KiB
TypeScript
Raw Normal View History

2026-03-14 14:44:40 -05:00
import { useEffect, useState } from "react";
import { Gantt } from "@svar-ui/react-gantt";
import "@svar-ui/react-gantt/style.css";
import type { GanttLinkDto, GanttTaskDto } from "@mrp/shared";
import { useAuth } from "../../auth/AuthProvider";
import { api } from "../../lib/api";
2026-03-14 15:47:29 -05:00
import { useTheme } from "../../theme/ThemeProvider";
2026-03-14 14:44:40 -05:00
export function GanttPage() {
const { token } = useAuth();
2026-03-14 15:47:29 -05:00
const { mode } = useTheme();
2026-03-14 14:44:40 -05:00
const [tasks, setTasks] = useState<GanttTaskDto[]>([]);
const [links, setLinks] = useState<GanttLinkDto[]>([]);
useEffect(() => {
if (!token) {
return;
}
api.getGanttDemo(token).then((data) => {
setTasks(data.tasks);
setLinks(data.links);
});
}, [token]);
return (
<section className="rounded-[28px] border border-line/70 bg-surface/90 p-8 shadow-panel">
<p className="text-xs font-semibold uppercase tracking-[0.24em] text-muted">Planning</p>
<h3 className="mt-3 text-2xl font-bold text-text">SVAR Gantt Preview</h3>
<p className="mt-2 text-sm text-muted">Theme-aware integration wrapper prepared for future manufacturing schedules and task dependencies.</p>
2026-03-14 15:47:29 -05:00
<div
className={`gantt-theme mt-6 overflow-hidden rounded-2xl border border-line/70 bg-page/70 p-4 ${
mode === "dark" ? "wx-willow-dark-theme" : "wx-willow-theme"
}`}
>
2026-03-14 14:44:40 -05:00
<Gantt
tasks={tasks.map((task) => ({
...task,
start: new Date(task.start),
end: new Date(task.end),
}))}
links={links}
/>
</div>
</section>
);
}