Spaces:
Running
Running
File size: 1,412 Bytes
96c0248 872046b 96c0248 140361e 96c0248 140361e 96c0248 872046b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | 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;
|