import { Route, Routes, Navigate } from "react-router-dom";
import AuthLayout from "../layouts/AuthLayout.jsx";
import LoginForm from "../components/LoginForm.jsx";
import RegisterPage from "../pages/auth/RegisterPage.jsx";
import ForgotPasswordPage from "../pages/auth/ForgotPasswordPage.jsx";
import ResetConfirmPage from "../pages/auth/ResetConfirmPage.jsx";

export default function AuthRoutes() {
    return(
        <Routes>
            {/* 1. Root Path ('/') นำทางไปยัง /login ทันที */}
            <Route path="/" element={<Navigate to="/login" replace />} />

            {/* 2. AuthLayout สำหรับหน้า Login, Register, Forgot Password */}
            <Route element={<AuthLayout/>}>
                <Route path="/login" element={<LoginForm/>}/>
                <Route path="/register" element={<RegisterPage/>}/>
                <Route path="/forgot-password" element={<ForgotPasswordPage/>}/>
                <Route path="/password/reset/confirm/:uid/:token" element={<ResetConfirmPage/>}
                />
            </Route>

            {/* 3. Fallback สำหรับเส้นทางที่ไม่รู้จักในส่วน Public */}
            <Route path="*" element={<div>404 Not Found</div>}/>
        </Routes>
    );
}