diff --git a/src/components/Filter/SelectChangeServer.tsx b/src/components/Filter/SelectChangeServer.tsx index 86aef91..d983dd6 100644 --- a/src/components/Filter/SelectChangeServer.tsx +++ b/src/components/Filter/SelectChangeServer.tsx @@ -10,33 +10,36 @@ interface Props { const SelectChangeServer = ({ myServer, func }: Props) => { const listServer = useSelector((state: AppState) => state.server.listServer); - return ( -
-
- + if (listServer.length > 0) + return ( + +
+ - -
- - ); + +
+ + ); + + return; }; export default SelectChangeServer; diff --git a/src/components/Popup/PriorityServerPopup.tsx b/src/components/Popup/PriorityServerPopup.tsx index 5c21c04..a121054 100644 --- a/src/components/Popup/PriorityServerPopup.tsx +++ b/src/components/Popup/PriorityServerPopup.tsx @@ -45,8 +45,10 @@ const PriorityServerPopup = ({ close }: Props) => { }; const handleSaveNewPriority = () => { - dispatch(changeServerIndex(stores)); - toast.success("Đã cập nhật độ ưu tiên nguồn truyện"); + if (stores.length > 0) { + dispatch(changeServerIndex(stores)); + toast.success("Đã cập nhật độ ưu tiên nguồn truyện"); + } close(); }; diff --git a/src/pages/AuthorPage.tsx b/src/pages/AuthorPage.tsx index 4333337..3472236 100644 --- a/src/pages/AuthorPage.tsx +++ b/src/pages/AuthorPage.tsx @@ -49,7 +49,7 @@ const AuthorPage = () => { useEffect(() => { if (isError) { - if (indexServer == listServer.length - 1) + if (listServer.length <= 0 || indexServer == listServer.length - 1) navigate("/notfound", { replace: true, }); diff --git a/src/pages/FilterPage.tsx b/src/pages/FilterPage.tsx index a766155..aa6a61b 100644 --- a/src/pages/FilterPage.tsx +++ b/src/pages/FilterPage.tsx @@ -2,7 +2,7 @@ import { useSearchParams } from "react-router-dom"; import Slider from "../components/Slider"; import BoxNovelAuthor from "../components/Novel/BoxNovelAuthor"; -import { useState } from "react"; +import { useEffect, useState } from "react"; import { useQuery } from "@tanstack/react-query"; import { IResponse } from "../types/response"; import { INovelRoot } from "../types/novel"; @@ -41,6 +41,10 @@ const FilterPage = () => { retry: 1, }); + useEffect(() => { + changeServerByHand(server); + }, [server]); + function changeServerByHand(srv: string) { setMyServer(srv); setCurrentPage(1); diff --git a/src/pages/NovelChapter.tsx b/src/pages/NovelChapter.tsx index cf2afda..27e4b62 100644 --- a/src/pages/NovelChapter.tsx +++ b/src/pages/NovelChapter.tsx @@ -132,7 +132,7 @@ const NovelChapter = () => { useEffect(() => { if (isError) { - if (indexServer == listServer.length - 1) + if (listServer.length <= 0 || indexServer == listServer.length - 1) navigate("/notfound", { replace: true, }); diff --git a/src/pages/NovelPreview.tsx b/src/pages/NovelPreview.tsx index c000975..beaad74 100644 --- a/src/pages/NovelPreview.tsx +++ b/src/pages/NovelPreview.tsx @@ -35,7 +35,7 @@ const NovelPreview = () => { useEffect(() => { if (isError) { - if (indexServer == listServer.length - 1) + if (listServer.length <= 0 || indexServer == listServer.length - 1) navigate("/notfound", { replace: true, });