diff --git a/attached_assets/image_1759410628670.png b/attached_assets/image_1759410628670.png new file mode 100644 index 0000000..8bc855f Binary files /dev/null and b/attached_assets/image_1759410628670.png differ diff --git a/client/src/pages/new-post.tsx b/client/src/pages/new-post.tsx index 89066ca..b9844bf 100644 --- a/client/src/pages/new-post.tsx +++ b/client/src/pages/new-post.tsx @@ -35,8 +35,17 @@ export default function NewPost() { }); const generateTextMutation = useMutation({ - mutationFn: (productInfo: string) => - apiRequest('POST', '/api/ai/generate', { productInfo }), + mutationFn: (productInfoText: string) => { + const productInfo = { + name: productInfoText.match(/Produit:\s*(.+?)(?:\n|$)/i)?.[1] || + productInfoText.match(/Nom:\s*(.+?)(?:\n|$)/i)?.[1] || + productInfoText, + price: productInfoText.match(/Prix:\s*(.+?)(?:\n|$)/i)?.[1] || "", + description: productInfoText.match(/Description:\s*(.+?)(?:\n|$)/i)?.[1] || "", + features: productInfoText.match(/Caractéristiques:\s*(.+?)(?:\n|$)/i)?.[1]?.split(",") || [], + }; + return apiRequest('POST', '/api/ai/generate', productInfo); + }, onSuccess: (data: any) => { const variants = data.variants || []; setGeneratedVariants(variants);