Skip to content

Commit

Permalink
chore: load source all page, toast message in mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
nxhawk committed Jun 7, 2024
1 parent f75b491 commit bda98a8
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 48 deletions.
7 changes: 5 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ import { ThemeContext } from "./contexts/ThemeContext";
import { THEME } from "./types/theme";
import { useSelector } from "react-redux";
import { AppState } from "./store";
import useMediaQuery from "@mui/material/useMediaQuery";
import "react-toastify/dist/ReactToastify.css";
import "react-loading-skeleton/dist/skeleton.css";

function App() {
const position = useMediaQuery("(max-width:500px)") ? "top-center" : "top-right";
console.log(position);
const isOpen = useSelector((state: AppState) => state.chapterOpen.isOpen);

const { theme } = useContext(ThemeContext)!;
Expand All @@ -34,7 +37,7 @@ function App() {
)}

<ToastContainer
position="top-right"
position={position}
autoClose={2000}
hideProgressBar={false}
newestOnTop={false}
Expand All @@ -43,7 +46,7 @@ function App() {
pauseOnHover
theme={theme}
pauseOnFocusLoss={false}
className="w-fit hidden md:block"
className="w-fit"
limit={5}
/>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Loading/LoadingSpinner.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const LoadingSpinner = () => {
return (
<div className="flex items-center justify-center w-full h-[50vh] text-gray-900 dark:text-gray-100 dark:bg-gray-950">
<div className="flex items-center justify-center w-full h-screen text-gray-900 dark:text-gray-100 dark:bg-gray-950">
<div>
<h1 className="text-xl md:text-6xl font-bold flex items-center">
L
Expand Down
2 changes: 1 addition & 1 deletion src/components/Popup/PriorityServerPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const PriorityServerPopup = ({ close }: Props) => {
</Droppable>
</div>
</DragDropContext>
<i className="md:text-base w-full flex flex-wrap font-semibold text-rose-500 items-center justify-center text-sm gap-1">
<i className="md:text-base w-full flex flex-wrap font-semibold text-sky-500 items-center justify-center text-sm gap-1">
<FaInfoCircle />
Kéo thả để thay đổi độ ưu tiên
</i>
Expand Down
14 changes: 6 additions & 8 deletions src/routers/CheckNewServer.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { useDispatch } from "react-redux";
import { Outlet, useNavigate } from "react-router-dom";
import { Outlet, useLocation } from "react-router-dom";
import { AppDispatch } from "../store";
import { useQuery } from "@tanstack/react-query";
import { ApiGetAllServer } from "../api/apiPlugin";
import { updateListServer } from "../store/server";
import LoadingSpinner from "../components/Loading/LoadingSpinner";
import { toast } from "react-toastify";

const CheckNewServer = () => {
const dispatch = useDispatch<AppDispatch>();
const navigate = useNavigate();
const location = useLocation();

const { isLoading, isError } = useQuery({
queryKey: ["server"],
queryKey: ["server", location.pathname],
queryFn: async () => {
const data: string[] = await ApiGetAllServer();

Expand All @@ -21,14 +22,11 @@ const CheckNewServer = () => {

return data;
},
retry: 1,
retry: 0,
});

if (isLoading) return <LoadingSpinner />;
if (isError)
navigate("/notfound", {
replace: true,
});
if (isError) toast.error("Không thể tải nguồn truyền");

return <Outlet />;
};
Expand Down
72 changes: 36 additions & 36 deletions src/routers/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,60 +19,60 @@ const router = createHashRouter([
element: <ScrollToTop />,
children: [
{
element: <Layout />,
element: <CheckNewServer />,
children: [
{
path: "/",
element: <Home />,
},
{
path: "/tu-truyen",
element: <Bookcase />,
},
{
path: "/truyen/:novelId",
element: <Layout />,
children: [
{
path: "",
element: <NovelPreview />,
path: "/",
element: <Home />,
},
{
element: <CheckNewServer />,
path: "/tu-truyen",
element: <Bookcase />,
},
{
path: "/truyen/:novelId",
children: [
{
path: "",
element: <NovelPreview />,
},
{
path: ":chapterId",
element: <NovelChapter />,
},
],
},
],
},
{
path: "/tac-gia/:authorId",
element: <AuthorPage />,
},
{
path: "/tim-kiem",
element: <FilterPage />,
},
{
path: "/thong-tin",
children: [
{
path: "dieu-khoan-dich-vu",
element: <TermOfService />,
},
{
path: "chinh-sach-bao-mat",
element: <PrivacyPolicy />,
path: "/tac-gia/:authorId",
element: <AuthorPage />,
},
{
path: "ve-ban-quyen",
element: <AboutLicense />,
path: "/tim-kiem",
element: <FilterPage />,
},
{
path: "nhom-phat-trien",
element: <AboutUs />,
path: "/thong-tin",
children: [
{
path: "dieu-khoan-dich-vu",
element: <TermOfService />,
},
{
path: "chinh-sach-bao-mat",
element: <PrivacyPolicy />,
},
{
path: "ve-ban-quyen",
element: <AboutLicense />,
},
{
path: "nhom-phat-trien",
element: <AboutUs />,
},
],
},
],
},
Expand Down

0 comments on commit bda98a8

Please sign in to comment.