import React, {Suspense} from "react";
import {BrowserRouter, Link, Route, Routes} from "react-router-dom";
import Home from "./Home";
import Login from "./Auth/Login";
import Register from "./Auth/Register";
import useAuthUser from "../hooks/AuthUser";
import Profile from "./Auth/Profile";
import Header from "../components/Header";
import Rainfall from "./Rainfall";
import Meteo from "./Meteo";
import Reset from "./Auth/Reset";
import ForgotPassword from "./Auth/ForgotPassword";

const Router = () => {

    const {authUser, loadingAuthUser, logout} = useAuthUser()

    return <>
        {loadingAuthUser ? '...loading'
            : <BrowserRouter>
                <Suspense fallback={'... loading'}>
                    <Header />
                    <Routes>
                        <Route path="/" element={<Home />} />
                        <Route path="/profile" element={<Profile />} />
                        <Route path="/connexion" element={<Login />} />
                        {/*<Route path="/sinscrire" element={<Register />} />*/}
                        <Route path="/mot-de-passe-oubliee" element={<ForgotPassword />} />
                        <Route path="/changer-le-mot-de-passe/:token" element={<Reset />} />
                        <Route path="/meteo" element={<Meteo />} />
                        <Route path="/pluviometrie" element={<Rainfall />} />
                    </Routes>
                </Suspense>
            </BrowserRouter>
        }
    </>
}

export default Router
