import { FunctionalComponent, h } from "preact";
import { Route, Router, RouterOnChangeArgs } from "preact-router";

import Home from "../routes/home/index";
import Project from "../routes/project/index";
import NotFoundPage from '../routes/notfound/index';
import Header from "./header/index";
import Footer from "./footer";

const App: FunctionalComponent = () => {
    let currentUrl: string;
    const handleRoute = (e: RouterOnChangeArgs) => {
        currentUrl = e.url;
    };

    return (
      <div id="app">
        <Header class="noPrint" />
        <Router onChange={handleRoute}>
          <Route path="/" component={Home} />
          <Route path="/p/:projectId" component={Project} />
          <NotFoundPage default />
        </Router>
        <Footer />
      </div>
    );
};

export default App;
