89 lines
3.1 KiB
TypeScript
89 lines
3.1 KiB
TypeScript
import React from 'react';
|
|
import { useTranslation } from 'react-i18next';
|
|
import { p2vProgress } from '../../utils/p2vApi';
|
|
import { GATE_ORDER, GateKey, PlayreelJob } from '../../utils/playreelApi';
|
|
|
|
interface PlayreelMakingContentProps {
|
|
job: PlayreelJob | null;
|
|
/** 실패한 잡을 버리고 처음부터. 실패하면 크레딧이 환불되므로 같은 잡을 다시 돌리지 않는다 */
|
|
onDiscard: () => void;
|
|
busy: boolean;
|
|
/** 방금 자동 승인한 게이트가 있으면 그 안내. 다음 확인 요청이 올 때까지 보여준다 */
|
|
autoApprovedGate?: GateKey | null;
|
|
}
|
|
|
|
/**
|
|
* 롱컷 진행·실패 화면. 검수 게이트 사이사이의 대기 구간에 쓰인다.
|
|
*
|
|
* 진행바는 스테이지 완료 수 기반이라 구간 사이에서 멈춰 보인다 —
|
|
* 스피너가 "살아 있다"를 따로 알린다(PosterMakingContent 와 같은 판단).
|
|
*/
|
|
const PlayreelMakingContent: React.FC<PlayreelMakingContentProps> = ({
|
|
job, onDiscard, busy, autoApprovedGate,
|
|
}) => {
|
|
const { t } = useTranslation();
|
|
|
|
if (!job) return null;
|
|
|
|
const percent = p2vProgress(job);
|
|
|
|
if (job.status === 'failed') {
|
|
return (
|
|
<div className="p2v-scope p2v-making">
|
|
<span className="p2v-making__name">{job.name}</span>
|
|
<h2 className="p2v-making__title warn">{t('playreel.making.failTitle')}</h2>
|
|
<p className="p2v-making__desc">
|
|
{t(`playreel.stages.${job.error?.stage}`, { defaultValue: job.error?.stage ?? '' })}
|
|
</p>
|
|
{job.error?.detail && <pre className="p2v-errorbox">{job.error.detail}</pre>}
|
|
<p className="p2v-making__desc">{t('playreel.making.refunded')}</p>
|
|
<div className="p2v-making__actions">
|
|
<button type="button" className="p2v-btn-mint" disabled={busy} onClick={onDiscard}>
|
|
{t('playreel.making.discard')}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
const stageKey = job.stage ?? '';
|
|
const copy = t(`playreel.running.${stageKey}`, { defaultValue: t('playreel.making.preparing') });
|
|
|
|
return (
|
|
<div className="p2v-scope p2v-making">
|
|
<span className="p2v-making__name">{job.name}</span>
|
|
<h2 className="p2v-making__title">{t('playreel.making.title')}</h2>
|
|
|
|
<div className="p2v-spinner" aria-hidden="true" />
|
|
|
|
<div
|
|
className="p2v-bar"
|
|
role="progressbar"
|
|
aria-valuenow={percent}
|
|
aria-valuemin={0}
|
|
aria-valuemax={100}
|
|
>
|
|
<div className="p2v-bar__fill" style={{ width: `${percent}%` }} />
|
|
</div>
|
|
|
|
<div className="p2v-making__meta">
|
|
<span>{job.status === 'queued' ? t('playreel.making.queued') : copy}</span>
|
|
<span className="p2v-making__pct">{percent}%</span>
|
|
</div>
|
|
|
|
<p className="p2v-making__desc">{t('playreel.making.wait')}</p>
|
|
|
|
{autoApprovedGate && (
|
|
<p className="pr-auto-note">
|
|
{t('playreel.auto.done', {
|
|
step: GATE_ORDER.indexOf(autoApprovedGate) + 1,
|
|
name: t(`playreel.gates.${autoApprovedGate}.name`),
|
|
})}
|
|
</p>
|
|
)}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default PlayreelMakingContent;
|