import { useState } from "react"; import Compose from "./Compose"; import Calendar from "./Calendar"; import clsx from "clsx"; type SubTab = "compose" | "calendar" | "blog"; type Tab = "dashboard" | "scheduler" | "autopost" | "analytics" | "profiles" | "settings"; interface Props { initialSubTab?: SubTab; scheduleForDate?: string | null; onScheduleDateConsumed?: () => void; onNavigate?: (tab: string) => void; } export default function Scheduler({ initialSubTab, scheduleForDate, onScheduleDateConsumed, onNavigate }: Props) { const [subTab, setSubTab] = useState(initialSubTab || "compose"); // When Compose or BlogPost successfully posts, switch to Calendar sub-tab const handleNavigateToCalendar = () => { setSubTab("calendar"); }; // When Calendar's + button is clicked, switch to Compose with the date const [composeDate, setComposeDate] = useState(scheduleForDate || null); const handleCreatePost = (date?: string) => { if (date) setComposeDate(date); setSubTab("compose"); }; // After compose consumes the date, clear it const handleDateConsumed = () => { setComposeDate(null); onScheduleDateConsumed?.(); }; return (
{/* Header with sub-tabs */}

Scheduler

Create, schedule, and manage your social media posts.

{([ { id: "compose" as SubTab, label: "Compose", icon: "fa-solid fa-pen-to-square" }, { id: "calendar" as SubTab, label: "Calendar", icon: "fa-solid fa-calendar-days" }, { id: "blog" as SubTab, label: "From Blog Post", icon: "fa-solid fa-blog" }, ]).map((tab) => ( ))}
{/* Sub-tab content */}
{subTab === "compose" && ( )} {subTab === "blog" && ( )}
{/* Calendar renders outside the card — it has its own card */} {subTab === "calendar" && ( )}
); }