From f6af11fababb25b566343fddf44669afc68e7a64 Mon Sep 17 00:00:00 2001 From: Joshua Hsueh Date: Tue, 6 Jul 2021 22:48:40 -0400 Subject: [PATCH] put notifications top of router --- src/components/App.tsx | 40 ++++++++++++++++++++++++++++++++++++++- src/components/Groups.tsx | 36 ----------------------------------- 2 files changed, 39 insertions(+), 37 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index 17c069f..fa7c4e5 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -1,16 +1,54 @@ -import { lazy, Suspense, useContext } from 'react'; +import { lazy, Suspense, useContext, useState, useEffect } from 'react'; import { BrowserRouter, Route, Switch } from 'react-router-dom'; import AuthenticationContext from './Authentication/AuthenticationContext'; import WheelShare from './WheelShare'; import WheelShareLoggedOut from './WheelShareLoggedOut'; +import { INotification } from './Notifications'; +import Notifications from './Notifications'; const Authenticator = lazy(() => import('./Authentication/Authenticator')); const Group = lazy(() => import('./Group')); +const dummyNotificationData: INotification[] = ([] = [ + { + user: { + id: 0, + name: 'Michael Fatemi', + }, + carpool: { + id: 0, + name: 'Cross Country', + }, + isRequest: true, + sentTime: new Date(), + }, + { + user: { + id: 1, + name: 'Joshua Hsueh', + }, + carpool: { + id: 0, + name: 'TJ Lax', + }, + isRequest: false, + sentTime: new Date(), + }, +]); + export default function App() { const { user } = useContext(AuthenticationContext); + const [notifications, setNotifications] = useState(dummyNotificationData); + useEffect(() => { + //getNotifications().then(setNotifications); + }, []); return (
+ {notifications.length > 0 ? ( + + ) : ( + No notifications + )} ([]); - const [notifications, setNotifications] = useState(dummyNotificationData); useEffect(() => { getGroups().then(setGroups); - //getNotifications().then(setNotifications); }, []); return ( <> - {notifications.length > 0 ? ( - - ) : ( - No notifications - )}

Groups