import { BrowserRouter, Navigate, Route, Routes } from 'react-router-dom';
//import AdminDashboard from './components/AdminDashboard';
import LoginForm from './components/LoginForm';
//import RegisterForm from './components/RegisterForm';
import Md5Tool from './components/Md5Tool';
import ToolOverview from './components/ToolOverview';

function App() {
  const isLoggedIn = localStorage.getItem('token') !== null;
  const role = localStorage.getItem('role');

  return (
    <BrowserRouter>
      <Routes>
        <Route path="/" element={isLoggedIn ? <ToolOverview /> : <Navigate to="/login" />} />
        <Route path="/login" element={<LoginForm />} />
        {/*<Route path="/register" element={<RegisterForm />} />*/}
        <Route path="/tools/md5" element={isLoggedIn ? <Md5Tool /> : <Navigate to="/login" />} />
        {/*<Route path="/admin" element={isLoggedIn && role === 'admin' ? <AdminDashboard /> : <Navigate to="/" />} />*/}
      </Routes>
    </BrowserRouter>
  );
}

export default App;
