import { Navigate, Outlet } from 'react-router-dom';
import { useAuth } from '../context/AuthContext';

export function ProtectedRoute() {
  const { ready, token } = useAuth();
  if (!ready) return <p className="loading">載入中…</p>;
  if (!token) return <Navigate to="/login" replace />;
  return <Outlet />;
}
