import axios from 'axios' export const API_BASE = import.meta.env.VITE_API_BASE ?? 'http://localhost:5000' const TOKEN = import.meta.env.VITE_TOKEN ?? '' // ajuste o path caso sua API seja /api/workshops const WORKSHOPS_PATH = '/workshops' // src/api.ts export type Workshop = { id: string; title: string; startAt: string; // ISO string endAt: string; // ISO string isOnline: boolean; location?: string | null; capacity?: number; }; export type WorkshopList = Workshop[]; export type NewWorkshop = { title: string; startAt: string; // ISO description: string; endAt: string; // ISO isOnline: boolean; location?: string | null; capacity?: number; // >= 1 (opcional) }; const getHeaders = () => { console.log(TOKEN) return { Authorization: `Bearer ${TOKEN}` } } export async function searchWorkshops(q: string): Promise { const { data } = await axios.get( `${API_BASE}${WORKSHOPS_PATH}`, { params: { q }, headers: getHeaders() } ); return data; } export async function createWorkshop(payload: NewWorkshop): Promise { // POST de criação; backend retorna o Workshop criado (com id) const { data } = await axios.post( `${API_BASE}${WORKSHOPS_PATH}`, payload, { headers: getHeaders() } ); return data; }