import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
import React, { Suspense, lazy } from 'react';
import Loading from "./routes/Loading"

//const Home = lazy(() => import('./routes/Home'));
const Home = lazy(() => {
    return new Promise(resolve => {
        setTimeout(() => resolve(import("./routes/Home")), 500);
    });
});
const Film = lazy(() => import('./routes/Film'));
const Anime = lazy(() => import('./routes/Anime'));
const SerieTV = lazy(() => import('./routes/SerieTV'));
const Immagini = lazy(() => import('./routes/Immagini'));
const Musica = lazy(() => import('./routes/Musica'));
const Giochi = lazy(() => import('./routes/Giochi'));
const Programmi = lazy(() => import('./routes/Programmi'));
const Pannocchiacattiva = lazy(() => import('./routes/Pannocchiacattiva'))

const NotFound = lazy(() => import('./routes/NotFound'));

class App extends React.Component {
    render() {
        return (
            <Router>
                <Suspense fallback={<Loading />}>
                    <Switch>
                        <Route exact path="/" component={Home}/>
                        <Route path="/Film" component={Film}/>
                        <Route path="/Anime" component={Anime}/>
                        <Route path="/SerieTV" component={SerieTV}/>
                        <Route path="/Immagini" component={Immagini}/>
                        <Route path="/Musica" component={Musica}/>
                        <Route path="/Giochi" component={Giochi}/>
                        <Route path="/Programmi" component={Programmi}/>
                        <Route path="/Pannocchiacattiva" component={Pannocchiacattiva}/>

                        <Route component={NotFound} />
                    </Switch>
                </Suspense>
            </Router>
        );
    }
}

export default App;
