import { CSSProperties, lazy, Suspense, useEffect, useState } from 'react'; import { BrowserRouter, Route, Switch } from 'react-router-dom'; import { getReceivedInvitationsAndRequests } from './api'; import { useMe } from './hooks'; import Notifications from './Notifications'; import { IInvitation } from './types'; import WheelShare from './WheelShare'; import WheelShareLoggedOut from './WheelShareLoggedOut'; const Authenticator = lazy(() => import('./Authentication/Authenticator')); const Group = lazy(() => import('./Group')); const dummyNotificationData: IInvitation[] = [ { user: { id: 0, name: 'Michael Fatemi', }, carpool: { id: 0, name: 'Cross Country', }, isRequest: true, sentTime: new Date().toISOString(), }, { user: { id: 1, name: 'Joshua Hsueh', }, carpool: { id: 0, name: 'TJ Lax', }, isRequest: false, sentTime: new Date().toISOString(), }, ]; const style: CSSProperties = { display: 'flex', flexDirection: 'column', alignItems: 'center', width: '30rem', maxWidth: '30rem', marginLeft: 'auto', marginRight: 'auto', }; function useNotifications() { const [notifications, setNotifications] = useState(dummyNotificationData); useEffect(() => { getReceivedInvitationsAndRequests().then(setNotifications); }, []); return notifications; } export default function App() { const user = useMe(); const notifications = useNotifications(); return (
{notifications.length > 0 ? ( ) : ( No notifications )}
); }