Spaces:
Running
Running
| import { api } from "./client"; | |
| import type { Milestone, MilestoneInput, Project, ProjectInput, ProjectPhase } from "../types"; | |
| export const listProjects = async (includeArchived = false) => | |
| ( | |
| await api.get<Project[]>("/projects", { | |
| params: includeArchived ? { include_archived: true } : undefined, | |
| }) | |
| ).data; | |
| export const createProject = async (input: ProjectInput) => | |
| (await api.post<Project>("/projects", input)).data; | |
| export const updateProject = async (id: number, input: Partial<ProjectInput>) => | |
| (await api.patch<Project>(`/projects/${id}`, input)).data; | |
| export const archiveProject = async (id: number) => | |
| (await api.delete<Project>(`/projects/${id}`)).data; | |
| export const restoreProject = async (id: number) => | |
| (await api.post<Project>(`/projects/${id}/restore`)).data; | |
| export const createMilestone = async (projectId: number, input: MilestoneInput) => | |
| (await api.post<Milestone>(`/projects/${projectId}/milestones`, input)).data; | |
| export const updateMilestone = async ( | |
| projectId: number, | |
| milestoneId: number, | |
| input: Partial<MilestoneInput>, | |
| ) => | |
| (await api.patch<Milestone>(`/projects/${projectId}/milestones/${milestoneId}`, input)).data; | |
| export const createPhase = async ( | |
| projectId: number, | |
| input: { name: string; start_date: string; end_date: string; color?: string }, | |
| ) => (await api.post<ProjectPhase>(`/projects/${projectId}/phases`, input)).data; | |