import AdminApprovedApplicationsList from "@/components/admin/ApprovedApplicationsList";
import CouncilApprovedApplicationsList from "@/components/council/ApprovedApplicationsList";
import { ApplicantRegistrationDashboard } from "@/components/applicant/dashboard";
import { useAuth } from "@/contexts/AuthContext";

/**
 * Route shell: admin / council lists vs applicant initiative registration workspace.
 * Applicant draft lifecycle (fresh vs resume from Postgres) lives in `ApplicantRegistrationDashboard` + `useApplicantRegistrationState`.
 */
export default function Dashboard() {
  const { hasRole } = useAuth();
  const isAdmin = hasRole("admin");
  const isCouncil = hasRole("editor");

  if (isAdmin) {
    return (
      <AdminApprovedApplicationsList
        lifecycle="inbox"
        viewSubmittedReturnPath="/dashboard"
      />
    );
  }
  if (isCouncil) {
    return <CouncilApprovedApplicationsList />;
  }
  return <ApplicantRegistrationDashboard />;
}
