import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom';
import { Toaster } from 'react-hot-toast';

import Login from '@/pages/Login';

import DashboardLayout from './layouts/DashboardLayout';

// import ProtectedRoute from "./components/ProtectedRoutes/ProtectedRoutes";

import ProtectedRoute from './auth/ProtectedRoute';
import PublicRoute from './auth/PublicRoute';
import { AuthProvider } from './context/AuthContext';
import Department from './pages/Department';
import Doctor from './pages/Doctor';
import Blog from './pages/Blog';
import BlogEditorPage from './pages/BlogEditor';
import Appointment from './pages/Appointment';
import EmailPage from './pages/email';
import CareerPage from './pages/Career';
import CandidatePage from './pages/candidates';
import InquiryPage from './pages/inquiry';
import AcademicsPage from './pages/Academics';
import NewsPage from './pages/newsMedia';
import BlogDetail from './pages/BlogDetails';
import ImportData from './pages/ImportData';
import HealthPackagePage from './pages/HealthPackagePage';
import HomepageBanner from './pages/HomepageBannerPage';

export default function App() {
	return (
		<BrowserRouter>
			<Toaster position="top-right" />

			<AuthProvider>
				<Routes>
					<Route element={<PublicRoute />}>
						<Route path="/" element={<Login />} />
					</Route>

					<Route element={<ProtectedRoute />}>
						<Route element={<DashboardLayout />}>
							<Route path="/department" element={<Department />} />
							<Route path="/doctor" element={<Doctor />} />
							<Route path="/blog" element={<Blog />} />
							<Route path="/blog/:id" element={<BlogDetail />} />
							<Route path="/blog/create" element={<BlogEditorPage />} />
							<Route path="/blog/edit/:id" element={<BlogEditorPage />} />
							<Route path="/appointment" element={<Appointment />} />
							<Route path="/email" element={<EmailPage />} />
							<Route path="/career" element={<CareerPage />} />
							<Route path="/candidate" element={<CandidatePage />} />
							<Route path="/inquiry" element={<InquiryPage />} />
							<Route path="/academics" element={<AcademicsPage />} />
							<Route path="/news" element={<NewsPage />} />
							<Route path="/import" element={<ImportData />} />
							<Route path="/health-check" element={<HealthPackagePage />} />
							<Route path="/homepage-banner" element={<HomepageBanner />} />
						</Route>
					</Route>

					<Route path="*" element={<Navigate to="/department" replace />} />
				</Routes>
			</AuthProvider>
		</BrowserRouter>
	);
}
