import React from 'react';
import {useContext} from 'react'
import './App.css';
import { BrowserRouter, Routes, Route, Navigate} from 'react-router-dom';
import "./App.css";
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/>} /> }
                { (
                  <>
                  {/* <Route path="/:qr_id" element={<Dog/>} /> */}
                  <Route path="/" element={<Home/>} />
                  <Route path="/d" element={<Dog/>} />
                  <Route path="/login" element={<Login/>} />
                  <Route path="/reg" element={<Register/>} />
                  </>
                )}
                {/* <Route path="*" element={<Navigate to={user ? '/':'/login'} />} /> */}
              </Routes>
            </BrowserRouter>
          </div>
    </div>
  );
}

export default App;
