feat: écriture de l'ID Shopify en col A du Sheets après création produit

Utilise un compte de service Google avec JWT pour authentifier les écritures
dans le Sheets — sans dépendance npm supplémentaire (crypto natif Node.js).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-19 12:42:17 +02:00
parent 15f647f58a
commit 42d0e2f855
2 changed files with 49 additions and 1 deletions
+2 -1
View File
@@ -1,7 +1,7 @@
import { NextRequest } from 'next/server'
import { getServerSession } from 'next-auth'
import { authOptions } from '@/lib/auth'
import { fetchPendingProducts } from '@/lib/creationSheets'
import { fetchPendingProducts, writeShopifyIdToSheet } from '@/lib/creationSheets'
import { generateDescriptions } from '@/lib/openaiClient'
import { ensureMetafieldDefinition, setProductMetafield } from '@/lib/shopifyMetafields'
import { addProductToCollection } from '@/lib/shopifyCollections'
@@ -92,6 +92,7 @@ export async function POST(req: NextRequest) {
await prisma.productCreation.create({
data: { userId, sheetTab: product.tab, sheetRow: product.rowNumber, shopifyId, sku: product.sku, title: product.title, status: 'success' },
})
await writeShopifyIdToSheet(product.tab, product.rowNumber, shopifyId)
created++
} catch (err) {
const message = err instanceof Error ? err.message : 'Erreur inconnue'