add frontend

This commit is contained in:
jaehwang committed 2026-09-08 13:48:20 +09:00
1 parent bc57b358f9
commit 5cd5ec5649
44 files changed
+10081

No files matched your search

+44
View File
@@ -0,0 +1,44 @@
import type { Metadata } from "next";
import Link from "next/link";
import Ado2Logo from "@/components/ado2-logo";
import NavLink from "@/components/nav-link";
/* Playreel 자체 셸.
* ADO2 BI 는 넣는다 — Playreel 은 별도 URL 로 나가지만 ADO2 제품이고,
* 서브도메인(playreel.o2osolution.ai)을 권한 이유도 소속이 드러나는 편이 B2B 에 유리해서다.
* 하우스 락업 문법은 (ado2) 셸과 같다: ADO2 로고 + 제품 워드마크.
* 다만 여기서는 Playreel 이 서비스 이름이라 워드마크에 더 무게를 준다.
*
* ADO2 "화면"으로 건너가는 링크는 두지 않는다 — 별도 서비스가 자기 화면에서
* 남의 서비스를 광고할 이유가 없다. 소속 표기와 이동 링크는 다른 문제다. */
export const metadata: Metadata = {
title: "Playreel — 공연 예고편 · ADO2",
description: "공연 상품페이지 주소 하나로 30초 세로 예고편을 만듭니다",
};
export default function PlayreelLayout({ children }: { children: React.ReactNode }) {
return (
<>
<aside className="sidebar">
<div className="sidebar-logo">
<Link href="/playreel" className="pr-wordmark">
<Ado2Logo height={24} />
<span className="pr-line">
<span className="pr-mark">PLAYREEL</span>
<span className="pr-mark-ko">플레이릴</span>
</span>
</Link>
</div>
<nav className="sidebar-menu">
<NavLink href="/playreel" icon="video">예고편 만들기</NavLink>
<NavLink href="/playreel/archive" icon="folder">아카이브</NavLink>
</nav>
<div className="sidebar-foot">Playreel · an ADO2 product · 내부 빌드</div>
</aside>
<main className="main-content">
<div style={{ maxWidth: 1080, margin: "0 auto" }}>{children}</div>
</main>
</>
);
}
@@ -0,0 +1,181 @@
"use client";
import { use, useEffect, useRef, useState } from "react";
import Link from "next/link";
import { useRouter, useSearchParams } from "next/navigation";
import StageStepper, { stageProgress } from "@/components/stage-stepper";
import { GateBody, GateShell } from "@/components/gate-card";
import { apiFetch } from "@/lib/api";
import { GATE_META, PLAYREEL_STAGE_LABELS, usePlayreelJob } from "@/lib/playreel";
import { useAutoApprove } from "@/lib/prefs";
import { isAutoApprovable } from "@/components/auto-approve";
const RUNNING_COPY: Record<string, string> = {
fetch: "상세페이지에서 포스터와 정보를 가져오는 중", split: "상세페이지를 섹션으로 나누는 중",
upscale: "포스터 화질을 보정하는 중 (약 1분)", analyze: "포스터에서 움직일 요소를 찾는 중",
motion: "연출 프롬프트를 쓰는 중", narration: "나레이션 문장을 쓰는 중",
tts: "나레이션을 읽는 중", bgm: "배경음악을 만드는 중 (몇 분 걸릴 수 있습니다)",
i2v: "포스터를 움직이는 중 (5~8분)", hybrid: "원본 글자를 다시 덮는 중",
compose: "상세페이지 스크롤과 함께 조립하는 중", review: "자동 검사 중",
};
export default function PlayreelJobPage({ params }: { params: Promise<{ id: string }> }) {
const { id } = use(params);
const router = useRouter();
const mock = useSearchParams().get("mock");
const { job, error, refresh } = usePlayreelJob(id, mock);
const edits = useRef<unknown>(null);
const [busy, setBusy] = useState(false);
const [actionError, setActionError] = useState<string | null>(null);
const prefs = useAutoApprove();
const autoFired = useRef<Set<string>>(new Set()); // 같은 게이트에 두 번 보내지 않는다
const [autoNote, setAutoNote] = useState<string | null>(null);
// 게이트 ①·③ 자동 승인 — 폴링이 awaiting_review 를 보는 순간 한 번만 approve. mock 은 화면 확인용이라 제외.
const autoGate = !mock && job?.status === "awaiting_review" && isAutoApprovable(job.gate) && prefs[job.gate] ? job.gate : null;
useEffect(() => {
if (!autoGate || autoFired.current.has(autoGate)) return;
autoFired.current.add(autoGate);
const g = GATE_META[autoGate];
apiFetch(`/api/playreel/jobs/${id}/approve`, {
method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ gate: autoGate }),
}).then(() => {
setAutoNote(`${g.step}단계 ${g.name}을 자동 승인했습니다.`);
refresh();
}).catch((e) => {
autoFired.current.delete(autoGate); // 실패하면 사람이 누를 수 있게 카드가 그대로 남는다
setActionError(`자동 승인 실패 — 직접 확인해 주세요. ${(e as Error).message}`);
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [autoGate, id]);
if (error) return <p style={{ color: "#ff7a7a" }}>{error}</p>;
if (!job) return <p style={{ color: "var(--color-text-gray-400)" }}>불러오는 중…</p>;
const post = async (path: string, body?: unknown) => {
setBusy(true);
setActionError(null);
try {
if (mock) {
// 서버 없이 화면만 볼 때 — 다음 게이트로 넘긴다
const i = job.gate ? Object.keys(GATE_META).indexOf(job.gate) : -1;
const next = Object.keys(GATE_META)[i + 1] ?? "done";
router.push(`/playreel/mock?mock=${path.endsWith("back") ? Object.keys(GATE_META)[Math.max(0, i - 1)] : next}`);
return;
}
await apiFetch(`/api/playreel/jobs/${id}/${path}`, {
method: "POST",
...(body ? { headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) } : {}),
});
edits.current = null;
refresh();
} catch (e) {
setActionError((e as Error).message);
} finally {
setBusy(false);
}
};
const remove = async () => {
if (!confirm(`"${job.name}" 작업과 만들어진 파일을 모두 지웁니다. 되돌릴 수 없습니다.`)) return;
await apiFetch(`/api/playreel/jobs/${id}`, { method: "DELETE" }).catch((e) => setActionError((e as Error).message));
router.push("/");
};
const pct = stageProgress(job);
const gate = job.gate ? GATE_META[job.gate] : null;
return (
<div>
<div style={{ display: "flex", alignItems: "flex-start" }}>
<Link href="/" className="btn-back">‹ 뒤로가기</Link>
{job.status !== "running" && !mock && (
<button onClick={remove} disabled={busy} className="btn-back" style={{ marginLeft: "auto", color: "#ff8c8c", borderColor: "rgba(255,140,140,0.4)" }}>작업 삭제</button>
)}
</div>
<div className="stepper-scroll"><StageStepper job={job} labels={PLAYREEL_STAGE_LABELS} /></div>
<h1 className="page-title">{job.status === "done" ? "예고편 완성" : job.name}</h1>
<p className="page-subtitle">
{job.status === "awaiting_review" && gate ? `확인 ${gate.step}/5 · ${gate.name}이 필요합니다` :
job.status === "running" ? (RUNNING_COPY[job.stage ?? ""] ?? "만드는 중") :
job.status === "queued" ? `대기 중 · 앞에 ${job.queue_size ?? 0}편` :
job.status === "failed" ? "작업이 중단되었습니다" : "아카이브에 저장되었습니다"}
{job.credits_used > 0 && <span style={{ color: "var(--color-text-gray-500)" }}> · 사용 {job.credits_used}크레딧</span>}
</p>
<div className="card" style={{ marginTop: "2rem", padding: "var(--spacing-page-md)" }}>
{(job.status === "running" || job.status === "queued") && (
<div style={{ display: "flex", flexDirection: "column", alignItems: "center", padding: "3rem 0", gap: "1.5rem" }}>
<div className="gen-spinner" />
<p style={{ margin: 0, color: "var(--color-text-gray-300)" }}>{RUNNING_COPY[job.stage ?? ""] ?? "준비 중"}</p>
<div style={{ width: 320 }}>
<div className="progress-bar-container"><div className="progress-bar-fill" style={{ width: `${pct}%` }} /></div>
<p style={{ textAlign: "center", margin: "0.5rem 0 0", fontSize: "var(--text-sm)", color: "var(--color-text-gray-400)" }}>{pct}%</p>
</div>
<p style={{ margin: 0, fontSize: "var(--text-sm)", color: "var(--color-text-gray-500)" }}>
다음 확인 요청이 오면 이 화면에 나타납니다. 창을 닫아도 작업은 계속됩니다.
</p>
{autoNote && <p style={{ margin: 0, fontSize: "var(--text-sm)", color: "var(--color-mint)" }}>{autoNote} <Link href="/playreel" style={{ color: "inherit" }}>설정 바꾸기 ›</Link></p>}
</div>
)}
{autoGate && !actionError && (
<div style={{ display: "flex", flexDirection: "column", alignItems: "center", padding: "3rem 0", gap: "1rem" }}>
<div className="gen-spinner" />
<p style={{ margin: 0, color: "var(--color-text-gray-300)" }}>{GATE_META[autoGate].step}단계 {GATE_META[autoGate].name}을 자동 승인하는 중</p>
<p style={{ margin: 0, fontSize: "var(--text-sm)", color: "var(--color-text-gray-500)" }}>시작 화면에서 끌 수 있습니다.</p>
</div>
)}
{job.status === "awaiting_review" && job.gate && job.review && !(autoGate && !actionError) && (
<GateShell gate={job.gate} busy={busy} error={actionError}
onApprove={() => post("approve", { gate: job.gate, edits: edits.current })}
onBack={gate?.canBack ? () => post("back") : undefined}
approveLabel={job.gate === "final_confirm" ? "승인하고 저장" : job.gate === "clip_confirm" ? "이 클립으로 계속" : undefined}>
<GateBody review={job.review} onEdits={(e) => { edits.current = e; }} />
{job.gate === "clip_confirm" && (
<button className="btn-outline btn-lg" style={{ marginTop: "0.75rem" }} disabled={busy} onClick={() => post("retry")}>
다시 만들기 (재과금)
</button>
)}
</GateShell>
)}
{job.status === "failed" && job.error && (
<div style={{ maxWidth: 640, margin: "0 auto" }}>
<p className="eyebrow" style={{ color: "#ff8c8c", margin: "0 0 1rem" }}>실패 · {PLAYREEL_STAGE_LABELS[job.error.stage] ?? job.error.stage}</p>
<pre className="card-inner" style={{ fontSize: "var(--text-sm)", whiteSpace: "pre-wrap", wordBreak: "break-all", maxHeight: 280, overflow: "auto", color: "var(--color-text-gray-400)", margin: 0 }}>{job.error.detail}</pre>
<div className="fail-actions">
<button className="btn-outline" disabled={busy} onClick={() => post("retry")}>다시 시도</button>
{job.error.stage === "i2v" && (
<button className="btn-tonal-mint" disabled={busy} onClick={() => post("force")}>클립은 쓸 만함 — 이대로 진행</button>
)}
</div>
{actionError && <p style={{ color: "#ff7a7a", fontSize: "var(--text-sm)", marginTop: "0.75rem", textAlign: "center" }}>{actionError}</p>}
</div>
)}
{job.status === "done" && (
<div className="result-grid">
<div className="card-inner result-video">
{job.artifacts.video
? <video src={job.artifacts.video} controls style={{ width: "100%", maxHeight: 560, borderRadius: "var(--radius-md)", display: "block" }} />
: <p style={{ color: "var(--color-text-gray-500)", fontSize: "var(--text-sm)" }}>영상</p>}
</div>
<div className="result-meta">
<p className="field-label" style={{ margin: 0 }}>파일명</p>
<p style={{ margin: "0.25rem 0 1rem", fontSize: "var(--text-xl)", fontWeight: 700 }}>{job.source.slug}_30_v{job.version}.mp4</p>
<p style={{ margin: 0, fontSize: "var(--text-sm)", color: "var(--color-text-gray-400)" }}>출처 · <a href={job.source.url} target="_blank" rel="noreferrer" style={{ color: "var(--color-mint)" }}>공연 상품페이지 열기 →</a></p>
<div className="result-actions">
<Link href="/" className="btn-tonal-mint" style={{ textDecoration: "none", textAlign: "center" }}>새 버전 만들기</Link>
<a href={job.artifacts.video} download className="btn-cta" style={{ padding: "0.75rem 1rem", fontSize: "var(--text-base)", borderRadius: "var(--radius-xl)", textDecoration: "none" }}>MP4 다운로드</a>
</div>
</div>
</div>
)}
</div>
</div>
);
}
@@ -0,0 +1,80 @@
"use client";
import { useEffect, useState } from "react";
import Link from "next/link";
import { apiFetch } from "@/lib/api";
/* Playreel 전용 아카이브.
* (ado2) 그룹의 /archive 로 보내면 독립 셸이 깨진다 — 같은 데이터를 여기서 보여주고
* playreel 갈래만 걸러낸다. 저장소는 공유다(요금 기획서 §8-⑤ 권장: 통합 유지). */
type Entry = {
slug: string;
kind?: string;
name: string;
poster_url?: string | null;
video_url?: string | null;
thumbnail_url?: string | null;
version?: number | null;
credits_used?: number | null;
source?: { url?: string } | null;
created_at?: number;
};
export default function PlayreelArchivePage() {
const [items, setItems] = useState<Entry[] | null>(null);
const [error, setError] = useState<string | null>(null);
useEffect(() => {
apiFetch<Entry[]>("/api/archive")
// kind 가 없던 옛 엔트리는 source 유무로 추정한다(프론트 archiveKind 와 같은 규칙)
.then((all) => setItems(all.filter((e) => e.kind === "playreel" || (!e.kind && e.source))))
.catch((e) => setError((e as Error).message));
}, []);
return (
<div style={{ paddingTop: "0.5rem" }}>
<h1 className="page-title">아카이브</h1>
<p className="page-subtitle">완성한 예고편이 여기 쌓입니다. 버전은 덮어쓰지 않습니다.</p>
{error && <p style={{ color: "#ff7a7a", textAlign: "center", marginTop: "1.5rem" }}>{error}</p>}
{items && items.length === 0 && (
<p className="page-subtitle" style={{ marginTop: "2.5rem" }}>
아직 완성한 예고편이 없습니다. <Link href="/playreel">첫 예고편 만들기 →</Link>
</p>
)}
{items && items.length > 0 && (
<div className="pr-archive">
{items.map((e) => (
<div key={e.slug} className="card-inner" style={{ padding: "0.85rem" }}>
{e.video_url ? (
<video
src={e.video_url}
poster={e.thumbnail_url ?? undefined}
controls
preload="none"
style={{ width: "100%", borderRadius: "var(--radius-md)", display: "block", background: "#000" }}
/>
) : (
<div className="pr-archive-blank">영상 없음</div>
)}
<p style={{ margin: "0.6rem 0 0", fontSize: "var(--text-sm)", fontWeight: 700, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }}>
{e.name}
</p>
<p style={{ margin: "0.3rem 0 0", fontSize: "var(--text-xs)", color: "var(--color-text-gray-500)" }}>
{e.version ? `v${e.version}` : "—"}
{e.credits_used != null && ` · ${e.credits_used}크레딧`}
</p>
{e.video_url && (
<a href={e.video_url} download className="btn-outline" style={{ display: "block", textAlign: "center", marginTop: "0.6rem", padding: "0.5rem", fontSize: "var(--text-sm)", textDecoration: "none" }}>
MP4 다운로드
</a>
)}
</div>
))}
</div>
)}
</div>
);
}
+134
View File
@@ -0,0 +1,134 @@
"use client";
import { useEffect, useMemo, useState } from "react";
import Link from "next/link";
import { useRouter } from "next/navigation";
import { apiFetch } from "@/lib/api";
import { GATE_META, parseGoodsId, type PlayreelJob } from "@/lib/playreel";
import { AutoApprovePanel } from "@/components/auto-approve";
const STATUS_LABEL: Record<string, string> = {
queued: "대기 중", running: "만드는 중", awaiting_review: "검수 대기", failed: "실패", done: "완료",
};
function statusTone(s: string) {
return s === "failed" ? "#ff7a7a"
: s === "done" ? "var(--color-mint)"
: s === "awaiting_review" ? "#ffd27a"
: "var(--color-text-gray-400)";
}
export default function PlayreelStartPage() {
const router = useRouter();
const [url, setUrl] = useState("");
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null);
const goodsId = useMemo(() => parseGoodsId(url), [url]);
// 독립 서비스가 되면서 ADO2 홈의 "최근 작업"을 잃는다. 여기서 대신 보여준다.
const [recent, setRecent] = useState<PlayreelJob[]>([]);
useEffect(() => {
apiFetch<PlayreelJob[]>("/api/playreel/jobs")
.then((j) => setRecent(j.slice(0, 6)))
.catch(() => setRecent([]));
}, []);
const submit = async () => {
if (!goodsId) return;
setBusy(true);
setError(null);
try {
const { id } = await apiFetch<{ id: string }>("/api/playreel/jobs", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ url: url.trim() }),
});
router.push(`/playreel/${id}`);
} catch (e) {
setError((e as Error).message);
setBusy(false);
}
};
return (
<div style={{ display: "flex", flexDirection: "column", alignItems: "center", paddingTop: "0.5rem" }}>
<h1 className="page-title">공연 상세페이지 주소만 넣으세요</h1>
<p className="page-subtitle" style={{ lineHeight: 1.7 }}>
포스터 · 캐스팅 · 일정 · 줄거리를 읽어<br />
30초 세로 예고 영상을 만듭니다. 중요한 순간마다 확인을 요청합니다.
</p>
<div style={{ width: "100%", maxWidth: 560, marginTop: "2rem", display: "flex", flexDirection: "column", gap: "0.75rem" }}>
<div style={{ position: "relative" }}>
<input
className="input"
placeholder="공연 상품페이지 주소를 붙여넣으세요"
value={url}
onChange={(e) => setUrl(e.target.value)}
onKeyDown={(e) => { if (e.key === "Enter") submit(); }}
style={{ paddingRight: goodsId ? 150 : undefined }}
autoFocus
/>
{goodsId && (
<span className="tag" style={{ position: "absolute", right: 14, top: "50%", transform: "translateY(-50%)", background: "var(--color-mint)", color: "var(--color-bg-dark)" }}>
상품 {goodsId} 인식됨
</span>
)}
</div>
{url.trim() && !goodsId && (
<p style={{ margin: 0, textAlign: "center", fontSize: "var(--text-sm)", color: "#ffb37a" }}>
아직 지원하지 않는 주소입니다. 공연 상품페이지 주소를 넣어주세요.
</p>
)}
{error && <p style={{ color: "#ff7a7a", fontSize: "var(--text-sm)", textAlign: "center", margin: 0 }}>{error}</p>}
<button className="btn-cta btn-lg" disabled={!goodsId || busy} onClick={submit}>
{busy ? "상세페이지 읽는 중…" : "예고편 만들기"}
</button>
</div>
{/* 게이트 ①·③ 자동 승인 — 시작 전에 정하고, 되돌리는 자리도 여기 */}
<div style={{ width: "100%", maxWidth: 720, marginTop: "3rem" }}>
<AutoApprovePanel />
</div>
{/* 어떻게 진행되나 — ICP가 처음 볼 때 확인 5회를 미리 알게 한다 */}
<div style={{ width: "100%", maxWidth: 720, marginTop: "2rem" }}>
<p className="field-label" style={{ margin: "0 0 0.75rem" }}>진행 순서 · 확인이 필요한 순간 5번</p>
<div className="playreel-steps">
{(Object.keys(GATE_META) as (keyof typeof GATE_META)[]).map((k) => {
const g = GATE_META[k];
return (
<div key={k} className="card-inner" style={{ padding: "0.85rem" }}>
<p style={{ margin: 0, fontSize: "var(--text-xs)", color: "var(--color-mint)", fontWeight: 700 }}>{g.step}단계</p>
<p style={{ margin: "0.25rem 0 0", fontSize: "var(--text-sm)", fontWeight: 700 }}>{g.name}</p>
<p style={{ margin: "0.35rem 0 0", fontSize: "var(--text-xs)", color: "var(--color-text-gray-500)" }}>
{g.credits > 0 ? `${g.credits}크레딧` : "무료"} · {g.eta}
</p>
</div>
);
})}
</div>
</div>
{recent.length > 0 && (
<div style={{ width: "100%", maxWidth: 720, marginTop: "2.5rem" }}>
<p className="field-label" style={{ margin: "0 0 0.75rem" }}>최근 작업</p>
<div className="playreel-recent">
{recent.map((j) => {
const label = j.status === "awaiting_review" && j.gate
? `${GATE_META[j.gate].name} 대기`
: STATUS_LABEL[j.status] ?? j.status;
return (
<Link key={j.id} href={`/playreel/${j.id}`} style={{ textDecoration: "none", color: "inherit" }}>
<div className="card-inner" style={{ padding: "0.85rem" }}>
<p style={{ margin: 0, fontSize: "var(--text-sm)", fontWeight: 700, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }}>{j.name}</p>
<p style={{ margin: "0.35rem 0 0", fontSize: "var(--text-xs)", fontWeight: 600, color: statusTone(j.status) }}>{label}</p>
</div>
</Link>
);
})}
</div>
</div>
)}
</div>
);
}