From cd6f55a9c99a05eed4edbf76857a8b2ce218af19 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Tue, 27 Aug 2024 12:54:44 -0700 Subject: [PATCH] Conditionally render some components based on admin status --- Client/src/App.jsx | 10 +++- Client/src/Components/Fallback/index.jsx | 19 +++--- Client/src/HOC/withAdminProp.jsx | 20 +++++++ Client/src/Pages/Monitors/Details/index.jsx | 53 +++++++++-------- Client/src/Pages/Monitors/index.jsx | 65 ++++++++++++--------- Client/src/Pages/PageSpeed/index.jsx | 6 +- 6 files changed, 110 insertions(+), 63 deletions(-) create mode 100644 Client/src/HOC/withAdminProp.jsx diff --git a/Client/src/App.jsx b/Client/src/App.jsx index 12db9dab9..f8a2f72f5 100644 --- a/Client/src/App.jsx +++ b/Client/src/App.jsx @@ -21,6 +21,7 @@ import ProtectedRoute from "./Components/ProtectedRoute"; import Details from "./Pages/Monitors/Details"; import Maintenance from "./Pages/Maintenance"; import withAdminCheck from "./HOC/withAdminCheck"; +import withAdminProp from "./HOC/withAdminProp"; import Configure from "./Pages/Monitors/Configure"; import PageSpeed from "./Pages/PageSpeed"; import CreatePageSpeed from "./Pages/PageSpeed/CreatePageSpeed"; @@ -30,6 +31,9 @@ import PageSpeedConfigure from "./Pages/PageSpeed/Configure"; function App() { const AdminCheckedRegister = withAdminCheck(Register); + const MonitorsWithAdminProp = withAdminProp(Monitors); + const DetailsWithAdminProp = withAdminProp(Details); + return ( <> @@ -37,11 +41,11 @@ function App() { } + element={} /> } + element={} /> } + element={} /> { +const Fallback = ({ title, checks, link = "/", isAdmin }) => { const theme = useTheme(); const navigate = useNavigate(); @@ -36,7 +36,7 @@ const Fallback = ({ title, checks, link = "/" }) => { /> - A {title} is used to: + A {title} monitor is used to: {checks.map((check, index) => ( { /> ))} -