From f07f897ce0945a4bd9436aa456c0ff79ca6501ac Mon Sep 17 00:00:00 2001 From: michaelschal <35957947-michaelschal@users.noreply.replit.com> Date: Thu, 2 Oct 2025 13:17:25 +0000 Subject: [PATCH] Improve AI text generation for new post creation Update the `new-post.tsx` page to correctly handle asynchronous API requests for AI text generation, mirroring the functionality of the AI assistant page. Replit-Commit-Author: Agent Replit-Commit-Session-Id: ae4037a0-2a6f-4530-9bac-79b543286bda Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/397bca8c-984f-43ff-841a-10897aeb8140/ae4037a0-2a6f-4530-9bac-79b543286bda/sjuGm8z --- client/src/pages/new-post.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/src/pages/new-post.tsx b/client/src/pages/new-post.tsx index b9844bf..1d921b8 100644 --- a/client/src/pages/new-post.tsx +++ b/client/src/pages/new-post.tsx @@ -35,7 +35,7 @@ export default function NewPost() { }); const generateTextMutation = useMutation({ - mutationFn: (productInfoText: string) => { + mutationFn: async (productInfoText: string) => { const productInfo = { name: productInfoText.match(/Produit:\s*(.+?)(?:\n|$)/i)?.[1] || productInfoText.match(/Nom:\s*(.+?)(?:\n|$)/i)?.[1] || @@ -44,7 +44,8 @@ export default function NewPost() { 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); + const response = await apiRequest('POST', '/api/ai/generate', productInfo); + return response.json(); }, onSuccess: (data: any) => { const variants = data.variants || [];