import React, { useState } from 'react'; import 'rsuite/lib/styles/index.less'; import { BrowserRouter as Router, Switch, Route } from 'react-router-dom'; import { AuthContext } from './helpers/authContext'; import { PrivateRoute } from './components'; import { Home, Login, Register, Dashboard, Invite, Availability, Schedule, } from './screens'; const existingToken = JSON.parse(localStorage.getItem('token')); const existingUser = JSON.parse(localStorage.getItem('user')); export default function App() { const [isAuthenticated, setIsAuthenticated] = useState(!!existingToken); const [currentUser, setCurrentUser] = useState(existingUser || ''); const [possibleDates, setPossibleDates] = useState(); const [currentMeeting, setCurrentMeeting] = useState({ title: '', description: '', timezone: '', duration: 0, status: 0, }); const [authToken, setAuthToken] = useState(existingToken || ''); const setToken = (data) => { localStorage.setItem('token', JSON.stringify(data)); setAuthToken(data); }; const setUser = (data) => { localStorage.setItem('user', JSON.stringify(data)); setCurrentUser(data); }; const setAuthentication = (boolean) => { if (!boolean) { localStorage.removeItem('token'); localStorage.removeItem('user'); } setIsAuthenticated(boolean); }; return ( ); }