From 8d411126176753e40eeb175a9b120234886ce84c Mon Sep 17 00:00:00 2001 From: "juancarlos.cavero" Date: Sat, 18 Jul 2026 23:24:20 +0200 Subject: [PATCH] feat(ui): gate publishing when no social accounts are linked; guide user to connect flow --- dashboard/src/App.jsx | 2 + dashboard/src/components/ResultCard.jsx | 60 ++++++++++++++++++++----- 2 files changed, 52 insertions(+), 10 deletions(-) diff --git a/dashboard/src/App.jsx b/dashboard/src/App.jsx index e1503b5..ba714a4 100644 --- a/dashboard/src/App.jsx +++ b/dashboard/src/App.jsx @@ -1367,6 +1367,8 @@ function App() { geminiApiKey={apiKey} elevenLabsKey={elevenLabsKey} isManaged={isManaged} + connectedPlatforms={(userProfiles.find((p) => p.username === uploadUserId) || userProfiles[0])?.connected ?? null} + onConnectSocials={isManaged ? handleConnectSocials : null} onPlay={(time) => handleClipPlay(time)} onPause={handleClipPause} onBulkSubtitle={handleBulkSubtitles} diff --git a/dashboard/src/components/ResultCard.jsx b/dashboard/src/components/ResultCard.jsx index c2451c7..dd79d26 100644 --- a/dashboard/src/components/ResultCard.jsx +++ b/dashboard/src/components/ResultCard.jsx @@ -1,5 +1,5 @@ import React, { useState, useEffect } from 'react'; -import { Download, Share2, Instagram, Youtube, Video, AlertCircle, Loader2, Copy, Check, Wand2, Type, Calendar, Languages, FileText } from 'lucide-react'; +import { Download, Share2, Instagram, Youtube, Video, AlertCircle, Loader2, Copy, Check, Wand2, Type, Calendar, Languages, FileText, Link2 } from 'lucide-react'; import { getApiUrl } from '../config'; import { apiFetch } from '../lib/api'; import SubtitleModal from './SubtitleModal'; @@ -23,7 +23,7 @@ function formatDuration(clip) { return `${String(Math.floor(secs / 60)).padStart(2, '0')}:${String(secs % 60).padStart(2, '0')}`; } -export default function ResultCard({ clip, index, jobId, durableUrl, uploadPostKey, uploadUserId, geminiApiKey, elevenLabsKey, isManaged, onPlay, onPause, onBulkSubtitle, clipCount = 1, bulkProgress, initialState = null, onStateChange }) { +export default function ResultCard({ clip, index, jobId, durableUrl, uploadPostKey, uploadUserId, geminiApiKey, elevenLabsKey, isManaged, onPlay, onPause, onBulkSubtitle, clipCount = 1, bulkProgress, initialState = null, onStateChange, connectedPlatforms = null, onConnectSocials }) { const [showModal, setShowModal] = useState(false); const [showDescModal, setShowDescModal] = useState(false); const [showSubtitleModal, setShowSubtitleModal] = useState(false); @@ -134,6 +134,20 @@ export default function ResultCard({ clip, index, jobId, durableUrl, uploadPostK .catch(() => {}); }, [jobId, index]); + // Which platforms the selected profile actually has linked. `null` means + // unknown (profile list not loaded) — in that case nothing is gated. + const knownConnections = Array.isArray(connectedPlatforms); + const noAccountsConnected = knownConnections && connectedPlatforms.length === 0; + const platformOptions = knownConnections + ? PLATFORM_OPTIONS.map((o) => (connectedPlatforms.includes(o.value) ? o : { ...o, disabled: true, hint: 'not connected' })) + : PLATFORM_OPTIONS; + + const handleConnectAccounts = () => { + setShowModal(false); + if (onConnectSocials) onConnectSocials(); + else window.open('https://app.upload-post.com', '_blank', 'noopener'); + }; + // Initialize/Reset form when modal opens useEffect(() => { if (showModal) { @@ -142,6 +156,14 @@ export default function ResultCard({ clip, index, jobId, durableUrl, uploadPostK setIsScheduling(false); setScheduleDate(""); setPostResult(null); + // Only preselect platforms the profile can actually publish to. + if (knownConnections) { + setPlatforms({ + tiktok: connectedPlatforms.includes('tiktok'), + instagram: connectedPlatforms.includes('instagram'), + youtube: connectedPlatforms.includes('youtube'), + }); + } } }, [showModal, clip]); @@ -442,6 +464,11 @@ export default function ResultCard({ clip, index, jobId, durableUrl, uploadPostK return; } + if (noAccountsConnected) { + setPostResult({ success: false, msg: "Connect a social account first." }); + return; + } + const selectedPlatforms = Object.keys(platforms).filter(k => platforms[k]); if (selectedPlatforms.length === 0) { setPostResult({ success: false, msg: "Select at least one platform." }); @@ -736,13 +763,19 @@ export default function ResultCard({ clip, index, jobId, durableUrl, uploadPostK title="post clip" size="md" footer={ - + noAccountsConnected ? ( + + ) : ( + + ) } > {!canPost && ( @@ -752,6 +785,13 @@ export default function ResultCard({ clip, index, jobId, durableUrl, uploadPostK )} + {noAccountsConnected && ( +
+ +
no social accounts connected yet — link tiktok, instagram or youtube to publish this clip.
+
+ )} +
{/* Title & Description */}
@@ -809,7 +849,7 @@ export default function ResultCard({ clip, index, jobId, durableUrl, uploadPostK platforms[k])} onChange={(arr) => setPlatforms({ tiktok: arr.includes('tiktok'),