mirror of
https://github.com/R0m1k3/Socialflow.git
synced 2026-10-19 13:08:12 +02:00
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:
1 parent
1af28f6f00
commit
f07f897ce0
1 file changed
+3
-2
@@ -35,7 +35,7 @@ export default function NewPost() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const generateTextMutation = useMutation({
|
const generateTextMutation = useMutation({
|
||||||
mutationFn: (productInfoText: string) => {
|
mutationFn: async (productInfoText: string) => {
|
||||||
const productInfo = {
|
const productInfo = {
|
||||||
name: productInfoText.match(/Produit:\s*(.+?)(?:\n|$)/i)?.[1] ||
|
name: productInfoText.match(/Produit:\s*(.+?)(?:\n|$)/i)?.[1] ||
|
||||||
productInfoText.match(/Nom:\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] || "",
|
description: productInfoText.match(/Description:\s*(.+?)(?:\n|$)/i)?.[1] || "",
|
||||||
features: productInfoText.match(/Caractéristiques:\s*(.+?)(?:\n|$)/i)?.[1]?.split(",") || [],
|
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) => {
|
onSuccess: (data: any) => {
|
||||||
const variants = data.variants || [];
|
const variants = data.variants || [];
|
||||||
|
|||||||
Reference in new issue
Block a user