import { cache } from "react"; import { fetchGanttApi } from "@/lib/data/gantt-api"; import type { Task } from "@/lib/data/tasks"; import type { Project, Sprint } from "@/lib/data/projects"; interface SnapshotResponse { tasks?: Task[]; projects?: Project[]; sprints?: Sprint[]; } export interface GanttSnapshot { tasks: Task[]; projects: Project[]; sprints: Sprint[]; } export const fetchGanttSnapshot = cache(async (): Promise => { try { const response = await fetchGanttApi("/tasks?scope=all"); return { tasks: Array.isArray(response.tasks) ? response.tasks : [], projects: Array.isArray(response.projects) ? response.projects : [], sprints: Array.isArray(response.sprints) ? response.sprints : [], }; } catch (error) { console.error("Error fetching gantt snapshot from API:", error); return { tasks: [], projects: [], sprints: [] }; } });