import axios from 'axios'; const API_BASE = import.meta.env.VITE_API_BASE || 'http://localhost:8001/api'; const api = axios.create({ baseURL: API_BASE, withCredentials: true }); export interface ProjectResponse { id: string; name: string; slug: string; description: string | null; is_public: boolean; board_type: string; code: string; components_json: string; wires_json: string; owner_username: string; created_at: string; updated_at: string; } export interface ProjectSaveData { name: string; description?: string; is_public: boolean; board_type: string; code: string; components_json: string; wires_json: string; } export async function getMyProjects(): Promise { const { data } = await api.get('/projects/me'); return data; } export async function getUserProjects(username: string): Promise { const { data } = await api.get(`/user/${username}`); return data; } export async function getProject(username: string, slug: string): Promise { const { data } = await api.get(`/user/${username}/${slug}`); return data; } export async function createProject(data: ProjectSaveData): Promise { const { data: result } = await api.post('/projects/', data); return result; } export async function updateProject(id: string, data: Partial): Promise { const { data: result } = await api.put(`/projects/${id}`, data); return result; } export async function deleteProject(id: string): Promise { await api.delete(`/projects/${id}`); }