feat(ssulbox): 썰박스 진입 탭·생성 플로우와 통합 콘텐츠 목록 분기
This commit is contained in:
1 parent
c4c46db0d9
commit
bb0ab91bcc
26 files changed
+2793
-119
No files matched your search
@@ -6,6 +6,7 @@ import LoginPromptModal from '../../components/LoginPromptModal';
|
||||
import VideoDetailModal from '../../components/VideoDetailModal';
|
||||
import CitySelectModal from '../../components/CitySelectModal';
|
||||
import ContentCardSocialActions from '../../components/ContentCardSocialActions';
|
||||
import SsulViewerModal from '../Ssulbox/SsulViewerModal';
|
||||
|
||||
interface ADO2ContentsPageProps {
|
||||
onBack?: () => void;
|
||||
@@ -15,6 +16,9 @@ const ADO2ContentsPage: React.FC<ADO2ContentsPageProps> = () => {
|
||||
const { t } = useTranslation();
|
||||
const authed = isLoggedIn();
|
||||
const [selectedVideoId, setSelectedVideoId] = useState<number | null>(null);
|
||||
// 썰박스는 별도 뷰어를 쓴다 — VideoDetailModal 은 video_id 로 조회하므로
|
||||
// 썰박스 id 를 넘기면 id 가 겹치는 다른 영상이 열린다.
|
||||
const [selectedSsul, setSelectedSsul] = useState<VideoListItem | null>(null);
|
||||
const [videos, setVideos] = useState<VideoListItem[]>([]);
|
||||
const [total, setTotal] = useState(0);
|
||||
const [loading, setLoading] = useState(authed);
|
||||
@@ -141,14 +145,25 @@ const ADO2ContentsPage: React.FC<ADO2ContentsPageProps> = () => {
|
||||
<>
|
||||
<div className="ado2-contents-grid">
|
||||
{videos.map((video) => (
|
||||
// key·상세 열기 모두 (type, video_id) 로 다뤄야 한다 —
|
||||
// video_id 는 종류별 독립 시퀀스라 값이 겹친다.
|
||||
<div
|
||||
key={video.video_id}
|
||||
key={`${video.type}-${video.video_id}`}
|
||||
className="ado2-content-card"
|
||||
style={{ cursor: 'pointer' }}
|
||||
onClick={() => handleCardClick(video.video_id)}
|
||||
onClick={() =>
|
||||
video.type === 'ssul'
|
||||
? setSelectedSsul(video)
|
||||
: handleCardClick(video.video_id)
|
||||
}
|
||||
role="button"
|
||||
tabIndex={0}
|
||||
onKeyDown={(e) => e.key === 'Enter' && handleCardClick(video.video_id)}
|
||||
onKeyDown={(e) =>
|
||||
e.key === 'Enter' &&
|
||||
(video.type === 'ssul'
|
||||
? setSelectedSsul(video)
|
||||
: handleCardClick(video.video_id))
|
||||
}
|
||||
>
|
||||
<div className="content-card-thumbnail ado2-gallery-thumbnail-wrap">
|
||||
{video.thumbnail_url ? (
|
||||
@@ -182,14 +197,19 @@ const ADO2ContentsPage: React.FC<ADO2ContentsPageProps> = () => {
|
||||
<h3 className="content-card-title">{video.store_name}</h3>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
|
||||
<p className="content-card-date">{formatDate(video.created_at)}</p>
|
||||
<ContentCardSocialActions
|
||||
videoId={video.video_id}
|
||||
storeName={video.store_name}
|
||||
region={video.region}
|
||||
commentCount={video.comment_count ?? 0}
|
||||
initialLikeCount={video.like_count ?? 0}
|
||||
initialIsLiked={video.is_liked_by_me}
|
||||
/>
|
||||
{/* 좋아요·댓글은 castad API 를 video_id 로 호출한다.
|
||||
썰박스 id 를 넘기면 id 가 겹치는 다른 영상에 반영되므로
|
||||
`/ssul/*` 반응 API 가 붙기 전까지 노출하지 않는다. */}
|
||||
{video.type === 'video' && (
|
||||
<ContentCardSocialActions
|
||||
videoId={video.video_id}
|
||||
storeName={video.store_name}
|
||||
region={video.region}
|
||||
commentCount={video.comment_count ?? 0}
|
||||
initialLikeCount={video.like_count ?? 0}
|
||||
initialIsLiked={video.is_liked_by_me}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -221,6 +241,8 @@ const ADO2ContentsPage: React.FC<ADO2ContentsPageProps> = () => {
|
||||
<LoginPromptModal onClose={() => { window.location.href = '/'; }} />
|
||||
)}
|
||||
|
||||
<SsulViewerModal item={selectedSsul} onClose={() => setSelectedSsul(null)} />
|
||||
|
||||
{selectedVideoId !== null && (
|
||||
<VideoDetailModal
|
||||
videoId={String(selectedVideoId)}
|
||||
|
||||
@@ -555,6 +555,8 @@ const CompletionContent: React.FC<CompletionContentProps> = ({
|
||||
onClose={handleCloseSocialConnect}
|
||||
onGoToCalendar={onGoToCalendar}
|
||||
video={videoUrl && videoDbId ? {
|
||||
// ADO2 파이프라인 완료 화면이므로 항상 영상이다
|
||||
type: 'video',
|
||||
video_id: videoDbId,
|
||||
store_name: songCompletionData?.businessName || '',
|
||||
region: '',
|
||||
|
||||
@@ -15,32 +15,50 @@ import ContentCalendarContent from './ContentCalendarContent';
|
||||
import LoadingSection from '../Analysis/LoadingSection';
|
||||
import AnalysisResultSection from '../Analysis/AnalysisResultSection';
|
||||
import { ImageItem, type ImageListItem, CrawlingResponse, UserMeResponse } from '../../types/api';
|
||||
import { crawlUrl, autocomplete, marketingAnalysis, AutocompleteRequest, getUserMe, getUserCredits, clearTokens } from '../../utils/api';
|
||||
import { crawlUrl, autocomplete, marketingAnalysis, AutocompleteRequest, getUserMe, getUserCredits, clearTokens, getActiveSsulTask, waitForSsulComplete } from '../../utils/api';
|
||||
import { useTutorial } from '../../components/Tutorial/useTutorial';
|
||||
import { TUTORIAL_KEYS } from '../../components/Tutorial/tutorialSteps';
|
||||
import TutorialOverlay, { TutorialRestartPopup } from '../../components/Tutorial/TutorialOverlay';
|
||||
import WizardStepper from '../../components/WizardStepper';
|
||||
|
||||
const WIZARD_STEP_KEY = 'castad_wizard_step';
|
||||
const ACTIVE_ITEM_KEY = 'castad_active_item';
|
||||
const SONG_TASK_ID_KEY = 'castad_song_task_id';
|
||||
const IMAGE_TASK_ID_KEY = 'castad_image_task_id';
|
||||
const ANALYSIS_DATA_KEY = 'castad_analysis_data';
|
||||
import { saveSearchHistory } from '../../components/SearchHistory/useSearchHistory';
|
||||
import { Pipeline } from '../../components/PipelineTabs';
|
||||
import { Scen } from '../Ssulbox/ssulData';
|
||||
import SsulMakingContent, { SsulJob } from '../Ssulbox/SsulMakingContent';
|
||||
import SsulResultContent from '../Ssulbox/SsulResultContent';
|
||||
import {
|
||||
K,
|
||||
clearProjectStorage,
|
||||
clearSessionStorage,
|
||||
} from '../../utils/storageKeys';
|
||||
|
||||
// 다른 컴포넌트에서 사용하는 storage key들 (초기화용)
|
||||
const SONG_GENERATION_KEY = 'castad_song_generation';
|
||||
const VIDEO_GENERATION_KEY = 'castad_video_generation';
|
||||
const VIDEO_COMPLETE_KEY = 'castad_video_complete'; // 완료된 영상 정보
|
||||
const WIZARD_STEP_KEY = K.WIZARD_STEP;
|
||||
const ACTIVE_ITEM_KEY = K.ACTIVE_ITEM;
|
||||
const SONG_TASK_ID_KEY = K.SONG_TASK_ID;
|
||||
const IMAGE_TASK_ID_KEY = K.IMAGE_TASK_ID;
|
||||
const ANALYSIS_DATA_KEY = K.ANALYSIS_DATA;
|
||||
|
||||
// 모든 프로젝트 관련 localStorage 초기화
|
||||
const clearAllProjectStorage = () => {
|
||||
localStorage.removeItem(WIZARD_STEP_KEY);
|
||||
localStorage.removeItem(SONG_TASK_ID_KEY);
|
||||
localStorage.removeItem(IMAGE_TASK_ID_KEY);
|
||||
localStorage.removeItem(SONG_GENERATION_KEY);
|
||||
localStorage.removeItem(VIDEO_GENERATION_KEY);
|
||||
localStorage.removeItem(VIDEO_COMPLETE_KEY);
|
||||
/**
|
||||
* 랜딩 CTA 에서 썰박스를 고르고 로그인하러 갈 때 남기는 1회성 프리셋.
|
||||
* 카카오 로그인은 외부 리다이렉트 왕복이고 initializeOnNewSession 이
|
||||
* localStorage 만 지우므로 sessionStorage 를 쓴다.
|
||||
*/
|
||||
const PENDING_PIPELINE_KEY = 'castad_pending_pipeline';
|
||||
|
||||
/** 썰박스 진행 단계. ADO2 의 wizardStep(-2~3) 과 별도 축이다 */
|
||||
type SsulStep = 'entry' | 'making' | 'result';
|
||||
|
||||
/** 썰박스 스텝퍼 라벨(i18n 키)과 0-based 인덱스 */
|
||||
const SSUL_STEP_LABELS = [
|
||||
'ssulbox.steps.pick',
|
||||
'ssulbox.steps.making',
|
||||
'ssulbox.steps.done',
|
||||
] as const;
|
||||
|
||||
const SSUL_STEP_INDEX: Record<SsulStep, number> = {
|
||||
entry: 0,
|
||||
making: 1,
|
||||
result: 2,
|
||||
};
|
||||
|
||||
interface BusinessInfo {
|
||||
@@ -111,6 +129,42 @@ const GenerationFlow: React.FC<GenerationFlowProps> = ({
|
||||
};
|
||||
|
||||
const [wizardStep, setWizardStep] = useState(getInitialWizardStep());
|
||||
|
||||
/**
|
||||
* 초기 파이프라인 결정 — 우선순위를 지켜야 한다.
|
||||
*
|
||||
* 2번이 없으면 위 getInitialWizardStep() 의 "분석 데이터가 있으면 step 1부터"
|
||||
* 강제 로직과 충돌한다. ADO2 분석을 마치고 돌아온 상태에서 파이프라인만
|
||||
* 'ssul' 로 남아 있으면, 썰박스 화면인데 ADO2 위저드 단계가 그려진다.
|
||||
*/
|
||||
const getInitialPipeline = (): Pipeline => {
|
||||
// 1) 랜딩 CTA 프리셋 (1회성). 카카오 로그인 리다이렉트 왕복을 견뎌야 해서 sessionStorage
|
||||
const pending = sessionStorage.getItem(PENDING_PIPELINE_KEY);
|
||||
if (pending === 'ssul' || pending === 'ado2') {
|
||||
sessionStorage.removeItem(PENDING_PIPELINE_KEY);
|
||||
return pending;
|
||||
}
|
||||
// 2) 분석 데이터가 있으면 ADO2 흐름 한가운데이므로 강제
|
||||
if (initialAnalysisData || savedAnalysisData) return 'ado2';
|
||||
// 3) 저장된 선택
|
||||
const saved = localStorage.getItem(K.PIPELINE);
|
||||
return saved === 'ssul' ? 'ssul' : 'ado2';
|
||||
};
|
||||
|
||||
const [pipeline, setPipeline] = useState<Pipeline>(getInitialPipeline);
|
||||
/** 썰박스 전용 진행 축. wizardStep 숫자 축은 확장하지 않는다 */
|
||||
const [ssulStep, setSsulStep] = useState<SsulStep>('entry');
|
||||
const [ssulJob, setSsulJob] = useState<SsulJob | null>(null);
|
||||
/** 언마운트·로그아웃·재시도 시 진행 중인 폴링을 멈추는 플래그 */
|
||||
const ssulCancelledRef = useRef(false);
|
||||
|
||||
const changePipeline = (next: Pipeline) => {
|
||||
setPipeline(next);
|
||||
localStorage.setItem(K.PIPELINE, next);
|
||||
};
|
||||
|
||||
/** 진입 화면(탭이 보이는 단계) 여부. 두 파이프라인이 공유한다 */
|
||||
const isEntry = pipeline === 'ado2' ? wizardStep === -2 : ssulStep === 'entry';
|
||||
const [songTaskId, setSongTaskId] = useState<string | null>(savedSongTaskId);
|
||||
const [imageTaskId, setImageTaskId] = useState<string | null>(savedImageTaskId);
|
||||
const [videoGenerationStatus, setVideoGenerationStatus] = useState<'idle' | 'generating' | 'complete' | 'error'>('idle');
|
||||
@@ -156,10 +210,9 @@ const GenerationFlow: React.FC<GenerationFlowProps> = ({
|
||||
// 로그아웃 핸들러
|
||||
const handleLogout = () => {
|
||||
clearTokens();
|
||||
localStorage.removeItem('castad_view_mode');
|
||||
localStorage.removeItem('castad_analysis_data');
|
||||
localStorage.removeItem(WIZARD_STEP_KEY);
|
||||
localStorage.removeItem(ACTIVE_ITEM_KEY);
|
||||
// 세션 키를 전부 지운다. 이전에는 view_mode/analysis/wizard/active_item 만 지워
|
||||
// 생성 중이던 song·video 상태가 남았고, 다른 계정으로 로그인하면 그대로 복원됐다.
|
||||
clearSessionStorage();
|
||||
window.location.href = '/';
|
||||
};
|
||||
|
||||
@@ -212,7 +265,7 @@ const GenerationFlow: React.FC<GenerationFlowProps> = ({
|
||||
|
||||
// 홈 버튼(로고) 클릭 시 모든 상태 초기화 후 홈으로 이동
|
||||
const handleHome = () => {
|
||||
clearAllProjectStorage();
|
||||
clearProjectStorage();
|
||||
localStorage.removeItem(ANALYSIS_DATA_KEY);
|
||||
setWizardStep(-2);
|
||||
setSongTaskId(null);
|
||||
@@ -395,16 +448,113 @@ const GenerationFlow: React.FC<GenerationFlowProps> = ({
|
||||
setActiveItem('내 정보');
|
||||
};
|
||||
|
||||
/**
|
||||
* 썰박스 잡 폴링을 시작한다.
|
||||
*
|
||||
* 폴링 소유가 GenerationFlow 인 이유: SsulMakingContent 가 들고 있으면
|
||||
* 사이드바로 이동하는 순간 언마운트되면서 폴링이 끊긴다.
|
||||
* 잡은 화면보다 오래 살아야 한다.
|
||||
*/
|
||||
const watchSsulTask = useCallback(
|
||||
(taskId: number, scenario: Scen) => {
|
||||
ssulCancelledRef.current = false;
|
||||
setSsulJob({ taskId, scenario, status: 'queued', step: 0, error: null });
|
||||
|
||||
waitForSsulComplete(
|
||||
taskId,
|
||||
(task) => {
|
||||
if (ssulCancelledRef.current) return;
|
||||
setSsulJob({
|
||||
taskId,
|
||||
scenario,
|
||||
status: task.status,
|
||||
step: task.step,
|
||||
error: task.error,
|
||||
});
|
||||
},
|
||||
() => ssulCancelledRef.current
|
||||
)
|
||||
.then(() => {
|
||||
if (ssulCancelledRef.current) return;
|
||||
localStorage.removeItem(K.SSUL_TASK_ID);
|
||||
setSsulStep('result');
|
||||
})
|
||||
.catch((e: Error) => {
|
||||
if (ssulCancelledRef.current || e.message === 'CANCELLED') return;
|
||||
localStorage.removeItem(K.SSUL_TASK_ID);
|
||||
setSsulJob((prev) =>
|
||||
prev ? { ...prev, status: 'error', error: e.message } : prev
|
||||
);
|
||||
})
|
||||
.finally(() => {
|
||||
if (ssulCancelledRef.current) return;
|
||||
// 완료든 실패든 잔액을 갱신한다. 실패 시 백엔드가 환불하므로
|
||||
// 갱신하지 않으면 사이드바 잔액이 낡은 값으로 굳는다.
|
||||
refreshCredits();
|
||||
});
|
||||
},
|
||||
[refreshCredits]
|
||||
);
|
||||
|
||||
/** 생성 요청이 접수됐을 때 */
|
||||
const handleSsulJobStarted = (taskId: number, scenario: Scen) => {
|
||||
localStorage.setItem(K.SSUL_TASK_ID, String(taskId));
|
||||
setSsulStep('making');
|
||||
// 생성 시작 시점에 크레딧이 선차감되므로 사이드바 잔액을 즉시 갱신
|
||||
refreshCredits();
|
||||
watchSsulTask(taskId, scenario);
|
||||
};
|
||||
|
||||
/** 실패 후 처음부터 */
|
||||
const handleSsulRetry = () => {
|
||||
ssulCancelledRef.current = true;
|
||||
localStorage.removeItem(K.SSUL_TASK_ID);
|
||||
setSsulJob(null);
|
||||
setSsulStep('entry');
|
||||
};
|
||||
|
||||
/**
|
||||
* 새로고침·새 탭 진입 시 진행 중인 잡을 복구한다.
|
||||
*
|
||||
* 권위는 서버(`/ssul/tasks/active`)다. localStorage 의 SSUL_TASK_ID 는 힌트일 뿐이고,
|
||||
* initializeOnNewSession 이 새 탭에서 그것을 지우기 때문에 서버를 물어야 한다.
|
||||
*/
|
||||
useEffect(() => {
|
||||
let alive = true;
|
||||
getActiveSsulTask().then((task) => {
|
||||
if (!alive || !task) return;
|
||||
changePipeline('ssul');
|
||||
setSsulStep('making');
|
||||
watchSsulTask(task.id, task.scenario as Scen);
|
||||
});
|
||||
return () => {
|
||||
alive = false;
|
||||
};
|
||||
// 마운트 시 1회만 — watchSsulTask 는 refreshCredits 에만 의존한다
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
/** 언마운트 시 폴링 중단 (로그아웃·화면 전환) */
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
ssulCancelledRef.current = true;
|
||||
};
|
||||
}, []);
|
||||
|
||||
// 네비게이션 핸들러 - "새 프로젝트 만들기" 클릭 시 기존 프로젝트 데이터 초기화
|
||||
const handleNavigate = (item: string) => {
|
||||
setMyInfoInitialTab(undefined);
|
||||
if (item === '새 프로젝트 만들기') {
|
||||
// 기존 프로젝트 데이터 초기화
|
||||
clearAllProjectStorage();
|
||||
clearProjectStorage();
|
||||
localStorage.removeItem(ANALYSIS_DATA_KEY);
|
||||
// URL 입력 단계로 명시적 저장 (다음 진입 시 올바른 단계 복원)
|
||||
localStorage.setItem(WIZARD_STEP_KEY, '-2');
|
||||
setWizardStep(-2);
|
||||
// 파이프라인도 기본값으로 되돌린다. clearProjectStorage() 가 K.PIPELINE 을
|
||||
// 지우므로 state 만 남으면 저장소와 어긋난다.
|
||||
setPipeline('ado2');
|
||||
setSsulStep('entry');
|
||||
setSongTaskId(null);
|
||||
setImageTaskId(null);
|
||||
setAnalysisData(null);
|
||||
@@ -419,17 +569,40 @@ const GenerationFlow: React.FC<GenerationFlowProps> = ({
|
||||
|
||||
// 새 프로젝트 만들기 - 단계별 컨텐츠 렌더링
|
||||
const renderWizardContent = () => {
|
||||
// 진입 화면은 두 파이프라인이 공유하므로 switch 밖에서 먼저 처리한다.
|
||||
// ADO2 는 wizardStep -2, 썰박스는 ssulStep 'entry' 가 여기 해당한다.
|
||||
if (isEntry) {
|
||||
return (
|
||||
<UrlInputContent
|
||||
pipeline={pipeline}
|
||||
onPipelineChange={changePipeline}
|
||||
onAnalyze={handleStartAnalysis}
|
||||
onAutocomplete={handleAutocomplete}
|
||||
onManualInput={handleManualInput}
|
||||
error={analysisError}
|
||||
onSsulJobStarted={handleSsulJobStarted}
|
||||
onGoToPayment={handleGoToPayment}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
// 썰박스는 자체 축으로 진행한다
|
||||
if (pipeline === 'ssul') {
|
||||
switch (ssulStep) {
|
||||
case 'making':
|
||||
return (
|
||||
<SsulMakingContent job={ssulJob} onRetry={handleSsulRetry} />
|
||||
);
|
||||
case 'result':
|
||||
return ssulJob ? (
|
||||
<SsulResultContent taskId={ssulJob.taskId} scenario={ssulJob.scenario} />
|
||||
) : null;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
switch (wizardStep) {
|
||||
case -2:
|
||||
// URL 입력 단계
|
||||
return (
|
||||
<UrlInputContent
|
||||
onAnalyze={handleStartAnalysis}
|
||||
onAutocomplete={handleAutocomplete}
|
||||
onManualInput={handleManualInput}
|
||||
error={analysisError}
|
||||
/>
|
||||
);
|
||||
case -1:
|
||||
// 로딩 단계
|
||||
return (
|
||||
@@ -457,8 +630,8 @@ const GenerationFlow: React.FC<GenerationFlowProps> = ({
|
||||
onBack={() => goToWizardStep(0)}
|
||||
onNext={(taskId: string) => {
|
||||
// Clear video generation state to start fresh
|
||||
localStorage.removeItem(VIDEO_GENERATION_KEY);
|
||||
localStorage.removeItem(VIDEO_COMPLETE_KEY);
|
||||
localStorage.removeItem(K.VIDEO_GENERATION);
|
||||
localStorage.removeItem(K.VIDEO_COMPLETE);
|
||||
setVideoGenerationStatus('idle');
|
||||
setVideoGenerationProgress(0);
|
||||
|
||||
@@ -502,8 +675,8 @@ const GenerationFlow: React.FC<GenerationFlowProps> = ({
|
||||
onBack={() => {
|
||||
// 뒤로가기 시 비디오 생성 상태 초기화
|
||||
// 새 노래 생성 후 다시 영상 생성할 수 있도록
|
||||
localStorage.removeItem(VIDEO_GENERATION_KEY);
|
||||
localStorage.removeItem(VIDEO_COMPLETE_KEY);
|
||||
localStorage.removeItem(K.VIDEO_GENERATION);
|
||||
localStorage.removeItem(K.VIDEO_COMPLETE);
|
||||
setVideoGenerationStatus('idle');
|
||||
setVideoGenerationProgress(0);
|
||||
goToWizardStep(2);
|
||||
@@ -539,10 +712,22 @@ const GenerationFlow: React.FC<GenerationFlowProps> = ({
|
||||
case '내 정보':
|
||||
return <MyInfoContent initialTab={myInfoInitialTab} />;
|
||||
case '새 프로젝트 만들기':
|
||||
// 로딩(-1), URL 입력(-2)은 스텝퍼 없이 전체 화면으로 표시
|
||||
if (wizardStep === -1 || wizardStep === -2) {
|
||||
// 진입 화면(탭)과 ADO2 로딩(-1)은 스텝퍼 없이 전체 화면으로 표시
|
||||
if (isEntry || (pipeline === 'ado2' && wizardStep === -1)) {
|
||||
return renderWizardContent();
|
||||
}
|
||||
// 썰박스는 자체 3단계 스텝퍼를 쓴다
|
||||
if (pipeline === 'ssul') {
|
||||
return (
|
||||
<div className="wizard-page-container">
|
||||
<WizardStepper
|
||||
steps={SSUL_STEP_LABELS.map((key) => t(key))}
|
||||
currentStep={SSUL_STEP_INDEX[ssulStep]}
|
||||
/>
|
||||
{renderWizardContent()}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
// 브랜드 분석(0)은 전체 화면 스크롤이지만 스텝퍼는 표시
|
||||
if (wizardStep === 0) {
|
||||
return (
|
||||
|
||||
@@ -6,6 +6,7 @@ import { VideoListItem } from '../../types/api';
|
||||
import SocialPostingModal from '../../components/SocialPostingModal';
|
||||
import VideoDetailModal from '../../components/VideoDetailModal';
|
||||
import ContentCardSocialActions from '../../components/ContentCardSocialActions';
|
||||
import SsulViewerModal from '../Ssulbox/SsulViewerModal';
|
||||
import { useTutorial } from '../../components/Tutorial/useTutorial';
|
||||
import { TUTORIAL_KEYS } from '../../components/Tutorial/tutorialSteps';
|
||||
|
||||
@@ -108,6 +109,9 @@ const MyContentsPage: React.FC<MyContentsPageProps> = ({ onNavigate }) => {
|
||||
const [uploadModalOpen, setUploadModalOpen] = useState(false);
|
||||
const [uploadTargetVideo, setUploadTargetVideo] = useState<VideoListItem | null>(null);
|
||||
const [selectedVideoId, setSelectedVideoId] = useState<number | null>(null);
|
||||
// 썰박스는 별도 뷰어를 쓴다 — VideoDetailModal 은 video_id 로 조회하므로
|
||||
// 썰박스 id 를 넘기면 id 가 겹치는 다른 영상이 열린다.
|
||||
const [selectedSsul, setSelectedSsul] = useState<VideoListItem | null>(null);
|
||||
|
||||
const pageSize = 12;
|
||||
|
||||
@@ -241,12 +245,18 @@ const MyContentsPage: React.FC<MyContentsPageProps> = ({ onNavigate }) => {
|
||||
<>
|
||||
<div className="ado2-contents-grid">
|
||||
{videos.map((video) => (
|
||||
<div key={video.task_id} className="ado2-content-card">
|
||||
// key 는 (type, video_id) 쌍이어야 한다 — task_id 는 썰박스에 없고(빈 문자열)
|
||||
// video_id 는 종류별 독립 시퀀스라 값이 겹친다.
|
||||
<div key={`${video.type}-${video.video_id}`} className="ado2-content-card">
|
||||
{/* Video Thumbnail */}
|
||||
<div
|
||||
className="content-card-thumbnail"
|
||||
style={{ cursor: 'pointer' }}
|
||||
onClick={() => setSelectedVideoId(video.video_id)}
|
||||
onClick={() =>
|
||||
video.type === 'ssul'
|
||||
? setSelectedSsul(video)
|
||||
: setSelectedVideoId(video.video_id)
|
||||
}
|
||||
>
|
||||
{video.result_movie_url ? (
|
||||
<VideoPreviewCard
|
||||
@@ -279,30 +289,40 @@ const MyContentsPage: React.FC<MyContentsPageProps> = ({ onNavigate }) => {
|
||||
<p className="content-card-date">
|
||||
{formatDate(video.created_at)}
|
||||
</p>
|
||||
<ContentCardSocialActions
|
||||
videoId={video.video_id}
|
||||
storeName={video.store_name}
|
||||
region={video.region}
|
||||
commentCount={video.comment_count ?? 0}
|
||||
initialLikeCount={video.like_count ?? 0}
|
||||
initialIsLiked={video.is_liked_by_me}
|
||||
/>
|
||||
{/* 좋아요·댓글은 castad API 를 video_id 로 호출한다.
|
||||
썰박스 id 를 넘기면 id 가 겹치는 다른 영상에 반영되므로
|
||||
`/ssul/*` 반응 API 가 붙기 전까지 노출하지 않는다. */}
|
||||
{video.type === 'video' && (
|
||||
<ContentCardSocialActions
|
||||
videoId={video.video_id}
|
||||
storeName={video.store_name}
|
||||
region={video.region}
|
||||
commentCount={video.comment_count ?? 0}
|
||||
initialLikeCount={video.like_count ?? 0}
|
||||
initialIsLiked={video.is_liked_by_me}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Action Buttons */}
|
||||
<div className="content-card-actions">
|
||||
<button
|
||||
className="content-download-btn"
|
||||
onClick={() => handleUploadClick(video)}
|
||||
disabled={!video.result_movie_url}
|
||||
>
|
||||
<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>
|
||||
<span>{t('ado2Contents.uploadToSocial')}</span>
|
||||
</button>
|
||||
{/* SNS 업로드는 SocialPostingModal 이 video_id 로 업로드 API 를 부른다.
|
||||
썰박스 id 를 넘기면 **엉뚱한 ADO2 영상이 업로드된다.**
|
||||
`/ssul/upload/*` 가 붙기 전까지 노출하지 않는다. */}
|
||||
{video.type === 'video' && (
|
||||
<button
|
||||
className="content-download-btn"
|
||||
onClick={() => handleUploadClick(video)}
|
||||
disabled={!video.result_movie_url}
|
||||
>
|
||||
<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>
|
||||
<span>{t('ado2Contents.uploadToSocial')}</span>
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
className="content-upload-btn"
|
||||
onClick={() => handleDownload(video.result_movie_url, video.store_name)}
|
||||
@@ -314,16 +334,22 @@ const MyContentsPage: React.FC<MyContentsPageProps> = ({ onNavigate }) => {
|
||||
<path d="M3 15v2h14v-2"/>
|
||||
</svg>
|
||||
</button>
|
||||
<button
|
||||
className="content-delete-btn"
|
||||
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"/>
|
||||
<line x1="8" y1="8" x2="8" y2="14"/>
|
||||
<line x1="12" y1="8" x2="12" y2="14"/>
|
||||
</svg>
|
||||
</button>
|
||||
{/* ⚠️ 삭제는 파괴적이다. `DELETE /archive/videos/{id}` 는 `Video.id` 로
|
||||
지우므로 썰박스 id 를 넘기면 **id 가 겹치는 ADO2 영상이 삭제된다.**
|
||||
소유권 검증도 통과한다(같은 사용자가 양쪽을 다 가진 경우).
|
||||
썰박스 삭제 API 가 붙기 전까지 절대 노출하지 않는다. */}
|
||||
{video.type === 'video' && (
|
||||
<button
|
||||
className="content-delete-btn"
|
||||
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"/>
|
||||
<line x1="8" y1="8" x2="8" y2="14"/>
|
||||
<line x1="12" y1="8" x2="12" y2="14"/>
|
||||
</svg>
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -384,6 +410,8 @@ const MyContentsPage: React.FC<MyContentsPageProps> = ({ onNavigate }) => {
|
||||
/>
|
||||
)}
|
||||
|
||||
<SsulViewerModal item={selectedSsul} onClose={() => setSelectedSsul(null)} />
|
||||
|
||||
{/* 소셜 미디어 업로드 모달 */}
|
||||
<SocialPostingModal
|
||||
isOpen={uploadModalOpen}
|
||||
|
||||
@@ -1,15 +1,40 @@
|
||||
import React from 'react';
|
||||
import { AutocompleteRequest } from '../../utils/api';
|
||||
import SearchInputForm, { SearchType } from '../../components/SearchInputForm';
|
||||
import PipelineTabs, { Pipeline } from '../../components/PipelineTabs';
|
||||
import SsulCreateForm from '../Ssulbox/SsulCreateForm';
|
||||
import { Scen } from '../Ssulbox/ssulData';
|
||||
|
||||
interface UrlInputContentProps {
|
||||
/** 현재 선택된 파이프라인. 소유자는 GenerationFlow (분기·리셋·랜딩 프리셋 때문) */
|
||||
pipeline: Pipeline;
|
||||
onPipelineChange: (pipeline: Pipeline) => void;
|
||||
onAnalyze: (value: string, type?: SearchType) => void;
|
||||
onAutocomplete?: (data: AutocompleteRequest) => void;
|
||||
onManualInput?: (businessName: string, address: string, category: string) => void;
|
||||
error: string | null;
|
||||
/** 썰박스 생성 요청 접수 시. 폴링 소유는 GenerationFlow */
|
||||
onSsulJobStarted: (taskId: number, scenario: Scen) => void;
|
||||
/** 크레딧 부족 시 충전 화면으로 */
|
||||
onGoToPayment: () => void;
|
||||
}
|
||||
|
||||
const UrlInputContent: React.FC<UrlInputContentProps> = ({ onAnalyze, onAutocomplete, onManualInput, error }) => {
|
||||
/**
|
||||
* 대시보드 진입 화면.
|
||||
*
|
||||
* 탭바는 로고와 하위 폼 **사이에 형제로** 얹고 하위 폼만 교체한다.
|
||||
* SearchInputForm 은 랜딩 HeroSection 과 공유되므로 어떤 경우에도 수정하지 않는다.
|
||||
*/
|
||||
const UrlInputContent: React.FC<UrlInputContentProps> = ({
|
||||
pipeline,
|
||||
onPipelineChange,
|
||||
onAnalyze,
|
||||
onAutocomplete,
|
||||
onManualInput,
|
||||
error,
|
||||
onSsulJobStarted,
|
||||
onGoToPayment,
|
||||
}) => {
|
||||
return (
|
||||
<div className="url-input-container">
|
||||
<div className="url-input-content">
|
||||
@@ -17,12 +42,18 @@ const UrlInputContent: React.FC<UrlInputContentProps> = ({ onAnalyze, onAutocomp
|
||||
<img src="/assets/images/ADO2_with Slogan_white.svg" alt="ADO2" />
|
||||
</div>
|
||||
|
||||
<SearchInputForm
|
||||
onAnalyze={onAnalyze}
|
||||
onAutocomplete={onAutocomplete}
|
||||
onManualInput={onManualInput}
|
||||
error={error}
|
||||
/>
|
||||
<PipelineTabs value={pipeline} onChange={onPipelineChange} />
|
||||
|
||||
{pipeline === 'ado2' ? (
|
||||
<SearchInputForm
|
||||
onAnalyze={onAnalyze}
|
||||
onAutocomplete={onAutocomplete}
|
||||
onManualInput={onManualInput}
|
||||
error={error}
|
||||
/>
|
||||
) : (
|
||||
<SsulCreateForm onSubmitted={onSsulJobStarted} onNeedCredit={onGoToPayment} />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,229 @@
|
||||
import React, { useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
InsufficientCreditError,
|
||||
SsulPlaceItem,
|
||||
createSsulJob,
|
||||
searchSsulPlace,
|
||||
} from '../../utils/api';
|
||||
import { SCEN, SCEN_KEYS, Scen, scenDesc, scenName } from './ssulData';
|
||||
|
||||
interface SsulCreateFormProps {
|
||||
/** 생성 요청이 접수되면 호출. 폴링 소유는 GenerationFlow */
|
||||
onSubmitted: (taskId: number, scenario: Scen) => void;
|
||||
/** 크레딧 부족(402) 시 충전 화면으로 유도 */
|
||||
onNeedCredit: () => void;
|
||||
}
|
||||
|
||||
/** 네이버 지도 링크로 보이는가 — 링크면 검색을 건너뛰고 그대로 크롤링한다 */
|
||||
const isNaverUrl = (s: string): boolean =>
|
||||
/naver\.me|map\.naver|place\.naver|^https?:\/\//i.test(s.trim());
|
||||
|
||||
/**
|
||||
* 썰박스 생성 폼. 진입 화면의 썰박스 탭에 들어간다.
|
||||
*
|
||||
* 원본 썰박스의 CreateSheet(바텀시트) 를 시트 크롬 없이 인라인으로 재배치했다.
|
||||
* 시나리오 선택과 업장 검색을 한 화면에 둔다(원본은 2단계로 나뉘어 있었으나,
|
||||
* 여기서는 위저드 스텝퍼가 이미 단계를 보여주므로 중복이다).
|
||||
*/
|
||||
const SsulCreateForm: React.FC<SsulCreateFormProps> = ({ onSubmitted, onNeedCredit }) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const [scenario, setScenario] = useState<Scen | null>(null);
|
||||
const [input, setInput] = useState('');
|
||||
const [results, setResults] = useState<SsulPlaceItem[]>([]);
|
||||
const [selected, setSelected] = useState<SsulPlaceItem | null>(null);
|
||||
const [searching, setSearching] = useState(false);
|
||||
const [searched, setSearched] = useState(false);
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
const isUrl = isNaverUrl(input);
|
||||
// place_url 이 확정됐거나(검색 결과 선택) 링크를 직접 붙여넣었을 때만 생성 가능
|
||||
const canSubmit = !!scenario && (!!selected || isUrl) && !submitting;
|
||||
|
||||
const runSearch = async () => {
|
||||
const query = input.trim();
|
||||
if (query.length < 2 || isUrl) return;
|
||||
|
||||
setSearching(true);
|
||||
setSearched(false);
|
||||
setResults([]);
|
||||
setSelected(null);
|
||||
try {
|
||||
setResults(await searchSsulPlace(query));
|
||||
} finally {
|
||||
setSearching(false);
|
||||
setSearched(true);
|
||||
}
|
||||
};
|
||||
|
||||
const handleSubmit = async () => {
|
||||
if (!scenario || submitting) return;
|
||||
|
||||
// 검색으로 고른 가게가 있으면 그 place_url 로 정확히 크롤링한다
|
||||
const payload = selected ? selected.place_url : input.trim();
|
||||
setSubmitting(true);
|
||||
setError(null);
|
||||
try {
|
||||
const res = await createSsulJob({
|
||||
scenario,
|
||||
input: payload,
|
||||
// 고른 가게가 있을 때만 함께 보낸다. 통합 목록의 업장명 표시와
|
||||
// 업장명·지역 필터가 이 값에 걸린다(링크 직접 입력 시에는 없다).
|
||||
// 도로명·지번을 모두 보낸다. 백엔드가 도로명에서 시/군 추출에 실패하면
|
||||
// 지번으로 재시도한다(한쪽만 보내면 지역이 비는 경우가 생긴다).
|
||||
...(selected && {
|
||||
store_name: selected.title,
|
||||
road_address: selected.roadAddress,
|
||||
address: selected.address,
|
||||
}),
|
||||
});
|
||||
onSubmitted(res.id, scenario);
|
||||
} catch (e) {
|
||||
if (e instanceof InsufficientCreditError) {
|
||||
onNeedCredit();
|
||||
} else {
|
||||
setError(t('ssulbox.error.createFailed'));
|
||||
}
|
||||
} finally {
|
||||
setSubmitting(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="ssul-scope ssul-create">
|
||||
{/* ── 1단계: 시나리오 ─────────────────────────────── */}
|
||||
<span className="ssul-create__step">{t('ssulbox.create.step1')}</span>
|
||||
|
||||
<div className="ssul-create__scenarios">
|
||||
{SCEN_KEYS.map((key) => {
|
||||
const pal = SCEN[key];
|
||||
const active = scenario === key;
|
||||
return (
|
||||
<button
|
||||
key={key}
|
||||
type="button"
|
||||
aria-pressed={active}
|
||||
className={`ssul-scn${active ? ' active' : ''}`}
|
||||
style={
|
||||
{
|
||||
// 표지 그라디언트 2단 + 대표색. CSS 가 옅게 깔아 쓴다
|
||||
'--scn': pal.hex,
|
||||
'--scn-a': pal.g[0],
|
||||
'--scn-b': pal.g[1],
|
||||
} as React.CSSProperties
|
||||
}
|
||||
onClick={() => setScenario(key)}
|
||||
>
|
||||
<span className="ssul-scn__emoji" aria-hidden="true">
|
||||
{pal.emoji}
|
||||
</span>
|
||||
<span className="ssul-scn__name">{t(scenName(key))}</span>
|
||||
<span className="ssul-scn__desc">{t(scenDesc(key))}</span>
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
{/* ── 2단계: 업장 ─────────────────────────────────── */}
|
||||
{/* 2단계는 약하게 — 시선이 1단계(아직 안 고른 경우)로 먼저 가야 한다 */}
|
||||
<span className="ssul-create__step muted">{t('ssulbox.create.step2')}</span>
|
||||
|
||||
<div className="ssul-create__search">
|
||||
<input
|
||||
className="ssul-create__input"
|
||||
placeholder={t('ssulbox.create.searchPlaceholder')}
|
||||
value={input}
|
||||
onChange={(e) => {
|
||||
setInput(e.target.value);
|
||||
if (selected) setSelected(null);
|
||||
}}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter') {
|
||||
e.preventDefault();
|
||||
runSearch();
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
className="ssul-create__search-btn"
|
||||
disabled={searching || input.trim().length < 2 || isUrl}
|
||||
onClick={runSearch}
|
||||
>
|
||||
{searching ? t('ssulbox.create.searching') : t('ssulbox.create.searchButton')}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* 검색 상태에 따른 안내 — 한 번에 하나만 보인다 */}
|
||||
{selected ? (
|
||||
<div className="ssul-picked">
|
||||
<div className="ssul-picked__body">
|
||||
<b>{selected.title}</b>
|
||||
<span>
|
||||
{selected.category ? `${selected.category} · ` : ''}
|
||||
{selected.address || selected.roadAddress}
|
||||
</span>
|
||||
</div>
|
||||
<button type="button" className="ssul-picked__change" onClick={() => setSelected(null)}>
|
||||
{t('ssulbox.create.change')}
|
||||
</button>
|
||||
</div>
|
||||
) : isUrl ? (
|
||||
<div className="ssul-hint ok">{t('ssulbox.create.hintUrlOk')}</div>
|
||||
) : searching ? (
|
||||
<div className="ssul-hint">{t('ssulbox.create.placeLoading')}</div>
|
||||
) : results.length > 0 ? (
|
||||
<ul className="ssul-places">
|
||||
{results.map((place, i) => (
|
||||
<li key={`${place.place_url}-${i}`}>
|
||||
<button type="button" onClick={() => setSelected(place)}>
|
||||
<b>{place.title}</b>
|
||||
<span>
|
||||
{place.category ? `${place.category} · ` : ''}
|
||||
{place.address || place.roadAddress}
|
||||
</span>
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : searched ? (
|
||||
<div className="ssul-hint warn">{t('ssulbox.create.noResult')}</div>
|
||||
) : scenario ? (
|
||||
// 고른 시나리오를 되짚어 준다. 소요 시간은 기본 옵션 실측 전이라
|
||||
// 분 단위를 못 박지 않는다("수 분 내외").
|
||||
<div className="ssul-hint dot">
|
||||
{t('ssulbox.create.hintScenario', { name: t(scenName(scenario)) })}
|
||||
</div>
|
||||
) : (
|
||||
<div className="ssul-hint">{t('ssulbox.create.hintDefault')}</div>
|
||||
)}
|
||||
|
||||
{error && <div className="ssul-hint warn">{error}</div>}
|
||||
|
||||
{/* ── 비용 고지 + 제출 ────────────────────────────── */}
|
||||
{/* 요청 시점에 즉시 차감되므로 누르기 전에 반드시 알린다 */}
|
||||
<div className="ssul-create__cost">
|
||||
<span>{t('ssulbox.create.cost')}</span>
|
||||
<span className="ssul-create__cost-badge">
|
||||
<span className="ssul-create__coin" aria-hidden="true">
|
||||
🪙
|
||||
</span>
|
||||
{t('ssulbox.create.costValue')}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
className="ssul-create__submit"
|
||||
disabled={!canSubmit}
|
||||
onClick={handleSubmit}
|
||||
>
|
||||
{submitting ? t('ssulbox.create.submitting') : t('ssulbox.create.submit')}
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default SsulCreateForm;
|
||||
@@ -0,0 +1,111 @@
|
||||
import React from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { SCEN, Scen, scenName } from './ssulData';
|
||||
|
||||
/** 생성 잡의 현재 상태. GenerationFlow 가 폴링해 내려준다 */
|
||||
export interface SsulJob {
|
||||
taskId: number;
|
||||
scenario: Scen;
|
||||
status: 'queued' | 'running' | 'done' | 'error';
|
||||
/** 0~4. 0=준비, 4=영상 합성 완료 */
|
||||
step: number;
|
||||
error: string | null;
|
||||
}
|
||||
|
||||
interface SsulMakingContentProps {
|
||||
job: SsulJob | null;
|
||||
/** 실패 후 처음부터 다시 */
|
||||
onRetry: () => void;
|
||||
}
|
||||
|
||||
/** 백엔드 generator 가 뱉는 4단계. `ssul_content.step` 과 1:1 대응 */
|
||||
const TOTAL_STEPS = 4;
|
||||
|
||||
const STEP_LABEL_KEYS = [
|
||||
'ssulbox.making.step1',
|
||||
'ssulbox.making.step2',
|
||||
'ssulbox.making.step3',
|
||||
'ssulbox.making.step4',
|
||||
] as const;
|
||||
|
||||
/**
|
||||
* 썰박스 생성 진행 화면.
|
||||
*
|
||||
* 원본은 SSE 로 진행률만 받아 막대 하나를 그렸지만, castad 는 폴링으로
|
||||
* `step`(0~4)을 받으므로 **지금 무슨 작업 중인지 단계명까지** 보여준다.
|
||||
* 수 분~십수 분이 걸리는 작업이라 진행바만 있으면 멈춘 것처럼 보인다.
|
||||
*
|
||||
* 잡 소유는 GenerationFlow 다. 이 컴포넌트는 표시만 하므로
|
||||
* 사이드바로 이동해 언마운트돼도 폴링이 끊기지 않는다.
|
||||
* 그래서 "백그라운드로 전환" 버튼을 두지 않는다 — 사이드바로 그냥 이동하면
|
||||
* 되고, 버튼이 있으면 마치 전환해야 계속 도는 것처럼 오해를 준다.
|
||||
*/
|
||||
const SsulMakingContent: React.FC<SsulMakingContentProps> = ({ job, onRetry }) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
if (!job) return null;
|
||||
|
||||
const palette = SCEN[job.scenario];
|
||||
const failed = job.status === 'error';
|
||||
// step 은 "완료한 단계 수"라 진행률은 step/4. queued(0) 면 0%
|
||||
const percent = Math.round((Math.min(job.step, TOTAL_STEPS) / TOTAL_STEPS) * 100);
|
||||
// 진행 중인 단계는 완료 수 + 1 (마지막 단계 완료 시엔 더 올리지 않음)
|
||||
const currentIndex = Math.min(job.step, TOTAL_STEPS - 1);
|
||||
|
||||
return (
|
||||
<div className="ssul-scope ssul-making">
|
||||
<span className="ssul-making__scenario" style={{ color: palette.hex }}>
|
||||
<span aria-hidden="true">{palette.emoji}</span> {t(scenName(job.scenario))}
|
||||
</span>
|
||||
|
||||
{failed ? (
|
||||
<>
|
||||
<h3 className="ssul-making__title warn">{t('ssulbox.making.failTitle')}</h3>
|
||||
<p className="ssul-making__desc">{job.error || t('ssulbox.making.failDefault')}</p>
|
||||
{/* 백엔드가 실패 시 크레딧을 환불한다 — 사용자가 손해 보지 않았음을 알린다 */}
|
||||
<p className="ssul-making__refund">{t('ssulbox.making.refunded')}</p>
|
||||
<button type="button" className="ssul-making__btn" onClick={onRetry}>
|
||||
{t('ssulbox.making.retry')}
|
||||
</button>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<h3 className="ssul-making__title">{t('ssulbox.making.title')}</h3>
|
||||
|
||||
{/*
|
||||
단계 사이 구간에서는 진행바가 멈춰 있어 고장처럼 보인다.
|
||||
스피너는 "살아 있다"는 신호 전용이라 진행률을 표현하지 않는다.
|
||||
색은 시나리오 대표색을 따른다(민트 고정이면 삼국지·오디세이와 부딪힌다).
|
||||
*/}
|
||||
<div
|
||||
className="ssul-making__spinner"
|
||||
style={{ ['--scn' as string]: palette.hex }}
|
||||
aria-hidden="true"
|
||||
/>
|
||||
|
||||
<div
|
||||
className="ssul-making__bar"
|
||||
role="progressbar"
|
||||
aria-valuenow={percent}
|
||||
aria-valuemin={0}
|
||||
aria-valuemax={100}
|
||||
>
|
||||
<div
|
||||
className="ssul-making__fill"
|
||||
style={{ width: `${percent}%`, background: palette.hex }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="ssul-making__meta">
|
||||
<span>{t(STEP_LABEL_KEYS[currentIndex])}</span>
|
||||
<span className="ssul-making__pct">{percent}%</span>
|
||||
</div>
|
||||
|
||||
<p className="ssul-making__desc">{t('ssulbox.making.takesTime')}</p>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default SsulMakingContent;
|
||||
@@ -0,0 +1,133 @@
|
||||
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';
|
||||
|
||||
interface SsulResultContentProps {
|
||||
taskId: number;
|
||||
scenario: Scen;
|
||||
}
|
||||
|
||||
/**
|
||||
* 썰박스 생성 완료 화면.
|
||||
*
|
||||
* 완성된 영상을 재생하고 다운로드할 수 있다.
|
||||
* SNS 업로드는 castad `SocialPostingModal` 재사용을 먼저 시도해야 하므로
|
||||
* 통합 목록 작업(Phase 8)과 함께 붙인다.
|
||||
*/
|
||||
const SsulResultContent: React.FC<SsulResultContentProps> = ({ taskId, scenario }) => {
|
||||
const { t } = useTranslation();
|
||||
const [task, setTask] = useState<SsulTaskStatus | null>(null);
|
||||
const [loadError, setLoadError] = useState(false);
|
||||
// 영상 전체를 받아오는 동안 시간이 걸린다 — 중복 클릭을 막고 진행을 알린다
|
||||
const [downloading, setDownloading] = useState(false);
|
||||
|
||||
// 폴링이 끝난 뒤 최종 상태(video_url 포함)를 한 번 더 읽는다.
|
||||
// 진행 중에는 video_url 이 비어 있으므로 완료 후 조회가 필요하다.
|
||||
useEffect(() => {
|
||||
let alive = true;
|
||||
getSsulTask(taskId)
|
||||
.then((data) => alive && setTask(data))
|
||||
.catch(() => alive && setLoadError(true));
|
||||
return () => {
|
||||
alive = false;
|
||||
};
|
||||
}, [taskId]);
|
||||
|
||||
const palette = SCEN[scenario];
|
||||
|
||||
/**
|
||||
* 영상 다운로드.
|
||||
*
|
||||
* **Blob URL 을 `<a download>` 에 그대로 걸면 다운로드가 아니라 재생 화면으로
|
||||
* 이동한다** — `download` 속성은 교차 출처 URL 에서 무시되고, 영상은 Azure Blob
|
||||
* 도메인에 있어 앱과 출처가 다르기 때문이다.
|
||||
* 그래서 castad `CompletionContent` 와 동일하게 fetch → Blob → 동일 출처
|
||||
* objectURL 로 바꿔서 내려받는다.
|
||||
*
|
||||
* fetch 가 실패하면(CORS 등) 새 탭으로라도 열어준다 — 사용자가 거기서
|
||||
* 직접 저장할 수 있으므로 아무 일도 안 일어나는 것보다 낫다.
|
||||
*/
|
||||
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);
|
||||
const blobUrl = URL.createObjectURL(await response.blob());
|
||||
const link = document.createElement('a');
|
||||
link.href = blobUrl;
|
||||
link.download = fileName;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
URL.revokeObjectURL(blobUrl);
|
||||
} catch {
|
||||
const link = document.createElement('a');
|
||||
link.href = task.video_url;
|
||||
link.download = fileName;
|
||||
link.target = '_blank';
|
||||
link.rel = 'noopener';
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
} finally {
|
||||
setDownloading(false);
|
||||
}
|
||||
};
|
||||
|
||||
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>
|
||||
);
|
||||
};
|
||||
|
||||
export default SsulResultContent;
|
||||
@@ -0,0 +1,128 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { VideoListItem } from '../../types/api';
|
||||
|
||||
interface SsulViewerModalProps {
|
||||
/** null 이면 닫힘 */
|
||||
item: VideoListItem | null;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* 썰박스 콘텐츠 뷰어.
|
||||
*
|
||||
* **castad `VideoDetailModal` 과 같은 형식**을 쓴다 — 백드롭·패널 인라인 스타일과
|
||||
* `video-detail-*` 클래스를 그대로 재사용하므로 통합 목록에서 어떤 카드를 열든
|
||||
* 같은 모양이 나온다. 신규 CSS 를 만들지 않는다.
|
||||
*
|
||||
* 컴포넌트를 그대로 못 쓰는 이유: `VideoDetailModal` 은 `videoId` 로 `/video/{id}` 를
|
||||
* 조회하는데, 썰박스 id 를 넘기면 **id 가 겹치는 다른 ADO2 영상**이 열린다
|
||||
* (`video.id` 와 `ssul_content.id` 는 각각 1부터 시작하는 독립 시퀀스).
|
||||
* 목록이 이미 재생에 필요한 정보를 갖고 있어 추가 조회도 필요 없다.
|
||||
*
|
||||
* 좋아요·댓글·공유는 castad API 를 video_id 로 호출하므로 여기서는 빼 뒀다.
|
||||
* `/ssul/*` 반응 API 가 붙으면 추가한다.
|
||||
*/
|
||||
const SsulViewerModal: React.FC<SsulViewerModalProps> = ({ item, onClose }) => {
|
||||
const { t } = useTranslation();
|
||||
// 가로 영상이면 castad 와 동일하게 landscape 레이아웃으로 전환한다
|
||||
const [isLandscape, setIsLandscape] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (!item) return;
|
||||
// 모달 열릴 때 배경 스크롤 잠금
|
||||
const prev = document.body.style.overflow;
|
||||
document.body.style.overflow = 'hidden';
|
||||
|
||||
const handleKeyDown = (e: KeyboardEvent) => {
|
||||
if (e.key === 'Escape') onClose();
|
||||
};
|
||||
document.addEventListener('keydown', handleKeyDown);
|
||||
|
||||
return () => {
|
||||
document.body.style.overflow = prev;
|
||||
document.removeEventListener('keydown', handleKeyDown);
|
||||
};
|
||||
}, [item, onClose]);
|
||||
|
||||
// 다른 콘텐츠를 열면 방향 판정을 초기화한다(이전 값이 남으면 레이아웃이 틀어진다)
|
||||
useEffect(() => {
|
||||
setIsLandscape(false);
|
||||
}, [item?.type, item?.video_id]);
|
||||
|
||||
if (!item) return null;
|
||||
|
||||
const formatDate = (value?: string) => {
|
||||
if (!value) return '';
|
||||
const d = new Date(value);
|
||||
return `${d.getFullYear()}.${String(d.getMonth() + 1).padStart(2, '0')}.${String(
|
||||
d.getDate()
|
||||
).padStart(2, '0')}`;
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
position: 'fixed',
|
||||
inset: 0,
|
||||
background: 'rgba(0, 0, 0, 0.85)',
|
||||
zIndex: 2000,
|
||||
display: 'flex',
|
||||
overflowY: 'auto',
|
||||
padding: '24px 16px',
|
||||
}}
|
||||
onClick={onClose}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
background: '#01282A',
|
||||
borderRadius: '16px',
|
||||
width: '100%',
|
||||
maxWidth: '800px',
|
||||
margin: 'auto',
|
||||
position: 'relative',
|
||||
}}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<div className="video-detail-modal-content">
|
||||
{/* 헤더 */}
|
||||
<div className="video-detail-header">
|
||||
<button
|
||||
className="video-detail-close-btn"
|
||||
onClick={onClose}
|
||||
aria-label={t('videoDetail.closeAriaLabel')}
|
||||
>
|
||||
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
||||
<line x1="18" y1="6" x2="6" y2="18" /><line x1="6" y1="6" x2="18" y2="18" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className={`video-detail-content ${isLandscape ? 'landscape' : ''}`}>
|
||||
<video
|
||||
src={item.result_movie_url}
|
||||
controls
|
||||
autoPlay
|
||||
controlsList="nodownload"
|
||||
onContextMenu={(e) => e.preventDefault()}
|
||||
className="video-detail-player"
|
||||
onLoadedMetadata={(e) => {
|
||||
const v = e.currentTarget;
|
||||
setIsLandscape(v.videoWidth > v.videoHeight);
|
||||
}}
|
||||
/>
|
||||
|
||||
<div className="video-detail-info">
|
||||
<h2 className="video-detail-store">
|
||||
{item.store_name || t('ssulbox.viewer.untitled')}
|
||||
</h2>
|
||||
<p className="video-detail-date">{formatDate(item.created_at)}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default SsulViewerModal;
|
||||
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* 썰박스 시나리오 팔레트와 표시 유틸.
|
||||
*
|
||||
* 원본(o2o-ssulbox/frontend/src/data.ts)에서 이식하되 **문구(name/desc)는 제외**했다.
|
||||
* castad 는 ko/en 다국어라 한글이 코드에 박히면 i18n 밖으로 새기 때문이다.
|
||||
* 표시 문구는 `t('ssulbox.scenario.<key>.name')` / `.desc` 로 가져온다.
|
||||
*
|
||||
* 목업(SAMPLE)도 제외했다 — 백엔드 `/ssul/feed` 가 진실 원천이다.
|
||||
*/
|
||||
|
||||
/** 시나리오 코드. 백엔드 `ssul_content.scenario` 와 값이 일치해야 한다 */
|
||||
export type Scen = 'joseon' | 'samgukji' | 'greek' | 'odyssey';
|
||||
|
||||
export interface ScenPalette {
|
||||
/** 카드 표지 이모지 */
|
||||
emoji: string;
|
||||
/** 대표색 (뱃지·강조선) */
|
||||
hex: string;
|
||||
/** 표지 그라디언트 시작/끝 */
|
||||
g: [string, string];
|
||||
}
|
||||
|
||||
export const SCEN: Record<Scen, ScenPalette> = {
|
||||
joseon: { emoji: '👑', hex: '#3b4cc0', g: ['#4054d6', '#8a3ffb'] },
|
||||
samgukji: { emoji: '⚔️', hex: '#d63a2f', g: ['#e0402f', '#f0872b'] },
|
||||
greek: { emoji: '🏛️', hex: '#0a8f6b', g: ['#0a9e78', '#3fb6d6'] },
|
||||
odyssey: { emoji: '⛵', hex: '#1565c0', g: ['#1565c0', '#42a5f5'] },
|
||||
};
|
||||
|
||||
/** 시나리오 순서. 선택 그리드(2x2)와 필터 칩이 이 순서를 따른다 */
|
||||
export const SCEN_KEYS = Object.keys(SCEN) as Scen[];
|
||||
|
||||
/** 카드 표지 그라디언트 */
|
||||
export const scGrad = (s: Scen): string =>
|
||||
`linear-gradient(150deg,${SCEN[s].g[0]} 0%,${SCEN[s].g[1]} 100%)`;
|
||||
|
||||
/** i18n 키 헬퍼 — t(scenName('joseon')) 형태로 쓴다 */
|
||||
export const scenName = (s: Scen): string => `ssulbox.scenario.${s}.name`;
|
||||
export const scenDesc = (s: Scen): string => `ssulbox.scenario.${s}.desc`;
|
||||
|
||||
/**
|
||||
* 조회수·좋아요 수 축약 표기 (1.2만 / 3.4천).
|
||||
*
|
||||
* 한글 단위가 박혀 있어 en 로케일에서는 어색하다. 통합 목록에서 castad 콘텐츠와
|
||||
* 나란히 놓이므로, 표기 방식은 Phase 8 에서 castad 쪽과 함께 정하는 게 맞다.
|
||||
* 그때까지는 원본 동작을 유지한다.
|
||||
*/
|
||||
export const fmt = (n: number): string =>
|
||||
n >= 10000
|
||||
? `${(n / 10000).toFixed(1).replace(/\.0$/, '')}만`
|
||||
: n >= 1000
|
||||
? `${(n / 1000).toFixed(1).replace(/\.0$/, '')}천`
|
||||
: `${n}`;
|
||||
@@ -0,0 +1,111 @@
|
||||
/**
|
||||
* 썰박스 UI 아이콘.
|
||||
*
|
||||
* 원본(o2o-ssulbox/frontend/src/icons.tsx)에서 이식하되 **castad 에 대응물이 있는 것은 제외**했다:
|
||||
* IcHome / IcSearch / IcUser / IcGrid → castad Sidebar 가 대체
|
||||
* IcBack → castad 각 화면의 뒤로가기 버튼이 대체
|
||||
*
|
||||
* 색·굵기는 대부분 CSS(컨텍스트)로 제어된다. 원본이 일부 아이콘에 `stroke="#fff"` 를
|
||||
* 하드코딩했는데, castad 다크 배경에서도 흰색이 맞아 그대로 두되
|
||||
* 재사용 가능성이 있는 것은 `currentColor` 로 바꿨다.
|
||||
*
|
||||
* 모두 장식용이므로 사용하는 쪽에서 `aria-hidden` 을 붙이거나 접근 가능한 라벨을 준다.
|
||||
*/
|
||||
import React from 'react';
|
||||
|
||||
/** 재생 (카드 오버레이) */
|
||||
export const IcPlay: React.FC = () => (
|
||||
<svg viewBox="0 0 24 24">
|
||||
<path d="M8 5v14l11-7z" />
|
||||
</svg>
|
||||
);
|
||||
|
||||
/** 좋아요 (채움) */
|
||||
export const IcHeart: React.FC = () => (
|
||||
<svg viewBox="0 0 24 24">
|
||||
<path d="M12 21s-8-5.3-8-11a4.5 4.5 0 0 1 8-2.8A4.5 4.5 0 0 1 20 10c0 5.7-8 11-8 11z" />
|
||||
</svg>
|
||||
);
|
||||
|
||||
/** 좋아요 (원본에서 채움과 동일 — 상태는 CSS 로 구분) */
|
||||
export const IcHeartLine = IcHeart;
|
||||
|
||||
/** 댓글 */
|
||||
export const IcComment: React.FC = () => (
|
||||
<svg viewBox="0 0 24 24">
|
||||
<path
|
||||
d="M21 12a8 8 0 0 1-11.6 7.1L4 20l1-5.2A8 8 0 1 1 21 12z"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeWidth="1.8"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
|
||||
/** 공유 */
|
||||
export const IcShare: React.FC = () => (
|
||||
<svg viewBox="0 0 24 24">
|
||||
<path
|
||||
d="M22 3 11 14M22 3l-7 19-4-8-8-4z"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeWidth="1.8"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
|
||||
/** 링크 복사 */
|
||||
export const IcLink: React.FC = () => (
|
||||
<svg viewBox="0 0 24 24">
|
||||
<path
|
||||
d="M10 13a5 5 0 0 0 7 0l2-2a5 5 0 0 0-7-7l-1 1m0 8a5 5 0 0 1-7 0 5 5 0 0 1 0-7l2-2a5 5 0 0 1 7 0"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeWidth="1.7"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
|
||||
/** 업로드 */
|
||||
export const IcUpload: React.FC = () => (
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8">
|
||||
<path d="M12 15V4M8 8l4-4 4 4M5 15v3a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-3" />
|
||||
</svg>
|
||||
);
|
||||
|
||||
/** 다운로드 */
|
||||
export const IcDownload: React.FC = () => (
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8">
|
||||
<path d="M12 4v11M8 11l4 4 4-4M5 19h14" />
|
||||
</svg>
|
||||
);
|
||||
|
||||
/** 복사 (캡션) */
|
||||
export const IcCopy: React.FC = () => (
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8">
|
||||
<rect x="9" y="9" width="11" height="11" rx="2" />
|
||||
<path d="M5 15V5a2 2 0 0 1 2-2h8" />
|
||||
</svg>
|
||||
);
|
||||
|
||||
// ── SNS 플랫폼 ────────────────────────────────────────────────
|
||||
export const IcYoutube: React.FC = () => (
|
||||
<svg viewBox="0 0 24 24">
|
||||
<rect x="2" y="5" width="20" height="14" rx="4" />
|
||||
<path d="M10 9l5 3-5 3z" fill="#fff" />
|
||||
</svg>
|
||||
);
|
||||
|
||||
export const IcInstagram: React.FC = () => (
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8">
|
||||
<rect x="3" y="3" width="18" height="18" rx="5" />
|
||||
<circle cx="12" cy="12" r="4" />
|
||||
<circle cx="17.5" cy="6.5" r="1" fill="currentColor" stroke="none" />
|
||||
</svg>
|
||||
);
|
||||
|
||||
export const IcTiktok: React.FC = () => (
|
||||
<svg viewBox="0 0 24 24">
|
||||
<path d="M14 3c.3 2.3 1.8 4 4 4.3V10c-1.5 0-2.9-.5-4-1.3V15a5 5 0 1 1-5-5v2.6a2.4 2.4 0 1 0 2.4 2.4V3z" />
|
||||
</svg>
|
||||
);
|
||||
Reference in new issue
Block a user