chore: adjust select item mapping method
This commit is contained in:
parent
9762069aa4
commit
fd94d4a599
|
|
@ -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 (
|
||||
<div className="w-full mx-auto">
|
||||
|
|
@ -62,18 +56,11 @@ export default function AnalysisClient() {
|
|||
className="bg-card border-border shadow-lg"
|
||||
position="popper"
|
||||
>
|
||||
<SelectItem className="cursor-pointer" value="programmer">
|
||||
Programmer
|
||||
</SelectItem>
|
||||
<SelectItem className="cursor-pointer" value="designer">
|
||||
Designer
|
||||
</SelectItem>
|
||||
<SelectItem className="cursor-pointer" value="student">
|
||||
Student
|
||||
</SelectItem>
|
||||
<SelectItem className="cursor-pointer" value="gamer">
|
||||
Gamer
|
||||
</SelectItem>
|
||||
{professions.map((item) => (
|
||||
<SelectItem key={item.value} value={item.value}>
|
||||
{item.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ export const useAnalyseText = () => {
|
|||
const [loading, setLoading] = useState(false);
|
||||
const [result, setResult] = useState<AnalysisResults | null>(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,
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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" },
|
||||
];
|
||||
|
|
|
|||
Loading…
Reference in New Issue