"use client"; import { useState, useEffect, useRef } from "react"; // ── Types (mirrors lib/schemas.py) ─────────────────────────────────────────── export interface GoNoGoScore { decision: string; weighted_score?: number | null; market_attractiveness?: number | null; technical_barrier?: number | null; unit_economics?: number | null; gtm_ease?: number | null; leap_of_faith?: string[] | null; ensemble_note?: string | null; } export interface MarketAnalysis { tam?: string | null; tam_formula?: string | null; sam?: string | null; som?: string | null; cagr?: string | null; macro_signals?: string | null; tam_source?: string | null; } export interface Competitor { name: string; url?: string | null; weakness?: string | null; funding?: string | null; } export interface TechFeasibility { stack?: string | null; cpu_cost?: string | null; ltv?: string | null; cac?: string | null; pricing_model?: string | null; } export interface FeasibilityReport { idea_title: string; executive_summary: GoNoGoScore; market: MarketAnalysis; competition: { competitors: Competitor[]; gap_summary?: string | null; entry_barriers?: string | null; }; technical: TechFeasibility; validation: { icp?: string | null; waitlist_h1?: string | null; waitlist_h2?: string | null; value_prop?: string | null; }; sources: Array<{ url: string; title?: string | null }>; confidence_index?: number | null; pivot_suggestions?: string[] | null; } // ── Helpers ────────────────────────────────────────────────────────────────── function mapDecision(d: string) { if (d === "Go") return { text: "GİT", cls: "vr-t-em", pCls: "vr-p-em" }; if (d === "No-Go") return { text: "VAZGEÇ", cls: "vr-t-ro", pCls: "vr-p-ro" }; return { text: "GELİŞTİR", cls: "vr-t-am", pCls: "vr-p-am" }; } function easeOut(t: number) { return 1 - Math.pow(1 - t, 3); } function barGrad(s: number) { if (s >= 9) return "linear-gradient(90deg,#10B981,#059669)"; if (s >= 7) return "linear-gradient(90deg,#6D28D9,#8B5CF6)"; if (s >= 5) return "linear-gradient(90deg,#F59E0B,#D97706)"; return "linear-gradient(90deg,#E11D48,#BE123C)"; } function textCol(s: number) { if (s >= 9) return "#34D399"; if (s >= 7) return "#A78BFA"; if (s >= 5) return "#FCD34D"; return "#FB7185"; } // ── Gauge (3-ring, Apple Fitness style) ────────────────────────────────────── function GaugeSVG({ skor, guven }: { skor: number; guven: number }) { const [progress, setProgress] = useState(0); useEffect(() => { setProgress(0); const tid = setTimeout(() => { const t0 = Date.now(), dur = 1700; const tick = () => { const p = Math.min((Date.now() - t0) / dur, 1); setProgress(easeOut(p)); if (p < 1) requestAnimationFrame(tick); }; requestAnimationFrame(tick); }, 300); return () => clearTimeout(tid); }, [skor, guven]); const cx = 82, cy = 82; const rings = [ { r: 72, pct: Math.min(skor / 100, 1), color: "#F59E0B" }, { r: 58, pct: Math.min(guven, 1), color: "#E11D48" }, { r: 44, pct: Math.min(guven * 0.9, 1), color: "#FB923C" }, ]; return ( {rings.map(({ r, pct, color }) => { const circ = 2 * Math.PI * r; const fill = circ * pct * progress; return ( ); })} ); } // ── Radar SVG ──────────────────────────────────────────────────────────────── const RADAR_AXES = ["Kullanılabilirlik", "Teknik Güç", "Entegrasyon", "Destek", "Fiyat"]; function RadarSVG({ competitors }: { competitors: Competitor[] }) { const cx = 150, cy = 155, maxR = 98, N = 5; const angles = Array.from({ length: N }, (_, i) => -Math.PI / 2 + (i * 2 * Math.PI) / N); const pt = (i: number, v: number): [number, number] => { const r = (v / 10) * maxR; return [cx + r * Math.cos(angles[i]), cy + r * Math.sin(angles[i])]; }; const poly = (vals: number[]) => vals.map((v, i) => pt(i, v).join(",")).join(" "); // Deterministic pseudo-scores from competitor name const compVals = (c: Competitor, idx: number) => { const s = c.name.charCodeAt(0) % 4; return [3 + s, 4 + ((s + idx) % 4), 3 + ((s + 2) % 4), 2 + ((s + idx + 1) % 5), 5 + (s % 3)]; }; const oppVals = [9, 8, 8, 7, 7]; const shown = competitors.slice(0, 2); const compColors = ["rgba(255,255,255,.22)", "rgba(255,255,255,.12)"]; const compFills = ["rgba(255,255,255,.03)", "rgba(255,255,255,.02)"]; const legend = [ ...shown.map((c, i) => ({ name: c.name, color: compColors[i] })), { name: "Fırsat Alanı", color: "rgba(109,40,217,.85)" }, ]; return ( {[0.25, 0.5, 0.75, 1].map(lv => ( `${cx + lv * maxR * Math.cos(a)},${cy + lv * maxR * Math.sin(a)}`).join(" ")} fill="none" stroke="rgba(255,255,255,.04)" strokeWidth="1" /> ))} {angles.map((a, i) => ( {RADAR_AXES[i]} ))} {shown.map((c, i) => ( ))} {oppVals.map((v, i) => { const [px, py] = pt(i, v); return ; })} {legend.map((l, i) => ( {l.name} ))} ); } // ── Main Component ──────────────────────────────────────────────────────────── interface Props { reportJson: FeasibilityReport; onCreateWaitlist: () => void; isCreatingWaitlist: boolean; } export function ReportDisplay({ reportJson, onCreateWaitlist, isCreatingWaitlist }: Props) { const [scoreDisplay, setScoreDisplay] = useState(0); const revealRefs = useRef<(HTMLDivElement | null)[]>([]); const dec = mapDecision(reportJson.executive_summary.decision); const skor = reportJson.executive_summary.weighted_score ?? 0; const guven = reportJson.confidence_index ?? 0; const market = reportJson.market; const tech = reportJson.technical; const competitors = reportJson.competition.competitors ?? []; // Animated score counter useEffect(() => { setScoreDisplay(0); const tid = setTimeout(() => { const t0 = Date.now(), dur = 1700; const tick = () => { const p = Math.min((Date.now() - t0) / dur, 1); setScoreDisplay(Math.round(skor * easeOut(p))); if (p < 1) requestAnimationFrame(tick); }; requestAnimationFrame(tick); }, 300); return () => clearTimeout(tid); }, [skor]); // Reveal animations useEffect(() => { const obs = new IntersectionObserver( (entries) => entries.forEach(e => { if (e.isIntersecting) { e.target.classList.add("in"); obs.unobserve(e.target); } }), { threshold: 0.05, rootMargin: "0px 0px -40px 0px" } ); revealRefs.current.forEach(el => el && obs.observe(el)); // Force-reveal elements already in viewport setTimeout(() => { revealRefs.current.forEach(el => { if (!el) return; const r = el.getBoundingClientRect(); if (r.top < window.innerHeight + 80) el.classList.add("in"); }); }, 80); return () => obs.disconnect(); }, []); const ref = (i: number) => (el: HTMLDivElement | null) => { revealRefs.current[i] = el; }; // Feasibility rows (from scoring sub-dimensions) const feasRows = [ { icon: "💳", name: "Pazar Çekiciliği", score: Math.round((reportJson.executive_summary.market_attractiveness ?? 0) / 3), tip: "Pazar büyüme hızı ve toplam pazar büyüklüğü değerlendirmesi." }, { icon: "🔧", name: "Teknik Fizibilite", score: Math.round((reportJson.executive_summary.technical_barrier ?? 0) / 3), tip: "Teknik engeller ve geliştirme karmaşıklığı değerlendirmesi." }, { icon: "💰", name: "Birim Ekonomisi", score: Math.round((reportJson.executive_summary.unit_economics ?? 0) / 2), tip: "LTV/CAC oranı ve finansal sürdürülebilirlik." }, { icon: "🚀", name: "Pazara Erişim", score: Math.round((reportJson.executive_summary.gtm_ease ?? 0) / 2), tip: "Hedef kitleye ulaşma kolaylığı ve dağıtım kanalları." }, { icon: "⚡", name: "Rekabetten Farklılaşma", score: competitors.length > 3 ? 6 : 8, tip: "Mevcut rakiplere karşı farklılaşma potansiyeli." }, ].filter(r => r.score > 0); const totalFeas = feasRows.reduce((s, r) => s + r.score, 0); const maxFeas = feasRows.length * 10; const feasLabel = totalFeas / maxFeas >= 0.7 ? "Güçlü Fırsat ▲" : totalFeas / maxFeas >= 0.5 ? "Orta Fırsat →" : "Zayıf Fırsat ▼"; const chips = reportJson.executive_summary.leap_of_faith?.slice(0, 3) ?? []; // ── Render ───────────────────────────────────────────────────────────────── return (
{/* ① HERO DECISION CARD */}
{/* ② TAM / SAM / SOM */}
PAZAR BÜYÜKLÜĞÜ
TAM
{market.tam ?? "—"}
Toplam Adreslenebilir Pazar
{market.cagr &&
{market.cagr} CAGR ↑
} {(market.tam_formula || market.tam_source) && (
{market.tam_formula && <>Formül{market.tam_formula}} {market.tam_source && Kaynak: {market.tam_source}}
)}
SAM
{market.sam ?? "—"}
Ulaşılabilir Pazar
SOM
{market.som ?? "—"}
İlk Yıl Hedef
{market.macro_signals && (
{market.macro_signals}
)}
{/* ③ COMPETITION */} {competitors.length > 0 && (
REKABET ANALİZİ
{competitors.map((c, i) => (
{(c.name[0] ?? "?").toUpperCase()}
{c.name}
{c.url &&
{c.url.replace(/^https?:\/\//, "").split("/")[0]}
}
{c.weakness &&
· {c.weakness.slice(0, 90)}{c.weakness.length > 90 ? "…" : ""}
} {c.funding &&
{c.funding}
}
))}
{reportJson.competition.gap_summary && (
🎯 Tespit Edilen Boşluk

{reportJson.competition.gap_summary.slice(0, 240)}

)}
)} {/* ④ FEASIBILITY */} {feasRows.length > 0 && (
FİZİBİLİTE DEĞERLENDİRMESİ
{feasRows.map((r, i) => (
{r.icon} {r.name}
{r.score}/10
{r.tip}
))}
Toplam Puan {totalFeas}/{maxFeas} · {feasLabel}
)} {/* ⑤ TECHNICAL & FINANCIAL */} {(tech.cpu_cost || tech.ltv || tech.cac || tech.pricing_model || tech.stack) && (
TEKNİK & FİNANSAL
{tech.cpu_cost && (
🖥️ CPU Maliyeti
{tech.cpu_cost}
istek başına
)} {tech.ltv && (
💰 LTV
{tech.ltv}
müşteri / yıl
)} {tech.cac && (
📣 CAC
{tech.cac}
edinim maliyeti
)} {tech.pricing_model && (
📦 Fiyatlandırma
{tech.pricing_model}
SaaS modeli
)} {tech.stack && (
⚙️ Teknoloji Stack
{tech.stack}
)}
)} {/* ⑥ PIVOT SUGGESTIONS */} {reportJson.pivot_suggestions && reportJson.pivot_suggestions.length > 0 && (
PİVOT ÖNERİLERİ
{reportJson.pivot_suggestions.map((p, i) => (
💡 {p}
))}
)} {/* ⑦ ICP / VALUE PROP */} {(reportJson.validation.icp || reportJson.validation.value_prop) && (
DOĞRULAMA & GTM
{reportJson.validation.icp && (
İdeal Müşteri Profili

{reportJson.validation.icp}

)} {reportJson.validation.value_prop && (
Değer Önerisi

{reportJson.validation.value_prop}

)}
)} {/* ⑧ CTA */}
SONRAKİ ADIM

Bu Fikri Doğrulamak İster Misin?

5 dakika içinde kişiselleştirilmiş doğrulama planı oluştur. Müşteri görüşmeleri, MVP testleri ve metrikler dahil.

); }