Backfill the completed acquisitions, sales, dashboard, pricing, search, public detail, worker, migration, contracts, validation, tests, and implementation-status changes into one verified application slice.
36 lines
987 B
JavaScript
36 lines
987 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 ?? "Provider mapping request failed.",
|
|
);
|
|
return payload?.data;
|
|
}
|
|
|
|
export function listAdminProviderMappings(productId) {
|
|
return request(
|
|
`/admin/products/${encodeURIComponent(productId)}/provider-mappings`,
|
|
);
|
|
}
|
|
|
|
export function createAdminProviderMapping(productId, input, csrfToken) {
|
|
return request(
|
|
`/admin/products/${encodeURIComponent(productId)}/provider-mappings`,
|
|
{
|
|
method: "POST",
|
|
headers: { "x-csrf-token": csrfToken },
|
|
body: JSON.stringify(input),
|
|
},
|
|
);
|
|
}
|