import React from 'react';
import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom';
import SignIn from './pages/auth/SignIn';
import SignUp from './pages/auth/Signup';
import { ProtectedRoute } from './ProtectedRoute';
import NotFound from './pages/blank/NotFound';

// Dashboard
import Home from './pages/home/Home';
import Blank from './pages/blank/Blank';

// Master
import IndexDevice from './pages/master/device/IndexDevice';
import IndexTag from './pages/master/tag/IndexTag';
import IndexBrandDevice from './pages/master/brandDevice/IndexBrandDevice';
import IndexErrorCode from './pages/master/errorCode/IndexErrorCode';

// History
import IndexTrending from './pages/history/trending/IndexTrending';
import IndexReport from './pages/history/report/IndexReport';

// Other Pages
import IndexNotification from './pages/notification/IndexNotification';
import IndexEventAlarm from './pages/eventAlarm/IndexEventAlarm';
import IndexRole from './pages/role/IndexRole';
import IndexUser from './pages/user/IndexUser';

// Shift Management
import IndexSchedule from './pages/shiftManagement/schedule/IndexSchedule';
import IndexMember from './pages/shiftManagement/member/IndexMember';

import SvgTest from './pages/home/SvgTest';

const App = () => {
    return (
        <BrowserRouter>
            <Routes>
                {/* Public Routes */}
                <Route path="/" element={<Navigate to="/signin" replace />} />
                <Route path="/signin" element={<SignIn />} />
                <Route path="/signup" element={<SignUp />} />
                <Route path="/svg" element={<SvgTest />} />

                {/* Protected Routes */}
                <Route path="/dashboard" element={<ProtectedRoute />}>
                    <Route path="home" element={<Home />} />
                    <Route path="blank" element={<Blank />} />
                </Route>

                <Route path="/master" element={<ProtectedRoute />}>
                    <Route path="device" element={<IndexDevice />} />
                    <Route path="tag" element={<IndexTag />} />
                    <Route path="brand-device" element={<IndexBrandDevice />} />
                    <Route path="error-code" element={<IndexErrorCode />} />
                </Route>

                <Route path="/history" element={<ProtectedRoute />}>
                    <Route path="trending" element={<IndexTrending />} />
                    <Route path="report" element={<IndexReport />} />
                </Route>

                <Route path="/notification" element={<ProtectedRoute />}>
                    <Route index element={<IndexNotification />} />
                </Route>

                <Route path="/event-alarm" element={<ProtectedRoute />}>
                    <Route index element={<IndexEventAlarm />} />
                </Route>

                <Route path="/role" element={<ProtectedRoute />}>
                    <Route index element={<IndexRole />} />
                </Route>

                <Route path="/user" element={<ProtectedRoute />}>
                    <Route index element={<IndexUser />} />
                </Route>

                <Route path="/shift-management" element={<ProtectedRoute />}>
                    <Route path="schedule" element={<IndexSchedule />} />
                    <Route path="member" element={<IndexMember />} />
                </Route>

                {/* Catch-all */}
                <Route path="*" element={<NotFound />} />
            </Routes>
        </BrowserRouter>
    );
};

export default App;
