From 2acdf3253e5a1fe5660fe149ae11a80949b4b049 Mon Sep 17 00:00:00 2001 From: BFlat Date: Mon, 22 Jan 2024 14:24:32 +0700 Subject: [PATCH] search page category and type works --- .../src/v2/view/pages/search/SearchPage.tsx | 96 ++++++++++++------- 1 file changed, 63 insertions(+), 33 deletions(-) diff --git a/packages/fakeyou.com/src/v2/view/pages/search/SearchPage.tsx b/packages/fakeyou.com/src/v2/view/pages/search/SearchPage.tsx index 11c2c10397..ed54752012 100644 --- a/packages/fakeyou.com/src/v2/view/pages/search/SearchPage.tsx +++ b/packages/fakeyou.com/src/v2/view/pages/search/SearchPage.tsx @@ -24,7 +24,11 @@ import Select from "components/common/Select"; export default function SearchPage() { const [foundWeights, setFoundWeights] = useState([]); const [weightType, setWeightType] = useState("all"); + const [weightCategory, setWeightCategory] = useState("all"); const [searchCompleted, setSearchCompleted] = useState(0); + const [weightTypeOpts, setWeightTypeOpts] = useState([ + { value: "all", label: "All Types" }, + ]); const bookmarks = useBookmarks(); const ratings = useRatings(); @@ -45,6 +49,10 @@ export default function SearchPage() { request["weight_type"] = weightType; } + if (weightCategory !== "all") { + request["weight_category"] = weightCategory; + } + let response = await SearchWeights(request); if (response.success) { @@ -55,7 +63,7 @@ export default function SearchPage() { setFoundWeights([]); } }, - [setFoundWeights, weightType] + [setFoundWeights, weightType, weightCategory] ); // eslint-disable-next-line react-hooks/exhaustive-deps @@ -75,24 +83,6 @@ export default function SearchPage() { } }, [urlSearchTerm, debouncedDoSearch]); - // let selectedTags: any = []; - // let handleSelectTag = () => {}; - - // const tags = ( - //
- // - //
- // ); - - // const sortOptions = [ - // { value: "most liked", label: "Most Liked" }, - // { value: "most used", label: "Most Used" }, - // { value: "moset recent", label: "Most Recent" }, - // ]; const languageOpts = [ { value: "all", label: "All Languages" }, { value: "english", label: "English" }, @@ -102,26 +92,63 @@ export default function SearchPage() { const weightCategoryOpts = [ { value: "all", label: "All Categories" }, - { value: "image_generation", label: "Image generation" }, - { value: "text_to_speech", label: "Text to speech" }, + { value: "image_generation", label: "Image Generation" }, + { value: "text_to_speech", label: "Text to Speech" }, { value: "vocoder", label: "Vocoder" }, - { value: "voice_conversion", label: "Voice conversion" }, + { value: "voice_conversion", label: "Voice Conversion" }, ]; - const weightTypeOpts = [ - { value: "all", label: "All Types" }, - { value: "hifigan_tt2", label: "HiFiGAN TT2" }, - { value: "sd_1.5", label: "SD 1.5" }, - { value: "sdxl", label: "SDXL" }, - { value: "so_vits_svc", label: "SVC" }, - { value: "rvc_v2", label: "RVC v2" }, - { value: "tt2", label: "TT2" }, - { value: "loRA", label: "LoRA" }, - ]; + const updateWeightTypeOpts = useCallback(category => { + switch (category) { + case "image_generation": + setWeightTypeOpts([ + { value: "all", label: "All Types" }, + { value: "sd_1.5", label: "SD 1.5" }, + { value: "sdxl", label: "SDXL" }, + { value: "loRA", label: "LoRA" }, + ]); + break; + case "text_to_speech": + setWeightTypeOpts([ + { value: "all", label: "All Types" }, + { value: "tt2", label: "TT2" }, + { value: "hifigan_tt2", label: "HiFiGAN TT2" }, + ]); + break; + case "voice_conversion": + setWeightTypeOpts([ + { value: "all", label: "All Types" }, + { value: "so_vits_svc", label: "SVC" }, + { value: "rvc_v2", label: "RVC v2" }, + ]); + break; + default: + setWeightTypeOpts([ + { value: "all", label: "All Types" }, + { value: "hifigan_tt2", label: "HiFiGAN TT2" }, + { value: "sd_1.5", label: "SD 1.5" }, + { value: "sdxl", label: "SDXL" }, + { value: "so_vits_svc", label: "SVC" }, + { value: "rvc_v2", label: "RVC v2" }, + { value: "tt2", label: "TT2" }, + { value: "loRA", label: "LoRA" }, + ]); + } + }, []); + + // Update weight type options when weight category changes + useEffect(() => { + updateWeightTypeOpts(weightCategory); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [weightCategory]); const weightTypeValue = weightTypeOpts.find(el => el.value === weightType) || weightTypeOpts[0]; + const weightCategoryValue = + weightCategoryOpts.find(el => el.value === weightCategory) || + weightCategoryOpts[0]; + return ( { + setWeightCategory(args.value); + }, }} />