From 9d2fcd022c5220bd9d031d1b2b4ce5decd8066af Mon Sep 17 00:00:00 2001 From: Sven Czarnian Date: Sat, 5 Nov 2022 01:42:40 +0100 Subject: [PATCH] first overview page --- src/components/overview.tsx | 97 ++++++++++++++++++++++++++++++++++++- 1 file changed, 95 insertions(+), 2 deletions(-) diff --git a/src/components/overview.tsx b/src/components/overview.tsx index 286c1b1..fe8e6dc 100644 --- a/src/components/overview.tsx +++ b/src/components/overview.tsx @@ -1,5 +1,98 @@ -import React from 'react'; +import React, { useContext, useState } from 'react'; +import { Button } from 'primereact/button'; +import { Card } from 'primereact/card'; +import { DataTable } from 'primereact/datatable'; +import { Password } from 'primereact/password'; +import { AuthContext } from '../contexts'; +import { Auth } from '../services'; +import { BackendReturnStatus } from '../types'; +import { Column } from 'primereact/column'; export const Overview: React.FC = () => { - return <>OVERVIEW; + const [statusMessage, setStatusMessage] = useState<{ error: boolean; message: string }>({ + error: false, + message: '', + }); + const { auth, reloadAuth } = useContext(AuthContext); + + const regenerateKey = async () => { + Auth.refreshRadarScopeKey().then((status) => { + if (status === BackendReturnStatus.Unauthorized) { + Auth.triggerLoginFlow(); + // TODO reload user data in auth + // TODO store current URL and get back after login + } else if (status === BackendReturnStatus.Failure) { + setStatusMessage({ + error: true, + message: 'Unable to regenerate the key', + }); + } else { + reloadAuth(); + setStatusMessage({ + error: false, + message: 'Updated the key', + }); + } + }); + } + + const userInformation: any[] = [ + { vatsimId: auth.user.vatsimId, fullName: auth.user.fullName !== '' ? auth.user.fullName : 'Unknown' }, + ]; + + const userData = ( + <> +
+ + + + +
+
+

RADAR scope key

+ +
+ + ); + + const initialSteps = ( + + ) + + return ( + <> +
+ + +
+ + ); };