Skip to content

Commit 57e5352

Browse files
Merge pull request deriv-com#18 from mayuran-deriv/mayuran/is-log-function-updatre
fix: function update
2 parents 2d4b93c + 758810a commit 57e5352

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/common/utils/index.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { authStore } from "../../stores/AuthStore";
2+
13
/**
24
* Check if code is running in a browser environment
35
* @returns {boolean} True if running in browser, false otherwise
@@ -21,8 +23,7 @@ export const getChartUrl = (): string => {
2123
};
2224

2325
export const isLogged = (): boolean => {
24-
const token = localStorage.getItem("auth_token");
25-
return !!token;
26+
return authStore.isAuthenticated;
2627
};
2728

2829
export const getUrlBase = (path: string = ""): string => {

src/pages/homepage/index.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import React from "react";
22
import { Button, Heading } from "@deriv-com/quill-ui";
3+
import { useNavigate } from "react-router-dom";
34
import { authStore } from "../../stores/AuthStore";
45
import { isLogged } from "../../common/utils";
56
import "./homepage.scss";
67

78
const Homepage: React.FC = () => {
9+
const navigate = useNavigate();
810
return (
911
<div className="homepage">
1012
<div className="homepage__content">
@@ -19,7 +21,7 @@ const Homepage: React.FC = () => {
1921
<Button
2022
onClick={() => {
2123
if (isLogged()) {
22-
window.location.href = "/dashboard";
24+
navigate("/dashboard");
2325
} else {
2426
authStore.login();
2527
}

0 commit comments

Comments
 (0)