diff --git a/src/app/(dashboard)/creation/page.tsx b/src/app/(dashboard)/creation/page.tsx index 49aa0c5..b675364 100644 --- a/src/app/(dashboard)/creation/page.tsx +++ b/src/app/(dashboard)/creation/page.tsx @@ -58,7 +58,7 @@ export default function CreationPage() { const res = await fetch('/api/creation/execute', { method: 'POST', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ resolutions }), + body: JSON.stringify({ resolutions, tab: selectedTab }), }) if (!res.body) return const reader = res.body.getReader() diff --git a/src/app/api/creation/execute/route.ts b/src/app/api/creation/execute/route.ts index 4b1d98f..7bf8a01 100644 --- a/src/app/api/creation/execute/route.ts +++ b/src/app/api/creation/execute/route.ts @@ -20,8 +20,9 @@ export async function POST(req: NextRequest) { } const userId = (session.user as { id: string }).id - const body = await req.json().catch(() => ({})) as { resolutions?: MetafieldResolution[] } + const body = await req.json().catch(() => ({})) as { resolutions?: MetafieldResolution[]; tab?: string } const resolutions: MetafieldResolution[] = body.resolutions ?? [] + const tabFilter: string | undefined = body.tab ?? undefined const resolutionMap = new Map(resolutions.map(r => [r.columnHeader, r])) const stream = new ReadableStream({ @@ -34,7 +35,7 @@ export async function POST(req: NextRequest) { ]) const alreadyCreated = new Set(existingRows.map(e => `${e.sheetTab}:${e.sheetRow}`)) const shopifyRefs = new Set(shopifyProducts.map(p => p.ref.trim().toLowerCase())) - const pending = await fetchPendingProducts(alreadyCreated) + const pending = await fetchPendingProducts(alreadyCreated, tabFilter) const total = pending.length if (total === 0) {