
import * as React from "react";
import Main from "./Main";
import Login from "./Modules/Authentication/Login";
import {  Switch, Route,Redirect, HashRouter } from "react-router-dom";
import {CachingService} from "../../Services";

const UserApp = () => {
    
    let _cachingService = new CachingService();
    let notAuthenticated = !_cachingService.read("Token") || _cachingService.read("Token")=='';
    return (
        <HashRouter basename="/">
          <div>
            {(notAuthenticated) && <Redirect to="/login"  key="from-root"></Redirect>}
                <Switch>
                    <Route path="/login" component={Login}  exact></Route>
                  
                    <Route path="/" component={Main}></Route>
                </Switch>
            </div>
        </HashRouter>
    )
}
export default UserApp;
