유튜브 업로드 기능 완료 .

This commit is contained in:
HyeongBaeYang committed 2026-02-02 16:43:41 +09:00
1 parent e1b860a15f
commit fd9db31e52
12 files changed
+2257 -30

No files matched your search

+40 -5
View File
@@ -2,6 +2,7 @@
import React, { useState, useEffect } from 'react';
import { getVideosList, deleteVideo } from '../../utils/api';
import { VideoListItem } from '../../types/api';
import SocialPostingModal from '../../components/SocialPostingModal';
interface ADO2ContentsPageProps {
onBack: () => void;
@@ -17,8 +18,10 @@ const ADO2ContentsPage: React.FC<ADO2ContentsPageProps> = ({ onBack }) => {
const [hasPrev, setHasPrev] = useState(false);
const [totalPages, setTotalPages] = useState(1);
const [deleteModalOpen, setDeleteModalOpen] = useState(false);
const [deleteTargetId, setDeleteTargetId] = useState<string | null>(null);
const [deleteTargetId, setDeleteTargetId] = useState<number | null>(null);
const [isDeleting, setIsDeleting] = useState(false);
const [uploadModalOpen, setUploadModalOpen] = useState(false);
const [uploadTargetVideo, setUploadTargetVideo] = useState<VideoListItem | null>(null);
const pageSize = 12;
@@ -31,6 +34,8 @@ const ADO2ContentsPage: React.FC<ADO2ContentsPageProps> = ({ onBack }) => {
setError(null);
try {
const response = await getVideosList(page, pageSize);
console.log('[ADO2] API response:', response);
console.log('[ADO2] First video item:', response.items[0]);
// result_movie_url이 있는 비디오만 필터링 (빈/더미 데이터 제외)
const validVideos = response.items.filter(video => video.result_movie_url && video.result_movie_url.trim() !== '');
setVideos(validVideos);
@@ -83,11 +88,23 @@ const ADO2ContentsPage: React.FC<ADO2ContentsPageProps> = ({ onBack }) => {
}
};
const handleDeleteClick = (taskId: string) => {
setDeleteTargetId(taskId);
const handleDeleteClick = (videoId: number) => {
setDeleteTargetId(videoId);
setDeleteModalOpen(true);
};
const handleUploadClick = (video: VideoListItem) => {
console.log('[ADO2] Upload clicked - video object:', video);
console.log('[ADO2] video.video_id:', video.video_id);
setUploadTargetVideo(video);
setUploadModalOpen(true);
};
const handleUploadModalClose = () => {
setUploadModalOpen(false);
setUploadTargetVideo(null);
};
const handleDeleteCancel = () => {
setDeleteModalOpen(false);
setDeleteTargetId(null);
@@ -102,7 +119,7 @@ const ADO2ContentsPage: React.FC<ADO2ContentsPageProps> = ({ onBack }) => {
// 삭제 성공 시 로컬 상태에서 즉시 제거 (UI 즉시 반영)
// fetchVideos()를 호출하지 않음 - 서버 캐시 또는 동기화 지연으로 인해
// 삭제된 항목이 다시 나타날 수 있기 때문
setVideos(prev => prev.filter(video => video.task_id !== deleteTargetId));
setVideos(prev => prev.filter(video => video.video_id !== deleteTargetId));
setTotal(prev => Math.max(0, prev - 1));
setDeleteModalOpen(false);
@@ -197,9 +214,20 @@ const ADO2ContentsPage: React.FC<ADO2ContentsPageProps> = ({ onBack }) => {
</svg>
<span>다운로드</span>
</button>
<button
className="content-upload-btn"
onClick={() => handleUploadClick(video)}
disabled={!video.result_movie_url}
title="소셜 미디어에 업로드"
>
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.5">
<path d="M10 13V3M10 3l-4 4M10 3l4 4"/>
<path d="M3 15v2h14v-2"/>
</svg>
</button>
<button
className="content-delete-btn"
onClick={() => handleDeleteClick(video.task_id)}
onClick={() => handleDeleteClick(video.video_id)}
>
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.5">
<path d="M3 5h14M8 5V3h4v2M6 5v12h8V5"/>
@@ -259,6 +287,13 @@ const ADO2ContentsPage: React.FC<ADO2ContentsPageProps> = ({ onBack }) => {
</div>
</div>
)}
{/* 소셜 미디어 업로드 모달 */}
<SocialPostingModal
isOpen={uploadModalOpen}
onClose={handleUploadModalClose}
video={uploadTargetVideo}
/>
</div>
);
};
@@ -9,7 +9,7 @@ interface AssetManagementSectionProps {
const AssetManagementSection: React.FC<AssetManagementSectionProps> = ({ onBack }) => {
return (
<div className="flex w-full h-screen bg-[#0d1416] text-white overflow-hidden">
<div className="flex w-full h-screen bg-[#002224] text-white overflow-hidden">
<Sidebar />
<div className="flex-1 overflow-y-auto">
<AssetManagementContent onBack={onBack} onNext={() => {}} />
+25 -1
View File
@@ -362,7 +362,7 @@ const CompletionContent: React.FC<CompletionContentProps> = ({
if (!youtubeAccount) return;
try {
await disconnectSocialAccount('youtube');
await disconnectSocialAccount(youtubeAccount.id);
setYoutubeAccount(null);
setSelectedSocials(prev => prev.filter(s => s !== 'Youtube'));
} catch (error) {
@@ -412,6 +412,29 @@ const CompletionContent: React.FC<CompletionContentProps> = ({
}
};
// 소셜 채널에 배포
const handleDeploy = () => {
if (selectedSocials.length === 0) {
alert('배포할 소셜 채널을 선택해주세요.');
return;
}
if (!videoUrl) {
alert('영상이 아직 준비되지 않았습니다.');
return;
}
// 선택된 채널 중 YouTube가 있고 연결된 경우
if (selectedSocials.includes('Youtube') && youtubeAccount) {
// TODO: YouTube 업로드 API 호출
alert(`YouTube 채널 "${youtubeAccount.display_name}"에 영상을 업로드합니다.\n\n(업로드 기능 준비 중)`);
return;
}
// 다른 플랫폼 선택 시
alert('선택한 소셜 채널에 배포 기능이 준비 중입니다.');
};
const handleRetry = () => {
hasStartedGeneration.current = false;
setVideoStatus('idle');
@@ -615,6 +638,7 @@ const CompletionContent: React.FC<CompletionContentProps> = ({
<div className="sharing-actions">
<button
onClick={handleDeploy}
disabled={selectedSocials.length === 0 || videoStatus !== 'complete'}
className="btn-completion-deploy"
>
+6 -3
View File
@@ -8,6 +8,7 @@ import DashboardContent from './DashboardContent';
import BusinessSettingsContent from './BusinessSettingsContent';
import UrlInputContent from './UrlInputContent';
import ADO2ContentsPage from './ADO2ContentsPage';
import MyInfoContent from './MyInfoContent';
import LoadingSection from '../Analysis/LoadingSection';
import AnalysisResultSection from '../Analysis/AnalysisResultSection';
import { ImageItem, CrawlingResponse } from '../../types/api';
@@ -355,6 +356,8 @@ const GenerationFlow: React.FC<GenerationFlowProps> = ({
onBack={() => setActiveItem('새 프로젝트 만들기')}
/>
);
case '내 정보':
return <MyInfoContent />;
case '새 프로젝트 만들기':
// 브랜드 분석(0)과 로딩(-1)은 전체 화면으로 표시
if (wizardStep === 0 || wizardStep === -1) {
@@ -379,8 +382,8 @@ const GenerationFlow: React.FC<GenerationFlowProps> = ({
// 브랜드 분석(0)일 때는 전체 페이지 스크롤
const isBrandAnalysis = activeItem === '새 프로젝트 만들기' && wizardStep === 0;
// 스크롤이 필요한 페이지: 대시보드, 비즈니스 설정, 브랜드 분석(0), ADO2 콘텐츠
const needsScroll = activeItem === '대시보드' || activeItem === '비즈니스 설정' || activeItem === 'ADO2 콘텐츠' || isBrandAnalysis;
// 스크롤이 필요한 페이지: 대시보드, 비즈니스 설정, 브랜드 분석(0), ADO2 콘텐츠, 내 정보
const needsScroll = activeItem === '대시보드' || activeItem === '비즈니스 설정' || activeItem === 'ADO2 콘텐츠' || activeItem === '내 정보' || isBrandAnalysis;
// 브랜드 분석일 때는 전체 화면 스크롤
if (isBrandAnalysis) {
@@ -397,7 +400,7 @@ const GenerationFlow: React.FC<GenerationFlowProps> = ({
}
return (
<div className={`flex w-full bg-[#0d1416] text-white ${needsScroll ? 'min-h-[100dvh]' : 'h-[100dvh] overflow-hidden'}`}>
<div className={`flex w-full bg-[#002224] text-white ${needsScroll ? 'min-h-[100dvh]' : 'h-[100dvh] overflow-hidden'}`}>
{showSidebar && (
<Sidebar activeItem={activeItem} onNavigate={handleNavigate} onHome={handleHome} />
)}
+239
View File
@@ -0,0 +1,239 @@
import React, { useState, useEffect } from 'react';
import { getSocialAccounts, getYouTubeConnectUrl, disconnectSocialAccount } from '../../utils/api';
import { SocialAccount } from '../../types/api';
type TabType = 'basic' | 'payment' | 'business';
const MyInfoContent: React.FC = () => {
const [activeTab, setActiveTab] = useState<TabType>('business');
const [businessUrl, setBusinessUrl] = useState('');
const [socialAccounts, setSocialAccounts] = useState<SocialAccount[]>([]);
const [isLoadingAccounts, setIsLoadingAccounts] = useState(false);
const [isConnecting, setIsConnecting] = useState<string | null>(null);
// 소셜 계정 목록 로드
useEffect(() => {
loadSocialAccounts();
}, []);
const loadSocialAccounts = async () => {
setIsLoadingAccounts(true);
try {
const response = await getSocialAccounts();
setSocialAccounts(response.accounts || []);
} catch (error) {
console.error('Failed to load social accounts:', error);
} finally {
setIsLoadingAccounts(false);
}
};
// YouTube 연결
const handleYoutubeConnect = async () => {
setIsConnecting('youtube');
try {
const response = await getYouTubeConnectUrl();
window.location.href = response.auth_url;
} catch (error) {
console.error('Failed to get YouTube connect URL:', error);
setIsConnecting(null);
}
};
// 소셜 계정 연결 해제 (특정 계정 ID로)
const handleDisconnectAccount = async (accountId: number) => {
try {
await disconnectSocialAccount(accountId);
setSocialAccounts(prev => prev.filter(acc => acc.id !== accountId));
} catch (error) {
console.error('Failed to disconnect:', error);
}
};
// 플랫폼별 연결된 모든 계정 가져오기
const getConnectedAccounts = (platform: string) => {
return socialAccounts.filter(acc => acc.platform === platform && acc.is_active);
};
const youtubeAccounts = getConnectedAccounts('youtube');
const instagramAccounts = getConnectedAccounts('instagram');
const hasConnectedAccounts = youtubeAccounts.length > 0 || instagramAccounts.length > 0;
const tabs = [
{ id: 'basic' as TabType, label: '기본 정보' },
{ id: 'payment' as TabType, label: '결제 정보' },
{ id: 'business' as TabType, label: '내 비즈니스 & 소셜 채널 관리' },
];
return (
<main className="myinfo-page">
<h1 className="myinfo-title">내 정보</h1>
{/* 탭 네비게이션 */}
<div className="myinfo-tabs">
{tabs.map(tab => (
<button
key={tab.id}
onClick={() => setActiveTab(tab.id)}
className={`myinfo-tab ${activeTab === tab.id ? 'active' : ''}`}
>
{tab.label}
</button>
))}
</div>
{/* 탭 컨텐츠 */}
<div className="myinfo-content">
{activeTab === 'basic' && (
<div className="myinfo-section">
<p className="myinfo-placeholder">기본 정보 설정 기능이 준비 중입니다.</p>
</div>
)}
{activeTab === 'payment' && (
<div className="myinfo-section">
<p className="myinfo-placeholder">결제 정보 설정 기능이 준비 중입니다.</p>
</div>
)}
{activeTab === 'business' && (
<>
{/* 내 비즈니스 섹션 */}
<div className="myinfo-section">
<h2 className="myinfo-section-title">내 비즈니스</h2>
<div className="myinfo-business-card">
<h3 className="myinfo-business-empty-title">아직 등록된 비즈니스가 없어요</h3>
<p className="myinfo-business-empty-desc">
네이버 지도 URL을 입력하면, 영상 제작에 필요한 정보를 자동으로 불러와요
</p>
<div className="myinfo-business-input-row">
<input
type="text"
value={businessUrl}
onChange={(e) => setBusinessUrl(e.target.value)}
placeholder="네이버 지도 URL 입력"
className="myinfo-business-input"
/>
<button className="myinfo-business-submit">
비즈니스 등록
</button>
</div>
</div>
</div>
{/* 소셜 채널 섹션 */}
<div className="myinfo-section">
<h2 className="myinfo-section-title">소셜 채널</h2>
{/* 연결 버튼들 (가로 배치) */}
<div className="myinfo-social-buttons">
<button
onClick={handleYoutubeConnect}
disabled={isConnecting === 'youtube'}
className={`myinfo-social-btn ${youtubeAccounts.length > 0 ? 'connected' : ''}`}
>
<img src="/assets/images/social-youtube.png" alt="YouTube" className="myinfo-social-btn-icon" />
<span>{isConnecting === 'youtube' ? '연결 중...' : 'YouTube 연결'}</span>
</button>
<button
disabled
className="myinfo-social-btn disabled"
>
<img src="/assets/images/social-instagram.png" alt="Instagram" className="myinfo-social-btn-icon" />
<span>Instagram 연결</span>
</button>
</div>
{/* 연결된 계정 목록 */}
{hasConnectedAccounts && (
<div className="myinfo-connected-accounts">
{/* YouTube 계정들 */}
{youtubeAccounts.map(account => (
<div key={account.id} className="myinfo-connected-card">
<div className="myinfo-connected-info">
{account.profile_image ? (
<img
src={account.profile_image}
alt={account.display_name}
className="myinfo-connected-avatar"
/>
) : (
<div className="myinfo-connected-icon">
<img src="/assets/images/social-youtube.png" alt="YouTube" />
</div>
)}
<div className="myinfo-connected-text">
<span className="myinfo-connected-channel">{account.display_name}</span>
<span className="myinfo-connected-platform">YouTube</span>
</div>
</div>
<div className="myinfo-connected-actions">
<span className="myinfo-connected-badge">
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">
<polyline points="20 6 9 17 4 12" />
</svg>
연결됨
</span>
<button
onClick={() => handleDisconnectAccount(account.id)}
className="myinfo-connected-disconnect"
>
연결 해제
</button>
</div>
</div>
))}
{/* Instagram 계정들 */}
{instagramAccounts.map(account => (
<div key={account.id} className="myinfo-connected-card">
<div className="myinfo-connected-info">
{account.profile_image ? (
<img
src={account.profile_image}
alt={account.display_name}
className="myinfo-connected-avatar"
/>
) : (
<div className="myinfo-connected-icon">
<img src="/assets/images/social-instagram.png" alt="Instagram" />
</div>
)}
<div className="myinfo-connected-text">
<span className="myinfo-connected-channel">{account.display_name}</span>
<span className="myinfo-connected-platform">Instagram</span>
</div>
</div>
<div className="myinfo-connected-actions">
<span className="myinfo-connected-badge">
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">
<polyline points="20 6 9 17 4 12" />
</svg>
연결됨
</span>
<button
onClick={() => handleDisconnectAccount(account.id)}
className="myinfo-connected-disconnect"
>
연결 해제
</button>
</div>
</div>
))}
</div>
)}
{isLoadingAccounts && (
<p className="myinfo-loading">계정 정보를 불러오는 중...</p>
)}
</div>
</>
)}
</div>
</main>
);
};
export default MyInfoContent;