import api from './api';

export default {
    async getProjects() {
        return api.get('/projects');
    },

    async createProject(projectData) {
        return api.post('/projects', projectData);
    },

    async getProject(id) {
        // Using getProjects for now as per previous plan, or could try specific endpoint if it exists
        // Validating with backend: project_router has GET /api/projects (list)
        // It does NOT have GET /api/projects/{id}.
        // So we must fetch all and find, or assume the store has them.
        return api.get('/projects');
    },
    
    async joinProject(projectId) {
        return api.post(`/projects/${projectId}/join`);
    },
    
    async addMember(projectId, username) {
        return api.post(`/projects/${projectId}/members`, { username });
    },
    
    async deleteProject(projectId) {
        return api.delete(`/projects/${projectId}`);
    }
};
