add analytics-view

This commit is contained in:
2026-03-13 23:14:51 +01:00
parent c5a3f5607d
commit 895448945a
27 changed files with 5545 additions and 35 deletions

View File

@@ -0,0 +1,19 @@
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<AuthResponse> {
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<AuthResponse>;
}
export async function refreshToken(token: string): Promise<AuthResponse> {
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<AuthResponse>;
}