import { useState, useCallback } from 'react';
import { motion } from 'motion/react';
import {
VideoFilled,
ShareFilled,
} from '@/shared/icons/FilledIcons';
import { Button } from '@/shared/ui/button';
import { Input } from '@/shared/ui/input';
import { Textarea } from '@/shared/ui/textarea';
import { MOCK_CONTENT, INITIAL_CHANNELS } from '../data/distributionMocks';
// ─── 컴포넌트 ───
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] = 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);
// 순차 발행 시뮬레이션
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 (
{/* Header */}
Content Distribution
콘텐츠 배포
제작된 콘텐츠를 연결된 채널에 동시 배포합니다.
{/* Left: Content Preview + Meta */}
콘텐츠
{/* Video Preview */}
{MOCK_CONTENT.aspectRatio}
{MOCK_CONTENT.duration}
{/* Title */}
setTitle(e.target.value)}
className="w-full px-4 py-3 h-auto rounded-xl border-slate-200 text-sm text-slate-700 focus-visible:border-brand-purple-vivid focus-visible:ring-brand-purple-vivid/20"
/>
{/* Description */}
{/* Tags */}
{tags.map(tag => (
#{tag}
))}
{/* Right: Channel Selection + Schedule + Publish */}
{/* Channel Selection */}
배포 채널 선택
{channels.map(ch => {
const Icon = ch.icon;
return (
{/* Checkbox */}
{/* Icon */}
{/* Info */}
{ch.name}
{!ch.connected && (
미연결
)}
{ch.format}
{/* Status */}
{ch.status === 'publishing' && (
)}
{ch.status === 'published' && (
)}
{ch.status === 'failed' && (
!
)}
);
})}
{/* Schedule */}
배포 시간
{([
{ key: 'now' as const, label: '즉시 배포' },
{ key: 'scheduled' as const, label: '예약 배포' },
]).map(opt => (
))}
{scheduleMode === 'scheduled' && (
{/* Date */}
setScheduleDate(e.target.value)}
className="w-full px-4 py-3 h-auto rounded-xl border-slate-200 text-sm text-slate-700 focus-visible:border-brand-purple-vivid appearance-none"
/>
{/* Custom Time Picker */}
{/* Hour */}
{String(scheduleHour).padStart(2, '0')}
:
{/* Minute */}
{String(scheduleMinute).padStart(2, '0')}
{/* AM/PM */}
{(['AM', 'PM'] as const).map(p => (
))}
)}
{/* Publish Button */}
{!allPublished ? (
) : (
배포 완료
{selectedChannels.length}개 채널에 성공적으로 배포되었습니다
)}
);
}