feat: integra /sistema/usuarios e /sistema/configuracoes com API real

- useApi.ts: composable centralizado com Authorization header automático
- usuarios.vue: GET /api/v1/users — lista usuários reais do tenant
- configuracoes.vue: GET/PUT /api/v1/tenant/me — carrega e salva dados reais

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Junior
2026-03-14 12:40:27 -03:00
parent e7016b6b10
commit 2e5eee15ad
3 changed files with 80 additions and 26 deletions

View File

@@ -0,0 +1,17 @@
// Wrapper sobre $fetch que injeta o Authorization header automaticamente.
export function useApi() {
const { public: { apiBase } } = useRuntimeConfig()
const token = useCookie<string | null>('auth_token')
function apiFetch<T>(path: string, options: Parameters<typeof $fetch>[1] = {}): Promise<T> {
return $fetch<T>(`${apiBase}${path}`, {
...options,
headers: {
...(options.headers as Record<string, string> || {}),
...(token.value ? { Authorization: `Bearer ${token.value}` } : {}),
},
})
}
return { apiFetch }
}