// @File: src/pages/admin/cms/CmsModuleSyncPage.tsx
// @Desc: Shared per-module "Data Fetch" settings page. Renders the
//        reusable ModuleSyncPanel in the standard CMS layout. Each
//        module exposes its own route (uptimerobot/bizmail/whatsapp)
//        that mounts this page with a different moduleName + title.
import { Zap } from "lucide-react";
import CmsLayout from "./CmsLayout";
import { PageHeader, SectionCard } from "./ui";
import ModuleSyncPanel from "@/components/admin/ModuleSyncPanel";

interface Props {
  moduleName: string;
  pageTitle: string;
  pageDescription: string;
}

/**
 * Full settings page that hosts the universal Fetch Data Toggle panel for
 * a single module. Used by three route-level components below so each
 * module gets its own URL without duplicating layout/header code.
 */
export default function CmsModuleSyncPage({ moduleName, pageTitle, pageDescription }: Props) {
  return (
    <CmsLayout>
      <PageHeader
        title={pageTitle}
        description={pageDescription}
        icon={<Zap className="h-6 w-6" />}
      />
      <SectionCard
        title="Fetch Data Toggles"
        description="Enable or disable automatic data fetching from WHMCS and the module's external API. Manual fetches always run regardless of toggles."
      >
        <ModuleSyncPanel moduleName={moduleName} title="" />
      </SectionCard>
    </CmsLayout>
  );
}

// ---------- Per-module route components ----------

export function CmsUptimeRobotSync() {
  return (
    <CmsModuleSyncPage
      moduleName="uptimerobot"
      pageTitle="UptimeRobot — Data Fetch"
      pageDescription="Control automatic fetching of WHMCS clients, UptimeRobot monitors, and matched domains."
    />
  );
}

export function CmsBizmailSync() {
  return (
    <CmsModuleSyncPage
      moduleName="bizmail360"
      pageTitle="Bizmail360 — Data Fetch"
      pageDescription="Control automatic fetching of WHMCS clients, SmarterMail mailboxes/domains, and matched WHMCS domains."
    />
  );
}

export function CmsWhatsAppSync() {
  return (
    <CmsModuleSyncPage
      moduleName="whatsapp"
      pageTitle="WhatsApp — Data Fetch"
      pageDescription="Control automatic fetching of WHMCS clients, WhatsApp devices/accounts, and matched WHMCS domains."
    />
  );
}