fix: pass tab filter to execute route so only selected family is created

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-24 15:51:47 +02:00
parent 6d8be0645d
commit 9e7423eee3
2 changed files with 4 additions and 3 deletions
+1 -1
View File
@@ -58,7 +58,7 @@ export default function CreationPage() {
const res = await fetch('/api/creation/execute', { const res = await fetch('/api/creation/execute', {
method: 'POST', method: 'POST',
headers: { 'Content-Type': 'application/json' }, headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ resolutions }), body: JSON.stringify({ resolutions, tab: selectedTab }),
}) })
if (!res.body) return if (!res.body) return
const reader = res.body.getReader() const reader = res.body.getReader()
+3 -2
View File
@@ -20,8 +20,9 @@ export async function POST(req: NextRequest) {
} }
const userId = (session.user as { id: string }).id 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 resolutions: MetafieldResolution[] = body.resolutions ?? []
const tabFilter: string | undefined = body.tab ?? undefined
const resolutionMap = new Map<string, MetafieldResolution>(resolutions.map(r => [r.columnHeader, r])) const resolutionMap = new Map<string, MetafieldResolution>(resolutions.map(r => [r.columnHeader, r]))
const stream = new ReadableStream({ 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 alreadyCreated = new Set(existingRows.map(e => `${e.sheetTab}:${e.sheetRow}`))
const shopifyRefs = new Set(shopifyProducts.map(p => p.ref.trim().toLowerCase())) 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 const total = pending.length
if (total === 0) { if (total === 0) {