import React from 'react';
import {useContext} from 'react'
import './App.css';
import { BrowserRouter, Routes, Route, Navigate} 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';


function App() 
{
  const {user} = useContext<UserCtxT | null>(UserCtx) as UserCtxT;

  return (
    <div className="App">
          <div className="col middle">
            <BrowserRouter basename='/dog'>
              <Routes>
                  {user && <Route path="/" element={<Home/>} />}
                  {!user && <Route path="/" element={<Login/>} />}
                  <Route path="/:qr_id" element={<Dog/>} />
                  {user && <Route path="/d" element={<Dog/>} />}
                  <Route path="/login" element={<Login/>} />
                  <Route path="/reg" element={<Register/>} />
              </Routes>
            </BrowserRouter>
          </div>
    </div>
  );
}

export default App;
