From 8b7a286a9c621e0cb33371425e43d4b0c2e6166a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Geonizeli?= Date: Thu, 2 Sep 2021 14:57:23 -0300 Subject: [PATCH] hide pages from unauthenticated users --- app/javascript/src/Routes.tsx | 37 +++++++++++-------- .../src/components/Navbar/Navbar.tsx | 9 +++-- .../src/components/SideNav/SideNav.tsx | 4 ++ .../Home/StakeOrderModal/StakeOrderModal.tsx | 12 ++++-- 4 files changed, 41 insertions(+), 21 deletions(-) diff --git a/app/javascript/src/Routes.tsx b/app/javascript/src/Routes.tsx index 9ca3819..db22c21 100644 --- a/app/javascript/src/Routes.tsx +++ b/app/javascript/src/Routes.tsx @@ -2,29 +2,36 @@ import type { FC } from "react"; import React from "react"; import { Switch, Route } from "react-router-dom"; +import { useCurrentUser } from "./contexts/UserProvider"; import { Dashbaord, Home, Orders, Wallet } from "./pages"; export const Routes: FC = () => { + const { isAuthenticated } = useCurrentUser(); + return ( - - - - - - - - - - - - - - - + {isAuthenticated && ( + <> + + + + + + + + + + + + + + + + + )} ); }; diff --git a/app/javascript/src/components/Navbar/Navbar.tsx b/app/javascript/src/components/Navbar/Navbar.tsx index 16f8f1e..fde8013 100644 --- a/app/javascript/src/components/Navbar/Navbar.tsx +++ b/app/javascript/src/components/Navbar/Navbar.tsx @@ -1,5 +1,6 @@ import * as React from "react"; import { MenuIcon } from "@heroicons/react/outline"; +import cs from "classnames"; import XStakeLogo from "../../assets/images/logo.png"; import { useApp } from "../../contexts/AppProvider"; @@ -9,13 +10,12 @@ const linkStyles = "cursor-pointer bg-transparent hover:bg-gray-100 h-full px-4 font-bold flex items-center"; export const Navbar = () => { + const { isAuthenticated } = useCurrentUser(); const { setSideNavExpanded } = useApp(); const handleExpandSideNav = () => { setSideNavExpanded((prevState) => !prevState); }; - const { isAuthenticated } = useCurrentUser(); - const csrfToken = document .querySelector('meta[name="csrf-token"]') @@ -24,7 +24,10 @@ export const Navbar = () => { return (