From fd94d4a5998164e8e1f00b4166dc9a047782553e Mon Sep 17 00:00:00 2001 From: Mahen Date: Fri, 13 Feb 2026 10:37:00 +0700 Subject: [PATCH] chore: adjust select item mapping method --- src/components/dashboards/AnalysisClient.tsx | 31 ++++++-------------- src/hooks/useAnalyzeText.ts | 7 +++-- src/utils/datas.ts | 7 +++++ 3 files changed, 21 insertions(+), 24 deletions(-) diff --git a/src/components/dashboards/AnalysisClient.tsx b/src/components/dashboards/AnalysisClient.tsx index 0db9408..ae78771 100644 --- a/src/components/dashboards/AnalysisClient.tsx +++ b/src/components/dashboards/AnalysisClient.tsx @@ -1,7 +1,7 @@ "use client"; import { useAnalyseText } from "@/src/hooks/useAnalyzeText"; -import { Sparkles, Trophy } from "lucide-react"; +import { Sparkles } from "lucide-react"; import { Select, SelectContent, @@ -11,9 +11,8 @@ import { } from "../ui/select"; import { Input } from "../ui/input"; import { Button } from "../ui/button"; -import { motion } from "framer-motion"; -import { useState } from "react"; import ResultSection from "./ResultSection"; +import { professions } from "@/src/utils/datas"; export default function AnalysisClient() { const { @@ -24,20 +23,15 @@ export default function AnalysisClient() { loading, result, disabled, + showField, handleAnalyze, setProfession, setUrl1, setUrl2, setDisabled, setUrl3, + setShowField, } = useAnalyseText(); - const [showField, setShowField] = useState(false); - - const getSentimentTone = (score: number) => { - if (score >= 80) return "strong"; - if (score >= 60) return "light"; - return "neutral"; - }; return (
@@ -62,18 +56,11 @@ export default function AnalysisClient() { className="bg-card border-border shadow-lg" position="popper" > - - Programmer - - - Designer - - - Student - - - Gamer - + {professions.map((item) => ( + + {item.label} + + ))}
diff --git a/src/hooks/useAnalyzeText.ts b/src/hooks/useAnalyzeText.ts index 9cf6cfa..fb63726 100644 --- a/src/hooks/useAnalyzeText.ts +++ b/src/hooks/useAnalyzeText.ts @@ -9,6 +9,7 @@ export const useAnalyseText = () => { const [loading, setLoading] = useState(false); const [result, setResult] = useState(null); const [disabled, setDisabled] = useState(false); + const [showField, setShowField] = useState(false); const handleAnalyze = async () => { setLoading(true); @@ -21,7 +22,7 @@ export const useAnalyseText = () => { if (urlsToScrape.length < 2) { alert("Produk Utama dan minimal 1 Produk Pembanding wajib diisi!"); - setLoading(false); + setLoading(false); return; } @@ -29,7 +30,7 @@ export const useAnalyseText = () => { fetch("/api/scrape", { method: "POST", headers: { - "Content-Type": "application/json", + "Content-Type": "application/json", }, body: JSON.stringify({ url: u }), }).then((res) => { @@ -81,11 +82,13 @@ export const useAnalyseText = () => { loading, result, disabled, + showField, handleAnalyze, setProfession, setUrl1, setUrl2, setUrl3, setDisabled, + setShowField, }; }; diff --git a/src/utils/datas.ts b/src/utils/datas.ts index 1d80c81..817ef9d 100644 --- a/src/utils/datas.ts +++ b/src/utils/datas.ts @@ -90,3 +90,10 @@ export function getFallbackData(url: string): ScrapeResult { ], }; } + +export const professions = [ + { value: "programmer", label: "Programmer" }, + { value: "designer", label: "Designer" }, + { value: "student", label: "Student" }, + { value: "gamer", label: "Gamer" }, +];