From 979e41845bb320c94b86dbba2dda4419d206dafa Mon Sep 17 00:00:00 2001 From: admin-valentin Date: Wed, 26 Aug 2026 19:12:33 +0000 Subject: [PATCH] =?UTF-8?q?feat(FE):=20AI=20Implementation=20Analyzer=20?= =?UTF-8?q?=E2=80=94=20readiness=20score,=20use-cases,=20roadmap,=20ROI=20?= =?UTF-8?q?via=20Hermes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/dashboard/ai-analyzer/page.tsx | 210 +++++++++++++++++++++++++ 1 file changed, 210 insertions(+) create mode 100644 src/app/dashboard/ai-analyzer/page.tsx diff --git a/src/app/dashboard/ai-analyzer/page.tsx b/src/app/dashboard/ai-analyzer/page.tsx new file mode 100644 index 0000000..373250c --- /dev/null +++ b/src/app/dashboard/ai-analyzer/page.tsx @@ -0,0 +1,210 @@ +'use client'; + +import { useState } from 'react'; +import { useMutation } from '@tanstack/react-query'; +import { apiFetch } from '../../../lib/api'; +import { useSession } from '../../../components/session-provider'; + +const DEPARTMENTS = [ + 'Sales & Marketing', 'Customer Success', 'Finance & Accounting', + 'HR & Recruitment', 'Operations & Logistics', 'Product & Engineering', + 'Legal & Compliance', 'Executive & Strategy', +]; + +const COMPANY_SIZES = ['1-10', '11-50', '51-200', '201-1000', '1000+']; + +interface AnalysisResult { + readinessScore: number; + summary: string; + useCases: string; + roadmap: string; + risks: string; + roi: string; +} + +export default function AiAnalyzerPage() { + const { activeTenant } = useSession(); + const tenantId = activeTenant?.tenantId ?? ''; + const [form, setForm] = useState({ + companyName: '', industry: '', size: '11-50', description: '', + currentTools: '', departments: [] as string[], budget: '', timeline: '6', + }); + const [result, setResult] = useState(null); + + const analyzeMut = useMutation({ + mutationFn: () => { + const prompt = [ + `Analizează potențialul de implementare AI pentru această companie și generează un raport detaliat.`, + ``, + `## Date companie`, + `Nume: ${form.companyName || 'Nespecificat'}`, + `Industrie: ${form.industry}`, + `Dimensiune: ${form.size} angajați`, + `Descriere: ${form.description}`, + `Tool-uri existente: ${form.currentTools || 'Nespecificate'}`, + `Departamente prioritare: ${form.departments.join(', ') || 'Toate'}`, + `Buget estimat: ${form.budget || 'Nespecificat'} EUR`, + `Timeline dorit: ${form.timeline} luni`, + ``, + `Generează un raport structurat cu aceste secțiuni (format JSON valid):`, + `{`, + ` "readinessScore": [0-100, scor de pregătire pentru AI],`, + ` "summary": "[2-3 fraze: situația actuală și potențialul]",`, + ` "useCases": "[top 5 use-case-uri specifice industriei, cu impact cuantificat]",`, + ` "roadmap": "[roadmap implementare 3 faze: Quick wins 0-3 luni, Foundation 3-6 luni, Scale 6-12 luni]",`, + ` "risks": "[top 3 riscuri și mitigation]",`, + ` "roi": "[estimare ROI: costuri implementare vs beneficii cuantificate]"`, + `}`, + `Răspunde DOAR cu JSON valid, fără text extra.`, + ].join('\n'); + + return apiFetch<{ reply: string }>('/v1/ai/ask', { + tenantId, method: 'POST', + body: { + messages: [{ role: 'user', content: prompt }], + context: JSON.stringify({ context: 'ai_implementation_analysis' }), + }, + }); + }, + onSuccess: (data) => { + try { + const json = JSON.parse(data.reply.match(/\{[\s\S]*\}/)?.[0] ?? data.reply); + setResult(json); + } catch { + setResult({ readinessScore: 0, summary: data.reply, useCases: '', roadmap: '', risks: '', roi: '' }); + } + }, + }); + + function toggleDept(d: string) { + setForm(f => ({ + ...f, + departments: f.departments.includes(d) ? f.departments.filter(x => x !== d) : [...f.departments, d], + })); + } + + const scoreColor = result + ? result.readinessScore >= 70 ? 'text-signal-ok' : result.readinessScore >= 40 ? 'text-amber-600' : 'text-signal-danger' + : 'text-ink'; + + return ( +
+
+

AI Implementation Analyzer

+

+ Analizează potențialul AI pentru orice companie — scor, use-case-uri, roadmap, ROI +

+
+ + {!result ? ( +
+
+
+ + setForm(f => ({...f, companyName: e.target.value}))} + placeholder="Acme GmbH" className="mt-1 w-full rounded-lg border bg-background px-3 py-2 text-sm text-ink focus:outline-none focus:ring-2 focus:ring-ring" /> +
+
+ + setForm(f => ({...f, industry: e.target.value}))} + placeholder="ex: Logistică, SaaS, Healthcare, Retail…" className="mt-1 w-full rounded-lg border bg-background px-3 py-2 text-sm text-ink focus:outline-none focus:ring-2 focus:ring-ring" /> +
+
+ +
+ +