import { useApi } from '~/composables/useApi' import type { UserData } from '~/services/dto/user-data' export async function getUsers() { const api = useApi() const data = await api.get('users', {}, { toastErrorKey: 'errors.auth.users' }) if (Array.isArray(data)) { return data } return data['hydra:member'] ?? [] } export async function getCurrentUser() { const api = useApi() return api.get('me', {}, { toast: false }) } export async function login(username: string, password: string) { const api = useApi() return api.post<{ token: string }>('login_check', { username, password }, { toastErrorKey: 'errors.auth.login', toastSuccessKey: 'success.auth.login' }) } export async function logout() { const api = useApi() return api.post('logout', {}, { toastErrorKey: 'errors.auth.logout', toastSuccessKey: 'success.auth.logout', redirect: 'manual' }) }