feat: collection picker in product creation flow
- API /api/creation/collections liste toutes les collections Shopify - Détection automatique depuis la colonne ID FAMILLE du Sheets - Sélecteur avec recherche si absente ou pour modifier - Collection affichée dans l'écran de confirmation - collectionOverride passé à l'exécution comme fallback Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -20,9 +20,10 @@ export async function POST(req: NextRequest) {
|
||||
}
|
||||
|
||||
const userId = (session.user as { id: string }).id
|
||||
const body = await req.json().catch(() => ({})) as { resolutions?: MetafieldResolution[]; tab?: string }
|
||||
const body = await req.json().catch(() => ({})) as { resolutions?: MetafieldResolution[]; tab?: string; collectionOverride?: string }
|
||||
const resolutions: MetafieldResolution[] = body.resolutions ?? []
|
||||
const tabFilter: string | undefined = body.tab ?? undefined
|
||||
const collectionOverride: string | undefined = body.collectionOverride ?? undefined
|
||||
const resolutionMap = new Map<string, MetafieldResolution>(resolutions.map(r => [r.columnHeader, r]))
|
||||
|
||||
const stream = new ReadableStream({
|
||||
@@ -83,7 +84,8 @@ export async function POST(req: NextRequest) {
|
||||
weightKg: product.weightKg,
|
||||
status: 'active',
|
||||
})
|
||||
if (product.collectionId) await addProductToCollection(shopifyId, product.collectionId)
|
||||
const effectiveCollectionId = product.collectionId || collectionOverride || ''
|
||||
if (effectiveCollectionId) await addProductToCollection(shopifyId, effectiveCollectionId)
|
||||
if (product.subCollectionId) await addProductToCollection(shopifyId, product.subCollectionId)
|
||||
send({ type: 'progress', current: i + 1, total, tab: product.tab, title: product.title, step: 'Métachamps…' })
|
||||
for (const [colHeader, value] of Object.entries(product.specificFields)) {
|
||||
|
||||
Reference in New Issue
Block a user