import { useAuth } from "@/features/auth/authContext"
import { Navigate, Outlet } from "react-router-dom"

export const ProtectedRoute = () => {
    const { isAuthenticated, isLoading } = useAuth()

    if (isLoading) {
        return <div className="flex items-center justify-center h-screen">Yükleniyor...</div>
    }

    if (!isAuthenticated) {
        return <Navigate to="/login" replace />
    }

    return <Outlet />
}
