refactor: 생성 완료 화면을 CompletionView 로 통일
This commit is contained in:
1 parent
3701490728
commit
b9fd77fb51
4 files changed
+383
-343
No files matched your search
@@ -3,9 +3,7 @@ import React, { useState, useEffect, useRef } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { generateVideo, waitForVideoComplete, getSubtitleStatus, waitForSubtitleComplete, trackFirstVideoCreated } from '../../utils/api';
|
||||
import SocialPostingModal from '../../components/SocialPostingModal';
|
||||
import { useTutorial } from '../../components/Tutorial/useTutorial';
|
||||
import { TUTORIAL_KEYS } from '../../components/Tutorial/tutorialSteps';
|
||||
import TutorialOverlay from '../../components/Tutorial/TutorialOverlay';
|
||||
import CompletionView from '../../components/CompletionView';
|
||||
|
||||
interface CompletionContentProps {
|
||||
onBack: () => void;
|
||||
@@ -46,22 +44,6 @@ const CompletionContent: React.FC<CompletionContentProps> = ({
|
||||
const hasStartedGeneration = useRef(false);
|
||||
const displayIntervalRef = useRef<ReturnType<typeof setInterval> | null>(null);
|
||||
|
||||
const tutorial = useTutorial();
|
||||
const tutorialIsActiveRef = useRef(tutorial.isActive);
|
||||
tutorialIsActiveRef.current = tutorial.isActive;
|
||||
|
||||
// 영상 생성 중 튜토리얼 트리거 (생성 상태 안내 -> 콘텐츠 정보 -> 내 정보 이동)
|
||||
useEffect(() => {
|
||||
const isComplete = videoStatus === 'complete';
|
||||
const isProcessing = videoStatus === 'generating' || videoStatus === 'polling';
|
||||
|
||||
if (isProcessing && !tutorialIsActiveRef.current && !tutorial.hasSeen(TUTORIAL_KEYS.GENERATING)) {
|
||||
tutorial.startTutorial(TUTORIAL_KEYS.GENERATING);
|
||||
} else if (isComplete && !tutorialIsActiveRef.current && !tutorial.hasSeen(TUTORIAL_KEYS.COMPLETION)) {
|
||||
tutorial.startTutorial(TUTORIAL_KEYS.COMPLETION);
|
||||
}
|
||||
}, [videoStatus]);
|
||||
|
||||
// 소셜 미디어 포스팅 모달
|
||||
const [showSocialModal, setShowSocialModal] = useState(false);
|
||||
const [videoDbId, setVideoDbId] = useState<number | null>(null);
|
||||
@@ -410,175 +392,97 @@ const CompletionContent: React.FC<CompletionContentProps> = ({
|
||||
return `${businessName}.mp4`;
|
||||
};
|
||||
|
||||
/**
|
||||
* 가사 단락 파싱.
|
||||
*
|
||||
* `[Verse]` 처럼 대괄호만 있는 줄을 섹션 머리로 보고, 뒤따르는 줄들을 그 섹션에
|
||||
* 묶는다. 태그 없이 시작하는 가사도 있어 첫 섹션은 태그 없이 열릴 수 있다.
|
||||
*/
|
||||
const renderLyrics = () => {
|
||||
if (!songCompletionData) {
|
||||
return <p className="comp2-lyrics-text">{t('completion.sampleLyrics')}</p>;
|
||||
}
|
||||
if (!songCompletionData.lyrics) {
|
||||
return <p className="comp2-lyrics-text">{t('completion.noLyricsBGM')}</p>;
|
||||
}
|
||||
const lines = songCompletionData.lyrics.split('\n').filter((l: string) => l.trim());
|
||||
const sections: { tag: string | null; lines: string[] }[] = [];
|
||||
lines.forEach((line: string) => {
|
||||
const tagMatch = line.trim().match(/^\[(.+)\]$/);
|
||||
if (tagMatch) {
|
||||
sections.push({ tag: `[${tagMatch[1]}]`, lines: [] });
|
||||
} else if (sections.length === 0) {
|
||||
sections.push({ tag: null, lines: [line] });
|
||||
} else {
|
||||
sections[sections.length - 1].lines.push(line);
|
||||
}
|
||||
});
|
||||
return (
|
||||
<div className="comp2-lyrics-paragraphs">
|
||||
{sections
|
||||
.filter((s) => s.lines.length > 0)
|
||||
.map((section, i) => (
|
||||
<div key={i} className="comp2-lyrics-para-section">
|
||||
{section.tag && <span className="comp2-lyrics-tag">{section.tag}</span>}
|
||||
<p className="comp2-lyrics-text">{section.lines.join('\n')}</p>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<main className="comp2-page">
|
||||
{/* <div className="comp2-header">
|
||||
<button onClick={onBack} className="comp2-back-btn">
|
||||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
||||
<path d="M15 18l-6-6 6-6" />
|
||||
</svg>
|
||||
<span>{t('completion.back')}</span>
|
||||
</button>
|
||||
</div> */}
|
||||
|
||||
<div className="comp2-title-row">
|
||||
<h1 className="comp2-page-title">{t('completion.contentComplete')}</h1>
|
||||
<p className="comp2-page-subtitle">{t('completion.contentCompleteDesc')}</p>
|
||||
</div>
|
||||
|
||||
<div className="comp2-container">
|
||||
<div className="comp2-grid">
|
||||
{/* 왼쪽: 영상 */}
|
||||
<div className="comp2-video-section">
|
||||
<div className="comp2-video-wrapper">
|
||||
{isLoading ? (
|
||||
<div className="comp2-video-loading">
|
||||
<div className="loading-spinner">
|
||||
<div className="loading-ring"></div>
|
||||
<div className="loading-dot">
|
||||
<div className="loading-dot-inner"></div>
|
||||
</div>
|
||||
</div>
|
||||
<p className="comp2-loading-text">{statusMessage}</p>
|
||||
<div className="loading-progress-wrapper">
|
||||
<div className="loading-progress-bar">
|
||||
<div
|
||||
className="loading-progress-fill"
|
||||
style={{ width: `${displayProgress}%` }}
|
||||
/>
|
||||
</div>
|
||||
<span className="loading-progress-text">{Math.floor(displayProgress)}%</span>
|
||||
</div>
|
||||
</div>
|
||||
) : videoStatus === 'error' ? (
|
||||
<div className="comp2-video-error">
|
||||
<svg className="comp2-error-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
||||
<circle cx="12" cy="12" r="10" />
|
||||
<path d="M12 8v4M12 16h.01" />
|
||||
</svg>
|
||||
<p className="comp2-error-text">{errorMessage}</p>
|
||||
<button onClick={handleRetry} className="comp2-retry-btn">
|
||||
{t('completion.retry')}
|
||||
</button>
|
||||
</div>
|
||||
) : videoUrl ? (
|
||||
<video
|
||||
src={videoUrl}
|
||||
className="comp2-video-player"
|
||||
controls
|
||||
playsInline
|
||||
/>
|
||||
) : (
|
||||
<div className="comp2-video-placeholder"></div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 오른쪽: 콘텐츠 정보 */}
|
||||
<div className="comp2-info-section">
|
||||
<div className="comp2-info-header">
|
||||
<span className="comp2-info-label">{t('completion.contentInfo')}</span>
|
||||
</div>
|
||||
<div className="comp2-file-info">
|
||||
<h3 className="comp2-filename">{getFileName()}</h3>
|
||||
{/* <p className="comp2-filesize">19.6MB</p> */}
|
||||
</div>
|
||||
<div className="comp2-info-content">
|
||||
<div className="comp2-meta-grid">
|
||||
<div className="comp2-meta-item">
|
||||
<span className="comp2-meta-label">{t('completion.genre')} : {songCompletionData?.genre || 'K-POP'}</span>
|
||||
</div>
|
||||
<div className="comp2-meta-divider"></div>
|
||||
<div className="comp2-meta-item">
|
||||
<span className="comp2-meta-label">{t('completion.resolution')} : {getVideoResolution()}</span>
|
||||
</div>
|
||||
<div className="comp2-meta-divider"></div>
|
||||
<div className="comp2-lyrics-section">
|
||||
<span className="comp2-meta-label">{t('completion.lyrics')}</span>
|
||||
{(() => {
|
||||
if (!songCompletionData) {
|
||||
return <p className="comp2-lyrics-text">{t('completion.sampleLyrics')}</p>;
|
||||
}
|
||||
if (!songCompletionData.lyrics) {
|
||||
return <p className="comp2-lyrics-text">{t('completion.noLyricsBGM')}</p>;
|
||||
}
|
||||
const lines = songCompletionData.lyrics.split('\n').filter((l: string) => l.trim());
|
||||
const sections: { tag: string | null; lines: string[] }[] = [];
|
||||
lines.forEach((line: string) => {
|
||||
const tagMatch = line.trim().match(/^\[(.+)\]$/);
|
||||
if (tagMatch) {
|
||||
sections.push({ tag: `[${tagMatch[1]}]`, lines: [] });
|
||||
} else if (sections.length === 0) {
|
||||
sections.push({ tag: null, lines: [line] });
|
||||
} else {
|
||||
sections[sections.length - 1].lines.push(line);
|
||||
}
|
||||
});
|
||||
return (
|
||||
<div className="comp2-lyrics-paragraphs">
|
||||
{sections.filter(s => s.lines.length > 0).map((section, i) => (
|
||||
<div key={i} className="comp2-lyrics-para-section">
|
||||
{section.tag && <span className="comp2-lyrics-tag">{section.tag}</span>}
|
||||
<p className="comp2-lyrics-text">{section.lines.join('\n')}</p>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
})()}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/* 하단 버튼 */}
|
||||
<div className="comp2-buttons">
|
||||
<button
|
||||
onClick={handleDownload}
|
||||
disabled={videoStatus !== 'complete' || !videoUrl || isDownloading}
|
||||
className="comp2-btn comp2-btn-secondary"
|
||||
>
|
||||
{isDownloading ? t('completion.downloading') : t('completion.download')}
|
||||
</button>
|
||||
<button
|
||||
onClick={handleOpenSocialConnect}
|
||||
disabled={videoStatus !== 'complete' || !videoDbId}
|
||||
className="comp2-btn comp2-btn-primary"
|
||||
>
|
||||
{t('completion.uploadToSocial')}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 소셜 미디어 포스팅 모달 (기존 SocialPostingModal 컴포넌트 사용) */}
|
||||
<SocialPostingModal
|
||||
isOpen={showSocialModal}
|
||||
onClose={handleCloseSocialConnect}
|
||||
onGoToCalendar={onGoToCalendar}
|
||||
video={videoUrl && videoDbId ? {
|
||||
// ADO2 파이프라인 완료 화면이므로 항상 영상이다
|
||||
type: 'video',
|
||||
video_id: videoDbId,
|
||||
store_name: songCompletionData?.businessName || '',
|
||||
region: '',
|
||||
task_id: songTaskId || '',
|
||||
result_movie_url: videoUrl,
|
||||
created_at: new Date().toISOString(),
|
||||
like_count: 0,
|
||||
comment_count: 0,
|
||||
} : null}
|
||||
/>
|
||||
|
||||
{tutorial.isActive && (
|
||||
<TutorialOverlay
|
||||
hints={tutorial.hints}
|
||||
currentIndex={tutorial.currentHintIndex}
|
||||
onNext={tutorial.nextHint}
|
||||
onPrev={tutorial.prevHint}
|
||||
onSkip={tutorial.skipTutorial}
|
||||
groupProgress={tutorial.groupProgress}
|
||||
/>
|
||||
)}
|
||||
</main>
|
||||
<CompletionView
|
||||
videoState={
|
||||
isLoading
|
||||
? 'loading'
|
||||
: videoStatus === 'error'
|
||||
? 'error'
|
||||
: videoUrl
|
||||
? 'ready'
|
||||
: 'empty'
|
||||
}
|
||||
videoUrl={videoUrl}
|
||||
loadingText={statusMessage}
|
||||
progress={displayProgress}
|
||||
errorMessage={errorMessage}
|
||||
onRetry={handleRetry}
|
||||
fileName={getFileName()}
|
||||
metaLines={[
|
||||
`${t('completion.genre')} : ${songCompletionData?.genre || 'K-POP'}`,
|
||||
`${t('completion.resolution')} : ${getVideoResolution()}`,
|
||||
]}
|
||||
detailLabel={t('completion.lyrics')}
|
||||
detail={renderLyrics()}
|
||||
onDownload={handleDownload}
|
||||
downloadDisabled={videoStatus !== 'complete' || !videoUrl || isDownloading}
|
||||
downloadLabel={isDownloading ? t('completion.downloading') : t('completion.download')}
|
||||
onUpload={handleOpenSocialConnect}
|
||||
uploadDisabled={videoStatus !== 'complete' || !videoDbId}
|
||||
>
|
||||
{/* 소셜 미디어 포스팅 모달 (기존 SocialPostingModal 컴포넌트 사용) */}
|
||||
<SocialPostingModal
|
||||
isOpen={showSocialModal}
|
||||
onClose={handleCloseSocialConnect}
|
||||
onGoToCalendar={onGoToCalendar}
|
||||
video={
|
||||
videoUrl && videoDbId
|
||||
? {
|
||||
// ADO2 파이프라인 완료 화면이므로 항상 영상이다
|
||||
type: 'video',
|
||||
video_id: videoDbId,
|
||||
store_name: songCompletionData?.businessName || '',
|
||||
region: '',
|
||||
task_id: songTaskId || '',
|
||||
result_movie_url: videoUrl,
|
||||
created_at: new Date().toISOString(),
|
||||
like_count: 0,
|
||||
comment_count: 0,
|
||||
}
|
||||
: null
|
||||
}
|
||||
/>
|
||||
</CompletionView>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { SsulTaskStatus, getSsulTask } from '../../utils/api';
|
||||
import { SCEN, Scen, scenName } from './ssulData';
|
||||
import { IcDownload } from './ssulIcons';
|
||||
import { VideoListItem } from '../../types/api';
|
||||
import SocialPostingModal from '../../components/SocialPostingModal';
|
||||
import CompletionView from '../../components/CompletionView';
|
||||
import { Scen, scenDesc, scenName } from './ssulData';
|
||||
|
||||
interface SsulResultContentProps {
|
||||
taskId: number;
|
||||
@@ -12,9 +14,18 @@ interface SsulResultContentProps {
|
||||
/**
|
||||
* 썰박스 생성 완료 화면.
|
||||
*
|
||||
* 완성된 영상을 재생하고 다운로드할 수 있다.
|
||||
* SNS 업로드는 castad `SocialPostingModal` 재사용을 먼저 시도해야 하므로
|
||||
* 통합 목록 작업(Phase 8)과 함께 붙인다.
|
||||
* **화면은 ADO2 완료 화면과 같은 `CompletionView` 를 쓴다**(2026-08-10 통일).
|
||||
* 이전에는 `.ssul-scope` 안의 중앙 1단 레이아웃이었는데, 같은 제품 안에서
|
||||
* 완료 화면이 둘로 갈리는 것이 혼란스러웠고 영상 로딩·에러 처리도 없었다.
|
||||
* 정보 패널만 썰박스 재료(시나리오·생성일시·시나리오 설명)로 채운다.
|
||||
*
|
||||
* `.ssul-scope` 를 벗어나면서 부수 효과가 하나 있다: 예전에는 상위의
|
||||
* `text-align: center` 가 SNS 업로드 모달 라벨까지 가운데로 끌어당겼는데
|
||||
* 그 경로가 사라졌다. 다만 오버레이 쪽 방어(`.social-posting-overlay` 의
|
||||
* `text-align`)는 다른 마운트 지점을 위해 그대로 둔다.
|
||||
*
|
||||
* 업로드는 castad `SocialPostingModal` 을 그대로 쓴다 — social_upload 병합으로
|
||||
* 모달이 `content_type` 을 함께 보내므로 종류 분기가 모달 내부에서 끝난다.
|
||||
*/
|
||||
const SsulResultContent: React.FC<SsulResultContentProps> = ({ taskId, scenario }) => {
|
||||
const { t } = useTranslation();
|
||||
@@ -22,6 +33,7 @@ const SsulResultContent: React.FC<SsulResultContentProps> = ({ taskId, scenario
|
||||
const [loadError, setLoadError] = useState(false);
|
||||
// 영상 전체를 받아오는 동안 시간이 걸린다 — 중복 클릭을 막고 진행을 알린다
|
||||
const [downloading, setDownloading] = useState(false);
|
||||
const [showSocialModal, setShowSocialModal] = useState(false);
|
||||
|
||||
// 폴링이 끝난 뒤 최종 상태(video_url 포함)를 한 번 더 읽는다.
|
||||
// 진행 중에는 video_url 이 비어 있으므로 완료 후 조회가 필요하다.
|
||||
@@ -35,7 +47,8 @@ const SsulResultContent: React.FC<SsulResultContentProps> = ({ taskId, scenario
|
||||
};
|
||||
}, [taskId]);
|
||||
|
||||
const palette = SCEN[scenario];
|
||||
// 파일명은 프론트가 정한다(백엔드는 title 을 갖지 않는다)
|
||||
const fileName = `ssulbox-${scenario}-${taskId}.mp4`;
|
||||
|
||||
/**
|
||||
* 영상 다운로드.
|
||||
@@ -51,8 +64,6 @@ const SsulResultContent: React.FC<SsulResultContentProps> = ({ taskId, scenario
|
||||
*/
|
||||
const handleDownload = async () => {
|
||||
if (!task?.video_url || downloading) return;
|
||||
// 파일명은 프론트가 정한다(백엔드는 title 을 갖지 않는다)
|
||||
const fileName = `ssulbox-${scenario}-${taskId}.mp4`;
|
||||
setDownloading(true);
|
||||
try {
|
||||
const response = await fetch(task.video_url);
|
||||
@@ -79,54 +90,55 @@ const SsulResultContent: React.FC<SsulResultContentProps> = ({ taskId, scenario
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="ssul-scope ssul-result">
|
||||
<span className="ssul-result__scenario" style={{ color: palette.hex }}>
|
||||
<span aria-hidden="true">{palette.emoji}</span> {t(scenName(scenario))}
|
||||
</span>
|
||||
|
||||
<h3 className="ssul-result__title">{t('ssulbox.result.title')}</h3>
|
||||
|
||||
{loadError ? (
|
||||
<div className="ssul-hint warn">{t('ssulbox.result.loadFailed')}</div>
|
||||
) : task?.video_url ? (
|
||||
<video
|
||||
className="ssul-result__video"
|
||||
src={task.video_url}
|
||||
controls
|
||||
playsInline
|
||||
preload="metadata"
|
||||
/>
|
||||
) : (
|
||||
<div className="ssul-result__video-skeleton" />
|
||||
)}
|
||||
|
||||
<div className="ssul-result__actions">
|
||||
<button
|
||||
type="button"
|
||||
className="ssul-result__btn primary"
|
||||
onClick={handleDownload}
|
||||
disabled={!task?.video_url || downloading}
|
||||
>
|
||||
<IcDownload />
|
||||
{downloading
|
||||
? t('ssulbox.result.downloading')
|
||||
: t('ssulbox.result.download')}
|
||||
</button>
|
||||
|
||||
{/*
|
||||
TODO(Phase 8): SNS 업로드 버튼 자리.
|
||||
castad `SocialPostingModal` 을 그대로 쓸 수 없다 — `VideoListItem` 을 받아
|
||||
`video_id` 로 업로드 API 를 호출하는데, 그 API 는 `video` 테이블을 조회하고
|
||||
`social_upload.video_id`(NOT NULL FK)에 쓴다. 썰박스에는 video_id 가 없고,
|
||||
taskId 를 넘기면 **id 가 겹치는 남의 ADO2 영상이 업로드된다**
|
||||
(ssul_content.id 와 video.id 가 둘 다 1부터 시작한다).
|
||||
→ `/ssul/upload/*` 백엔드와 모달 분기가 선행되어야 한다.
|
||||
|
||||
'새로 만들기' 버튼은 제거했다. 사이드바 '새 프로젝트 만들기'가 같은 일을
|
||||
하고, ADO2 완료 화면도 재생성 버튼을 두지 않는다.
|
||||
*/}
|
||||
</div>
|
||||
</div>
|
||||
<CompletionView
|
||||
// 여기에 도달했다는 것은 생성이 이미 끝났다는 뜻이라 'loading' 은 쓰지 않는다.
|
||||
// 남는 실패 경우는 최종 상태 조회 실패뿐이며, 재시도 버튼은 두지 않는다
|
||||
// (생성을 다시 돌리는 것이 아니라 조회만 실패한 것이므로 새로고침이 맞다).
|
||||
videoState={loadError ? 'error' : task?.video_url ? 'ready' : 'empty'}
|
||||
videoUrl={task?.video_url}
|
||||
errorMessage={t('ssulbox.result.loadFailed')}
|
||||
fileName={fileName}
|
||||
metaLines={[
|
||||
`${t('ssulbox.result.scenarioLabel')} : ${t(scenName(scenario))}`,
|
||||
`${t('ssulbox.result.createdLabel')} : ${
|
||||
task?.created_at ? new Date(task.created_at).toLocaleString('ko-KR') : '-'
|
||||
}`,
|
||||
]}
|
||||
// ADO2 의 가사 자리. 썰박스는 대본이 영상 안에 그려지므로 내려받을 텍스트가
|
||||
// 없고, 대신 어떤 이야기인지 알려주는 시나리오 설명을 넣는다.
|
||||
detailLabel={t('ssulbox.result.scenarioLabel')}
|
||||
detail={<p className="comp2-lyrics-text">{t(scenDesc(scenario))}</p>}
|
||||
onDownload={handleDownload}
|
||||
downloadDisabled={!task?.video_url || downloading}
|
||||
downloadLabel={
|
||||
downloading ? t('ssulbox.result.downloading') : t('ssulbox.result.download')
|
||||
}
|
||||
onUpload={() => setShowSocialModal(true)}
|
||||
uploadDisabled={!task?.video_url}
|
||||
>
|
||||
{/* castad 모달 재사용 — VideoListItem 형태로 매핑해 넘긴다.
|
||||
type='ssul' 이 핵심이다: 모달이 content_type 으로 보내므로
|
||||
id 가 겹치는 ADO2 영상이 업로드되는 사고가 없다. */}
|
||||
<SocialPostingModal
|
||||
isOpen={showSocialModal}
|
||||
onClose={() => setShowSocialModal(false)}
|
||||
video={
|
||||
task?.video_url
|
||||
? ({
|
||||
type: 'ssul',
|
||||
video_id: taskId,
|
||||
store_name: t(scenName(scenario)),
|
||||
region: '',
|
||||
task_id: '',
|
||||
result_movie_url: task.video_url,
|
||||
created_at: task.created_at,
|
||||
like_count: 0,
|
||||
comment_count: 0,
|
||||
} as VideoListItem)
|
||||
: null
|
||||
}
|
||||
/>
|
||||
</CompletionView>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user