refactor: consolidate 3 MKT fetch routes into fetch-mkt-data to stay within Vercel 12-function limit

Replace fetch-deals, fetch-promos, fetch-chargebacks with a single
/api/fetch-mkt-data?file=deals|promos|chargebacks endpoint.
Update MktDataView fetch calls accordingly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Christian Vidal Wolf
2026-03-11 12:36:45 +01:00
co-authored by Claude Sonnet 4.6
parent 49498c5c51
commit 6a1cb0e8dd
5 changed files with 51 additions and 117 deletions
+6 -6
View File
@@ -109,9 +109,9 @@ export default function MktDataView({ rawData, adsData }: MktDataViewProps) {
setMktLoading(true);
try {
const [dealsRes, promosRes, chargesRes] = await Promise.all([
fetch('/api/fetch-deals'),
fetch('/api/fetch-promos'),
fetch('/api/fetch-chargebacks'),
fetch('/api/fetch-mkt-data?file=deals'),
fetch('/api/fetch-mkt-data?file=promos'),
fetch('/api/fetch-mkt-data?file=chargebacks'),
]);
if (cancelled) return;
@@ -120,21 +120,21 @@ export default function MktDataView({ rawData, adsData }: MktDataViewProps) {
const buf = await dealsRes.arrayBuffer();
if (!cancelled) setDealsMap(parseDealsExcel(buf));
} else {
console.warn('[MktDataView] fetch-deals failed:', dealsRes.status);
console.warn('[MktDataView] fetch-mkt-data?file=deals failed:', dealsRes.status);
}
if (promosRes.ok) {
const buf = await promosRes.arrayBuffer();
if (!cancelled) setPromosMap(parsePromosExcel(buf));
} else {
console.warn('[MktDataView] fetch-promos failed:', promosRes.status);
console.warn('[MktDataView] fetch-mkt-data?file=promos failed:', promosRes.status);
}
if (chargesRes.ok) {
const buf = await chargesRes.arrayBuffer();
if (!cancelled) setChargebacksMap(parseChargebacksExcel(buf));
} else {
console.warn('[MktDataView] fetch-chargebacks failed:', chargesRes.status);
console.warn('[MktDataView] fetch-mkt-data?file=chargebacks failed:', chargesRes.status);
}
} catch (e) {
console.error('[MktDataView] Error fetching marketing data:', e);