"use client";

import type { ReactElement } from "react";

import { isAgentOperator, isSiteFinanceOperator, isSiteCsOperator, isSiteOperator } from "@/lib/admin-session-variants";
import { AgentDashboardConsole } from "@/modules/dashboard/agent-dashboard-console";
import { DashboardConsole } from "@/modules/dashboard/dashboard-console";
import { SiteCsDashboardConsole } from "@/modules/dashboard/site-cs-dashboard-console";
import { SiteFinanceDashboardConsole } from "@/modules/dashboard/site-finance-dashboard-console";
import { SiteDashboardConsole } from "@/modules/dashboard/site-dashboard-console";
import { useAdminProfile } from "@/stores/admin-session";

/** 超管/平台账号走全站仪表盘；站点运营账号走站点仪表盘；代理经营账号走代理仪表盘。 */
export function DashboardPageClient(): ReactElement {
  const profile = useAdminProfile();

  if (isAgentOperator(profile)) {
    return <AgentDashboardConsole />;
  }

  if (isSiteFinanceOperator(profile)) {
    return <SiteFinanceDashboardConsole />;
  }

  if (isSiteCsOperator(profile)) {
    return <SiteCsDashboardConsole />;
  }

  if (isSiteOperator(profile)) {
    return <SiteDashboardConsole />;
  }

  return <DashboardConsole />;
}
