import {BrowserRouter, Route, Routes, Navigate} from 'react-router-dom';
import {ProtectedRoute} from 'components';
import {LoginForm, ChannelList} from 'views';

export default function Router() {
  return (
    <BrowserRouter>
      <Routes>
        {/* Public routes */}
        <Route path="/login" element={<LoginForm />} />

        {/* Protected routes */}
        <Route path="/" element={<Navigate to="/channels" replace />} />
        <Route path="/channels" element={<ProtectedRoute component={<ChannelList />} />} />

        {/* Fallback route */}
        <Route path="*" element={<Navigate to="/login" replace />} />
      </Routes>
    </BrowserRouter>
  );
}
