From d228597d0e3bb86c6b44d82775ad7a977b16ad22 Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Sun, 20 Nov 2022 18:40:25 +0200 Subject: [PATCH] bs --- src/components/UserControls.js | 5 +++-- src/index.js | 2 +- src/pages/Admin.js | 11 +++++++++++ src/pages/Users.js | 11 +++++++++++ src/structures/UnauthedRoute.js | 9 +++++++++ 5 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 src/pages/Admin.js create mode 100644 src/pages/Users.js create mode 100644 src/structures/UnauthedRoute.js diff --git a/src/components/UserControls.js b/src/components/UserControls.js index c39b62c..22a8741 100644 --- a/src/components/UserControls.js +++ b/src/components/UserControls.js @@ -5,12 +5,13 @@ import { useLoginContext } from "../structures/UserContext"; const UserControls = () => { const [user] = useLoginContext(); - console.log(user); if (!user) return; return
- Hello {user.displayName} +
+ Hello {user.displayName} +
; }; diff --git a/src/index.js b/src/index.js index df85416..705503b 100644 --- a/src/index.js +++ b/src/index.js @@ -15,4 +15,4 @@ root.render( // If you want to start measuring performance in your app, pass a function // to log results (for example: reportWebVitals(console.log)) // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals -reportWebVitals(console.log); +// reportWebVitals(console.log); diff --git a/src/pages/Admin.js b/src/pages/Admin.js new file mode 100644 index 0000000..fe95ee7 --- /dev/null +++ b/src/pages/Admin.js @@ -0,0 +1,11 @@ +import React from "react"; + +const Admin = () => { + + return
+ ADMIN +
; + +}; + +export default Admin; \ No newline at end of file diff --git a/src/pages/Users.js b/src/pages/Users.js new file mode 100644 index 0000000..6c624d8 --- /dev/null +++ b/src/pages/Users.js @@ -0,0 +1,11 @@ +import React from "react"; + +const Users = () => { + + return
+ USERS +
; + +}; + +export default Users; \ No newline at end of file diff --git a/src/structures/UnauthedRoute.js b/src/structures/UnauthedRoute.js new file mode 100644 index 0000000..53a05c3 --- /dev/null +++ b/src/structures/UnauthedRoute.js @@ -0,0 +1,9 @@ +import React from 'react'; +import { Navigate } from "react-router-dom"; +import { getUser } from "../util/Util"; + +export const UnauthedRoute = ({ children }) => { + const user = getUser(); + if (user) return ; + return children; +}; \ No newline at end of file