"use client"; import { useState } from "react"; import CampaignListPanel, { CampaignEditPanel } from "./CampaignListPanel"; import { TemplateListPanel, TemplateEditForm } from "./TemplateEditForm"; import MessageLogPanel from "./MessageLogPanel"; import ContactListPanel from "./ContactListPanel"; import ContactImportForm from "./ContactImportForm"; import SegmentBuilderPage from "@/components/admin/HarvestReach/SegmentBuilderPage"; import AnalyticsDashboard from "@/components/admin/HarvestReach/AnalyticsDashboard"; import CampaignComposerPage from "@/components/admin/HarvestReach/CampaignComposerPage"; import CommunicationSettingsForm from "./CommunicationSettingsForm"; import { PageHeader, AdminFilterTabs } from "@/components/admin/design-system"; import type { Campaign } from "@/actions/communications/campaigns"; import type { Template } from "@/actions/communications/templates"; import type { Contact } from "@/actions/communications/contacts"; import type { Segment } from "@/actions/harvest-reach/segments"; import type { CampaignAnalytics } from "@/actions/harvest-reach/campaigns"; type Tab = "campaigns" | "compose" | "templates" | "contacts" | "segments" | "logs" | "analytics" | "settings"; const SettingsIcon = () => ( ); const ComposeIcon = () => ( ); const MailIcon = () => ( ); const FileTextIcon = () => ( ); const UsersIcon = () => ( ); const LayersIcon = () => ( ); const ListIcon = () => ( ); const ChartIcon = () => ( ); export default function CommunicationsPage({ campaigns, templates, brandId, editCampaign, editMode, editTemplate, initialContacts = [], initialContactTotal = 0, initialSegments = [], initialAnalytics = [], editCampaignId, initialTab, }: { campaigns: Campaign[]; templates: Template[]; brandId: string; editCampaign?: Campaign | null; editMode?: "edit" | "new"; editTemplate?: Template | null; initialContacts?: Contact[]; initialContactTotal?: number; initialSegments?: Segment[]; initialAnalytics?: CampaignAnalytics[]; editCampaignId?: string; initialTab?: Tab; }) { const [currentTab, setCurrentTab] = useState(initialTab ?? "campaigns"); const [isComposing, setIsComposing] = useState(false); return (
{/* Page Header */}
} /> {/* Tab navigation */}
{ setCurrentTab(tab as Tab); setIsComposing(false); }} tabs={[ { value: "campaigns", label: "Campaigns", icon: }, { value: "compose", label: "Compose", icon: }, { value: "templates", label: "Templates", icon: }, { value: "contacts", label: "Contacts", icon: }, { value: "segments", label: "Segments", icon: }, { value: "logs", label: "Logs", icon: }, { value: "analytics", label: "Analytics", icon: }, { value: "settings", label: "Settings", icon: }, ]} size="md" />
{/* Content */}
{/* Campaigns Tab */} {currentTab === "campaigns" && !isComposing && ( editCampaign !== undefined || editMode === "new" ? ( ) : (
) )} {/* Templates Tab */} {currentTab === "templates" && !isComposing && ( editTemplate !== undefined || editMode === "new" ? (
) : (
) )} {/* Contacts Tab */} {currentTab === "contacts" && !isComposing && (
)} {/* Segments Tab */} {currentTab === "segments" && !isComposing && (
)} {/* Logs Tab */} {currentTab === "logs" && !isComposing && (
)} {/* Analytics Tab */} {currentTab === "analytics" && !isComposing && (
)} {/* Settings Tab */} {currentTab === "settings" && !isComposing && (
)} {/* Compose Tab */} {currentTab === "compose" && (
)} {/* Legacy Compose Mode (from edit mode) */} {(isComposing || editCampaignId) && currentTab === "campaigns" && (
)}
); }