chore: adjust select item mapping method
This commit is contained in:
parent
9762069aa4
commit
fd94d4a599
|
|
@ -1,7 +1,7 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useAnalyseText } from "@/src/hooks/useAnalyzeText";
|
import { useAnalyseText } from "@/src/hooks/useAnalyzeText";
|
||||||
import { Sparkles, Trophy } from "lucide-react";
|
import { Sparkles } from "lucide-react";
|
||||||
import {
|
import {
|
||||||
Select,
|
Select,
|
||||||
SelectContent,
|
SelectContent,
|
||||||
|
|
@ -11,9 +11,8 @@ import {
|
||||||
} from "../ui/select";
|
} from "../ui/select";
|
||||||
import { Input } from "../ui/input";
|
import { Input } from "../ui/input";
|
||||||
import { Button } from "../ui/button";
|
import { Button } from "../ui/button";
|
||||||
import { motion } from "framer-motion";
|
|
||||||
import { useState } from "react";
|
|
||||||
import ResultSection from "./ResultSection";
|
import ResultSection from "./ResultSection";
|
||||||
|
import { professions } from "@/src/utils/datas";
|
||||||
|
|
||||||
export default function AnalysisClient() {
|
export default function AnalysisClient() {
|
||||||
const {
|
const {
|
||||||
|
|
@ -24,20 +23,15 @@ export default function AnalysisClient() {
|
||||||
loading,
|
loading,
|
||||||
result,
|
result,
|
||||||
disabled,
|
disabled,
|
||||||
|
showField,
|
||||||
handleAnalyze,
|
handleAnalyze,
|
||||||
setProfession,
|
setProfession,
|
||||||
setUrl1,
|
setUrl1,
|
||||||
setUrl2,
|
setUrl2,
|
||||||
setDisabled,
|
setDisabled,
|
||||||
setUrl3,
|
setUrl3,
|
||||||
|
setShowField,
|
||||||
} = useAnalyseText();
|
} = useAnalyseText();
|
||||||
const [showField, setShowField] = useState(false);
|
|
||||||
|
|
||||||
const getSentimentTone = (score: number) => {
|
|
||||||
if (score >= 80) return "strong";
|
|
||||||
if (score >= 60) return "light";
|
|
||||||
return "neutral";
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-full mx-auto">
|
<div className="w-full mx-auto">
|
||||||
|
|
@ -62,18 +56,11 @@ export default function AnalysisClient() {
|
||||||
className="bg-card border-border shadow-lg"
|
className="bg-card border-border shadow-lg"
|
||||||
position="popper"
|
position="popper"
|
||||||
>
|
>
|
||||||
<SelectItem className="cursor-pointer" value="programmer">
|
{professions.map((item) => (
|
||||||
Programmer
|
<SelectItem key={item.value} value={item.value}>
|
||||||
</SelectItem>
|
{item.label}
|
||||||
<SelectItem className="cursor-pointer" value="designer">
|
|
||||||
Designer
|
|
||||||
</SelectItem>
|
|
||||||
<SelectItem className="cursor-pointer" value="student">
|
|
||||||
Student
|
|
||||||
</SelectItem>
|
|
||||||
<SelectItem className="cursor-pointer" value="gamer">
|
|
||||||
Gamer
|
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
|
))}
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ export const useAnalyseText = () => {
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [result, setResult] = useState<AnalysisResults | null>(null);
|
const [result, setResult] = useState<AnalysisResults | null>(null);
|
||||||
const [disabled, setDisabled] = useState(false);
|
const [disabled, setDisabled] = useState(false);
|
||||||
|
const [showField, setShowField] = useState(false);
|
||||||
|
|
||||||
const handleAnalyze = async () => {
|
const handleAnalyze = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|
@ -81,11 +82,13 @@ export const useAnalyseText = () => {
|
||||||
loading,
|
loading,
|
||||||
result,
|
result,
|
||||||
disabled,
|
disabled,
|
||||||
|
showField,
|
||||||
handleAnalyze,
|
handleAnalyze,
|
||||||
setProfession,
|
setProfession,
|
||||||
setUrl1,
|
setUrl1,
|
||||||
setUrl2,
|
setUrl2,
|
||||||
setUrl3,
|
setUrl3,
|
||||||
setDisabled,
|
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