diff --git a/src/App.tsx b/src/App.tsx
index a53698a..c187f08 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -1,26 +1,20 @@
import React from 'react';
-import logo from './logo.svg';
+import { BrowserRouter, Routes, Route } from 'react-router-dom';
+import { Auth } from './components/auth';
+import { Login } from './components/login';
import './App.css';
+import { Overview } from './components/overview';
-function App() {
- return (
-
- );
-}
+const App: React.FC = () => (
+ <>
+
+
+ } />
+ } />
+ } />
+
+
+ >
+);
export default App;
diff --git a/src/components/auth.tsx b/src/components/auth.tsx
new file mode 100644
index 0000000..dcc56ea
--- /dev/null
+++ b/src/components/auth.tsx
@@ -0,0 +1,18 @@
+import React from 'react';
+import { useSearchParams } from 'react-router-dom';
+
+export const Auth: React.FC = () => {
+ const [searchParams] = useSearchParams();
+ const token = searchParams.get('token');
+
+ const baseUrl = `${window.location.protocol}//${window.location.host}`
+ if (token) {
+ sessionStorage.setItem('token', token);
+ window.location.href = `${baseUrl}/overview`;
+ } else {
+ sessionStorage.removeItem('token');
+ window.location.href = `${baseUrl}`;
+ }
+
+ return <>>;
+};
diff --git a/src/components/configuration.ts b/src/components/configuration.ts
new file mode 100644
index 0000000..3676840
--- /dev/null
+++ b/src/components/configuration.ts
@@ -0,0 +1,7 @@
+export const Configuration = {
+ resourceServer: process.env.RESOURCE_SERVER || 'http://localhost:3000',
+ vatsim: {
+ authorizeUrl: process.env.VATSIM_AUTH_URL || 'https://auth-dev.vatsim.net/oauth/authorize',
+ clientId: process.env.VATSIM_CLIENT_ID || '461',
+ },
+};
diff --git a/src/components/login.tsx b/src/components/login.tsx
new file mode 100644
index 0000000..4341eb3
--- /dev/null
+++ b/src/components/login.tsx
@@ -0,0 +1,42 @@
+import React, { useEffect } from 'react';
+import { Button } from 'primereact/button';
+import { Card } from 'primereact/card';
+import { Configuration } from './configuration';
+
+export const Login: React.FC = () => {
+ // reset every old token
+ useEffect(() => sessionStorage.removeItem('token'), []);
+
+ const redirectToVatsim = () => {
+ const url = [
+ Configuration.vatsim.authorizeUrl,
+ `?client_id=${Configuration.vatsim.clientId}`,
+ `&redirect_uri=http://localhost:3000/auth/vatsim`,
+ `&response_type=code`,
+ `&scope=full_name+vatsim_details`,
+ `&approval_prompt=auto`,
+ ].join('');
+ window.location.replace(url);
+ }
+
+ const footer = (
+
+
+
+ );
+
+ return (
+ <>
+
+
+ >
+ );
+};
diff --git a/src/components/overview.tsx b/src/components/overview.tsx
new file mode 100644
index 0000000..c7396c0
--- /dev/null
+++ b/src/components/overview.tsx
@@ -0,0 +1,14 @@
+import React, { useState } from 'react';
+import axios from 'axios';
+
+export const Overview: React.FC = () => {
+ const [msg, setMsg] = useState('LOADING');
+
+ axios.get('http://localhost:3000/auth/user', {
+ headers: {
+ Authorization: `Bearer ${sessionStorage.getItem('token')}`,
+ },
+ }).then((data) => setMsg(data.data)).catch(() => setMsg('FAILED'));
+
+ return <>OVERVIEW {msg}>;
+};