"use client";
import { Button } from "@/src/components/ui/button";
import { Input } from "@/src/components/ui/input";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/src/components/ui/select";
import { useAnalyseText } from "@/src/hooks/useAnalyzeText";
import { CheckCircle2, Sparkles, Star, Trophy } from "lucide-react";
import { motion } from "framer-motion";
export default function AnalysisPage() {
const {
url1,
url2,
profession,
loading,
result,
disabled,
handleAnalyze,
setProfession,
setUrl1,
setUrl2,
setDisabled,
} = useAnalyseText();
const getSentimentTone = (score: number) => {
if (score >= 80) return "strong";
if (score >= 60) return "light";
return "neutral";
};
return (
Analisis Sentimen Real-time
{result && (
{/* ================= HEADER WINNER ================= */}
Rekomendasi Terbaik
{result.winning_product}
Pilihan paling tepat untuk{" "}
{result.profession_target}
{/* ================= CARDS GRID ================= */}
{result.details.map((item, index) => {
const isWinner = item.name === result.winning_product;
const getSentimentTone = (score: number) => {
if (score >= 80) return "strong";
if (score >= 60) return "light";
return "neutral";
};
const sentimentTone = getSentimentTone(
item.general_sentiment_score,
);
return (
{/* WINNER BADGE */}
{isWinner && (
Top Choice
)}
{/* PRODUCT NAME */}
{/* COMPATIBILITY SCORE */}
Kecocokan Profesi
{item.profession_compatibility_score}%
{/* SENTIMENT SCORE */}
Sentimen Publik
{item.general_sentiment_score}% Positif
{/* KEYWORDS */}
Kata Kunci Dominan
{item.top_keywords.map((kw, i) => (
#{kw}
))}
);
})}
)}
);
}