import { useState, useCallback } from 'react'; import { motion, AnimatePresence } from 'motion/react'; import { YoutubeFilled, InstagramFilled, FacebookFilled, GlobeFilled, TiktokFilled, VideoFilled, FileTextFilled, ShareFilled, } from '../components/icons/FilledIcons'; import type { ComponentType } from 'react'; // ─── Types ─── type DistributeStatus = 'ready' | 'publishing' | 'published' | 'failed'; interface ChannelTarget { id: string; name: string; icon: ComponentType<{ size?: number; className?: string }>; brandColor: string; bgColor: string; connected: boolean; selected: boolean; status: DistributeStatus; format: string; } // ─── Mock content from Studio ─── const MOCK_CONTENT = { title: '한번에 성공하는 코성형, VIEW의 비결', description: '코성형은 얼굴의 중심을 결정하는 중요한 수술입니다. VIEW 성형외과는 21년간 축적된 노하우를 바탕으로 자연스러운 결과를 만들어냅니다.', type: 'video' as const, duration: '0:58', aspectRatio: '9:16', tags: ['코성형', '뷰성형외과', '강남성형외과', '코수술', '자연스러운코'], thumbnail: null as string | null, }; const INITIAL_CHANNELS: ChannelTarget[] = [ { id: 'youtube', name: 'YouTube Shorts', icon: YoutubeFilled, brandColor: '#FF0000', bgColor: '#FFF0F0', connected: true, selected: true, status: 'ready', format: 'Shorts (9:16)' }, { id: 'instagram_kr', name: 'Instagram Reels', icon: InstagramFilled, brandColor: '#E1306C', bgColor: '#FFF0F5', connected: true, selected: true, status: 'ready', format: 'Reels (9:16)' }, { id: 'instagram_en', name: 'Instagram EN', icon: InstagramFilled, brandColor: '#E1306C', bgColor: '#FFF0F5', connected: true, selected: false, status: 'ready', format: 'Reels (9:16)' }, { id: 'tiktok', name: 'TikTok', icon: TiktokFilled, brandColor: '#000000', bgColor: '#F5F5F5', connected: true, selected: true, status: 'ready', format: 'Short Video (9:16)' }, { id: 'facebook_kr', name: 'Facebook KR', icon: FacebookFilled, brandColor: '#1877F2', bgColor: '#F0F4FF', connected: true, selected: false, status: 'ready', format: 'Video Post' }, { id: 'naver_blog', name: 'Naver Blog', icon: GlobeFilled, brandColor: '#03C75A', bgColor: '#F0FFF5', connected: false, selected: false, status: 'ready', format: 'Blog Post' }, { id: 'facebook_en', name: 'Facebook EN', icon: FacebookFilled, brandColor: '#1877F2', bgColor: '#F0F4FF', connected: false, selected: false, status: 'ready', format: 'Video Post' }, ]; // ─── Component ─── export default function DistributionPage() { const [channels, setChannels] = useState(INITIAL_CHANNELS); const [title, setTitle] = useState(MOCK_CONTENT.title); const [description, setDescription] = useState(MOCK_CONTENT.description); const [tags, setTags] = useState(MOCK_CONTENT.tags); const [scheduleMode, setScheduleMode] = useState<'now' | 'scheduled'>('now'); const [scheduleDate, setScheduleDate] = useState(''); const [scheduleHour, setScheduleHour] = useState(9); const [scheduleMinute, setScheduleMinute] = useState(0); const [schedulePeriod, setSchedulePeriod] = useState<'AM' | 'PM'>('AM'); const [isPublishing, setIsPublishing] = useState(false); const selectedChannels = channels.filter(c => c.connected && c.selected); const allPublished = selectedChannels.length > 0 && selectedChannels.every(c => c.status === 'published'); const toggleChannel = useCallback((id: string) => { setChannels(prev => prev.map(c => c.id === id && c.connected ? { ...c, selected: !c.selected } : c )); }, []); const handlePublish = useCallback(() => { setIsPublishing(true); // Simulate sequential publishing const selected = channels.filter(c => c.connected && c.selected); selected.forEach((ch, i) => { setTimeout(() => { setChannels(prev => prev.map(c => c.id === ch.id ? { ...c, status: 'publishing' } : c )); }, i * 1500); setTimeout(() => { setChannels(prev => prev.map(c => c.id === ch.id ? { ...c, status: 'published' } : c )); if (i === selected.length - 1) setIsPublishing(false); }, (i + 1) * 1500 + 500); }); }, [channels]); return (
Content Distribution
제작된 콘텐츠를 연결된 채널에 동시 배포합니다.
{MOCK_CONTENT.aspectRatio}
{MOCK_CONTENT.duration}
{ch.format}
배포 완료
{selectedChannels.length}개 채널에 성공적으로 배포되었습니다