30 lines
818 B
TypeScript
30 lines
818 B
TypeScript
import apiClient from './client';
|
|
|
|
export interface ProjectItem {
|
|
id: string;
|
|
workspace_id: string;
|
|
name: string;
|
|
description: string;
|
|
}
|
|
|
|
export interface CreateProjectRequest {
|
|
workspace_id: string;
|
|
name: string;
|
|
description?: string;
|
|
}
|
|
|
|
export const getProject = async (projectId: string): Promise<ProjectItem> => {
|
|
const response = await apiClient.get(`/projects/${projectId}`);
|
|
return response.data;
|
|
};
|
|
|
|
export const getProjects = async (workspaceId: string): Promise<ProjectItem[]> => {
|
|
const response = await apiClient.get('/projects', { params: { workspace_id: workspaceId } });
|
|
return response.data.items;
|
|
};
|
|
|
|
export const createProject = async (data: CreateProjectRequest): Promise<ProjectItem> => {
|
|
const response = await apiClient.post('/projects', data);
|
|
return response.data;
|
|
};
|