126 lines
4.3 KiB
TypeScript
126 lines
4.3 KiB
TypeScript
import React, { useState } from 'react';
|
|
import { useTranslation } from 'react-i18next';
|
|
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';
|
|
import PosterCreateForm from '../Poster/PosterCreateForm';
|
|
import PosterStartChoice from '../Poster/PosterStartChoice';
|
|
import PlayreelCreateForm from '../P2v/PlayreelCreateForm';
|
|
|
|
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, officialSiteUrl?: string) => void;
|
|
error: string | null;
|
|
/** 썰박스 생성 요청 접수 시. 폴링 소유는 GenerationFlow */
|
|
onSsulJobStarted: (taskId: number, scenario: Scen) => void;
|
|
/** 포스터 영상(F1) 생성 요청 접수 시. 폴링 소유는 GenerationFlow */
|
|
onPosterJobStarted: (jobId: string) => void;
|
|
/** 롱컷 생성 요청 접수 시. 폴링 소유는 GenerationFlow */
|
|
onPlayreelJobStarted: (jobId: string) => void;
|
|
/** 크레딧 부족 시 충전 화면으로 */
|
|
onGoToPayment: () => void;
|
|
}
|
|
|
|
/**
|
|
* 대시보드 진입 화면.
|
|
*
|
|
* 탭바는 로고와 하위 폼 **사이에 형제로** 얹고 하위 폼만 교체한다.
|
|
*/
|
|
const UrlInputContent: React.FC<UrlInputContentProps> = ({
|
|
pipeline,
|
|
onPipelineChange,
|
|
onAnalyze,
|
|
onAutocomplete,
|
|
onManualInput,
|
|
error,
|
|
onSsulJobStarted,
|
|
onPosterJobStarted,
|
|
onPlayreelJobStarted,
|
|
onGoToPayment,
|
|
}) => {
|
|
const { t } = useTranslation();
|
|
|
|
/**
|
|
* 무빙 포스터 탭의 시작 화면. 롱컷은 별도 탭이 아니라 이 화면의 두 번째 갈래다 —
|
|
* 'choose' 에서 가진 것(이미지 / 상품페이지 주소)을 고르면 폼으로 들어간다.
|
|
*/
|
|
const [posterStart, setPosterStart] = useState<'choose' | 'image'>('choose');
|
|
const showChoice = pipeline === 'poster' && posterStart === 'choose';
|
|
|
|
const handleTabChange = (next: Pipeline) => {
|
|
// 무빙 포스터 탭을 다시 누르면 어느 폼에 있었든 선택 화면으로 돌아간다
|
|
if (next === 'poster') setPosterStart('choose');
|
|
onPipelineChange(next);
|
|
};
|
|
|
|
const backToChoice = () => {
|
|
setPosterStart('choose');
|
|
onPipelineChange('poster');
|
|
};
|
|
|
|
const renderForm = () => {
|
|
switch (pipeline) {
|
|
case 'ado2':
|
|
return (
|
|
<SearchInputForm
|
|
onAnalyze={onAnalyze}
|
|
onAutocomplete={onAutocomplete}
|
|
onManualInput={onManualInput}
|
|
error={error}
|
|
/>
|
|
);
|
|
case 'ssul':
|
|
return <SsulCreateForm onSubmitted={onSsulJobStarted} onNeedCredit={onGoToPayment} />;
|
|
case 'poster':
|
|
return posterStart === 'choose' ? (
|
|
<PosterStartChoice
|
|
onPickImage={() => setPosterStart('image')}
|
|
onPickUrl={() => onPipelineChange('playreel')}
|
|
/>
|
|
) : (
|
|
<PosterCreateForm
|
|
onSubmitted={onPosterJobStarted}
|
|
onNeedCredit={onGoToPayment}
|
|
onBack={backToChoice}
|
|
/>
|
|
);
|
|
case 'playreel':
|
|
return (
|
|
<PlayreelCreateForm
|
|
onSubmitted={onPlayreelJobStarted}
|
|
onNeedCredit={onGoToPayment}
|
|
onBack={backToChoice}
|
|
/>
|
|
);
|
|
default:
|
|
return null;
|
|
}
|
|
};
|
|
|
|
return (
|
|
<div className="url-input-container">
|
|
<div className="url-input-content">
|
|
<div className="url-input-logo">
|
|
<img src="/assets/images/ADO2_with Slogan_white.svg" alt="ADO2" />
|
|
</div>
|
|
|
|
<PipelineTabs value={pipeline} onChange={handleTabChange} />
|
|
|
|
{/* 고른 기능이 무엇을 해주는지 한 줄. 탭 라벨(2~6자)만으로는 네 기능의 차이가
|
|
전달되지 않아 처음 온 사람이 아무거나 눌러본다. STEP 1 위에 둔다. */}
|
|
{!showChoice && <p className="pipeline-desc">{t(`pipelineTabs.desc.${pipeline}`)}</p>}
|
|
|
|
{renderForm()}
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default UrlInputContent;
|