From c8b92ce4d5ba9e964313658650f45a46b942b990 Mon Sep 17 00:00:00 2001 From: dhrubesh-makeen Date: Sun, 25 Apr 2021 17:44:07 +0530 Subject: [PATCH] removes hardcoding--2 --- frontend/src/constants/auth.ts | 1 + frontend/src/modules/AppWrapper.tsx | 3 ++- frontend/src/modules/Auth/Signup.tsx | 5 ++--- 3 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 frontend/src/constants/auth.ts diff --git a/frontend/src/constants/auth.ts b/frontend/src/constants/auth.ts new file mode 100644 index 0000000000..c4b137b23e --- /dev/null +++ b/frontend/src/constants/auth.ts @@ -0,0 +1 @@ +export const IS_LOGGED_IN = "isLoggedIn"; \ No newline at end of file diff --git a/frontend/src/modules/AppWrapper.tsx b/frontend/src/modules/AppWrapper.tsx index 8a8bf2283f..716345594b 100644 --- a/frontend/src/modules/AppWrapper.tsx +++ b/frontend/src/modules/AppWrapper.tsx @@ -2,6 +2,7 @@ import React, { Suspense } from "react"; import { Layout, Spin } from "antd"; import { useThemeSwitcher } from "react-css-theme-switcher"; import ROUTES from "Src/constants/routes"; +import { IS_LOGGED_IN } from "Src/constants/auth"; import { BrowserRouter as Router, Route, @@ -58,7 +59,7 @@ const App = () => { path="/" exact render={() => { - return localStorage.getItem("isLoggedIn") === "yes" ? ( + return localStorage.getItem(IS_LOGGED_IN) === "yes" ? ( ) : ( diff --git a/frontend/src/modules/Auth/Signup.tsx b/frontend/src/modules/Auth/Signup.tsx index 4aeaa0db79..3557b0a1b6 100644 --- a/frontend/src/modules/Auth/Signup.tsx +++ b/frontend/src/modules/Auth/Signup.tsx @@ -2,6 +2,7 @@ import React, { useState } from "react"; import { Row, Space, Button, Input } from "antd"; import api, { apiV1 } from "../../api"; import ROUTES from "Src/constants/routes"; +import { IS_LOGGED_IN } from "Src/constants/auth"; import { withRouter } from "react-router"; import { RouteComponentProps } from "react-router-dom"; @@ -36,8 +37,6 @@ const Signup = (props: SignUpProps) => { const handleSubmit = (e: any) => { e.preventDefault(); - console.log("in handle submit"); - setState({ ...state, submitted: true }); const payload = { @@ -52,7 +51,7 @@ const Signup = (props: SignUpProps) => { console.log(res.data); }); - localStorage.setItem("isLoggedIn", "yes"); + localStorage.setItem(IS_LOGGED_IN, "yes"); props.history.push(ROUTES.APPLICATION); };