import Register from './pages/Register';
import Login from './pages/Login';
import Dashboard from './components/Dashboard';
import Layout from './components/Layout';
import Profile from './pages/Profile';
import Product from './pages/Product';
import Sales from './pages/Sales';
import Customer from './pages/Customer';
import Reports from './pages/Reports';
import ProtectedRoute from './components/ProtectedRoute';

import { BrowserRouter as Router, Routes, Route, Navigate } from 'react-router-dom';

function App() {
  return (
    <Router>
      <Routes>
        <Route path="/login" element={<Login />} />
        <Route path="/register" element={<Register />} />
        <Route path="/" element={<ProtectedRoute><Layout /></ProtectedRoute>}>
          <Route index element={<Dashboard />} />
          <Route path="dashboard" element={<Dashboard />} />
          <Route path="dashboard/customers" element={<Customer />} />
          <Route path="dashboard/products" element={<Product />} />
          <Route path="dashboard/sales" element={<Sales />} />
          <Route path="dashboard/reports" element={<Reports />} />
          <Route path="dashboard/profile" element={<Profile />} />
        </Route>
        <Route path="*" element={<Navigate to="/dashboard" replace />} />
      </Routes>
    </Router>
  );
}

export default App;
