From d4aca493028c81dd26e01e98b99d1731ce4cbdd7 Mon Sep 17 00:00:00 2001 From: Michael Fatemi Date: Sat, 3 Jul 2021 01:07:02 -0400 Subject: [PATCH] add screen for logged out users --- src/components/App.tsx | 33 +++++--------------------- src/components/UILink.tsx | 8 +++++++ src/components/WheelShareLoggedOut.tsx | 28 ++++++++++++++++++++++ 3 files changed, 42 insertions(+), 27 deletions(-) create mode 100644 src/components/WheelShareLoggedOut.tsx diff --git a/src/components/App.tsx b/src/components/App.tsx index e46c25b..17c069f 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -1,44 +1,23 @@ import { lazy, Suspense, useContext } from 'react'; import { BrowserRouter, Route, Switch } from 'react-router-dom'; import AuthenticationContext from './Authentication/AuthenticationContext'; -import logout from './Authentication/logout'; -import UIButton from './UIButton'; import WheelShare from './WheelShare'; +import WheelShareLoggedOut from './WheelShareLoggedOut'; const Authenticator = lazy(() => import('./Authentication/Authenticator')); const Group = lazy(() => import('./Group')); -const dev = true; -const ION_AUTHORIZATION_ENDPOINT = dev - ? 'https://ion.tjhsst.edu/oauth/authorize?response_type=code&client_id=rNa6n9YSg8ftINdyVPpUsaMuxNbHLo9dh1OsOktR&scope=read&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fauth%2Fion%2Fcallback' - : 'https://ion.tjhsst.edu/oauth/authorize?response_type=code&client_id=rNa6n9YSg8ftINdyVPpUsaMuxNbHLo9dh1OsOktR&scope=read&redirect_uri=https%3A%2F%2Fwheelshare.space%2Fauth%2Fion%2Fcallback'; - export default function App() { const { user } = useContext(AuthenticationContext); return (
- {user ? ( -
- {user.name}{' '} - - Log out - -
- ) : ( - Log in - )} - + diff --git a/src/components/UILink.tsx b/src/components/UILink.tsx index 324b36f..7022ff3 100644 --- a/src/components/UILink.tsx +++ b/src/components/UILink.tsx @@ -21,6 +21,14 @@ export default function UILink({ [style] ); + if (href.startsWith('http://') || href.startsWith('https://')) { + return ( + + {children} + + ); + } + return ( {children} diff --git a/src/components/WheelShareLoggedOut.tsx b/src/components/WheelShareLoggedOut.tsx new file mode 100644 index 0000000..b910e15 --- /dev/null +++ b/src/components/WheelShareLoggedOut.tsx @@ -0,0 +1,28 @@ +import { CSSProperties } from 'react'; +import UILink from './UILink'; +import UIPrimaryTitle from './UIPrimaryTitle'; + +const dev = true; +const ION_AUTHORIZATION_ENDPOINT = dev + ? 'https://ion.tjhsst.edu/oauth/authorize?response_type=code&client_id=rNa6n9YSg8ftINdyVPpUsaMuxNbHLo9dh1OsOktR&scope=read&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fauth%2Fion%2Fcallback' + : 'https://ion.tjhsst.edu/oauth/authorize?response_type=code&client_id=rNa6n9YSg8ftINdyVPpUsaMuxNbHLo9dh1OsOktR&scope=read&redirect_uri=https%3A%2F%2Fwheelshare.space%2Fauth%2Fion%2Fcallback'; + +const style: CSSProperties = { + display: 'flex', + flexDirection: 'column', + alignItems: 'center', + width: '30rem', + maxWidth: '30rem', + marginLeft: 'auto', + marginRight: 'auto', +}; + +export default function WheelShareLoggedOut() { + return ( +
+ WheelShare +

To get started, log in with your Ion account.

+ Log in +
+ ); +}