/** * Projects API Client * Handles project-related API requests */ import { apiGet, apiPost, apiPatch, apiDelete } from "./client"; /** * Project status enum (matches backend ProjectStatus) */ export enum ProjectStatus { PLANNING = "PLANNING", ACTIVE = "ACTIVE", PAUSED = "PAUSED", COMPLETED = "COMPLETED", ARCHIVED = "ARCHIVED", } /** * Project response interface (matches Prisma Project model) */ export interface Project { id: string; workspaceId: string; name: string; description: string | null; status: ProjectStatus; startDate: string | null; endDate: string | null; creatorId: string; domainId: string | null; color: string | null; metadata: Record; createdAt: string; updatedAt: string; } /** * DTO for creating a new project */ export interface CreateProjectDto { name: string; description?: string; status?: ProjectStatus; startDate?: string; endDate?: string; color?: string; metadata?: Record; } /** * DTO for updating an existing project */ export interface UpdateProjectDto { name?: string; description?: string | null; status?: ProjectStatus; startDate?: string | null; endDate?: string | null; color?: string | null; metadata?: Record; } /** * Fetch all projects for a workspace */ export async function fetchProjects(workspaceId?: string): Promise { const response = await apiGet<{ data: Project[]; meta?: unknown }>("/api/projects", workspaceId); return response.data; } /** * Fetch a single project by ID */ export async function fetchProject(id: string, workspaceId?: string): Promise { return apiGet(`/api/projects/${id}`, workspaceId); } /** * Create a new project */ export async function createProject( data: CreateProjectDto, workspaceId?: string ): Promise { return apiPost("/api/projects", data, workspaceId); } /** * Update an existing project */ export async function updateProject( id: string, data: UpdateProjectDto, workspaceId?: string ): Promise { return apiPatch(`/api/projects/${id}`, data, workspaceId); } /** * Delete a project */ export async function deleteProject(id: string, workspaceId?: string): Promise { await apiDelete>(`/api/projects/${id}`, workspaceId); }