34 lines
786 B
JavaScript
34 lines
786 B
JavaScript
|
|
const API_BASE_URL =
|
||
|
|
import.meta.env.VITE_API_BASE_URL || import.meta.env.VITE_API_URL || 'http://localhost:3001';
|
||
|
|
|
||
|
|
async function request(path, options = {}) {
|
||
|
|
const response = await fetch(`${API_BASE_URL}${path}`, {
|
||
|
|
headers: {
|
||
|
|
'Content-Type': 'application/json',
|
||
|
|
...options.headers,
|
||
|
|
},
|
||
|
|
...options,
|
||
|
|
});
|
||
|
|
|
||
|
|
if (!response.ok) {
|
||
|
|
throw new Error('Falha ao consultar acessos');
|
||
|
|
}
|
||
|
|
|
||
|
|
return response.json();
|
||
|
|
}
|
||
|
|
|
||
|
|
export async function getAccessOptions() {
|
||
|
|
return request('/admin/access/options');
|
||
|
|
}
|
||
|
|
|
||
|
|
export async function getAccessUsers() {
|
||
|
|
return request('/admin/access/users');
|
||
|
|
}
|
||
|
|
|
||
|
|
export async function updateUserAccess(userId, access) {
|
||
|
|
return request(`/admin/access/users/${userId}`, {
|
||
|
|
method: 'PUT',
|
||
|
|
body: JSON.stringify(access),
|
||
|
|
});
|
||
|
|
}
|