import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom';
import CounterLayout from './layouts/CounterLayout';
import FastEntryPage from './pages/FastEntryPage';
import CashRegisterPage from './pages/CashRegisterPage';
import LoginPage from './pages/LoginPage';

// Componente simple de protección
const PrivateRoute = ({ children }: { children: React.ReactNode }) => {
  const token = localStorage.getItem('token');
  return token ? <>{children}</> : <Navigate to="/login" />;
};

function App() {
  return (
    <BrowserRouter>
      <Routes>
        <Route path="/login" element={<LoginPage />} />

        <Route element={<PrivateRoute><CounterLayout /></PrivateRoute>}>
          <Route path="/" element={<FastEntryPage />} />
          <Route path="/cash-register" element={<CashRegisterPage />} />
        </Route>
      </Routes>
    </BrowserRouter>
  );
}

export default App;