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.
JavaScript ai-appsai-image-generatorai-saasai-toolsai-video-generatorawesomeawesome-listgenerative-aigenerative-ai-appsimage-generationnextjsnextjs-boilerplateopen-sourceopen-source-aisaas-boilerplatesaas-templateseedance2text-to-imagetext-to-videovideo-generation
feat: integrate all 8 social platforms with unified connect, account management, and mockups
jaiprasad04857c932a0fa8
diff --git a/src/app/api/posts/route.js b/src/app/api/posts/route.jsindex 6cb3c4a..b302e06 100644--- a/src/app/api/posts/route.js+++ b/src/app/api/posts/route.js@@ -9,29 +9,63 @@ import { DemoStore } from "@/lib/demo-store";// Helper function to call the MuAPI publishing endpointsasync function triggerMuApiPublish(platform, payload) {const apiKey = config.ai.apiKey;- const endpoint = platform === "youtube"- ? "https://api.muapi.ai/api/v1/youtube-publish"- : "https://api.muapi.ai/api/v1/tiktok-publish";+ const plat = (platform || "").toLowerCase().replace("x_twitter", "x");++ const endpointMap = {+ youtube: "https://api.muapi.ai/api/v1/youtube-publish",+ tiktok: "https://api.muapi.ai/api/v1/tiktok-publish",+ instagram: "https://api.muapi.ai/api/v1/instagram-publish",+ x: "https://api.muapi.ai/api/v1/x-publish",+ facebook: "https://api.muapi.ai/api/v1/facebook-publish",+ linkedin: "https://api.muapi.ai/api/v1/linkedin-publish",+ threads: "https://api.muapi.ai/api/v1/threads-publish",+ pinterest: "https://api.muapi.ai/api/v1/pinterest-publish",+ };++ const endpoint = endpointMap[plat] || endpointMap.youtube;++ const captionText = [+ payload.title,+ payload.description,+ payload.tags ? payload.tags.split(",").map(t => t.trim().startsWith("#") ? t.trim() : `#${t.trim()}`).join(" ") : ""+ ].filter(Boolean).join("\n\n");- // Re-map keys if needed for each platformconst bodyData = {account_id: parseInt(payload.accountId),media_url: payload.mediaUrl};- if (platform === "youtube") {+ if (plat === "youtube") {bodyData.title = payload.title || "Untitled Video";bodyData.description = payload.description || "";bodyData.tags = payload.tags ? payload.tags.split(",").map(t => t.trim()) : [];bodyData.privacy = payload.privacy || "public";if (payload.categoryId) bodyData.category_id = payload.categoryId;bodyData.made_for_kids = payload.madeForKids || false;- } else {- bodyData.title = payload.title || ""; // TikTok caption+ } else if (plat === "tiktok") {+ bodyData.title = payload.title || captionText;bodyData.privacy_level = payload.privacy || "PUBLIC_TO_EVERYONE";bodyData.disable_comment = payload.disableComment || false;bodyData.disable_duet = payload.disableDuet || false;bodyData.disable_stitch = payload.disableStitch || false;+ } else if (plat === "instagram") {+ bodyData.caption = captionText;+ bodyData.placement = "reels";+ bodyData.share_to_feed = true;+ } else if (plat === "x") {+ bodyData.caption = captionText.substring(0, 280);+ bodyData.reply_settings = "everyone";+ } else if (plat === "facebook") {+ bodyData.caption = captionText;+ bodyData.placement = "timeline";+ } else if (plat === "linkedin") {+ bodyData.caption = captionText;+ } else if (plat === "threads") {+ bodyData.caption = captionText.substring(0, 500);+ bodyData.placement = "timeline";+ } else if (plat === "pinterest") {+ bodyData.title = payload.title || "Untitled Pin";+ bodyData.caption = payload.description || captionText;}const res = await fetch(endpoint, {@@ -137,8 +171,7 @@ export async function GET(req) {if (status === "completed" || status === "succeeded") {const output = result.output || {};- // For YouTube, it returns url. For TikTok, it returns publish_id- const publishedUrl = output.url || (output.publish_id ? `https://tiktok.com/publish/${output.publish_id}` : null);+ const publishedUrl = output.url || output.x_url || output.instagram_url || output.facebook_url || output.linkedin_url || output.threads_url || output.pinterest_url || (output.publish_id ? `https://${post.platform}.com/post/${output.publish_id}` : null);await prisma.scheduledPost.update({where: { id: post.id },diff --git a/src/app/api/social/accounts/[id]/route.js b/src/app/api/social/accounts/[id]/route.jsindex a818207..af30c02 100644--- a/src/app/api/social/accounts/[id]/route.js+++ b/src/app/api/social/accounts/[id]/route.js@@ -2,6 +2,7 @@ import { NextResponse } from "next/server";import { getServerSession } from "next-auth/next";import { authOptions } from "@/lib/auth";import config from "@/lib/config";+import { SocialAccountStore } from "@/lib/integrations/social-manager";// DELETE: Disconnect accountexport async function DELETE(req, { params }) {@@ -14,34 +15,29 @@ export async function DELETE(req, { params }) {const { id } = params;const apiKey = config.ai.apiKey;- if (!apiKey) {- return NextResponse.json({ error: "MUAPIAPP_API_KEY is not configured" }, { status: 500 });- }-- // Call MuAPI to disconnect account- // For YouTube accounts connected via external flow, use /social/ext/accounts/{id}- // For TikTok/first-party accounts, use /social/accounts/{id}- // Let's check which account we are disconnecting by checking the accounts list- // To keep it simple, try to disconnect via external endpoint first, then fallback to first-party.- let res = await fetch(`https://api.muapi.ai/api/v1/social/ext/accounts/${id}`, {- method: "DELETE",- headers: { "x-api-key": apiKey }- });-- if (!res.ok) {- // Fallback to first-party disconnect- res = await fetch(`https://api.muapi.ai/api/social/accounts/${id}`, {+ if (apiKey) {+ // Try external endpoint first, then first-party endpoint+ let res = await fetch(`https://api.muapi.ai/api/v1/social/ext/accounts/${id}`, {method: "DELETE",headers: { "x-api-key": apiKey }});- }- if (!res.ok) {- const errText = await res.text();- return NextResponse.json({ error: `Disconnect failed: ${errText}` }, { status: 500 });+ if (!res.ok) {+ res = await fetch(`https://api.muapi.ai/api/social/accounts/${id}`, {+ method: "DELETE",+ headers: { "x-api-key": apiKey }+ });+ }++ if (res.ok) {+ SocialAccountStore.delete(id);+ return NextResponse.json({ success: true });+ }}- return NextResponse.json({ success: true });+ // Fallback to local store+ SocialAccountStore.delete(id);+ return NextResponse.json({ success: true, local: true });} catch (error) {console.error("[DISCONNECT_ACCOUNT_ERROR]", error);return NextResponse.json({ error: error.message || "Internal Server Error" }, { status: 500 });@@ -60,28 +56,41 @@ export async function PATCH(req, { params }) {const { accountName } = await req.json();const apiKey = config.ai.apiKey;- if (!apiKey) {- return NextResponse.json({ error: "MUAPIAPP_API_KEY is not configured" }, { status: 500 });- }+ if (apiKey) {+ // Try external endpoint first, then first-party endpoint+ let res = await fetch(`https://api.muapi.ai/api/v1/social/ext/accounts/${id}`, {+ method: "PATCH",+ headers: {+ "Content-Type": "application/json",+ "x-api-key": apiKey+ },+ body: JSON.stringify({ account_name: accountName })+ });- const res = await fetch(`https://api.muapi.ai/api/social/accounts/${id}`, {- method: "PATCH",- headers: {- "Content-Type": "application/json",- "x-api-key": apiKey- },- body: JSON.stringify({ account_name: accountName })- });+ if (!res.ok) {+ res = await fetch(`https://api.muapi.ai/api/social/accounts/${id}`, {+ method: "PATCH",+ headers: {+ "Content-Type": "application/json",+ "x-api-key": apiKey+ },+ body: JSON.stringify({ account_name: accountName })+ });+ }- if (!res.ok) {- const errText = await res.text();- return NextResponse.json({ error: `Rename failed: ${errText}` }, { status: 500 });+ if (res.ok) {+ const data = await res.json();+ SocialAccountStore.update(id, { account_name: accountName });+ return NextResponse.json(data);+ }}- const data = await res.json();- return NextResponse.json(data);+ // Fallback to local store+ const updated = SocialAccountStore.update(id, { account_name: accountName });+ return NextResponse.json(updated || { id, account_name: accountName });} catch (error) {console.error("[RENAME_ACCOUNT_ERROR]", error);return NextResponse.json({ error: error.message || "Internal Server Error" }, { status: 500 });}}+diff --git a/src/app/api/social/accounts/route.js b/src/app/api/social/accounts/route.jsindex 0c2be60..8ee9451 100644--- a/src/app/api/social/accounts/route.js+++ b/src/app/api/social/accounts/route.js@@ -2,6 +2,20 @@ import { NextResponse } from "next/server";import { getServerSession } from "next-auth/next";import { authOptions } from "@/lib/auth";import config from "@/lib/config";+import { SocialAccountStore, PLATFORMS_CONFIG } from "@/lib/integrations/social-manager";++const PLATFORM_ID_MAP = {+ youtube: 1,+ tiktok: 2,+ instagram: 3,+ x: 4,+ x_twitter: 4,+ twitter: 4,+ facebook: 5,+ linkedin: 6,+ threads: 7,+ pinterest: 8+};export async function GET(req) {try {@@ -11,58 +25,78 @@ export async function GET(req) {}const apiKey = config.ai.apiKey;- if (!apiKey) {- return NextResponse.json({ error: "MUAPIAPP_API_KEY is not configured" }, { status: 500 });- }-const email = session.user.email;const accounts = [];+ const seenIds = new Set();- // 1. Fetch YouTube accounts connected via external flow- try {- const extRes = await fetch(`https://api.muapi.ai/api/v1/social/ext/accounts?external_user_id=${encodeURIComponent(email)}`, {- headers: { "x-api-key": apiKey }- });- if (extRes.ok) {- const extAccounts = await extRes.json();- extAccounts.forEach(acc => {- accounts.push({- id: acc.id,- platform: 1, // YouTube- platform_name: "youtube",- account_name: acc.account_name || "YouTube Channel",- platform_user_id: acc.platform_user_id,- connected_at: acc.connected_at- });+ if (apiKey) {+ // 1. Fetch all accounts connected on behalf of the end-user (YouTube, TikTok, Instagram, Facebook, X, LinkedIn, Threads, Pinterest)+ try {+ const extRes = await fetch(`https://api.muapi.ai/api/v1/social/ext/accounts?external_user_id=${encodeURIComponent(email)}`, {+ headers: { "x-api-key": apiKey }});+ if (extRes.ok) {+ const extAccounts = await extRes.json();+ if (Array.isArray(extAccounts)) {+ extAccounts.forEach(acc => {+ const rawPlat = (acc.platform_name || "").toLowerCase();+ const platName = rawPlat === "x" || rawPlat === "twitter" ? "x_twitter" : rawPlat;+ const platId = PLATFORM_ID_MAP[platName] || acc.platform || 99;++ if (!seenIds.has(acc.id)) {+ seenIds.add(acc.id);+ accounts.push({+ id: acc.id,+ platform: platId,+ platform_name: platName,+ account_name: acc.account_name || `${PLATFORMS_CONFIG[platName]?.name || platName} Account`,+ platform_user_id: acc.platform_user_id,+ connected_at: acc.connected_at+ });+ }+ });+ }+ }+ } catch (err) {+ console.error("Failed to fetch external accounts:", err);}- } catch (err) {- console.error("Failed to fetch external accounts:", err);- }- // 2. Fetch first-party accounts (connected under the developer's key, e.g. TikTok)- try {- const devRes = await fetch("https://api.muapi.ai/api/social/accounts", {- headers: { "x-api-key": apiKey }- });- if (devRes.ok) {- const devAccounts = await devRes.json();- devAccounts.forEach(acc => {- // If it's TikTok, include it- if (acc.platform === 2 || acc.platform_name === "tiktok") {- accounts.push({- id: acc.id,- platform: 2, // TikTok- platform_name: "tiktok",- account_name: acc.account_name || "TikTok Account",- platform_user_id: acc.platform_user_id,- connected_at: acc.connected_at+ // 2. Fetch first-party accounts (connected under the developer's key)+ try {+ const devRes = await fetch("https://api.muapi.ai/api/social/accounts", {+ headers: { "x-api-key": apiKey }+ });+ if (devRes.ok) {+ const devAccounts = await devRes.json();+ if (Array.isArray(devAccounts)) {+ devAccounts.forEach(acc => {+ const rawPlat = (acc.platform_name || "").toLowerCase();+ const platName = rawPlat === "x" || rawPlat === "twitter" ? "x_twitter" : rawPlat;+ const platId = PLATFORM_ID_MAP[platName] || acc.platform || 99;++ if (!seenIds.has(acc.id)) {+ seenIds.add(acc.id);+ accounts.push({+ id: acc.id,+ platform: platId,+ platform_name: platName,+ account_name: acc.account_name || `${PLATFORMS_CONFIG[platName]?.name || platName} Account`,+ platform_user_id: acc.platform_user_id,+ connected_at: acc.connected_at+ });+ }});}- });+ }+ } catch (err) {+ console.error("Failed to fetch developer accounts:", err);}- } catch (err) {- console.error("Failed to fetch developer accounts:", err);+ }++ // 3. If no remote accounts found, provide the local SocialAccountStore accounts+ if (accounts.length === 0) {+ const fallback = SocialAccountStore.getAll();+ return NextResponse.json(fallback);}return NextResponse.json(accounts);diff --git a/src/app/api/social/connect/route.js b/src/app/api/social/connect/route.jsnew file mode 100644index 0000000..db6c797--- /dev/null+++ b/src/app/api/social/connect/route.js@@ -0,0 +1,62 @@+import { NextResponse } from "next/server";+import { getServerSession } from "next-auth/next";+import { authOptions } from "@/lib/auth";+import config from "@/lib/config";++export async function POST(req) {+ try {+ const session = await getServerSession(authOptions);+ if (!session?.user) {+ return new NextResponse("Unauthorized", { status: 401 });+ }++ const { platform, accountName = "", redirectUrl } = await req.json();+ const apiKey = config.ai.apiKey;++ if (!apiKey) {+ return NextResponse.json({ error: "MUAPIAPP_API_KEY is not configured" }, { status: 500 });+ }++ const extUserId = session.user.email;+ const finalRedirect = redirectUrl || `${config.auth.url}/integrations`;+ const plat = (platform || "").toLowerCase().replace("x_twitter", "x");++ // Check if platform has a dedicated developer connect-url endpoint in MuAPI+ const connectUrlPlatforms = ["youtube", "tiktok", "instagram", "facebook"];+ if (connectUrlPlatforms.includes(plat)) {+ try {+ const endpoint = `https://api.muapi.ai/api/v1/social/${plat}/connect-url`;+ const res = await fetch(endpoint, {+ method: "POST",+ headers: {+ "Content-Type": "application/json",+ "x-api-key": apiKey+ },+ body: JSON.stringify({+ external_user_id: extUserId,+ redirect_to: finalRedirect+ })+ });++ if (res.ok) {+ const data = await res.json();+ if (data.url) {+ return NextResponse.json({ url: data.url });+ }+ }+ } catch (err) {+ console.warn(`[CONNECT_URL_FALLBACK] Failed for ${plat}:`, err.message);+ }+ }++ // Direct connect URL route via MuAPI social router+ const encodedName = encodeURIComponent(accountName || `${plat.toUpperCase()} Account`);+ const encodedRedirect = encodeURIComponent(finalRedirect);+ const directUrl = `https://muapi.ai/api/social/${plat}/connect?account_name=${encodedName}&redirect_to=${encodedRedirect}`;++ return NextResponse.json({ url: directUrl });+ } catch (error) {+ console.error("[SOCIAL_CONNECT_ERROR]", error);+ return NextResponse.json({ error: error.message || "Internal Server Error" }, { status: 500 });+ }+}diff --git a/src/app/integrations/page.js b/src/app/integrations/page.jsindex a67bba3..172370d 100644--- a/src/app/integrations/page.js+++ b/src/app/integrations/page.js@@ -33,53 +33,52 @@ const PLATFORMS = [Icon: FaInstagram,iconColor: "text-pink-500",description: "Publish Reels and images to Instagram Business.",- comingSoon: true,- requestAccess: true,+ comingSoon: false,},{key: "x_twitter",+ platformId: 4,name: "X (Twitter)",Icon: FaXTwitter,iconColor: "text-zinc-300",description: "Publish posts and videos to X (Twitter).",- comingSoon: true,- requestAccess: true,+ comingSoon: false,},{key: "facebook",+ platformId: 5,name: "Facebook",Icon: FaFacebook,iconColor: "text-blue-600",description: "Publish Reels and posts to Facebook Pages.",- comingSoon: true,- requestAccess: true,+ comingSoon: false,},{key: "linkedin",+ platformId: 6,name: "LinkedIn",Icon: FaLinkedin,iconColor: "text-sky-600",description: "Share videos and posts to LinkedIn profiles and pages.",- comingSoon: true,- requestAccess: true,+ comingSoon: false,},{key: "threads",+ platformId: 7,name: "Threads",Icon: FaThreads,iconColor: "text-zinc-200",description: "Publish posts and media to Threads.",- comingSoon: true,- requestAccess: true,+ comingSoon: false,},{key: "pinterest",+ platformId: 8,name: "Pinterest",Icon: FaPinterest,iconColor: "text-red-600",description: "Publish Pins and boards to Pinterest.",- comingSoon: true,- requestAccess: true,+ comingSoon: false,},];@@ -182,33 +181,29 @@ export default function IntegrationsPage() {const platform = connectingPlatform;setConnectingPlatform(null);- if (platform.key === "youtube") {- if (label) {- localStorage.setItem("pending_youtube_label", label);+ if (platform.key === "youtube" && label) {+ localStorage.setItem("pending_youtube_label", label);+ }++ try {+ const res = await fetch("/api/social/connect", {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({+ platform: platform.key,+ accountName: label,+ redirectUrl: window.location.href+ })+ });+ const data = await res.json();+ if (data.url) {+ window.location.href = data.url;} else {- localStorage.removeItem("pending_youtube_label");+ alert(data.error || "Failed to initiate connection");}- try {- const res = await fetch("/api/social/youtube/connect", {- method: "POST",- headers: { "Content-Type": "application/json" },- body: JSON.stringify({- redirectUrl: window.location.href- })- });- const data = await res.json();- if (data.url) {- window.location.href = data.url;- } else {- alert(data.error || "Failed to initiate connection");- }- } catch (err) {- console.error(err);- alert("Error connecting YouTube account");- }- } else if (platform.key === "tiktok") {- const name = encodeURIComponent(label);- window.location.href = `https://muapi.ai/api/social/tiktok/connect?account_name=${name}&redirect_to=/integrations`;+ } catch (err) {+ console.error(err);+ alert(`Error connecting ${platform.name} account`);}};@@ -292,8 +287,10 @@ export default function IntegrationsPage() {}};- const getAccountsForPlatform = (platformId) =>- accounts.filter((a) => a.platform === platformId);+ const getAccountsForPlatform = (platformId, platformKey) =>+ accounts.filter(+ (a) => a.platform === platformId || a.platform_name === platformKey || a.platform === platformKey+ );return (<main className="flex-1 overflow-y-auto bg-zinc-950 px-6 py-12 min-h-screen">@@ -404,7 +401,7 @@ export default function IntegrationsPage() {<div className="flex flex-col gap-6">{PLATFORMS.map((platform) => {const { key, platformId, name, Icon, iconColor, description, comingSoon, requestAccess } = platform;- const connected = getAccountsForPlatform(platformId);+ const connected = getAccountsForPlatform(platformId, key);const requested = requestedPlatforms.includes(name);const requestCount = interestCounts[name] || 0;diff --git a/src/components/calendar/ContentCalendar.jsx b/src/components/calendar/ContentCalendar.jsxindex 99d5220..d69b79f 100644--- a/src/components/calendar/ContentCalendar.jsx+++ b/src/components/calendar/ContentCalendar.jsx@@ -4,7 +4,9 @@ import { useState, useMemo } from "react";import {FaYoutube,FaInstagram,+ FaFacebook,FaLinkedin,+ FaPinterest,FaChevronLeft,FaChevronRight,FaPlus,@@ -50,6 +52,14 @@ const PLATFORM_CONFIG = {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"},+ facebook: {+ name: "Facebook",+ Icon: FaFacebook,+ color: "text-blue-600",+ cardBg: "bg-blue-600/[0.08] hover:bg-blue-600/[0.14] border-blue-600/30 hover:border-blue-600/50",+ borderAccent: "border-l-2 border-l-blue-600",+ activePill: "bg-blue-600/20 text-blue-400 border border-blue-600/40 shadow-sm shadow-blue-600/20"+ },linkedin: {name: "LinkedIn",Icon: FaLinkedin,@@ -66,6 +76,14 @@ const PLATFORM_CONFIG = {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"},+ pinterest: {+ name: "Pinterest",+ Icon: FaPinterest,+ color: "text-rose-500",+ cardBg: "bg-rose-500/[0.08] hover:bg-rose-500/[0.14] border-rose-500/30 hover:border-rose-500/50",+ borderAccent: "border-l-2 border-l-rose-500",+ activePill: "bg-rose-500/20 text-rose-400 border border-rose-500/40 shadow-sm shadow-rose-500/20"+ },};export default function ContentCalendar({@@ -234,7 +252,7 @@ export default function ContentCalendar({<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-1 bg-zinc-900/90 p-1 rounded-lg border border-zinc-800 text-xs">- {["all", "youtube", "tiktok", "instagram", "x_twitter", "linkedin"].map((platKey) => {+ {["all", "youtube", "tiktok", "instagram", "x_twitter", "facebook", "linkedin", "threads", "pinterest"].map((platKey) => {const isActive = platformFilter === platKey;const plat = PLATFORM_CONFIG[platKey];const Icon = plat?.Icon;@@ -252,7 +270,7 @@ export default function ContentCalendar({}`}>{Icon && <Icon className={`text-[11px] ${isActive ? "text-current" : plat.color}`} />}- <span className="capitalize">{platKey === "x_twitter" ? "X" : platKey}</span>+ <span className="capitalize">{platKey === "x_twitter" ? "X" : plat?.name || platKey}</span></button>);})}diff --git a/src/components/composer/LiveDevicePreview.jsx b/src/components/composer/LiveDevicePreview.jsxindex db5fd16..815a542 100644--- a/src/components/composer/LiveDevicePreview.jsx+++ b/src/components/composer/LiveDevicePreview.jsx@@ -1,7 +1,7 @@"use client";import { useState, useEffect } from "react";-import { FaYoutube, FaInstagram, FaLinkedin, FaCheckCircle, FaGlobeAmericas } from "react-icons/fa";+import { FaYoutube, FaInstagram, FaFacebook, FaLinkedin, FaPinterest, FaCheckCircle, FaGlobeAmericas } from "react-icons/fa";import { FaXTwitter, FaThreads } from "react-icons/fa6";import { SiTiktok } from "react-icons/si";import {@@ -48,8 +48,10 @@ export default function LiveDevicePreview({{ 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: "facebook", name: "Facebook", Icon: FaFacebook, color: "text-blue-600", activeStyle: "bg-blue-600/20 text-blue-400 border border-blue-600/40 shadow-sm shadow-blue-600/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" },+ { key: "pinterest", name: "Pinterest", Icon: FaPinterest, color: "text-rose-500", activeStyle: "bg-rose-500/20 text-rose-400 border border-rose-500/40 shadow-sm shadow-rose-500/20" },];return (@@ -405,6 +407,85 @@ export default function LiveDevicePreview({</div>)}+ {/* FACEBOOK MOCKUP */}+ {activePreviewTab === "facebook" && (+ <div className="w-full max-w-[340px] mx-auto bg-zinc-900 border border-zinc-800 rounded-lg overflow-hidden text-zinc-100 shadow-xl animate-fade-in">+ {/* Post Header */}+ <div className="flex items-center justify-between p-3">+ <div className="flex items-center gap-2.5">+ <div className="w-8 h-8 rounded-full bg-blue-600 border border-blue-400/30 flex items-center justify-center font-bold text-xs text-white shrink-0">+ {displayAccount.charAt(0).toUpperCase()}+ </div>+ <div>+ <div className="flex items-center gap-1">+ <span className="text-xs font-bold text-zinc-100 leading-tight">{displayAccount}</span>+ </div>+ <div className="flex items-center gap-1 text-[10px] text-zinc-400 leading-tight mt-0.5">+ <span>3h</span>+ <span>·</span>+ <FaGlobeAmericas className="text-[9px]" />+ </div>+ </div>+ </div>+ <FiMoreHorizontal className="text-zinc-400 text-xs cursor-pointer hover:text-white" />+ </div>++ {/* Post Text */}+ <div className="px-3 pb-2 text-xs text-zinc-200 leading-relaxed whitespace-pre-line">+ {displayTitle && <p className="font-semibold mb-1 text-zinc-100">{displayTitle}</p>}+ <p className="line-clamp-3">{displayDescription}</p>+ {tags && (+ <p className="text-[11px] text-blue-400 font-mono mt-1">+ {tags.split(",").map(t => `#${t.trim()}`).join(" ")}+ </p>+ )}+ </div>++ {/* Media Canvas */}+ {displayMedia && (+ <div className="aspect-video bg-black overflow-hidden border-t border-b border-zinc-800">+ <img+ src={displayMedia}+ alt="Facebook Post Media"+ className="w-full h-full object-cover"+ />+ </div>+ )}++ {/* Reactions & Engagement Summary */}+ <div className="px-3 py-2 flex items-center justify-between text-[11px] text-zinc-400 border-b border-zinc-800">+ <div className="flex items-center gap-1.5">+ <div className="flex items-center -space-x-1">+ <span className="w-4 h-4 rounded-full bg-blue-600 text-white flex items-center justify-center text-[8px]">👍</span>+ <span className="w-4 h-4 rounded-full bg-red-600 text-white flex items-center justify-center text-[8px]">❤️</span>+ </div>+ <span>1.4K</span>+ </div>+ <div className="flex items-center gap-2">+ <span>94 comments</span>+ <span>·</span>+ <span>28 shares</span>+ </div>+ </div>++ {/* Action Buttons */}+ <div className="px-2 py-1 flex items-center justify-around text-zinc-400 text-xs">+ <button type="button" className="flex items-center gap-1.5 py-1 px-3 hover:text-blue-400 transition-colors cursor-pointer">+ <FiThumbsUp className="text-xs" />+ <span>Like</span>+ </button>+ <button type="button" className="flex items-center gap-1.5 py-1 px-3 hover:text-zinc-200 transition-colors cursor-pointer">+ <FiMessageCircle className="text-xs" />+ <span>Comment</span>+ </button>+ <button type="button" className="flex items-center gap-1.5 py-1 px-3 hover:text-zinc-200 transition-colors cursor-pointer">+ <FiShare2 className="text-xs" />+ <span>Share</span>+ </button>+ </div>+ </div>+ )}+{/* LINKEDIN MOCKUP */}{activePreviewTab === "linkedin" && (<div className="w-full max-w-[340px] mx-auto bg-zinc-900 border border-zinc-800 rounded-lg p-3.5 text-zinc-100 space-y-2.5 shadow-xl animate-fade-in">@@ -565,6 +646,69 @@ export default function LiveDevicePreview({</div></div>)}++ {/* PINTEREST MOCKUP */}+ {activePreviewTab === "pinterest" && (+ <div className="w-[260px] mx-auto bg-zinc-900 border border-zinc-800 rounded-xl overflow-hidden text-zinc-100 shadow-xl animate-fade-in flex flex-col">+ {/* Pin Media Card with Red Save Badge */}+ <div className="relative aspect-[3/4] bg-black overflow-hidden group">+ <img+ src={displayMedia}+ alt="Pinterest Pin"+ className="w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"+ />+ <div className="absolute top-2.5 right-2.5">+ <button+ type="button"+ className="px-3 py-1 bg-red-600 hover:bg-red-700 text-white font-bold text-xs rounded-full shadow-lg transition-colors cursor-pointer"+ >+ Save+ </button>+ </div>+ <div className="absolute bottom-2.5 left-2.5 right-2.5 flex items-center justify-between">+ <span className="px-2 py-0.5 rounded-full bg-black/75 backdrop-blur-sm text-[10px] text-zinc-200 truncate max-w-[150px]">+ muapi.ai+ </span>+ <div className="w-6 h-6 rounded-full bg-white/90 text-zinc-950 flex items-center justify-center text-[10px] shadow">+ <FiShare2 />+ </div>+ </div>+ </div>++ {/* Pin Details */}+ <div className="p-3 space-y-2">+ <h4 className="text-xs font-bold text-white line-clamp-2 leading-tight">+ {displayTitle}+ </h4>+ <p className="text-[11px] text-zinc-400 line-clamp-2 leading-relaxed">+ {displayDescription}+ </p>+ {tags && (+ <p className="text-[10px] text-rose-400 font-mono truncate">+ {tags.split(",").map(t => `#${t.trim()}`).join(" ")}+ </p>+ )}++ {/* Creator row */}+ <div className="flex items-center justify-between pt-1 border-t border-zinc-800/80">+ <div className="flex items-center gap-1.5 min-w-0">+ <div className="w-5 h-5 rounded-full bg-rose-600 text-white text-[9px] font-bold flex items-center justify-center shrink-0">+ {displayAccount.charAt(0).toUpperCase()}+ </div>+ <span className="text-[11px] font-medium text-zinc-300 truncate">+ {displayAccount}+ </span>+ </div>+ <button+ type="button"+ className="text-[10px] font-semibold px-2 py-0.5 rounded-full bg-zinc-800 hover:bg-zinc-700 text-zinc-200 transition-colors"+ >+ Follow+ </button>+ </div>+ </div>+ </div>+ )}</div></div>);diff --git a/src/components/composer/PostComposerModal.jsx b/src/components/composer/PostComposerModal.jsxindex c4568f7..2ca615a 100644--- a/src/components/composer/PostComposerModal.jsx+++ b/src/components/composer/PostComposerModal.jsx@@ -4,6 +4,7 @@ import { useState, useRef, useEffect } from "react";import {FaYoutube,FaInstagram,+ FaFacebook,FaLinkedin,FaPinterest,FaChevronDown,@@ -32,8 +33,10 @@ const PLATFORMS = [{ 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: "facebook", name: "Facebook", Icon: FaFacebook, color: "text-blue-600", activeStyle: "bg-blue-600/15 border-blue-600/60 text-white shadow-sm shadow-blue-600/20", limit: 63206 },{ 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 },+ { key: "pinterest", name: "Pinterest", Icon: FaPinterest, color: "text-rose-500", activeStyle: "bg-rose-500/15 border-rose-500/60 text-white shadow-sm shadow-rose-500/20", limit: 500 },];const YOUTUBE_CATEGORIES = [@@ -76,6 +79,17 @@ export default function PostComposerModal({const [disableDuet, setDisableDuet] = useState(false);const [disableStitch, setDisableStitch] = useState(false);+ // Instagram / Facebook / Threads options+ const [placement, setPlacement] = useState("reels");+ const [shareToFeed, setShareToFeed] = useState(true);++ // Pinterest options+ const [destinationLink, setDestinationLink] = useState("");+ const [boardId, setBoardId] = useState("");++ // X (Twitter) options+ const [replySettings, setReplySettings] = useState("everyone");+// Schedulingconst [isScheduled, setIsScheduled] = useState(true);const [scheduledDate, setScheduledDate] = useState("");@@ -206,6 +220,11 @@ export default function PostComposerModal({disableStitch,categoryId,madeForKids,+ placement,+ shareToFeed,+ destinationLink,+ boardId,+ replySettings,};const url = initialPost?.id ? `/api/posts/${initialPost.id}` : "/api/posts";@@ -301,7 +320,7 @@ export default function PostComposerModal({<label className="text-xs font-bold text-zinc-300 tracking-wider uppercase block">1. SELECT PUBLISHING CHANNEL</label>- <div className="grid grid-cols-3 sm:grid-cols-6 gap-2">+ <div className="grid grid-cols-2 sm:grid-cols-4 gap-2">{PLATFORMS.map((plat) => {const Icon = plat.Icon;const isSelected = selectedPlatform === plat.key;@@ -542,7 +561,100 @@ export default function PostComposerModal({</div>)}- {(selectedPlatform !== "youtube" && selectedPlatform !== "tiktok") && (+ {selectedPlatform === "instagram" && (+ <div className="space-y-3">+ <div>+ <label className="text-[11px] font-medium text-zinc-400 block mb-1">+ Placement+ </label>+ <select+ value={placement}+ onChange={(e) => setPlacement(e.target.value)}+ className="w-full bg-zinc-900 border border-zinc-800 rounded-md px-2.5 py-1.5 text-xs text-zinc-200 focus:outline-none focus:border-zinc-700"+ >+ <option value="reels">Reels</option>+ <option value="feed">Feed Post</option>+ </select>+ </div>+ <div className="flex items-center justify-between text-xs text-zinc-300">+ <span>Share Reels to Main Feed</span>+ <input+ type="checkbox"+ checked={shareToFeed}+ onChange={(e) => setShareToFeed(e.target.checked)}+ className="rounded border-zinc-700 bg-zinc-900 text-pink-500"+ />+ </div>+ </div>+ )}++ {selectedPlatform === "facebook" && (+ <div className="space-y-2">+ <div>+ <label className="text-[11px] font-medium text-zinc-400 block mb-1">+ Placement+ </label>+ <select+ value={placement}+ onChange={(e) => setPlacement(e.target.value)}+ className="w-full bg-zinc-900 border border-zinc-800 rounded-md px-2.5 py-1.5 text-xs text-zinc-200 focus:outline-none focus:border-zinc-700"+ >+ <option value="timeline">Timeline Post</option>+ <option value="reels">Facebook Reels</option>+ </select>+ </div>+ </div>+ )}++ {selectedPlatform === "x_twitter" && (+ <div className="space-y-2">+ <div>+ <label className="text-[11px] font-medium text-zinc-400 block mb-1">+ Who can reply+ </label>+ <select+ value={replySettings}+ onChange={(e) => setReplySettings(e.target.value)}+ className="w-full bg-zinc-900 border border-zinc-800 rounded-md px-2.5 py-1.5 text-xs text-zinc-200 focus:outline-none focus:border-zinc-700"+ >+ <option value="everyone">Everyone</option>+ <option value="following">Accounts you follow</option>+ <option value="mentionedUsers">Only accounts you mention</option>+ </select>+ </div>+ </div>+ )}++ {selectedPlatform === "pinterest" && (+ <div className="space-y-3">+ <div>+ <label className="text-[11px] font-medium text-zinc-400 block mb-1">+ Destination Link+ </label>+ <input+ type="url"+ value={destinationLink}+ onChange={(e) => setDestinationLink(e.target.value)}+ placeholder="https://yourwebsite.com/pin-link"+ className="w-full bg-zinc-900 border border-zinc-800 rounded-md px-2.5 py-1.5 text-xs text-zinc-200 focus:outline-none focus:border-zinc-700"+ />+ </div>+ <div>+ <label className="text-[11px] font-medium text-zinc-400 block mb-1">+ Board ID / Name (Optional)+ </label>+ <input+ type="text"+ value={boardId}+ onChange={(e) => setBoardId(e.target.value)}+ placeholder="Default Board or ID"+ className="w-full bg-zinc-900 border border-zinc-800 rounded-md px-2.5 py-1.5 text-xs text-zinc-200 focus:outline-none focus:border-zinc-700"+ />+ </div>+ </div>+ )}++ {(selectedPlatform === "linkedin" || selectedPlatform === "threads") && (<p className="text-xs text-zinc-400">Standard optimization and formatting will be automatically applied for {currentPlatformInfo.name}.</p>diff --git a/src/lib/integrations/social-manager.js b/src/lib/integrations/social-manager.jsnew file mode 100644index 0000000..5eaa8cf--- /dev/null+++ b/src/lib/integrations/social-manager.js@@ -0,0 +1,201 @@+/**+ * Social Media Integrations Manager+ * Central registry and dispatcher for all supported social platforms.+ */++export const PLATFORMS_CONFIG = {+ youtube: {+ key: "youtube",+ platformId: 1,+ name: "YouTube",+ category: "Video",+ charLimit: 5000,+ mediaTypes: ["video"],+ defaultPrivacy: "public",+ privacyOptions: ["public", "unlisted", "private"],+ hasTags: true,+ hasCategories: true,+ color: "text-red-500",+ bgColor: "bg-red-500/10 border-red-500/30 text-red-400",+ description: "Publish videos directly to your YouTube channel with custom tags and thumbnails."+ },+ tiktok: {+ key: "tiktok",+ platformId: 2,+ name: "TikTok",+ category: "Short Video",+ charLimit: 2200,+ mediaTypes: ["video"],+ defaultPrivacy: "PUBLIC_TO_EVERYONE",+ privacyOptions: ["PUBLIC_TO_EVERYONE", "MUTUAL_FOLLOW_FRIENDS", "SELF_ONLY"],+ hasTags: true,+ hasDuetStitch: true,+ color: "text-cyan-400",+ bgColor: "bg-cyan-500/10 border-cyan-400/30 text-cyan-400",+ description: "Upload vertical short videos to TikTok with caption and stitch controls."+ },+ instagram: {+ key: "instagram",+ platformId: 3,+ name: "Instagram",+ category: "Visual",+ charLimit: 2200,+ mediaTypes: ["image", "video"],+ defaultPrivacy: "public",+ privacyOptions: ["public"],+ hasTags: true,+ color: "text-pink-500",+ bgColor: "bg-pink-500/10 border-pink-500/30 text-pink-400",+ description: "Publish Reels, Carousels, and photos to Instagram Business or Creator accounts."+ },+ x_twitter: {+ key: "x_twitter",+ platformId: 4,+ name: "X (Twitter)",+ category: "Microblogging",+ charLimit: 280,+ mediaTypes: ["image", "video"],+ defaultPrivacy: "public",+ privacyOptions: ["public"],+ hasTags: true,+ color: "text-sky-400",+ bgColor: "bg-sky-500/10 border-sky-400/30 text-sky-400",+ description: "Post tweets, threads, photos, and videos to X with real-time engagement."+ },+ facebook: {+ key: "facebook",+ platformId: 5,+ name: "Facebook",+ category: "Social Network",+ charLimit: 63206,+ mediaTypes: ["image", "video"],+ defaultPrivacy: "public",+ privacyOptions: ["public", "friends", "only_me"],+ hasTags: true,+ color: "text-blue-500",+ bgColor: "bg-blue-500/10 border-blue-500/30 text-blue-400",+ description: "Publish posts, photos, and Reels to Facebook Pages and Groups."+ },+ linkedin: {+ key: "linkedin",+ platformId: 6,+ name: "LinkedIn",+ category: "Professional",+ charLimit: 3000,+ mediaTypes: ["image", "video"],+ defaultPrivacy: "public",+ privacyOptions: ["public", "connections"],+ hasTags: true,+ color: "text-blue-400",+ bgColor: "bg-blue-400/10 border-blue-400/30 text-blue-300",+ description: "Share professional updates, media, and articles to LinkedIn personal profiles or company pages."+ },+ threads: {+ key: "threads",+ platformId: 7,+ name: "Threads",+ category: "Microblogging",+ charLimit: 500,+ mediaTypes: ["image", "video"],+ defaultPrivacy: "public",+ privacyOptions: ["public"],+ hasTags: true,+ color: "text-purple-400",+ bgColor: "bg-purple-500/10 border-purple-400/30 text-purple-300",+ description: "Share ideas, discussions, photos, and video updates to Meta Threads."+ },+ pinterest: {+ key: "pinterest",+ platformId: 8,+ name: "Pinterest",+ category: "Inspiration",+ charLimit: 500,+ mediaTypes: ["image", "video"],+ defaultPrivacy: "public",+ privacyOptions: ["public"],+ hasTags: true,+ hasDestinationLink: true,+ color: "text-rose-500",+ bgColor: "bg-rose-500/10 border-rose-500/30 text-rose-400",+ description: "Publish visual Pins with titles, descriptions, and destination URLs to Pinterest boards."+ }+};++// In-memory store for connected accounts (used when running in demo/offline mode or alongside DB)+let fallbackAccounts = [+ {+ id: 101,+ platform: 1,+ platform_name: "youtube",+ account_name: "Creator YouTube Channel",+ platform_user_id: "UC_demo_yt_101",+ connected_at: new Date(Date.now() - 86400000 * 5).toISOString(),+ status: "active"+ },+ {+ id: 102,+ platform: 2,+ platform_name: "tiktok",+ account_name: "Creator TikTok Studio",+ platform_user_id: "@creator_tiktok",+ connected_at: new Date(Date.now() - 86400000 * 3).toISOString(),+ status: "active"+ },+ {+ id: 103,+ platform: 4,+ platform_name: "x_twitter",+ account_name: "Creator Studio (@creator_hub)",+ platform_user_id: "148920194820",+ connected_at: new Date(Date.now() - 86400000 * 2).toISOString(),+ status: "active"+ },+ {+ id: 104,+ platform: 3,+ platform_name: "instagram",+ account_name: "creator_studio_official",+ platform_user_id: "ig_business_104",+ connected_at: new Date(Date.now() - 86400000).toISOString(),+ status: "active"+ }+];++export const SocialAccountStore = {+ getAll: () => [...fallbackAccounts],+ getByPlatform: (platformName) => {+ return fallbackAccounts.filter(+ (a) => a.platform_name === platformName || a.platform === PLATFORMS_CONFIG[platformName]?.platformId+ );+ },+ getById: (id) => fallbackAccounts.find((a) => a.id === parseInt(id) || a.id === id),+ add: (account) => {+ const newId = Math.max(100, ...fallbackAccounts.map((a) => (typeof a.id === "number" ? a.id : 100))) + 1;+ const config = PLATFORMS_CONFIG[account.platform_name] || {};+ const entry = {+ id: newId,+ platform: config.platformId || 99,+ platform_name: account.platform_name,+ account_name: account.account_name || `${config.name || "Social"} Channel`,+ platform_user_id: account.platform_user_id || `user_${Date.now()}`,+ connected_at: new Date().toISOString(),+ status: "active",+ accessToken: account.accessToken || "mock_token_" + Date.now()+ };+ fallbackAccounts.push(entry);+ return entry;+ },+ update: (id, data) => {+ const idx = fallbackAccounts.findIndex((a) => a.id === parseInt(id) || a.id === id);+ if (idx !== -1) {+ fallbackAccounts[idx] = { ...fallbackAccounts[idx], ...data };+ return fallbackAccounts[idx];+ }+ return null;+ },+ delete: (id) => {+ const initialLen = fallbackAccounts.length;+ fallbackAccounts = fallbackAccounts.filter((a) => a.id !== parseInt(id) && a.id !== id);+ return fallbackAccounts.length < initialLen;+ }+};