import { useState, useMemo } from 'react';
import { Gantt, Editor, ContextMenu } from '@svar-ui/react-gantt';
import { Calendar } from '@svar-ui/gantt-store';
import '@svar-ui/react-gantt/all.css';
const calendar = new Calendar({
weekHours: {
monday: 8, tuesday: 8, wednesday: 8,
thursday: 8, friday: 8,
saturday: 0, sunday: 0,
},
});
const tasks = [
{ id: 1, text: 'Requirements', type: 'task', start: new Date(2026, 3, 2), duration: 3, progress: 100 },
{ id: 2, text: 'Design', type: 'task', start: new Date(2026, 3, 7), duration: 5, progress: 40 },
{ id: 3, text: 'Development', type: 'task', start: new Date(2026, 3, 14), duration: 10, progress: 0 },
{ id: 4, text: 'Testing', type: 'task', start: new Date(2026, 3, 28), duration: 5, progress: 0 },
// Unscheduled
{ id: 5, text: 'Documentation', type: 'task', duration: 3, progress: 0 },
];
const links = [
{ id: 1, source: 1, target: 2, type: 'e2s' },
{ id: 2, source: 2, target: 3, type: 'e2s' },
{ id: 3, source: 3, target: 4, type: 'e2s' },
];
export default function App() {
const [api, setApi] = useState();
const [projectStart, setProjectStart] = useState(new Date(2026, 3, 2));
return (
<>
<ContextMenu api={api}>
<Gantt
init={setApi}
tasks={tasks}
links={links}
calendar={calendar}
schedule={{ auto: true }}
projectStart={projectStart}
projectEnd={new Date(2026, 5, 30)}
unscheduledTasks={true}
undo={true}
/>
</ContextMenu>
{api && <Editor api={api} />}
</>
);
}