import { resolveAssetUrl } from '@/lib/api/asset-url'; const API_URL = process.env.NEXT_PUBLIC_API_URL ?? 'http://localhost:3000'; export interface TenantTheme { nome: string; logoUrl: string | null; corPrimaria: string | null; } interface PublicTenantThemeResponse { nome: string; logo_url: string | null; cor_primaria: string | null; } /** * `GET /public/tenants/:id/tema` (Etapa 8 do backend) — sem autenticação, * usado tanto antes do login (se o tenant for identificável, ver * `lib/theme/theme-provider.tsx`) quanto depois (a partir do `tenant_id` * do usuário autenticado). */ export async function fetchTenantTheme(tenantId: string): Promise { try { const response = await fetch(`${API_URL}/public/tenants/${tenantId}/tema`); if (!response.ok) return null; const data = (await response.json()) as PublicTenantThemeResponse; return { nome: data.nome, logoUrl: resolveAssetUrl(data.logo_url), corPrimaria: data.cor_primaria }; } catch { return null; } }