mirror of
https://github.com/Radiquum/AniX.git
synced 2025-04-30 18:09:40 +05:00
fix: opening auth only pages, without auth
now they are redirecting to the login page in that case
This commit is contained in:
parent
9e65838569
commit
d28011b4fb
6 changed files with 64 additions and 26 deletions
|
@ -7,6 +7,7 @@ import { useScrollPosition } from "#/hooks/useScrollPosition";
|
|||
import { useUserStore } from "../store/auth";
|
||||
import { ENDPOINTS } from "#/api/config";
|
||||
import { Button } from "flowbite-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
const fetcher = async (url: string) => {
|
||||
const res = await fetch(url);
|
||||
|
@ -24,7 +25,9 @@ const fetcher = async (url: string) => {
|
|||
|
||||
export function HistoryPage() {
|
||||
const token = useUserStore((state) => state.token);
|
||||
const authState = useUserStore((state) => state.state);
|
||||
const [isLoadingEnd, setIsLoadingEnd] = useState(false);
|
||||
const router = useRouter();
|
||||
|
||||
const getKey = (pageIndex: number, previousPageData: any) => {
|
||||
if (previousPageData && !previousPageData.content.length) return null;
|
||||
|
@ -58,6 +61,12 @@ export function HistoryPage() {
|
|||
}
|
||||
}, [scrollPosition]);
|
||||
|
||||
useEffect(() => {
|
||||
if (authState === "finished" && !token) {
|
||||
router.push("/login");
|
||||
}
|
||||
}, [authState, token]);
|
||||
|
||||
return (
|
||||
<main className="container pt-2 pb-16 mx-auto sm:pt-4 sm:pb-4">
|
||||
{content && content.length > 0 ? (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue