diff --git a/components/MarketResearcher.tsx b/components/MarketResearcher.tsx index 5cde212..a08d8b4 100644 --- a/components/MarketResearcher.tsx +++ b/components/MarketResearcher.tsx @@ -1,6 +1,6 @@ "use client"; -import { useState } from "react"; +import { useState, useEffect } from "react"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Textarea } from "@/components/ui/textarea"; @@ -25,6 +25,8 @@ const MarketResearcher = () => { const [specialInstructions, setSpecialInstructions] = useState(""); const [isProcessing, setIsProcessing] = useState(false); + const [progress, setProgress] = useState(0); + const [thoughtIndex, setThoughtIndex] = useState(0); const [error, setError] = useState(null); const selectedModel = selectedModels[selectedProvider]; @@ -61,6 +63,31 @@ const MarketResearcher = () => { return null; }; + useEffect(() => { + let interval: NodeJS.Timeout; + if (isProcessing) { + setProgress(0); + setThoughtIndex(0); + interval = setInterval(() => { + setProgress(prev => { + if (prev >= 95) return prev; + return prev + (prev < 30 ? 2 : prev < 70 ? 1 : 0.5); + }); + }, 300); + + const thoughtInterval = setInterval(() => { + setThoughtIndex(prev => (prev < (t.thoughts?.length || 0) - 1 ? prev + 1 : prev)); + }, 4000); + + return () => { + clearInterval(interval); + clearInterval(thoughtInterval); + }; + } else { + setProgress(0); + } + }, [isProcessing, t.thoughts]); + const handleStartResearch = async () => { const validationError = validateUrls(); if (validationError) { @@ -93,6 +120,7 @@ const MarketResearcher = () => { }, selectedProvider, selectedModel); if (result.success && result.data) { + setProgress(100); try { const cleanJson = result.data.replace(/```json\s*([\s\S]*?)\s*```/i, '$1').trim(); const parsed = JSON.parse(cleanJson); @@ -319,6 +347,37 @@ const MarketResearcher = () => { /> + {isProcessing && ( +
+
+
+ + {language === "ru" ? "Идет анализ" : language === "he" ? "מנתח..." : "Analysis in progress"} + + {Math.round(progress)}% +
+
+
+
+
+ +
+
+ +
+

+ AI Thoughts & Actions +

+

+ "{t.thoughts?.[thoughtIndex] || t.researching}" +

+
+
+ )} + {error && (
diff --git a/lib/i18n/translations.ts b/lib/i18n/translations.ts index 7c79128..859125b 100644 --- a/lib/i18n/translations.ts +++ b/lib/i18n/translations.ts @@ -138,6 +138,16 @@ export const translations = { generate: "Start Research", researching: "Performing Deep Analysis...", emptyState: "Your comprehensive market research report will appear here", + thoughts: [ + "Initializing deep scan of primary website...", + "Extracting product hierarchy and pricing structures...", + "Identifying competitor digital footprints...", + "Analyzing competitor feature sets and USPs...", + "Cross-referencing pricing data across target URLs...", + "Evaluating market positioning and landscape...", + "Synthesizing strategic advantages and identifying gaps...", + "Finalizing comprehensive intelligence report..." + ] } }, ru: { @@ -277,6 +287,16 @@ export const translations = { generate: "Начать исследование", researching: "Выполнение глубокого анализа...", emptyState: "Ваш подробный отчет об исследовании рынка появится здесь", + thoughts: [ + "Инициализация глубокого сканирования основного сайта...", + "Извлечение иерархии продуктов и структур ценообразования...", + "Идентификация цифровых следов конкурентов...", + "Анализ наборов функций и УТП конкурентов...", + "Перекрестная проверка ценовых данных по целевым URL...", + "Оценка позиционирования на рынке и ландшафта...", + "Синтез стратегических преимуществ и выявление пробелов...", + "Финализация подробного отчета о разведке..." + ] } }, he: { @@ -416,6 +436,16 @@ export const translations = { generate: "התחל מחקר", researching: "מבצע ניתוח מעמיק...", emptyState: "דו\"ח מחקר השוק המקיף שלך יופיע כאן", + thoughts: [ + "מאתחל סריקה עמוקה של אתר האינטרנט הראשי...", + "מחלץ היררכיית מוצרים ומבני תמחור...", + "מזהה טביעות רגל דיגיטליות של מתחרים...", + "מנתח סטים של תכונות ו-USP של מתחרים...", + "מצליב נתוני תמחור בין כתובות URL ממוקדות...", + "מעריך מיצוב שוק ונוף תחרותי...", + "מסנכרן יתרונות אסטרטגיים ומזהה פערים...", + "מגבש דו\"ח מודיעין מקיף סופי..." + ] } } };