Skip to content

Commit

Permalink
unnecessary code removed
Browse files Browse the repository at this point in the history
  • Loading branch information
Md-Rubel-Ahmed-Rana committed Jul 3, 2024
1 parent 008a53a commit 39f9b68
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 42 deletions.
4 changes: 2 additions & 2 deletions frontend/src/pages/dashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const DashboardPage: NextPageWithLayout = () => {
useEffect(() => {
const handleAuth = async () => {
setLoading(true);
const isLoggedIn = await Cookies.get("tmAccessToken");
if (!isLoggedIn) {
const isLoggedIn = Cookies.get("tmAccessToken");
if (isLoggedIn === "undefined") {
setLoading(false);
return router.push("/login");
} else {
Expand Down
22 changes: 2 additions & 20 deletions frontend/src/pages/login/index.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,10 @@
import Login from "@/components/pages/login/Login";
import RootLayout from "@/layout/RootLayout";
import { NextPageWithLayout } from "pages/_app";
import React, { ReactElement, useEffect, useState } from "react";
import Cookies from "js-cookie";
import { useRouter } from "next/router";
import Loader from "@/components/shared/Loader";
import React, { ReactElement } from "react";

const LoginPage: NextPageWithLayout = () => {
const [loading, setLoading] = useState(false);
const router = useRouter();
useEffect(() => {
const handleAuth = async () => {
setLoading(true);
const isLoggedIn = Cookies.get("tmAccessToken");
if (isLoggedIn !== "undefined") {
setLoading(false);
return router.push("/dashboard");
} else {
setLoading(false);
}
};
handleAuth();
}, [router]);
return <div>{loading ? <Loader /> : <Login />}</div>;
return <Login />;
};

export default LoginPage;
Expand Down
22 changes: 2 additions & 20 deletions frontend/src/pages/signup/index.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,10 @@
import Signup from "@/components/pages/Signup/Signup";
import RootLayout from "@/layout/RootLayout";
import { NextPageWithLayout } from "pages/_app";
import React, { ReactElement, useEffect, useState } from "react";
import Cookies from "js-cookie";
import { useRouter } from "next/router";
import Loader from "@/components/shared/Loader";
import React, { ReactElement } from "react";

const SignupPage: NextPageWithLayout = () => {
const [loading, setLoading] = useState(false);
const router = useRouter();
useEffect(() => {
const handleAuth = async () => {
setLoading(true);
const isLoggedIn = Cookies.get("tmAccessToken");
if (isLoggedIn !== "undefined") {
setLoading(false);
return router.push("/dashboard");
} else {
setLoading(false);
}
};
handleAuth();
}, [router]);
return <div>{loading ? <Loader /> : <Signup />}</div>;
return <Signup />;
};

export default SignupPage;
Expand Down

0 comments on commit 39f9b68

Please sign in to comment.