import type { AuthResponse } from "../types"; const AUTH_BASE = `${import.meta.env.VITE_API_BASE_URL ?? ""}/api/auth`; export async function login(email: string, password: string): Promise { const res = await fetch(`${AUTH_BASE}/login`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ email, password }), }); if (!res.ok) throw new Error(`Login failed: ${res.status}`); return res.json() as Promise; } export async function refreshToken(token: string): Promise { const res = await fetch(`${AUTH_BASE}/refresh/token?token=${encodeURIComponent(token)}`); if (!res.ok) throw new Error(`Refresh failed: ${res.status}`); return res.json() as Promise; }