import React from 'react';
import {useContext} from 'react'
import './App.css';
import { BrowserRouter, Routes, Route } from 'react-router-dom';
import Login from './components/Login';
import Register from './components/Register';
import Home from './components/Home';
import Dog from './components/Dog';
import {UserCtx, UserCtxT} from './context/UserContext';
import Qr from './components/Qr';
import Header from './components/Header';
import Footer from './components/Footer';
import Impressum from './components/Impressum';
import "bootstrap/dist/css/bootstrap.min.css";
import FileUpload from './components/FileUpload';
import Profil from './components/Profil';


const App: React.FC = () => 
{
  const {user} = useContext<UserCtxT | null>(UserCtx) as UserCtxT;

  return (
    <div className="App">
          <div className="col middle">
            <BrowserRouter basename='/dog'>
              {user && <Header />}
              <Routes>
                  {user && <Route index path="/" element={<Profil/>} />}
                  {/* {user && <Route index path="/" element={<Home/>} />} */}
                  {!user && <Route index path="/" element={<Login/>} />}
                  {user && <Route path="/qr" element={<Qr/>} />}
                  {user && <Route path="/d" element={<Dog/>} />}
                  <Route path="/:qr_id" element={<Dog/>} />
                  <Route path="/login" element={<Login/>} />
                  <Route path="/reg" element={<Register/>} />
                  <Route path="/impressum" element={<Impressum/>} />
                  {user && <Route path="/upload" element={<FileUpload/>} />}
                  {user && <Route path="/profil" element={<Profil/>} />}
              </Routes>
              <Footer/>
            </BrowserRouter>
          </div>
        
    </div>
  );
}

export default App;
