Skip to content

50+ open-source generative AI apps you can clone, deploy, and monetize — image generators, video tools, virtual try-ons, AI SaaS templates, and platform integrations. One-click Vercel deploy on every template.

feat: add AI post writer with gpt-5-mini and vibrant platform styling

jaiprasad042c3f22f7006f
diff --git a/src/app/api/ai/generate/route.js b/src/app/api/ai/generate/route.js
new file mode 100644
index 0000000..756bb2b
--- /dev/null
+++ b/src/app/api/ai/generate/route.js
@@ -0,0 +1,187 @@
+import { NextResponse } from "next/server";
+import { getServerSession } from "next-auth/next";
+import { authOptions } from "@/lib/auth";
+import config from "@/lib/config";
+
+// Platform-tailored guidelines for gpt-5-mini
+const PLATFORM_GUIDELINES = {
+ youtube: `Target Platform: YouTube
+- Title: Highly clickable, intriguing hook under 70 characters. Never misleading, but creates a strong curiosity gap.
+- Description: Structured with:
+ 1. Compelling 1-2 sentence hook above the fold.
+ 2. Brief summary of what the viewer will learn or experience.
+ 3. Clear Call to Action (like, subscribe, comment).
+- Tags: 4-6 relevant comma-separated tags without hash symbols (e.g. "ai, productivity, social media").`,
+
+ tiktok: `Target Platform: TikTok
+- Title: Punchy, high-energy video caption under 150 characters.
+- Description: Direct, relatable hook that speaks directly to the viewer with 1-2 emojis.
+- Tags: 3-5 trending, viral comma-separated hashtags (e.g. "fyp, viral, ai, creators").`,
+
+ instagram: `Target Platform: Instagram
+- Title: Scroll-stopping first sentence hook.
+- Description: Engaging, conversational caption formatted with clean line breaks and expressive emojis. Include a clear engagement call-to-action (e.g., "Save this for later", "Share with a friend").
+- Tags: 5-8 targeted, high-reach comma-separated hashtags.`,
+
+ x_twitter: `Target Platform: X (Twitter)
+- Title: Strong, provocative opening thought.
+- Description: Concise, high-value tweet under 280 characters with clean spacing. No fluff.
+- Tags: 1-2 focused, high-impact comma-separated hashtags.`,
+
+ linkedin: `Target Platform: LinkedIn
+- Title: Professional, curiosity-driven opening line.
+- Description: Story-driven or value-packed professional insight with generous line breaks for readability. End with a thoughtful discussion question to encourage comments.
+- Tags: 3-5 industry-relevant comma-separated hashtags (e.g. "marketing, leadership, innovation").`,
+
+ threads: `Target Platform: Threads
+- Title: Conversational thought or question.
+- Description: Casual, relatable observation under 500 characters designed to spark quick replies.
+- Tags: 2-3 clean comma-separated hashtags.`
+};
+
+function buildSystemPrompt(platform, tone) {
+ const platformGuide = PLATFORM_GUIDELINES[platform] || PLATFORM_GUIDELINES.youtube;
+
+ return `You are an elite social media strategist and viral copywriter who crafts top-performing content across social platforms.
+
+${platformGuide}
+
+Tone of Voice: ${tone || "Engaging, authentic, and modern"}
+
+CRITICAL OUTPUT FORMAT:
+You MUST respond with a valid JSON object ONLY. Do NOT include markdown code blocks, backticks, or any explanatory text outside the JSON object.
+
+Format:
+{
+ "title": "The post title or main hook",
+ "description": "The full post caption or description text",
+ "tags": "tag1, tag2, tag3"
+}`;
+}
+
+export async function POST(req) {
+ try {
+ const session = await getServerSession(authOptions);
+ if (!session?.user) {
+ return NextResponse.json({ error: "Unauthorized. Please sign in." }, { status: 401 });
+ }
+
+ const body = await req.json();
+ const { prompt, platform = "youtube", tone = "Engaging" } = body;
+
+ if (!prompt || typeof prompt !== "string" || !prompt.trim()) {
+ return NextResponse.json({ error: "Please provide a prompt or topic for the post." }, { status: 400 });
+ }
+
+ const apiKey = config.ai.apiKey;
+ if (!apiKey) {
+ return NextResponse.json({
+ error: "MuAPI API key is not configured. Please check MUAPIAPP_API_KEY in .env."
+ }, { status: 500 });
+ }
+
+ const systemPrompt = buildSystemPrompt(platform, tone);
+
+ // 1. Submit generation request to MuAPI gpt-5-mini
+ const submitRes = await fetch("https://api.muapi.ai/api/v1/gpt-5-mini", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ "x-api-key": apiKey
+ },
+ body: JSON.stringify({
+ prompt: prompt.trim(),
+ system_prompt: systemPrompt
+ })
+ });
+
+ if (!submitRes.ok) {
+ const errText = await submitRes.text().catch(() => "");
+ console.error("[MuAPI gpt-5-mini Error]:", submitRes.status, errText);
+ return NextResponse.json({
+ error: `AI generation submission failed: ${errText || submitRes.statusText}`
+ }, { status: submitRes.status });
+ }
+
+ const submitData = await submitRes.json();
+ const requestId = submitData.request_id || submitData.id;
+
+ if (!requestId) {
+ return NextResponse.json({ error: "No request ID returned from AI provider." }, { status: 502 });
+ }
+
+ // 2. Poll for the prediction result
+ const maxAttempts = 30; // 30 * 1.5s = 45s max
+ let attempts = 0;
+ let rawOutput = null;
+
+ while (attempts < maxAttempts) {
+ await new Promise((r) => setTimeout(r, 1500));
+ attempts++;
+
+ try {
+ const pollRes = await fetch(`https://api.muapi.ai/api/v1/predictions/${requestId}/result`, {
+ headers: {
+ "x-api-key": apiKey
+ }
+ });
+
+ if (pollRes.ok) {
+ const pollData = await pollRes.json();
+
+ if (pollData.status === "completed" || pollData.status === "succeeded") {
+ // Check possible output shapes
+ if (Array.isArray(pollData.outputs) && pollData.outputs.length > 0) {
+ rawOutput = pollData.outputs[0];
+ } else if (pollData.output) {
+ rawOutput = typeof pollData.output === "string" ? pollData.output : JSON.stringify(pollData.output);
+ } else if (pollData.result) {
+ rawOutput = typeof pollData.result === "string" ? pollData.result : JSON.stringify(pollData.result);
+ }
+ break;
+ } else if (pollData.status === "failed") {
+ throw new Error(pollData.error || "AI generation failed during processing.");
+ }
+ }
+ } catch (pollErr) {
+ console.warn(`[MuAPI Poll Attempt ${attempts} Error]:`, pollErr.message);
+ }
+ }
+
+ if (!rawOutput) {
+ return NextResponse.json({ error: "AI generation timed out. Please try again." }, { status: 504 });
+ }
+
+ // 3. Clean and parse JSON from the AI response
+ let parsed = null;
+ try {
+ // Remove any markdown code blocks if the model wrapped output in ```json ... ```
+ let cleaned = rawOutput.trim();
+ if (cleaned.startsWith("```")) {
+ cleaned = cleaned.replace(/^```(?:json)?\s*/i, "").replace(/\s*```$/, "");
+ }
+ parsed = JSON.parse(cleaned);
+ } catch (parseErr) {
+ console.warn("JSON parsing failed, extracting with fallback:", parseErr.message);
+ // Fallback extraction
+ parsed = {
+ title: rawOutput.slice(0, 80).split("\n")[0].replace(/^[#"*\s]+/, ""),
+ description: rawOutput,
+ tags: "ai, socialmedia, content"
+ };
+ }
+
+ return NextResponse.json({
+ success: true,
+ data: {
+ title: parsed.title || "",
+ description: parsed.description || "",
+ tags: parsed.tags || ""
+ }
+ });
+
+ } catch (error) {
+ console.error("[AI Generate Route Error]:", error);
+ return NextResponse.json({ error: error.message || "An unexpected error occurred." }, { status: 500 });
+ }
+}
diff --git a/src/app/page.js b/src/app/page.js
index fd551db..a943a47 100644
--- a/src/app/page.js
+++ b/src/app/page.js
@@ -29,6 +29,7 @@ export default function WorkspaceDashboard() {
// Composer Modal State
const [composerOpen, setComposerOpen] = useState(false);
+ const [openWithAi, setOpenWithAi] = useState(false);
const [selectedDate, setSelectedDate] = useState(null);
const [editingPost, setEditingPost] = useState(null);
@@ -62,6 +63,7 @@ export default function WorkspaceDashboard() {
const handleDateClick = (date) => {
setSelectedDate(date);
setEditingPost(null);
+ setOpenWithAi(false);
setComposerOpen(true);
};
@@ -72,12 +74,21 @@ export default function WorkspaceDashboard() {
const handleNewPost = () => {
setSelectedDate(null);
setEditingPost(null);
+ setOpenWithAi(false);
+ setComposerOpen(true);
+ };
+
+ const handleWriteWithAi = () => {
+ setSelectedDate(null);
+ setEditingPost(null);
+ setOpenWithAi(true);
setComposerOpen(true);
};
const handleEditPost = (post) => {
setViewingPost(null);
setEditingPost(post);
+ setOpenWithAi(false);
setComposerOpen(true);
};
@@ -193,10 +204,10 @@ export default function WorkspaceDashboard() {
return (
<div className="min-h-screen bg-bg-page text-zinc-100 p-4 sm:p-6 lg:p-8 space-y-6 pb-20">
<div className="max-w-7xl mx-auto space-y-6">
- {/* Clean, Minimal Header */}
+ {/* Clean, Vibrant Header */}
<div className="flex flex-col sm:flex-row sm:items-center justify-between gap-4 pb-4 border-b border-zinc-800/60">
<div>
- <h1 className="text-xl sm:text-2xl font-semibold text-zinc-100 tracking-tight">
+ <h1 className="text-xl sm:text-2xl font-bold tracking-tight text-transparent bg-clip-text bg-gradient-to-r from-white via-zinc-100 to-indigo-300">
Content Calendar
</h1>
<p className="text-xs text-zinc-400 mt-0.5">
@@ -205,13 +216,22 @@ export default function WorkspaceDashboard() {
</div>
<div className="flex items-center gap-2.5 flex-wrap sm:flex-nowrap justify-between sm:justify-end">
- {/* Minimal Stats Pill */}
- <div className="flex items-center gap-3 px-3 py-1.5 rounded-lg bg-zinc-900/60 border border-zinc-800/80 text-xs text-zinc-400">
- <span><strong className="text-zinc-200 font-semibold">{scheduledCount}</strong> scheduled</span>
+ {/* Vibrant Stats Pill */}
+ <div className="flex items-center gap-3 px-3 py-1.5 rounded-lg bg-zinc-900/80 border border-zinc-800 text-xs text-zinc-300 shadow-sm">
+ <span className="flex items-center gap-1.5">
+ <span className="w-2 h-2 rounded-full bg-blue-400 shadow-sm shadow-blue-400/50 animate-pulse" />
+ <strong className="text-blue-400 font-bold">{scheduledCount}</strong> scheduled
+ </span>
<span className="text-zinc-700">|</span>
- <span><strong className="text-zinc-200 font-semibold">{publishedCount}</strong> published</span>
+ <span className="flex items-center gap-1.5">
+ <span className="w-2 h-2 rounded-full bg-emerald-400 shadow-sm shadow-emerald-400/50" />
+ <strong className="text-emerald-400 font-bold">{publishedCount}</strong> published
+ </span>
<span className="text-zinc-700">|</span>
- <span><strong className="text-zinc-200 font-semibold">{uniqueChannels}</strong> channels</span>
+ <span className="flex items-center gap-1.5">
+ <span className="w-2 h-2 rounded-full bg-purple-400 shadow-sm shadow-purple-400/50" />
+ <strong className="text-purple-400 font-bold">{uniqueChannels}</strong> channels
+ </span>
</div>
<button
@@ -222,9 +242,17 @@ export default function WorkspaceDashboard() {
<FiRefreshCw className={`text-xs ${loading ? "animate-spin text-zinc-200" : ""}`} />
</button>
+ <button
+ onClick={handleWriteWithAi}
+ className="px-3.5 py-1.5 rounded-lg text-xs font-semibold text-white bg-gradient-to-r from-violet-600 via-purple-600 to-indigo-600 hover:from-violet-500 hover:to-indigo-500 border border-violet-400/30 transition-all cursor-pointer flex items-center gap-1.5 shadow-md shadow-violet-600/25 active:scale-95"
+ >
+ <FaBolt className="text-[11px] text-amber-300" />
+ <span>Write with AI</span>
+ </button>
+
<button
onClick={handleNewPost}
- className="px-3.5 py-1.5 rounded-lg text-xs font-semibold text-zinc-950 bg-white hover:bg-zinc-200 transition-colors cursor-pointer flex items-center gap-1.5 shadow-sm"
+ className="px-3.5 py-1.5 rounded-lg text-xs font-semibold text-white bg-indigo-600 hover:bg-indigo-500 border border-indigo-500/40 transition-all cursor-pointer flex items-center gap-1.5 shadow-md shadow-indigo-600/25 active:scale-95"
>
<FiPlus className="text-xs" />
<span>New Post</span>
@@ -254,13 +282,20 @@ export default function WorkspaceDashboard() {
{/* Header */}
<div className="flex items-center justify-between pb-3 border-b border-zinc-800">
<div className="flex items-center gap-2">
- <span className="px-2 py-0.5 rounded text-[11px] font-medium uppercase tracking-wider bg-zinc-800 text-zinc-200">
+ <span className={`px-2.5 py-0.5 rounded text-[11px] font-semibold uppercase tracking-wider ${
+ viewingPost.platform === "youtube" ? "bg-red-500/20 text-red-400 border border-red-500/30" :
+ viewingPost.platform === "instagram" ? "bg-pink-500/20 text-pink-400 border border-pink-500/30" :
+ viewingPost.platform === "tiktok" ? "bg-cyan-500/20 text-cyan-400 border border-cyan-500/30" :
+ viewingPost.platform === "linkedin" ? "bg-blue-500/20 text-blue-400 border border-blue-500/30" :
+ viewingPost.platform === "threads" ? "bg-purple-500/20 text-purple-400 border border-purple-500/30" :
+ "bg-sky-500/20 text-sky-400 border border-sky-500/30"
+ }`}>
{viewingPost.platform}
</span>
- <span className={`text-[11px] font-medium px-2 py-0.5 rounded ${
+ <span className={`text-[11px] font-medium px-2.5 py-0.5 rounded ${
viewingPost.status === "completed"
- ? "bg-emerald-500/10 text-emerald-400"
- : "bg-blue-500/10 text-blue-400"
+ ? "bg-emerald-500/20 text-emerald-400 border border-emerald-500/30"
+ : "bg-blue-500/20 text-blue-400 border border-blue-500/30"
}`}>
{viewingPost.status}
</span>
@@ -292,7 +327,7 @@ export default function WorkspaceDashboard() {
{viewingPost.description || "No description provided."}
</p>
{viewingPost.tags && (
- <p className="text-xs text-zinc-400 font-mono">
+ <p className="text-xs text-indigo-400 font-mono">
{viewingPost.tags.split(",").map(t => `#${t.trim()}`).join(" ")}
</p>
)}
@@ -334,7 +369,7 @@ export default function WorkspaceDashboard() {
<button
type="button"
onClick={() => handleEditPost(viewingPost)}
- className="px-3.5 py-1.5 rounded-lg text-xs font-medium text-zinc-950 bg-white hover:bg-zinc-200 transition-colors flex items-center gap-1.5 cursor-pointer"
+ className="px-3.5 py-1.5 rounded-lg text-xs font-semibold text-white bg-indigo-600 hover:bg-indigo-500 transition-colors flex items-center gap-1.5 cursor-pointer shadow-md shadow-indigo-600/25 active:scale-95"
>
<FiEdit2 /> Edit
</button>
@@ -351,10 +386,12 @@ export default function WorkspaceDashboard() {
setComposerOpen(false);
setSelectedDate(null);
setEditingPost(null);
+ setOpenWithAi(false);
}}
initialDate={selectedDate}
initialPost={editingPost}
onPostSaved={handlePostSaved}
+ initialOpenAiWriter={openWithAi}
/>
</div>
);
diff --git a/src/components/Navbar.js b/src/components/Navbar.js
index 4e5507f..73961d1 100644
--- a/src/components/Navbar.js
+++ b/src/components/Navbar.js
@@ -38,11 +38,11 @@ export default function Navbar() {
<div className="mx-auto flex max-w-7xl items-center justify-between px-4 py-4 sm:px-6 lg:px-8">
{/* Logo and Brand Title (Visible at all times) */}
- <Link href="/" className="flex items-center gap-2 transition-transform hover:scale-[1.02] active:scale-95">
- <div className="flex h-9 w-9 items-center justify-center rounded-lg bg-primary text-white font-extrabold text-lg shadow-md shadow-primary/30">
+ <Link href="/" className="flex items-center gap-2.5 transition-transform hover:scale-[1.02] active:scale-95">
+ <div className="flex h-9 w-9 items-center justify-center rounded-xl bg-gradient-to-br from-indigo-500 via-purple-600 to-pink-500 text-white font-extrabold text-lg shadow-md shadow-indigo-500/30">
{logoLetter}
</div>
- <span className="text-lg font-black tracking-tight text-primary-text text-nowrap">
+ <span className="text-lg font-black tracking-tight text-transparent bg-clip-text bg-gradient-to-r from-white via-zinc-100 to-indigo-300 text-nowrap">
{appName}
</span>
</Link>
@@ -56,12 +56,12 @@ export default function Navbar() {
key={link.name}
href={link.path}
className={`text-[13px] font-semibold transition-all relative py-1 ${
- isActive ? "text-primary" : "text-secondary-text hover:text-primary-text"
+ isActive ? "text-indigo-400 font-bold" : "text-zinc-400 hover:text-zinc-100"
}`}
>
{link.name}
{isActive && (
- <div className="absolute -bottom-[20px] left-0 right-0 h-0.5 bg-primary rounded-full" />
+ <div className="absolute -bottom-[20px] left-0 right-0 h-0.5 bg-indigo-500 rounded-full shadow-sm shadow-indigo-500/50" />
)}
</Link>
);
diff --git a/src/components/calendar/ContentCalendar.jsx b/src/components/calendar/ContentCalendar.jsx
index 8a372bf..9f46927 100644
--- a/src/components/calendar/ContentCalendar.jsx
+++ b/src/components/calendar/ContentCalendar.jsx
@@ -13,16 +13,59 @@ import {
FaCheckCircle,
FaExclamationCircle
} from "react-icons/fa";
-import { FaXTwitter } from "react-icons/fa6";
+import { FaXTwitter, FaThreads } from "react-icons/fa6";
import { SiTiktok } from "react-icons/si";
import { FiTrash2, FiEdit2, FiExternalLink, FiFilter } from "react-icons/fi";
const PLATFORM_CONFIG = {
- youtube: { name: "YouTube", Icon: FaYoutube, color: "text-red-500", bg: "bg-red-500/10 border-red-500/20" },
- tiktok: { name: "TikTok", Icon: SiTiktok, color: "text-cyan-400", bg: "bg-cyan-500/10 border-cyan-500/20" },
- instagram: { name: "Instagram", Icon: FaInstagram, color: "text-pink-500", bg: "bg-pink-500/10 border-pink-500/20" },
- x_twitter: { name: "X", Icon: FaXTwitter, color: "text-zinc-200", bg: "bg-zinc-700/20 border-zinc-600/20" },
- linkedin: { name: "LinkedIn", Icon: FaLinkedin, color: "text-sky-500", bg: "bg-sky-500/10 border-sky-500/20" },
+ youtube: {
+ name: "YouTube",
+ Icon: FaYoutube,
+ color: "text-red-500",
+ cardBg: "bg-red-500/[0.08] hover:bg-red-500/[0.14] border-red-500/30 hover:border-red-500/50",
+ borderAccent: "border-l-2 border-l-red-500",
+ activePill: "bg-red-500/20 text-red-400 border border-red-500/40 shadow-sm shadow-red-500/20"
+ },
+ tiktok: {
+ name: "TikTok",
+ Icon: SiTiktok,
+ color: "text-cyan-400",
+ cardBg: "bg-cyan-500/[0.08] hover:bg-cyan-500/[0.14] border-cyan-500/30 hover:border-cyan-500/50",
+ borderAccent: "border-l-2 border-l-cyan-400",
+ activePill: "bg-cyan-500/20 text-cyan-400 border border-cyan-500/40 shadow-sm shadow-cyan-500/20"
+ },
+ instagram: {
+ name: "Instagram",
+ Icon: FaInstagram,
+ color: "text-pink-500",
+ cardBg: "bg-pink-500/[0.08] hover:bg-pink-500/[0.14] border-pink-500/30 hover:border-pink-500/50",
+ borderAccent: "border-l-2 border-l-pink-500",
+ activePill: "bg-pink-500/20 text-pink-400 border border-pink-500/40 shadow-sm shadow-pink-500/20"
+ },
+ x_twitter: {
+ name: "X",
+ Icon: FaXTwitter,
+ color: "text-sky-400",
+ cardBg: "bg-sky-500/[0.08] hover:bg-sky-500/[0.14] border-sky-500/30 hover:border-sky-500/50",
+ borderAccent: "border-l-2 border-l-sky-400",
+ activePill: "bg-sky-500/20 text-sky-400 border border-sky-500/40 shadow-sm shadow-sky-500/20"
+ },
+ linkedin: {
+ name: "LinkedIn",
+ Icon: FaLinkedin,
+ color: "text-blue-500",
+ cardBg: "bg-blue-500/[0.08] hover:bg-blue-500/[0.14] border-blue-500/30 hover:border-blue-500/50",
+ borderAccent: "border-l-2 border-l-blue-500",
+ activePill: "bg-blue-500/20 text-blue-400 border border-blue-500/40 shadow-sm shadow-blue-500/20"
+ },
+ threads: {
+ name: "Threads",
+ Icon: FaThreads,
+ color: "text-purple-400",
+ cardBg: "bg-purple-500/[0.08] hover:bg-purple-500/[0.14] border-purple-500/30 hover:border-purple-500/50",
+ borderAccent: "border-l-2 border-l-purple-400",
+ activePill: "bg-purple-500/20 text-purple-400 border border-purple-500/40 shadow-sm shadow-purple-500/20"
+ },
};
export default function ContentCalendar({
@@ -190,8 +233,8 @@ export default function ContentCalendar({
{/* Right: Filters & View Toggle */}
<div className="flex items-center gap-2.5 flex-wrap sm:flex-nowrap justify-between sm:justify-end">
{/* Platform Filter Pills */}
- <div className="flex items-center gap-0.5 bg-zinc-900 p-0.5 rounded-lg border border-zinc-800 text-xs">
- {["all", "youtube", "tiktok", "instagram", "x_twitter", "linkedin"].map((platKey) => {
+ <div className="flex items-center gap-1 bg-zinc-900/90 p-1 rounded-lg border border-zinc-800 text-xs">
+ {["all", "youtube", "tiktok", "instagram", "x_twitter", "linkedin", "threads"].map((platKey) => {
const isActive = platformFilter === platKey;
const plat = PLATFORM_CONFIG[platKey];
const Icon = plat?.Icon;
@@ -200,13 +243,15 @@ export default function ContentCalendar({
key={platKey}
type="button"
onClick={() => setPlatformFilter(platKey)}
- className={`px-2 py-1 rounded text-[11px] font-medium transition-colors cursor-pointer flex items-center gap-1 ${
+ className={`px-2 py-1 rounded-md text-[11px] font-medium transition-all cursor-pointer flex items-center gap-1.5 ${
isActive
- ? "bg-zinc-800 text-white"
- : "text-zinc-400 hover:text-zinc-200"
+ ? platKey === "all"
+ ? "bg-indigo-600 text-white shadow-sm shadow-indigo-500/30 font-semibold"
+ : plat?.activePill || "bg-zinc-800 text-white"
+ : "text-zinc-400 hover:text-zinc-200 hover:bg-zinc-800/50"
}`}
>
- {Icon && <Icon className={`text-[10px] ${plat.color}`} />}
+ {Icon && <Icon className={`text-[11px] ${isActive ? "text-current" : plat.color}`} />}
<span className="capitalize">{platKey === "x_twitter" ? "X" : platKey}</span>
</button>
);
@@ -214,12 +259,14 @@ export default function ContentCalendar({
</div>
{/* View Mode (Month / Week) */}
- <div className="flex items-center bg-zinc-900 p-0.5 rounded-lg border border-zinc-800 text-xs">
+ <div className="flex items-center bg-zinc-900/90 p-1 rounded-lg border border-zinc-800 text-xs">
<button
type="button"
onClick={() => setViewMode("month")}
- className={`px-2.5 py-1 rounded text-xs font-medium transition-colors cursor-pointer ${
- viewMode === "month" ? "bg-zinc-800 text-white" : "text-zinc-400 hover:text-white"
+ className={`px-2.5 py-1 rounded-md text-xs font-medium transition-all cursor-pointer ${
+ viewMode === "month"
+ ? "bg-indigo-600 text-white shadow-sm shadow-indigo-500/25 font-semibold"
+ : "text-zinc-400 hover:text-white"
}`}
>
Month
@@ -227,8 +274,10 @@ export default function ContentCalendar({
<button
type="button"
onClick={() => setViewMode("week")}
- className={`px-2.5 py-1 rounded text-xs font-medium transition-colors cursor-pointer ${
- viewMode === "week" ? "bg-zinc-800 text-white" : "text-zinc-400 hover:text-white"
+ className={`px-2.5 py-1 rounded-md text-xs font-medium transition-all cursor-pointer ${
+ viewMode === "week"
+ ? "bg-indigo-600 text-white shadow-sm shadow-indigo-500/25 font-semibold"
+ : "text-zinc-400 hover:text-white"
}`}
>
Week
@@ -241,7 +290,7 @@ export default function ContentCalendar({
{viewMode === "month" && (
<div className="flex flex-col">
{/* Day of Week Header */}
- <div className="grid grid-cols-7 border-b border-zinc-800/60 bg-zinc-900/30 text-center py-2 text-xs font-medium text-zinc-400">
+ <div className="grid grid-cols-7 border-b border-zinc-800/60 bg-zinc-900/50 text-center py-2 text-xs font-semibold text-zinc-400">
<span>Mon</span>
<span>Tue</span>
<span>Wed</span>
@@ -252,7 +301,7 @@ export default function ContentCalendar({
</div>
{/* Calendar Grid */}
- <div className="grid grid-cols-7 divide-x divide-y divide-zinc-800/50 bg-zinc-950">
+ <div className="grid grid-cols-7 divide-x divide-y divide-zinc-800/60 bg-zinc-950">
{calendarDays.map((item, idx) => {
const dayPosts = getPostsForDay(item.date);
const isToday = isSameDay(item.date, today);
@@ -263,18 +312,18 @@ export default function ContentCalendar({
onClick={() => onDateClick(item.date)}
className={`min-h-[105px] sm:min-h-[120px] p-2 flex flex-col justify-between group transition-colors cursor-pointer relative ${
item.isCurrentMonth
- ? "bg-transparent hover:bg-zinc-900/40"
+ ? "bg-transparent hover:bg-zinc-900/50"
: "bg-zinc-950/80 text-zinc-600 hover:bg-zinc-900/30"
- } ${isToday ? "ring-1 ring-inset ring-blue-500/30 bg-blue-500/[0.02]" : ""}`}
+ } ${isToday ? "ring-1 ring-inset ring-indigo-500/40 bg-indigo-500/[0.04]" : ""}`}
>
{/* Top Bar inside Date Cell */}
<div className="flex items-center justify-between mb-1">
<span
className={`text-xs w-5 h-5 flex items-center justify-center rounded-full ${
isToday
- ? "bg-zinc-100 text-zinc-950 font-semibold"
+ ? "bg-indigo-600 text-white font-bold shadow-md shadow-indigo-500/40"
: item.isCurrentMonth
- ? "text-zinc-400"
+ ? "text-zinc-300 font-medium"
: "text-zinc-600"
}`}
>
@@ -288,7 +337,7 @@ export default function ContentCalendar({
e.stopPropagation();
onDateClick(item.date);
}}
- className="opacity-0 group-hover:opacity-100 w-4 h-4 rounded bg-zinc-800 hover:bg-zinc-700 text-zinc-400 hover:text-white flex items-center justify-center transition-all cursor-pointer"
+ className="opacity-0 group-hover:opacity-100 w-4 h-4 rounded bg-indigo-600/30 hover:bg-indigo-600 text-indigo-300 hover:text-white flex items-center justify-center transition-all cursor-pointer shadow-sm"
title="Add post for this day"
>
<FaPlus className="text-[8px]" />
@@ -310,14 +359,14 @@ export default function ContentCalendar({
e.stopPropagation();
onPostClick(post);
}}
- className="p-1 px-1.5 rounded border border-zinc-800 bg-zinc-900/60 hover:border-zinc-700 flex items-center gap-1.5 text-xs transition-colors cursor-pointer"
+ className={`p-1 px-1.5 rounded-md border ${plat.borderAccent} ${plat.cardBg} flex items-center gap-1.5 text-xs transition-all cursor-pointer shadow-sm`}
>
- <Icon className={`text-[10px] shrink-0 ${plat.color}`} />
+ <Icon className={`text-[11px] shrink-0 ${plat.color}`} />
<div className="flex-1 min-w-0">
- <p className="text-[11px] font-medium text-zinc-300 truncate leading-none">
+ <p className="text-[11px] font-medium text-zinc-200 truncate leading-none">
{post.title || "Scheduled Post"}
</p>
- <span className="text-[9px] text-zinc-500 flex items-center gap-1 mt-0.5 font-mono">
+ <span className="text-[9px] text-zinc-400 flex items-center gap-1 mt-0.5 font-mono">
<FaClock className="text-[7px]" />
{formatTime(post.scheduledAt)}
</span>
@@ -327,10 +376,10 @@ export default function ContentCalendar({
<span
className={`w-1.5 h-1.5 rounded-full shrink-0 ${
isCompleted
- ? "bg-emerald-400"
+ ? "bg-emerald-400 shadow-sm shadow-emerald-400/50"
: isScheduled
- ? "bg-blue-400"
- : "bg-amber-400"
+ ? "bg-blue-400 shadow-sm shadow-blue-400/50"
+ : "bg-amber-400 shadow-sm shadow-amber-400/50"
}`}
title={post.status}
/>
@@ -349,20 +398,22 @@ export default function ContentCalendar({
{viewMode === "week" && (
<div className="flex flex-col">
{/* Week Day Header */}
- <div className="grid grid-cols-7 border-b border-zinc-800/60 bg-zinc-900/30 divide-x divide-zinc-800/50">
+ <div className="grid grid-cols-7 border-b border-zinc-800/60 bg-zinc-900/50 divide-x divide-zinc-800/50">
{weekDays.map((d, i) => {
const isToday = isSameDay(d, today);
return (
<div
key={i}
- className={`p-2.5 text-center ${isToday ? "bg-zinc-900/50" : ""}`}
+ className={`p-2.5 text-center ${isToday ? "bg-indigo-500/[0.08]" : ""}`}
>
- <span className="text-[11px] font-medium uppercase tracking-wider text-zinc-500 block">
+ <span className={`text-[11px] font-semibold uppercase tracking-wider block ${
+ isToday ? "text-indigo-400" : "text-zinc-400"
+ }`}>
{d.toLocaleDateString("en-US", { weekday: "short" })}
</span>
<span
- className={`text-sm font-semibold mt-0.5 inline-block w-6 h-6 leading-6 rounded-full ${
- isToday ? "bg-zinc-100 text-zinc-950" : "text-zinc-300"
+ className={`text-sm font-bold mt-0.5 inline-block w-6 h-6 leading-6 rounded-full ${
+ isToday ? "bg-indigo-600 text-white shadow-md shadow-indigo-500/40" : "text-zinc-200"
}`}
>
{d.getDate()}
@@ -380,12 +431,12 @@ export default function ContentCalendar({
<div
key={i}
onClick={() => onDateClick(d)}
- className="p-2 space-y-1.5 hover:bg-zinc-900/30 transition-colors cursor-pointer"
+ className="p-2 space-y-1.5 hover:bg-zinc-900/40 transition-colors cursor-pointer"
>
{dayPosts.length === 0 ? (
- <div className="h-full flex flex-col items-center justify-center text-center opacity-30 hover:opacity-80 py-10 transition-opacity">
- <FaPlus className="text-zinc-600 text-xs mb-1" />
- <span className="text-[10px] text-zinc-500 font-medium">
+ <div className="h-full flex flex-col items-center justify-center text-center opacity-30 hover:opacity-100 py-10 transition-opacity">
+ <FaPlus className="text-zinc-500 text-xs mb-1" />
+ <span className="text-[10px] text-zinc-400 font-medium">
Add post
</span>
</div>
@@ -401,19 +452,19 @@ export default function ContentCalendar({
e.stopPropagation();
onPostClick(post);
}}
- className="p-2 rounded-lg border border-zinc-800 bg-zinc-900/60 hover:border-zinc-700 space-y-1 transition-colors"
+ className={`p-2 rounded-lg border ${plat.borderAccent} ${plat.cardBg} space-y-1.5 transition-all shadow-sm`}
>
<div className="flex items-center justify-between">
- <span className="flex items-center gap-1 text-[10px] font-medium text-zinc-300">
+ <span className="flex items-center gap-1.5 text-[10px] font-semibold text-zinc-200">
<Icon className={plat.color} />
{plat.name}
</span>
- <span className="text-[9px] font-mono text-zinc-500">
+ <span className="text-[9px] font-mono text-zinc-300 px-1.5 py-0.5 rounded bg-black/40 border border-white/5">
{formatTime(post.scheduledAt)}
</span>
</div>
- <h5 className="text-[11px] font-medium text-zinc-200 line-clamp-2 leading-snug">
+ <h5 className="text-[11px] font-medium text-zinc-100 line-clamp-2 leading-snug">
{post.title || "Scheduled Post"}
</h5>
@@ -426,6 +477,16 @@ export default function ContentCalendar({
/>
</div>
)}
+
+ <div className="flex items-center justify-between pt-0.5">
+ <span className={`text-[9px] font-medium px-1.5 py-0.5 rounded-full capitalize ${
+ post.status === "completed"
+ ? "bg-emerald-500/20 text-emerald-300 border border-emerald-500/30"
+ : "bg-blue-500/20 text-blue-300 border border-blue-500/30"
+ }`}>
+ {post.status}
+ </span>
+ </div>
</div>
);
})
diff --git a/src/components/composer/AiPostWriter.jsx b/src/components/composer/AiPostWriter.jsx
new file mode 100644
index 0000000..f0cfed5
--- /dev/null
+++ b/src/components/composer/AiPostWriter.jsx
@@ -0,0 +1,246 @@
+"use client";
+
+import { useState } from "react";
+import { FaMagic, FaCheck, FaSync } from "react-icons/fa";
+import { FiX, FiAlertCircle, FiCornerDownLeft } from "react-icons/fi";
+
+const TONES = [
+ "Engaging",
+ "Professional",
+ "Casual",
+ "Excited",
+ "Educational",
+ "Viral",
+ "Storytelling"
+];
+
+export default function AiPostWriter({
+ platform = "youtube",
+ onApply,
+ onClose,
+}) {
+ const [prompt, setPrompt] = useState("");
+ const [selectedTone, setSelectedTone] = useState("Engaging");
+ const [loading, setLoading] = useState(false);
+ const [error, setError] = useState("");
+ const [generatedResult, setGeneratedResult] = useState(null);
+
+ const handleGenerate = async () => {
+ if (!prompt.trim()) {
+ setError("Please enter a topic or instruction for your post.");
+ return;
+ }
+
+ setLoading(true);
+ setError("");
+
+ try {
+ const res = await fetch("/api/ai/generate", {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({
+ prompt: prompt.trim(),
+ platform,
+ tone: selectedTone,
+ }),
+ });
+
+ const data = await res.json();
+
+ if (!res.ok) {
+ throw new Error(data.error || "Failed to generate post with AI.");
+ }
+
+ setGeneratedResult(data.data);
+ } catch (err) {
+ setError(err.message || "Failed to connect to AI generation service.");
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ const handlePrefill = () => {
+ if (!generatedResult) return;
+ onApply(generatedResult);
+ };
+
+ return (
+ <div className="bg-gradient-to-b from-violet-950/20 via-zinc-900/70 to-zinc-900/90 border border-violet-500/30 rounded-xl p-4 space-y-3.5 text-xs text-zinc-100 shadow-xl shadow-violet-950/20 animate-fade-in">
+ {/* Header */}
+ <div className="flex items-center justify-between pb-2.5 border-b border-violet-500/20">
+ <div className="flex items-center gap-2">
+ <div className="w-6 h-6 rounded-lg bg-gradient-to-br from-violet-500 via-purple-600 to-indigo-600 text-white flex items-center justify-center shadow-md shadow-violet-500/30">
+ <FaMagic className="text-[11px]" />
+ </div>
+ <span className="font-semibold text-zinc-100">
+ Write with AI <span className="text-[10px] text-violet-300 font-mono font-normal">(gpt-5-mini)</span>
+ </span>
+ <span className={`px-2 py-0.5 rounded text-[10px] uppercase font-semibold ${
+ platform === "youtube" ? "bg-red-500/20 text-red-400 border border-red-500/30" :
+ platform === "instagram" ? "bg-pink-500/20 text-pink-400 border border-pink-500/30" :
+ platform === "tiktok" ? "bg-cyan-500/20 text-cyan-400 border border-cyan-500/30" :
+ platform === "linkedin" ? "bg-blue-500/20 text-blue-400 border border-blue-500/30" :
+ platform === "threads" ? "bg-purple-500/20 text-purple-400 border border-purple-500/30" :
+ "bg-sky-500/20 text-sky-400 border border-sky-500/30"
+ }`}>
+ {platform.replace("_", " ")}
+ </span>
+ </div>
+
+ {onClose && (
+ <button
+ type="button"
+ onClick={onClose}
+ className="text-zinc-500 hover:text-zinc-300 transition-colors cursor-pointer"
+ title="Close AI Assistant"
+ >
+ <FiX className="text-sm" />
+ </button>
+ )}
+ </div>
+
+ {error && (
+ <div className="p-2.5 bg-red-500/10 border border-red-500/30 rounded-lg text-[11px] text-red-400 flex items-center gap-1.5">
+ <FiAlertCircle className="text-xs shrink-0" />
+ <span>{error}</span>
+ </div>
+ )}
+
+ {/* Prompt Input */}
+ <div className="space-y-1">
+ <label className="text-[11px] font-medium text-zinc-300 block">
+ What is your post about?
+ </label>
+ <textarea
+ value={prompt}
+ onChange={(e) => setPrompt(e.target.value)}
+ rows={2}
+ placeholder="e.g. Announce our new AI scheduling tool with key benefits, or share 3 productivity tips for creators..."
+ className="w-full bg-zinc-950/80 border border-zinc-800 rounded-lg p-2.5 text-xs text-zinc-100 placeholder-zinc-500 focus:outline-none focus:border-violet-500/60 focus:ring-1 focus:ring-violet-500/30 resize-none transition-all leading-relaxed"
+ onKeyDown={(e) => {
+ if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
+ handleGenerate();
+ }
+ }}
+ />
+ </div>
+
+ {/* Tone Selection */}
+ <div className="space-y-1.5">
+ <label className="text-[11px] font-medium text-zinc-300 block">
+ Tone of Voice
+ </label>
+ <div className="flex items-center gap-1.5 flex-wrap">
+ {TONES.map((tone) => (
+ <button
+ key={tone}
+ type="button"
+ onClick={() => setSelectedTone(tone)}
+ className={`px-2.5 py-1 rounded-md text-[11px] font-medium transition-all cursor-pointer ${
+ selectedTone === tone
+ ? "bg-gradient-to-r from-violet-600 to-indigo-600 text-white shadow-sm shadow-violet-500/30 border border-violet-400/40 font-semibold"
+ : "bg-zinc-900/80 border border-zinc-800 text-zinc-400 hover:text-zinc-200 hover:border-violet-500/30"
+ }`}
+ >
+ {tone}
+ </button>
+ ))}
+ </div>
+ </div>
+
+ {/* Generate Action Button */}
+ <div className="flex items-center justify-between pt-1">
+ <span className="text-[10px] text-zinc-500">
+ Press <kbd className="px-1 py-0.5 rounded bg-zinc-800 border border-zinc-700 font-mono text-[9px] text-zinc-400">Ctrl+Enter</kbd> to generate
+ </span>
+
+ <button
+ type="button"
+ disabled={loading}
+ onClick={handleGenerate}
+ className="px-4 py-1.5 rounded-lg text-xs font-semibold text-white bg-gradient-to-r from-violet-600 via-purple-600 to-indigo-600 hover:from-violet-500 hover:to-indigo-500 transition-all flex items-center gap-1.5 cursor-pointer shadow-md shadow-violet-500/30 active:scale-95 disabled:opacity-50"
+ >
+ {loading ? (
+ <>
+ <div className="w-3 h-3 border-2 border-white border-t-transparent rounded-full animate-spin" />
+ <span>Generating with gpt-5-mini...</span>
+ </>
+ ) : (
+ <>
+ <FaMagic className="text-[10px] text-amber-300" />
+ <span>Generate Post</span>
+ </>
+ )}
+ </button>
+ </div>
+
+ {/* Generated Result Preview */}
+ {generatedResult && (
+ <div className="mt-3 p-3.5 rounded-lg bg-zinc-950/90 border border-violet-500/30 space-y-2.5 animate-fade-in shadow-inner">
+ <div className="flex items-center justify-between border-b border-zinc-800/80 pb-2">
+ <span className="text-[11px] font-semibold text-violet-300 flex items-center gap-1">
+ <FaMagic className="text-[10px]" /> Generated Suggestion
+ </span>
+ <div className="flex items-center gap-1.5">
+ <button
+ type="button"
+ onClick={handleGenerate}
+ disabled={loading}
+ className="text-[11px] text-zinc-400 hover:text-white flex items-center gap-1 transition-colors cursor-pointer"
+ title="Regenerate"
+ >
+ <FaSync className={`text-[9px] ${loading ? "animate-spin text-violet-400" : ""}`} />
+ <span>Retry</span>
+ </button>
+ </div>
+ </div>
+
+ <div className="space-y-2 text-zinc-300">
+ {generatedResult.title && (
+ <div>
+ <span className="text-[10px] font-medium text-zinc-500 block uppercase tracking-wide">
+ Title
+ </span>
+ <p className="font-semibold text-zinc-100 text-xs">
+ {generatedResult.title}
+ </p>
+ </div>
+ )}
+
+ <div>
+ <span className="text-[10px] font-medium text-zinc-500 block uppercase tracking-wide">
+ Caption
+ </span>
+ <p className="text-zinc-200 text-xs whitespace-pre-line leading-relaxed max-h-36 overflow-y-auto pr-1">
+ {generatedResult.description}
+ </p>
+ </div>
+
+ {generatedResult.tags && (
+ <div>
+ <span className="text-[10px] font-medium text-zinc-500 block uppercase tracking-wide">
+ Tags
+ </span>
+ <p className="text-indigo-400 text-[11px] font-mono">
+ {generatedResult.tags}
+ </p>
+ </div>
+ )}
+ </div>
+
+ {/* Prefill Button */}
+ <div className="pt-2 flex justify-end">
+ <button
+ type="button"
+ onClick={handlePrefill}
+ className="px-4 py-1.5 rounded-lg text-xs font-semibold text-white bg-gradient-to-r from-emerald-600 to-teal-600 hover:from-emerald-500 hover:to-teal-500 transition-all flex items-center gap-1.5 cursor-pointer shadow-md shadow-emerald-500/25 active:scale-95"
+ >
+ <FaCheck className="text-[10px]" />
+ <span>Prefill into Composer</span>
+ </button>
+ </div>
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/src/components/composer/LiveDevicePreview.jsx b/src/components/composer/LiveDevicePreview.jsx
index 1bed4a9..92769df 100644
--- a/src/components/composer/LiveDevicePreview.jsx
+++ b/src/components/composer/LiveDevicePreview.jsx
@@ -34,11 +34,12 @@ export default function LiveDevicePreview({
const handle = "@" + displayAccount.toLowerCase().replace(/[^a-z0-9_]/g, "");
const previewTabs = [
- { key: "youtube", name: "YouTube", Icon: FaYoutube, color: "text-red-500" },
- { key: "tiktok", name: "TikTok", Icon: SiTiktok, color: "text-cyan-400" },
- { key: "instagram", name: "Instagram", Icon: FaInstagram, color: "text-pink-500" },
- { key: "x_twitter", name: "X", Icon: FaXTwitter, color: "text-zinc-200" },
- { key: "linkedin", name: "LinkedIn", Icon: FaLinkedin, color: "text-sky-500" },
+ { key: "youtube", name: "YouTube", Icon: FaYoutube, color: "text-red-500", activeStyle: "bg-red-500/20 text-red-400 border border-red-500/40 shadow-sm shadow-red-500/20" },
+ { key: "tiktok", name: "TikTok", Icon: SiTiktok, color: "text-cyan-400", activeStyle: "bg-cyan-500/20 text-cyan-400 border border-cyan-500/40 shadow-sm shadow-cyan-500/20" },
+ { key: "instagram", name: "Instagram", Icon: FaInstagram, color: "text-pink-500", activeStyle: "bg-pink-500/20 text-pink-400 border border-pink-500/40 shadow-sm shadow-pink-500/20" },
+ { key: "x_twitter", name: "X", Icon: FaXTwitter, color: "text-sky-400", activeStyle: "bg-sky-500/20 text-sky-400 border border-sky-500/40 shadow-sm shadow-sky-500/20" },
+ { key: "linkedin", name: "LinkedIn", Icon: FaLinkedin, color: "text-blue-500", activeStyle: "bg-blue-500/20 text-blue-400 border border-blue-500/40 shadow-sm shadow-blue-500/20" },
+ { key: "threads", name: "Threads", Icon: FaThreads, color: "text-purple-400", activeStyle: "bg-purple-500/20 text-purple-400 border border-purple-500/40 shadow-sm shadow-purple-500/20" },
];
return (
@@ -46,12 +47,12 @@ export default function LiveDevicePreview({
{/* Header & Platform Switcher Tabs */}
<div className="flex flex-col sm:flex-row sm:items-center justify-between pb-3 mb-3 border-b border-zinc-800/80 gap-2">
<div className="flex items-center gap-2">
- <span className="w-1.5 h-1.5 rounded-full bg-emerald-400" />
- <span className="text-[11px] font-medium text-zinc-400">
- Feed Preview
+ <span className="w-2 h-2 rounded-full bg-emerald-400 shadow-sm shadow-emerald-400/50 animate-pulse" />
+ <span className="text-[11px] font-semibold text-zinc-300">
+ Live Feed Mockup
</span>
</div>
- <div className="flex items-center gap-1 bg-zinc-900/80 p-0.5 rounded-lg border border-zinc-800 flex-wrap">
+ <div className="flex items-center gap-1 bg-zinc-900/90 p-1 rounded-lg border border-zinc-800 flex-wrap">
{previewTabs.map((tab) => {
const Icon = tab.Icon;
const isActive = activePreviewTab === tab.key;
@@ -60,14 +61,14 @@ export default function LiveDevicePreview({
key={tab.key}
type="button"
onClick={() => setActivePreviewTab(tab.key)}
- className={`p-1 px-2 rounded-md text-[11px] font-medium flex items-center gap-1 transition-colors cursor-pointer ${
+ className={`p-1 px-2 rounded-md text-[11px] font-medium flex items-center gap-1.5 transition-all cursor-pointer ${
isActive
- ? "bg-zinc-800 text-zinc-100"
- : "text-zinc-400 hover:text-zinc-200"
+ ? tab.activeStyle
+ : "text-zinc-400 hover:text-zinc-200 hover:bg-zinc-800/50"
}`}
title={`Preview on ${tab.name}`}
>
- <Icon className={`text-xs ${tab.color}`} />
+ <Icon className={`text-xs ${isActive ? "text-current" : tab.color}`} />
<span>{tab.name}</span>
</button>
);
diff --git a/src/components/composer/PostComposerModal.jsx b/src/components/composer/PostComposerModal.jsx
index 6c2f2ec..849054f 100644
--- a/src/components/composer/PostComposerModal.jsx
+++ b/src/components/composer/PostComposerModal.jsx
@@ -25,14 +25,15 @@ import {
FiInfo
} from "react-icons/fi";
import LiveDevicePreview from "./LiveDevicePreview";
+import AiPostWriter from "./AiPostWriter";
const PLATFORMS = [
- { key: "youtube", name: "YouTube", Icon: FaYoutube, color: "text-red-500", bg: "bg-red-500/10 border-red-500/30", limit: 5000 },
- { key: "tiktok", name: "TikTok", Icon: SiTiktok, color: "text-cyan-400", bg: "bg-cyan-500/10 border-cyan-500/30", limit: 2200 },
- { key: "instagram", name: "Instagram", Icon: FaInstagram, color: "text-pink-500", bg: "bg-pink-500/10 border-pink-500/30", limit: 2200 },
- { key: "x_twitter", name: "X (Twitter)", Icon: FaXTwitter, color: "text-zinc-200", bg: "bg-zinc-700/20 border-zinc-600/30", limit: 280 },
- { key: "linkedin", name: "LinkedIn", Icon: FaLinkedin, color: "text-sky-500", bg: "bg-sky-500/10 border-sky-500/30", limit: 3000 },
- { key: "threads", name: "Threads", Icon: FaThreads, color: "text-zinc-300", bg: "bg-zinc-700/20 border-zinc-600/30", limit: 500 },
+ { key: "youtube", name: "YouTube", Icon: FaYoutube, color: "text-red-500", activeStyle: "bg-red-500/15 border-red-500/60 text-white shadow-sm shadow-red-500/20", limit: 5000 },
+ { key: "tiktok", name: "TikTok", Icon: SiTiktok, color: "text-cyan-400", activeStyle: "bg-cyan-500/15 border-cyan-400/60 text-white shadow-sm shadow-cyan-500/20", limit: 2200 },
+ { key: "instagram", name: "Instagram", Icon: FaInstagram, color: "text-pink-500", activeStyle: "bg-pink-500/15 border-pink-500/60 text-white shadow-sm shadow-pink-500/20", limit: 2200 },
+ { key: "x_twitter", name: "X (Twitter)", Icon: FaXTwitter, color: "text-sky-400", activeStyle: "bg-sky-500/15 border-sky-400/60 text-white shadow-sm shadow-sky-500/20", limit: 280 },
+ { key: "linkedin", name: "LinkedIn", Icon: FaLinkedin, color: "text-blue-500", activeStyle: "bg-blue-500/15 border-blue-500/60 text-white shadow-sm shadow-blue-500/20", limit: 3000 },
+ { key: "threads", name: "Threads", Icon: FaThreads, color: "text-purple-400", activeStyle: "bg-purple-500/15 border-purple-400/60 text-white shadow-sm shadow-purple-500/20", limit: 500 },
];
const YOUTUBE_CATEGORIES = [
@@ -54,6 +55,7 @@ export default function PostComposerModal({
onClose,
initialDate = null,
initialPost = null,
+ initialOpenAiWriter = false,
onPostSaved,
}) {
const [selectedPlatform, setSelectedPlatform] = useState("youtube");
@@ -83,9 +85,16 @@ export default function PostComposerModal({
const [uploading, setUploading] = useState(false);
const [submitting, setSubmitting] = useState(false);
const [advancedOpen, setAdvancedOpen] = useState(false);
+ const [aiWriterOpen, setAiWriterOpen] = useState(false);
const [errorMsg, setErrorMsg] = useState("");
const fileInputRef = useRef(null);
+ useEffect(() => {
+ if (initialOpenAiWriter) {
+ setAiWriterOpen(true);
+ }
+ }, [initialOpenAiWriter, isOpen]);
+
useEffect(() => {
if (initialPost) {
setSelectedPlatform(initialPost.platform || "youtube");
@@ -115,6 +124,14 @@ export default function PostComposerModal({
}
}, [initialDate, initialPost, isOpen]);
+ const handleApplyAiContent = ({ title: newTitle, description: newDescription, tags: newTags }) => {
+ if (newTitle) setTitle(newTitle);
+ if (newDescription) setDescription(newDescription);
+ if (newTags) setTags(newTags);
+ setAiWriterOpen(false);
+ };
+
+
if (!isOpen) return null;
const currentPlatformInfo = PLATFORMS.find(p => p.key === selectedPlatform) || PLATFORMS[0];
@@ -231,19 +248,42 @@ export default function PostComposerModal({
Multi-channel scheduling with live preview
</p>
</div>
- <button
- type="button"
- onClick={onClose}
- className="w-7 h-7 rounded-md hover:bg-zinc-900 text-zinc-400 hover:text-zinc-200 flex items-center justify-center transition-colors cursor-pointer"
- >
- <FiX className="text-sm" />
- </button>
+ <div className="flex items-center gap-2">
+ <button
+ type="button"
+ onClick={() => setAiWriterOpen(!aiWriterOpen)}
+ className={`px-3 py-1 rounded-lg text-xs font-semibold transition-all flex items-center gap-1.5 cursor-pointer border ${
+ aiWriterOpen
+ ? "bg-gradient-to-r from-violet-600 to-indigo-600 text-white border-violet-400/40 shadow-md shadow-violet-500/30"
+ : "bg-gradient-to-r from-violet-600/15 to-indigo-600/15 text-violet-300 border-violet-500/30 hover:border-violet-500/60 hover:text-white"
+ }`}
+ >
+ <FaMagic className="text-[10px] text-amber-300" />
+ <span>Write with AI</span>
+ </button>
+ <button
+ type="button"
+ onClick={onClose}
+ className="w-7 h-7 rounded-md hover:bg-zinc-900 text-zinc-400 hover:text-zinc-200 flex items-center justify-center transition-colors cursor-pointer"
+ >
+ <FiX className="text-sm" />
+ </button>
+ </div>
</div>
{/* Modal Main Content - 2 Column Split */}
<div className="flex-1 grid grid-cols-1 lg:grid-cols-12 overflow-hidden divide-y lg:divide-y-0 lg:divide-x divide-zinc-800">
{/* LEFT COLUMN: Composer Form (7 cols) */}
<div className="lg:col-span-7 p-5 space-y-4 overflow-y-auto overflow-x-hidden max-h-[calc(88vh-110px)]">
+ {/* AI Post Writer Assistant (Collapsible) */}
+ {aiWriterOpen && (
+ <AiPostWriter
+ platform={selectedPlatform}
+ onApply={handleApplyAiContent}
+ onClose={() => setAiWriterOpen(false)}
+ />
+ )}
+
{errorMsg && (
<div className="p-2.5 bg-red-500/10 border border-red-500/20 rounded-lg text-xs text-red-400 flex items-center gap-2">
<FiInfo className="text-sm shrink-0" />
@@ -265,14 +305,14 @@ export default function PostComposerModal({
key={plat.key}
type="button"
onClick={() => setSelectedPlatform(plat.key)}
- className={`p-1.5 px-2 rounded-lg border flex items-center justify-center gap-1.5 transition-colors cursor-pointer ${
+ className={`p-1.5 px-2 rounded-lg border flex items-center justify-center gap-1.5 transition-all cursor-pointer ${
isSelected
- ? "border-zinc-600 bg-zinc-800 text-zinc-100 font-medium"
+ ? plat.activeStyle
: "border-zinc-800/80 bg-zinc-900/40 text-zinc-400 hover:border-zinc-700 hover:text-zinc-200"
}`}
>
- <Icon className={`text-xs ${plat.color}`} />
- <span className="text-[11px] truncate">
+ <Icon className={`text-xs ${isSelected ? "text-current" : plat.color}`} />
+ <span className="text-[11px] truncate font-medium">
{plat.name}
</span>
</button>
@@ -298,9 +338,22 @@ export default function PostComposerModal({
{/* Caption & Content */}
<div className="space-y-1.5">
<div className="flex items-center justify-between">
- <label className="text-xs font-medium text-zinc-400">
- Caption & Details
- </label>
+ <div className="flex items-center gap-2">
+ <label className="text-xs font-medium text-zinc-400">
+ Caption & Details
+ </label>
+ {!aiWriterOpen && (
+ <button
+ type="button"
+ onClick={() => setAiWriterOpen(true)}
+ className="text-[11px] text-violet-400 hover:text-violet-300 font-medium flex items-center gap-1 transition-colors cursor-pointer"
+ title="Write post with AI"
+ >
+ <FaMagic className="text-[9px] text-amber-300" />
+ <span>Write with AI</span>
+ </button>
+ )}
+ </div>
<span className={`text-[11px] font-mono ${currentChars > charLimit ? "text-red-400 font-semibold" : "text-zinc-500"}`}>
{currentChars} / {charLimit}
</span>
@@ -315,15 +368,15 @@ export default function PostComposerModal({
{/* Hashtag Quick Chips */}
<div className="flex items-center gap-1.5 flex-wrap pt-0.5">
- <span className="text-[11px] text-zinc-500 flex items-center gap-1 mr-1">
- <FaMagic className="text-zinc-400 text-[10px]" /> Tags:
+ <span className="text-[11px] text-zinc-400 flex items-center gap-1 mr-1 font-medium">
+ <FaMagic className="text-violet-400 text-[10px]" /> Tags:
</span>
{POPULAR_HASHTAGS.map((tag) => (
<button
key={tag}
type="button"
onClick={() => addHashtag(tag)}
- className="px-2 py-0.5 rounded bg-zinc-900 hover:bg-zinc-800 border border-zinc-800 text-[11px] text-zinc-400 hover:text-zinc-200 transition-colors cursor-pointer font-mono"
+ className="px-2 py-0.5 rounded bg-zinc-900/80 hover:bg-indigo-500/10 border border-zinc-800 hover:border-indigo-500/40 text-[11px] text-zinc-400 hover:text-indigo-300 transition-all cursor-pointer font-mono"
>
{tag}
</button>
@@ -586,11 +639,11 @@ export default function PostComposerModal({
type="button"
disabled={submitting}
onClick={() => handleSubmit()}
- className="px-4 py-1.5 rounded-lg text-xs font-medium text-zinc-950 bg-white hover:bg-zinc-200 transition-colors cursor-pointer flex items-center gap-1.5 shadow-sm"
+ className="px-4 py-1.5 rounded-lg text-xs font-semibold text-white bg-gradient-to-r from-indigo-600 to-blue-600 hover:from-indigo-500 hover:to-blue-500 transition-all cursor-pointer flex items-center gap-1.5 shadow-md shadow-indigo-500/25 active:scale-95 disabled:opacity-50"
>
{submitting ? (
<>
- <div className="w-3 h-3 border-2 border-zinc-950 border-t-transparent rounded-full animate-spin" />
+ <div className="w-3 h-3 border-2 border-white border-t-transparent rounded-full animate-spin" />
<span>Saving...</span>
</>
) : (