import { Routes, Route, Navigate } from 'react-router-dom'
import Login from './pages/Login'
import Signup from './pages/Signup'
import Chat from './pages/Chat'
import ApiKeys from './pages/ApiKeys'
import About from './pages/About'
import HowToUse from './pages/HowToUse'
import NotFound from './pages/NotFound'
const isAuthed = () => !!localStorage.getItem('token')
export default function App(){
  return (
    <Routes>
      <Route path="/" element={isAuthed()?<Navigate to="/chat"/>:<Navigate to="/login"/>} />
      <Route path="/login" element={<Login/>} />
      <Route path="/signup" element={<Signup/>} />
      <Route path="/chat" element={isAuthed()?<Chat/>:<Navigate to="/login"/>} />
      <Route path="/apikeys" element={isAuthed()?<ApiKeys/>:<Navigate to="/login"/>} />
      <Route path="/about" element={<About/>} />
      <Route path="/howto" element={<HowToUse/>} />
      <Route path="*" element={<NotFound/>} />
    </Routes>
  )
}
