This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
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),
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user