From e6251367be52d7a872dde5421594ca317025e66c Mon Sep 17 00:00:00 2001 From: Tim Pechersky Date: Mon, 6 Dec 2021 17:46:03 +0000 Subject: [PATCH] unauthorized check --- frontend/pages/status/index.js | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/frontend/pages/status/index.js b/frontend/pages/status/index.js index d2955f9b..8f9765a8 100644 --- a/frontend/pages/status/index.js +++ b/frontend/pages/status/index.js @@ -1,11 +1,14 @@ -import React from "react"; +import React, { useContext } from "react"; import { useStatus } from "../../src/core/hooks"; import { Heading, Text, Flex, Spacer, chakra, Spinner } from "@chakra-ui/react"; import { getLayout, getLayoutProps } from "../../src/layouts/InfoPageLayout"; +import UserContext from "../../src/core/providers/UserProvider/context"; const Status = () => { + const user = useContext(UserContext); const healthyStatusText = "Available"; const downStatusText = "Unavailable"; + const unauthorizedText = "Please login"; const healthyStatusColor = "green.900"; const downStatusColor = "red.600"; @@ -106,11 +109,13 @@ const Status = () => { - {crawlersStatusCache?.data?.ethereum_txpool_timestamp - ? shortTimestamp( - crawlersStatusCache?.data?.ethereum_txpool_timestamp - ) - : downStatusText} + {!user + ? crawlersStatusCache?.data?.ethereum_txpool_timestamp + ? shortTimestamp( + crawlersStatusCache?.data?.ethereum_txpool_timestamp + ) + : downStatusText + : unauthorizedText} { cache={crawlersStatusCache} > - {crawlersStatusCache?.data?.ethereum_trending_timestamp - ? shortTimestamp( - crawlersStatusCache?.data?.ethereum_trending_timestamp - ) - : downStatusText} + {!user + ? crawlersStatusCache?.data?.ethereum_trending_timestamp + ? shortTimestamp( + crawlersStatusCache?.data?.ethereum_trending_timestamp + ) + : downStatusText + : unauthorizedText}