fuck if i know

This commit is contained in:
2025-12-04 15:06:57 -05:00
parent fb3c23fa46
commit cb16698940
76 changed files with 1197 additions and 603 deletions
+60
View File
@@ -0,0 +1,60 @@
const API_BASE =
process.env.NEXT_PUBLIC_API_URL ?? "http://localhost:8080";
export interface AdminMerchantCategoryMapping {
id: number;
merchantId: number;
merchantName: string;
rawCategoryPath: string;
partCategorySlug: string | null;
}
export async function fetchMerchantCategoryMappings(
token: string,
filters?: { merchantId?: number }
): Promise<AdminMerchantCategoryMapping[]> {
const params = new URLSearchParams();
if (filters?.merchantId) {
params.append("merchantId", String(filters.merchantId));
}
const res = await fetch(
`${API_BASE}/api/admin/category-mappings?${params.toString()}`,
{
headers: {
Authorization: `Bearer ${token}`,
},
cache: "no-store",
}
);
if (!res.ok) {
const text = await res.text();
throw new Error(`API error ${res.status}: ${text}`);
}
return res.json();
}
export async function updateMerchantCategoryMapping(
token: string,
id: number,
payload: { partCategorySlug: string | null }
): Promise<AdminMerchantCategoryMapping> {
const res = await fetch(`${API_BASE}/api/admin/category-mappings/${id}`, {
method: "PUT",
headers: {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
},
body: JSON.stringify(payload),
});
if (!res.ok) {
const text = await res.text();
throw new Error(`API error ${res.status}: ${text}`);
}
return res.json();
}