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
This commit is contained in:
michaelschal committed 2025-10-02 13:17:25 +00:00
1 parent 1af28f6f00
commit f07f897ce0
1 file changed
+3 -2
+3 -2
View File
@@ -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 || [];