Quality / test (push) Canceled after 0s
Add the admin Acquisition form and history, calculated cost-basis display, API client, and deterministic authenticated browser coverage.
25 lines
796 B
JavaScript
25 lines
796 B
JavaScript
const apiBaseUrl = import.meta.env?.VITE_API_BASE_URL ?? '/api/v1';
|
|
|
|
async function request(path, options = {}) {
|
|
const response = await fetch(`${apiBaseUrl}${path}`, {
|
|
credentials: 'include',
|
|
...options,
|
|
headers: { ...(options.body ? { 'content-type': 'application/json' } : {}), ...options.headers },
|
|
});
|
|
const payload = await response.json().catch(() => null);
|
|
if (!response.ok) throw new Error(payload?.error?.message ?? 'Acquisition request failed.');
|
|
return payload?.data;
|
|
}
|
|
|
|
export function listAdminAcquisitions() {
|
|
return request('/admin/acquisitions');
|
|
}
|
|
|
|
export function createAdminAcquisition(input, csrfToken) {
|
|
return request('/admin/acquisitions', {
|
|
method: 'POST',
|
|
headers: { 'x-csrf-token': csrfToken },
|
|
body: JSON.stringify(input),
|
|
});
|
|
}
|