add frontend
This commit is contained in:
1 parent
bc57b358f9
commit
5cd5ec5649
44 files changed
+10081
No files matched your search
@@ -0,0 +1,88 @@
|
||||
"use client";
|
||||
|
||||
import { use, useEffect, useState } from "react";
|
||||
import Link from "next/link";
|
||||
import MetadataCard from "@/components/metadata-card";
|
||||
import { InternalOnlyWarning, LicenseBadge } from "@/components/license-badge";
|
||||
import { apiFetch, archiveKind, type ArchiveEntry } from "@/lib/api";
|
||||
|
||||
export default function ArchiveDetailPage({ params }: { params: Promise<{ slug: string }> }) {
|
||||
const { slug } = use(params);
|
||||
const [entry, setEntry] = useState<ArchiveEntry | null>(null);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
apiFetch<ArchiveEntry>(`/api/archive/${slug}`).then(setEntry).catch((e) => setError(e.message));
|
||||
}, [slug]);
|
||||
|
||||
if (error) return <p style={{ color: "rgb(255,122,122)" }}>{error}</p>;
|
||||
if (!entry) return <p style={{ color: "var(--text-teal-1)" }}>불러오는 중…</p>;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div style={{ display: "flex", alignItems: "flex-start", marginBottom: "1rem" }}>
|
||||
<Link href="/archive" className="btn-back">‹ 아카이브</Link>
|
||||
</div>
|
||||
<span className="tag" style={{ height: 20, padding: "0 8px", fontSize: "var(--text-xs)" }}>{archiveKind(entry)}</span>
|
||||
<h1 className="page-title" style={{ textAlign: "left", margin: "0.5rem 0 1.5rem" }}>
|
||||
{entry.metadata?.event_name ?? entry.name}
|
||||
</h1>
|
||||
|
||||
<div className="archive-detail">
|
||||
<div className="card" style={{ padding: "var(--s-4)" }}>
|
||||
{entry.video_url ? (
|
||||
<video src={entry.video_url} controls style={{ width: "100%", borderRadius: "var(--r-sm)", display: "block" }} />
|
||||
) : (
|
||||
// eslint-disable-next-line @next/next/no-img-element
|
||||
<img src={entry.poster_url} alt={entry.name} style={{ width: "100%", borderRadius: "var(--r-sm)" }} />
|
||||
)}
|
||||
{entry.video_url && (
|
||||
<div style={{ display: "flex", justifyContent: "center", marginTop: "var(--s-3)" }}>
|
||||
<a href={entry.video_url} download className="btn-tonal-mint">MP4 다운로드</a>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div style={{ display: "flex", flexDirection: "column", gap: "var(--s-5)" }}>
|
||||
{entry.metadata && <MetadataCard meta={entry.metadata} />}
|
||||
|
||||
{entry.narration && (
|
||||
<div className="card" style={{ padding: "var(--s-5)" }}>
|
||||
<p className="eyebrow" style={{ margin: "0 0 var(--s-3)" }}>
|
||||
나레이션
|
||||
</p>
|
||||
<ol style={{ margin: 0, paddingLeft: 18, fontSize: 15, lineHeight: 2 }}>
|
||||
{entry.narration.map((s, i) => <li key={i}>{s}</li>)}
|
||||
</ol>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{entry.f2_variants.length > 0 && (
|
||||
<div>
|
||||
<p className="eyebrow" style={{ margin: "0 0 var(--s-3)" }}>
|
||||
스타일 변형
|
||||
</p>
|
||||
{entry.f2_variants.some((v) => v.license === "internal-only") && (
|
||||
<InternalOnlyWarning />
|
||||
)}
|
||||
<div style={{ display: "grid", gridTemplateColumns: "repeat(auto-fill, minmax(140px, 1fr))", gap: "var(--s-3)", marginTop: "var(--s-3)" }}>
|
||||
{entry.f2_variants.map((v) => (
|
||||
<div key={v.template_id} className="card" style={{ overflow: "hidden" }}>
|
||||
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||
<img src={v.image_url} alt={v.name_ko ?? v.template_id} style={{ width: "100%", display: "block" }} />
|
||||
<div style={{ padding: "var(--s-2)", display: "flex", flexDirection: "column", alignItems: "center", gap: 4 }}>
|
||||
<p style={{ margin: 0, fontSize: 12, fontWeight: 600, color: "var(--text-teal-1)", textAlign: "center" }}>
|
||||
{v.name_ko ?? v.template_id}
|
||||
</p>
|
||||
<LicenseBadge license={v.license ?? "internal-only"} />
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import Link from "next/link";
|
||||
import { apiFetch, archiveKind, type ArchiveEntry } from "@/lib/api";
|
||||
|
||||
export default function ArchivePage() {
|
||||
const [entries, setEntries] = useState<ArchiveEntry[] | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
apiFetch<ArchiveEntry[]>("/api/archive").then(setEntries).catch(() => setEntries([]));
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1 className="page-title">포스터 숏폼 아카이브</h1>
|
||||
<p className="page-subtitle" style={{ marginBottom: "2rem" }}>
|
||||
만들어진 모든 포스터 숏폼이 메타태그와 함께 쌓입니다. 행사·지역·키워드로 축적되는 온라인 숏폼 광고판입니다.
|
||||
</p>
|
||||
|
||||
{entries === null && <p style={{ color: "var(--text-teal-1)" }}>불러오는 중…</p>}
|
||||
{entries?.length === 0 && <p style={{ color: "var(--text-teal-3)" }}>아직 아카이브된 영상이 없습니다.</p>}
|
||||
|
||||
<div style={{ display: "grid", gridTemplateColumns: "repeat(auto-fill, minmax(220px, 1fr))", gap: "var(--s-5)" }}>
|
||||
{entries?.map((e) => (
|
||||
<Link key={e.slug} href={`/archive/${e.slug}`} style={{ textDecoration: "none", color: "inherit" }}>
|
||||
<div className="card" style={{ overflow: "hidden" }}>
|
||||
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||
<img src={e.poster_url} alt={e.name}
|
||||
style={{ width: "100%", aspectRatio: "3/4", objectFit: "cover", display: "block" }} />
|
||||
<div style={{ padding: "var(--s-4)" }}>
|
||||
<span className="tag" style={{ height: 20, padding: "0 8px", fontSize: "var(--text-xs)", marginBottom: "var(--s-2)" }}>{archiveKind(e)}</span>
|
||||
<p style={{ margin: 0, fontSize: 15, fontWeight: 800 }}>{e.metadata?.event_name ?? e.name}</p>
|
||||
<p style={{ margin: "var(--s-1) 0 0", fontSize: 13, color: "var(--text-teal-1)" }}>
|
||||
{e.metadata?.place}{e.metadata?.category ? ` · ${e.metadata.category}` : ""}
|
||||
</p>
|
||||
<div style={{ marginTop: "var(--s-3)", display: "flex", flexWrap: "wrap", gap: "var(--s-1)" }}>
|
||||
{(e.metadata?.keywords ?? []).slice(0, 3).map((k) => (
|
||||
<span key={k} className="tag" style={{ fontSize: 12 }}>{k}</span>
|
||||
))}
|
||||
{(e.metadata?.keywords?.length ?? 0) > 3 && (
|
||||
<span className="tag" style={{ fontSize: 12 }}>+{(e.metadata!.keywords.length - 3)}</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import type { Metadata } from "next";
|
||||
import Link from "next/link";
|
||||
import Ado2Logo from "@/components/ado2-logo";
|
||||
import NavLink from "@/components/nav-link";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "ADO2 무빙포스터",
|
||||
description: "포스터 한 장으로 세로 영상을 만듭니다",
|
||||
};
|
||||
|
||||
export default function Ado2Layout({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
<>
|
||||
<aside className="sidebar">
|
||||
<div className="sidebar-logo">
|
||||
<Link href="/" style={{ color: "var(--color-text-white)", display: "inline-flex", alignItems: "baseline", gap: 8, textDecoration: "none" }}>
|
||||
<Ado2Logo height={20} />
|
||||
<span className="sidebar-product">MOVING POSTER</span>
|
||||
</Link>
|
||||
</div>
|
||||
<nav className="sidebar-menu">
|
||||
<NavLink href="/" icon="video">무빙포스터</NavLink>
|
||||
<NavLink href="/studio" icon="image">포스터 스타일링</NavLink>
|
||||
<NavLink href="/archive" icon="folder">아카이브</NavLink>
|
||||
</nav>
|
||||
<div className="sidebar-foot">무빙포스터 · 내부 빌드</div>
|
||||
</aside>
|
||||
<main className="main-content">
|
||||
<div style={{ maxWidth: 1080, margin: "0 auto" }}>{children}</div>
|
||||
</main>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import Link from "next/link";
|
||||
import { apiFetch, type Job } from "@/lib/api";
|
||||
import { GATE_META, type PlayreelJob } from "@/lib/playreel";
|
||||
|
||||
/* 무빙포스터 진입 — 두 갈래 (MOVING_POSTER_ENTRY_PLAN.md §1·§5) */
|
||||
|
||||
const ENTRIES = [
|
||||
{
|
||||
href: "/poster", icon: "IMG", title: "이미지로 시작하기",
|
||||
desc: "포스터 한 장이 첫 프레임 그대로 살아나는 8~15초 무빙포스터",
|
||||
flow: ["포스터 원본이 첫 프레임", "불꽃·물결·조명 등 요소만 움직임", "제목·일시 나레이션 + 음악"],
|
||||
facts: [["필요한 것", "이미지 1장"], ["확인", "1회"], ["시간", "약 3분"], ["비용", "14크레딧"]],
|
||||
cta: "포스터 올리기", hot: false, badge: null,
|
||||
},
|
||||
{
|
||||
href: "/playreel", icon: "URL", title: "공연상품페이지로 시작하기",
|
||||
desc: "상품페이지 주소 하나로 캐스팅·일정·줄거리까지 담긴 30초 예고편",
|
||||
flow: ["포스터 무빙 훅 8초", "상세페이지 스크롤 (줄거리·캐스트·캐스팅 스케줄·할인)", "예매 안내 밴드 + QR"],
|
||||
facts: [["필요한 것", "상품페이지 URL"], ["확인", "5회"], ["시간", "약 15분"], ["비용", "16크레딧"]],
|
||||
cta: "주소 넣기", hot: true, badge: "상세페이지까지",
|
||||
},
|
||||
] as const;
|
||||
|
||||
type Recent = { id: string; name: string; href: string; kind: "이미지" | "상품페이지"; label: string; tone: string };
|
||||
|
||||
const F1_STATUS: Record<string, string> = {
|
||||
queued: "대기 중", running: "만드는 중", awaiting_review: "검수 대기", failed: "실패", done: "완료",
|
||||
};
|
||||
|
||||
function tone(status: string) {
|
||||
return status === "failed" ? "#ff7a7a" : status === "done" ? "var(--color-mint)" : status === "awaiting_review" ? "#ffd27a" : "var(--color-text-gray-400)";
|
||||
}
|
||||
|
||||
export default function HomePage() {
|
||||
const [recent, setRecent] = useState<Recent[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
// 두 갈래의 최근 작업을 합쳐 최신순 6개. 한쪽 API가 없어도(playreel 미구현) 다른 쪽은 보인다.
|
||||
Promise.all([
|
||||
apiFetch<Job[]>("/api/f1/jobs").catch(() => [] as Job[]),
|
||||
apiFetch<PlayreelJob[]>("/api/playreel/jobs").catch(() => [] as PlayreelJob[]),
|
||||
]).then(([f1, pr]) => {
|
||||
const a: (Recent & { t: number })[] = [
|
||||
...f1.map((j) => ({ id: j.id, name: j.name, href: `/poster/${j.id}`, kind: "이미지" as const, label: F1_STATUS[j.status] ?? j.status, tone: tone(j.status), t: j.created_at })),
|
||||
...pr.map((j) => ({ id: j.id, name: j.name, href: `/playreel/${j.id}`, kind: "상품페이지" as const,
|
||||
label: j.status === "awaiting_review" && j.gate ? `${GATE_META[j.gate].name} 대기` : (F1_STATUS[j.status] ?? j.status), tone: tone(j.status), t: j.created_at })),
|
||||
];
|
||||
setRecent(a.sort((x, y) => y.t - x.t).slice(0, 6));
|
||||
});
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div style={{ display: "flex", flexDirection: "column", alignItems: "center", paddingTop: "1.5rem" }}>
|
||||
<h1 className="page-title">어떻게 시작할까요?</h1>
|
||||
<p className="page-subtitle">가진 것에 따라 고르세요. 둘 다 9:16 세로 영상으로 완성됩니다.</p>
|
||||
|
||||
<div className="entry-stack">
|
||||
{ENTRIES.map((e) => (
|
||||
<div key={e.href} className={`card entry${e.hot ? " entry--hot" : ""}`}>
|
||||
{e.badge && <span className="entry-badge">{e.badge}</span>}
|
||||
<div className="entry-head">
|
||||
<div className="entry-icon">{e.icon}</div>
|
||||
<div>
|
||||
<h2 className="entry-title">{e.title}</h2>
|
||||
<p className="entry-desc">{e.desc}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="entry-flow">
|
||||
{e.flow.map((f, i) => (
|
||||
<span key={f} style={{ display: "contents" }}>
|
||||
{i > 0 && <em>→</em>}
|
||||
<span>{f}</span>
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
<div className="entry-facts">
|
||||
{e.facts.map(([k, v]) => (
|
||||
<div key={k}><b>{k}</b><span>{v}</span></div>
|
||||
))}
|
||||
</div>
|
||||
<Link href={e.href} className="btn-cta btn-lg" style={{ textDecoration: "none" }}>{e.cta}</Link>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{recent.length > 0 && (
|
||||
<div style={{ width: "100%", maxWidth: 560, marginTop: "2.5rem" }}>
|
||||
<p className="field-label" style={{ margin: "0 0 0.75rem" }}>최근 작업</p>
|
||||
<div style={{ display: "grid", gridTemplateColumns: "repeat(auto-fill, minmax(160px, 1fr))", gap: "0.75rem" }}>
|
||||
{recent.map((j) => (
|
||||
<Link key={j.href} href={j.href} style={{ textDecoration: "none", color: "inherit" }}>
|
||||
<div className="card-inner" style={{ padding: "1rem" }}>
|
||||
<span className="tag" style={{ height: 20, padding: "0 8px", fontSize: "var(--text-xs)" }}>{j.kind}</span>
|
||||
<p style={{ margin: "0.5rem 0 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: j.tone }}>{j.label}</p>
|
||||
</div>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,333 @@
|
||||
"use client";
|
||||
|
||||
import { use, useEffect, useState } from "react";
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/navigation";
|
||||
import StageStepper, { stageProgress } from "@/components/stage-stepper";
|
||||
import MetadataCard from "@/components/metadata-card";
|
||||
import { apiFetch, useJob } from "@/lib/api";
|
||||
|
||||
const SUBTITLES: Record<string, string> = {
|
||||
queued: "대기 중입니다. 앞선 작업이 끝나면 자동으로 시작됩니다",
|
||||
running: "AI 분석 및 편집을 통해 콘텐츠를 만들고 있습니다",
|
||||
awaiting_review: "나레이션과 모션을 확인하고 승인하면 음성·음악·렌더가 이어집니다",
|
||||
failed: "작업이 중단되었습니다. 오류를 확인하고 다시 시도해 주세요",
|
||||
done: "AI 분석 및 편집을 통해 최적화된 콘텐츠가 완성되었습니다",
|
||||
};
|
||||
|
||||
// scripts/motion_plan.py의 MOTION_PHRASE 화이트리스트와 1:1. 여기 없는 키는 서버가 422로 거른다.
|
||||
const MOTION_LABELS: Record<string, string> = {
|
||||
firework: "불꽃놀이", water: "물살", wave: "파도", cloud: "구름", smoke: "연기",
|
||||
moon: "달", sun: "해", star: "별", light: "조명", flag: "깃발·천",
|
||||
foliage: "나뭇잎·풀", wheel: "바퀴·관람차", vessel: "배", crowd: "사람 무리",
|
||||
};
|
||||
|
||||
export default function JobPage({ params }: { params: Promise<{ id: string }> }) {
|
||||
const { id } = use(params);
|
||||
const router = useRouter();
|
||||
const { job, error, refresh } = useJob("f1", id);
|
||||
const [lines, setLines] = useState<string[]>([]);
|
||||
const [motions, setMotions] = useState<string[] | null>(null);
|
||||
const [meta, setMeta] = useState({ event_name: "", date_text: "", place: "" });
|
||||
const [metaLoaded, setMetaLoaded] = useState(false);
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [actionError, setActionError] = useState<string | null>(null);
|
||||
|
||||
// 아래 3개 effect: 서버 잡이 처음 도착했을 때 편집 상태를 한 번 시딩한다(이후 사용자 편집 우선).
|
||||
useEffect(() => {
|
||||
// eslint-disable-next-line react-hooks/set-state-in-effect -- 최초 1회 시딩
|
||||
if (job?.narration && lines.length === 0) setLines(job.narration);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [job?.narration]);
|
||||
|
||||
useEffect(() => {
|
||||
// 0종([])도 유효한 초기값이므로 null(미로딩)로만 판별한다
|
||||
if (job && motions === null && job.motion_elements !== undefined && job.motion_elements !== null)
|
||||
// eslint-disable-next-line react-hooks/set-state-in-effect -- 최초 1회 시딩
|
||||
setMotions(job.motion_elements);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [job?.motion_elements]);
|
||||
|
||||
useEffect(() => {
|
||||
if (job?.metadata && !metaLoaded) {
|
||||
// eslint-disable-next-line react-hooks/set-state-in-effect -- 최초 1회 시딩
|
||||
setMeta({
|
||||
event_name: job.metadata.event_name ?? "",
|
||||
date_text: job.metadata.date_text ?? "",
|
||||
place: job.metadata.place ?? "",
|
||||
});
|
||||
setMetaLoaded(true);
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [job?.metadata]);
|
||||
|
||||
if (error) return <p style={{ color: "#ff7a7a" }}>{error}</p>;
|
||||
if (!job) return <p style={{ color: "var(--color-text-gray-400)" }}>불러오는 중…</p>;
|
||||
|
||||
const approve = async () => {
|
||||
setBusy(true);
|
||||
setActionError(null);
|
||||
try {
|
||||
if (JSON.stringify(lines) !== JSON.stringify(job.narration)) {
|
||||
await apiFetch(`/api/f1/jobs/${id}/narration`, {
|
||||
method: "PUT",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ narration: lines }),
|
||||
});
|
||||
}
|
||||
const md = job.metadata;
|
||||
if (md && (md.event_name !== meta.event_name || md.date_text !== meta.date_text || md.place !== meta.place)) {
|
||||
await apiFetch(`/api/f1/jobs/${id}/metadata`, {
|
||||
method: "PUT",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(meta),
|
||||
});
|
||||
}
|
||||
const motionsChanged = motions !== null &&
|
||||
JSON.stringify([...motions].sort()) !== JSON.stringify([...(job.motion_elements ?? [])].sort());
|
||||
await apiFetch(`/api/f1/jobs/${id}/approve`, {
|
||||
method: "POST",
|
||||
...(motionsChanged ? {
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ motions }),
|
||||
} : {}),
|
||||
});
|
||||
refresh();
|
||||
} catch (e) {
|
||||
setActionError((e as Error).message);
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
};
|
||||
|
||||
const retry = async () => {
|
||||
setBusy(true);
|
||||
setActionError(null);
|
||||
try {
|
||||
const motionsChanged = motions !== null &&
|
||||
JSON.stringify([...motions].sort()) !== JSON.stringify([...(job!.motion_elements ?? [])].sort());
|
||||
await apiFetch(`/api/f1/jobs/${id}/retry`, {
|
||||
method: "POST",
|
||||
...(motionsChanged ? {
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ motions }),
|
||||
} : {}),
|
||||
});
|
||||
refresh();
|
||||
} catch (e) {
|
||||
setActionError((e as Error).message);
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
};
|
||||
|
||||
const remove = async () => {
|
||||
if (!confirm(`"${job.name}" 작업과 만들어진 영상·음성·분석 파일을 모두 지웁니다. 되돌릴 수 없습니다.`)) return;
|
||||
setBusy(true);
|
||||
setActionError(null);
|
||||
try {
|
||||
await apiFetch(`/api/f1/jobs/${id}`, { method: "DELETE" });
|
||||
router.push("/");
|
||||
} catch (e) {
|
||||
setActionError((e as Error).message);
|
||||
setBusy(false);
|
||||
}
|
||||
};
|
||||
|
||||
const pct = stageProgress(job);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div style={{ display: "flex", alignItems: "flex-start" }}>
|
||||
<Link href="/" className="btn-back">‹ 뒤로가기</Link>
|
||||
{job.status !== "running" && (
|
||||
<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} /></div>
|
||||
|
||||
<h1 className="page-title">
|
||||
{job.status === "done" ? "콘텐츠 제작 완료" : job.name}
|
||||
</h1>
|
||||
<p className="page-subtitle">{SUBTITLES[job.status]}</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, fontSize: "var(--text-base)", color: "var(--color-text-gray-300)" }}>
|
||||
생성 중 (음악 단계는 몇 분 걸릴 수 있습니다)
|
||||
</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>
|
||||
{job.narration && (
|
||||
<div className="card-inner" style={{ maxWidth: 520, width: "100%" }}>
|
||||
<p className="field-label" style={{ margin: "0 0 0.5rem" }}>나레이션</p>
|
||||
{job.narration.map((s, i) => (
|
||||
<p key={i} style={{ margin: "0.25rem 0", fontSize: "var(--text-base)", color: "var(--color-text-gray-300)" }}>{s}</p>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{job.status === "awaiting_review" && (
|
||||
<div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: "var(--spacing-page-md)", alignItems: "start" }}>
|
||||
<div>
|
||||
<p className="eyebrow" style={{ margin: "0 0 1rem" }}>나레이션 검수</p>
|
||||
<p style={{ fontSize: "var(--text-base)", color: "var(--color-text-gray-400)", margin: "0 0 1rem", lineHeight: 1.6 }}>
|
||||
자동 작성된 3문장을 확인하고 필요하면 고쳐주세요.
|
||||
</p>
|
||||
{lines.map((s, i) => (
|
||||
<input key={i} className="input" value={s} style={{ marginBottom: "0.5rem" }}
|
||||
onChange={(e) => setLines(lines.map((v, j) => (j === i ? e.target.value : v)))} />
|
||||
))}
|
||||
|
||||
<p className="eyebrow" style={{ margin: "1.5rem 0 0.5rem" }}>움직일 요소</p>
|
||||
<p style={{ fontSize: "var(--text-sm)", color: "var(--color-text-gray-400)", margin: "0 0 0.75rem", lineHeight: 1.6 }}>
|
||||
{motions !== null && motions.length === 0
|
||||
? "포스터에서 움직일 요소를 찾지 못했습니다. 직접 골라 추가하거나, 비워두면 애니메이션 없이 중단됩니다."
|
||||
: "AI가 포스터에서 찾은 요소입니다. 빼거나 더할 수 있습니다."}
|
||||
</p>
|
||||
<div style={{ display: "flex", flexWrap: "wrap", gap: "0.5rem" }}>
|
||||
{Object.entries(MOTION_LABELS).map(([key, label]) => {
|
||||
const on = motions?.includes(key) ?? false;
|
||||
return (
|
||||
<button key={key} type="button"
|
||||
onClick={() => setMotions(on ? (motions ?? []).filter((m) => m !== key)
|
||||
: [...(motions ?? []), key])}
|
||||
style={{
|
||||
padding: "0.35rem 0.8rem", borderRadius: 999, cursor: "pointer",
|
||||
fontSize: "var(--text-sm)",
|
||||
border: on ? "1px solid var(--color-mint)" : "1px solid var(--color-border-white-10)",
|
||||
background: on ? "var(--color-mint-20)" : "transparent",
|
||||
color: on ? "var(--color-mint)" : "var(--color-text-gray-400)",
|
||||
}}>
|
||||
{on ? "✓ " : "+ "}{label}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
<p className="eyebrow" style={{ margin: "1.5rem 0 0.5rem" }}>메타태그</p>
|
||||
<p style={{ fontSize: "var(--text-sm)", color: "var(--color-text-gray-400)", margin: "0 0 0.75rem", lineHeight: 1.6 }}>
|
||||
아카이브에 영구 저장됩니다. 연도나 지명이 잘못 읽혔는지 포스터와 대조해 주세요.
|
||||
</p>
|
||||
{([
|
||||
["event_name", "행사명"],
|
||||
["date_text", "일시"],
|
||||
["place", "장소"],
|
||||
] as const).map(([key, label]) => (
|
||||
<div key={key} style={{ display: "flex", alignItems: "center", gap: "0.75rem", marginBottom: "0.5rem" }}>
|
||||
<span style={{ width: 52, flexShrink: 0, fontSize: "var(--text-sm)", color: "var(--color-text-gray-400)" }}>{label}</span>
|
||||
<input className="input" value={meta[key]}
|
||||
onChange={(e) => setMeta({ ...meta, [key]: e.target.value })} />
|
||||
</div>
|
||||
))}
|
||||
|
||||
<button className="btn-cta btn-lg" style={{ marginTop: "1rem" }} disabled={busy} onClick={approve}>
|
||||
승인하고 계속
|
||||
</button>
|
||||
{actionError && <p style={{ color: "#ff7a7a", fontSize: "var(--text-sm)", marginTop: "0.75rem" }}>{actionError}</p>}
|
||||
</div>
|
||||
<div>
|
||||
<p className="eyebrow" style={{ margin: "0 0 1rem" }}>포스터 분석 결과</p>
|
||||
{job.artifacts.check_jpg && (
|
||||
// eslint-disable-next-line @next/next/no-img-element
|
||||
<img src={job.artifacts.check_jpg} alt="영역 분석 확인 이미지" className="card-inner"
|
||||
style={{ width: "100%", padding: 0, display: "block" }} />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{job.status === "failed" && job.error && (
|
||||
<div style={{ maxWidth: 640, margin: "0 auto" }}>
|
||||
<p className="eyebrow" style={{ color: "#ff8c8c", margin: "0 0 1rem" }}>
|
||||
실패 · {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>
|
||||
{job.error.stage === "i2v" && motions !== null && (
|
||||
<div style={{ marginTop: "1.25rem" }}>
|
||||
<p style={{ fontSize: "var(--text-sm)", color: "var(--color-text-gray-400)", margin: "0 0 0.6rem" }}>
|
||||
움직일 요소를 바꿔 다시 시도할 수 있습니다:
|
||||
</p>
|
||||
<div style={{ display: "flex", flexWrap: "wrap", gap: "0.5rem" }}>
|
||||
{Object.entries(MOTION_LABELS).map(([key, label]) => {
|
||||
const on = motions.includes(key);
|
||||
return (
|
||||
<button key={key} type="button"
|
||||
onClick={() => setMotions(on ? motions.filter((m) => m !== key) : [...motions, key])}
|
||||
style={{
|
||||
padding: "0.35rem 0.8rem", borderRadius: 999, cursor: "pointer",
|
||||
fontSize: "var(--text-sm)",
|
||||
border: on ? "1px solid var(--color-mint)" : "1px solid var(--color-border-white-10)",
|
||||
background: on ? "var(--color-mint-20)" : "transparent",
|
||||
color: on ? "var(--color-mint)" : "var(--color-text-gray-400)",
|
||||
}}>
|
||||
{on ? "✓ " : "+ "}{label}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<div style={{ display: "flex", justifyContent: "center", marginTop: "1.5rem" }}>
|
||||
<button className="btn-outline" disabled={busy} onClick={retry}>재시도</button>
|
||||
</div>
|
||||
{actionError && <p style={{ color: "#ff7a7a", fontSize: "var(--text-sm)", marginTop: "0.75rem", textAlign: "center" }}>{actionError}</p>}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{job.status === "done" && job.artifacts.video && (
|
||||
<div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: "var(--spacing-page-md)", alignItems: "stretch" }}>
|
||||
<div className="card-inner" style={{ display: "flex", alignItems: "center", justifyContent: "center" }}>
|
||||
<video src={job.artifacts.video} controls
|
||||
style={{ width: "100%", maxHeight: 560, borderRadius: "var(--radius-md)", display: "block" }} />
|
||||
</div>
|
||||
<div style={{ display: "flex", flexDirection: "column", borderLeft: "2px solid var(--color-mint-20)", paddingLeft: "var(--spacing-page)" }}>
|
||||
<p className="field-label" style={{ margin: 0 }}>파일명</p>
|
||||
<p style={{ margin: "0.25rem 0 1rem", fontSize: "var(--text-xl)", fontWeight: 700, lineHeight: 1.35 }}>
|
||||
{job.name}.mp4
|
||||
</p>
|
||||
{job.metadata && (
|
||||
<div style={{ borderTop: "1px solid var(--color-border-white-10)", paddingTop: "1rem" }}>
|
||||
<MetadataCard meta={job.metadata} bare />
|
||||
</div>
|
||||
)}
|
||||
{job.narration && (
|
||||
<div style={{ borderTop: "1px solid var(--color-border-white-10)", marginTop: "1rem", paddingTop: "1rem" }}>
|
||||
<p className="field-label" style={{ margin: "0 0 0.5rem" }}>나레이션</p>
|
||||
{job.narration.map((s, i) => (
|
||||
<p key={i} style={{ margin: "0.35rem 0", fontSize: "var(--text-base)", color: "var(--color-text-gray-300)" }}>{s}</p>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
<div style={{ marginTop: "auto", paddingTop: "1.5rem", display: "grid", gridTemplateColumns: "1fr 1fr", gap: "0.75rem" }}>
|
||||
{job.artifacts.thumbnail ? (
|
||||
<a href={job.artifacts.thumbnail} download className="btn-tonal-mint">정지 컷 JPG</a>
|
||||
) : <span />}
|
||||
<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,55 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/navigation";
|
||||
import PosterDropzone from "@/components/poster-dropzone";
|
||||
import { apiFetch } from "@/lib/api";
|
||||
|
||||
export default function HomePage() {
|
||||
const router = useRouter();
|
||||
const [file, setFile] = useState<File | null>(null);
|
||||
const [name, setName] = useState("");
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
const submit = async () => {
|
||||
if (!file) return;
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
try {
|
||||
const fd = new FormData();
|
||||
fd.append("poster", file);
|
||||
fd.append("name", name);
|
||||
const { id } = await apiFetch<{ id: string }>("/api/f1/jobs", { method: "POST", body: fd });
|
||||
router.push(`/poster/${id}`);
|
||||
} catch (e) {
|
||||
setError((e as Error).message);
|
||||
setBusy(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div style={{ display: "flex", flexDirection: "column", alignItems: "center", paddingTop: "0.5rem" }}>
|
||||
<Link href="/" className="btn-back" style={{ alignSelf: "flex-start" }}>‹ 시작 방법 고르기</Link>
|
||||
<h1 className="page-title" style={{ marginTop: "1.25rem" }}>포스터를 올려주세요</h1>
|
||||
<p className="page-subtitle">나레이션·음악·연출까지 자동으로 만들어 9:16 숏폼으로 완성합니다</p>
|
||||
|
||||
<div style={{ width: "100%", maxWidth: 480, marginTop: "2.5rem", display: "flex", flexDirection: "column", gap: "1rem" }}>
|
||||
<PosterDropzone file={file} onFile={setFile} />
|
||||
<input
|
||||
className="input input--center"
|
||||
placeholder="행사 이름을 입력하세요 (비우면 자동 추출)"
|
||||
value={name}
|
||||
onChange={(e) => setName(e.target.value)}
|
||||
/>
|
||||
{error && <p style={{ color: "#ff7a7a", fontSize: "var(--text-sm)", textAlign: "center", margin: 0 }}>{error}</p>}
|
||||
<button className="btn-cta btn-lg" disabled={!file || busy} onClick={submit}>
|
||||
{busy ? "업로드 중…" : <>숏폼 만들기 <span className="btn-sub">14크레딧</span></>}
|
||||
</button>
|
||||
<p className="note">공연 상품페이지 주소가 있나요? <Link href="/playreel">상품페이지로 시작하면 캐스팅·일정까지 담깁니다 →</Link></p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,303 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import PosterDropzone from "@/components/poster-dropzone";
|
||||
import {
|
||||
InternalOnlyWarning, LicenseBadge, UserReferenceNotice,
|
||||
} from "@/components/license-badge";
|
||||
import { apiFetch, useJob, type F2Category, type F2Template } from "@/lib/api";
|
||||
|
||||
interface F2Format { id: string; label: string }
|
||||
interface UploadHint { enabled: boolean; min_long_edge: number }
|
||||
|
||||
const USER_CATEGORY = "user";
|
||||
|
||||
export default function StudioPage() {
|
||||
const [templates, setTemplates] = useState<F2Template[]>([]);
|
||||
const [categories, setCategories] = useState<F2Category[]>([]);
|
||||
const [formats, setFormats] = useState<F2Format[]>([]);
|
||||
const [file, setFile] = useState<File | null>(null);
|
||||
const [selected, setSelected] = useState<string | null>(null);
|
||||
const [format, setFormat] = useState("poster");
|
||||
const [jobId, setJobId] = useState<string | null>(null);
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [tplOpen, setTplOpen] = useState(true);
|
||||
const [hint, setHint] = useState<UploadHint | null>(null);
|
||||
const [refBusy, setRefBusy] = useState(false);
|
||||
const refInput = useRef<HTMLInputElement>(null);
|
||||
const { job } = useJob("f2", jobId);
|
||||
|
||||
const selectedTpl = templates.find((t) => t.id === selected) ?? null;
|
||||
|
||||
const loadTemplates = () =>
|
||||
apiFetch<F2Template[]>("/api/f2/templates").then(setTemplates);
|
||||
|
||||
useEffect(() => {
|
||||
loadTemplates().catch((e) => setError(e.message));
|
||||
apiFetch<F2Category[]>("/api/f2/categories").then(setCategories).catch(() => {});
|
||||
apiFetch<F2Format[]>("/api/f2/formats").then(setFormats).catch(() => {});
|
||||
apiFetch<UploadHint>("/api/f2/upload-hint").then(setHint).catch(() => {});
|
||||
}, []);
|
||||
|
||||
/** 레퍼런스 업로드 — 저장 + vision 분석까지 서버가 동기로 끝낸다(10초 안팎) */
|
||||
const uploadReference = async (f: File) => {
|
||||
setRefBusy(true);
|
||||
setError(null);
|
||||
try {
|
||||
const fd = new FormData();
|
||||
fd.append("reference", f);
|
||||
fd.append("name", f.name.replace(/\.[^.]+$/, "").slice(0, 40));
|
||||
const t = await apiFetch<F2Template>("/api/f2/templates", { method: "POST", body: fd });
|
||||
await loadTemplates();
|
||||
setSelected(t.id); // 방금 올린 것을 바로 고른 상태로
|
||||
} catch (e) {
|
||||
setError((e as Error).message);
|
||||
} finally {
|
||||
setRefBusy(false);
|
||||
if (refInput.current) refInput.current.value = "";
|
||||
}
|
||||
};
|
||||
|
||||
const removeReference = async (id: string) => {
|
||||
if (!confirm("이 레퍼런스를 삭제할까요? 되돌릴 수 없습니다.")) return;
|
||||
try {
|
||||
await apiFetch(`/api/f2/templates/${id}`, { method: "DELETE" });
|
||||
if (selected === id) setSelected(null);
|
||||
await loadTemplates();
|
||||
} catch (e) {
|
||||
setError((e as Error).message);
|
||||
}
|
||||
};
|
||||
|
||||
const submit = async () => {
|
||||
if (!file || !selected) return;
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
try {
|
||||
const fd = new FormData();
|
||||
fd.append("poster", file);
|
||||
fd.append("template_id", selected);
|
||||
fd.append("format", format);
|
||||
const { id } = await apiFetch<{ id: string }>("/api/f2/jobs", { method: "POST", body: fd });
|
||||
setJobId(id);
|
||||
} catch (e) {
|
||||
setError((e as Error).message);
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const renderCard = (t: F2Template) => (
|
||||
<div key={t.id} style={{ position: "relative" }}>
|
||||
<button onClick={() => setSelected(t.id)}
|
||||
className={selected === t.id ? "btn-select selected" : "btn-select"}
|
||||
style={{ width: "100%", height: "100%", padding: "0.5rem", display: "flex", flexDirection: "column", gap: "0.5rem", alignItems: "stretch" }}>
|
||||
{/* 명화는 가로 그림도 있다. cover로 자르면 파도가 잘려 무엇인지 알 수 없다 */}
|
||||
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||
<img src={t.thumb_url} alt={t.name_ko}
|
||||
style={{
|
||||
width: "100%", aspectRatio: "2/3", objectFit: "contain", display: "block",
|
||||
borderRadius: "var(--radius-md)", background: "var(--color-bg-darker)",
|
||||
}} />
|
||||
<span style={{ fontSize: "var(--text-sm)", fontWeight: 700, whiteSpace: "normal", lineHeight: 1.3 }}>
|
||||
{t.name_ko}
|
||||
</span>
|
||||
{/* 제목이 1줄인 카드와 2줄인 카드가 섞인다. 그리드가 높이를 맞춰주므로
|
||||
배지를 아래로 밀어붙이면 한 행의 배지가 같은 선에 선다 */}
|
||||
<span style={{ display: "flex", marginTop: "auto" }}>
|
||||
<LicenseBadge license={t.license} />
|
||||
</span>
|
||||
</button>
|
||||
{t.removable && (
|
||||
<button onClick={() => removeReference(t.id)} title="레퍼런스 삭제"
|
||||
style={{
|
||||
position: "absolute", top: 10, right: 10, width: 26, height: 26,
|
||||
borderRadius: "var(--radius-full)", border: "1px solid var(--color-border-white-10)",
|
||||
background: "rgba(0,0,0,0.62)", color: "var(--color-text-gray-300)",
|
||||
cursor: "pointer", fontSize: 15, lineHeight: 1, fontFamily: "var(--font)",
|
||||
}}>×</button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
|
||||
const running = job && (job.status === "queued" || job.status === "running");
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1 className="page-title">포스터 스타일링</h1>
|
||||
<p className="page-subtitle">
|
||||
내 포스터를 명화·고전화·영화 포스터의 화법으로 재해석합니다. 행사명·날짜·장소 텍스트는 그대로 유지됩니다.
|
||||
</p>
|
||||
|
||||
<div className="card" style={{ maxWidth: 880, margin: "1.5rem auto 0", padding: "var(--spacing-page-md)" }}>
|
||||
{/* 스타일 템플릿 — 접이식, 종류가 늘어나도 접어둘 수 있다 */}
|
||||
<button
|
||||
onClick={() => setTplOpen(!tplOpen)}
|
||||
style={{
|
||||
width: "100%", display: "flex", alignItems: "center", gap: "0.75rem",
|
||||
background: "none", border: "none", cursor: "pointer", padding: 0,
|
||||
fontFamily: "var(--font)", color: "var(--color-text-white)", textAlign: "left",
|
||||
}}
|
||||
>
|
||||
<span className="eyebrow">스타일 템플릿</span>
|
||||
{!tplOpen && selectedTpl && (
|
||||
<span style={{ display: "inline-flex", alignItems: "center", gap: "0.5rem" }}>
|
||||
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||
<img src={selectedTpl.thumb_url} alt="" style={{ width: 22, height: 30, objectFit: "cover", borderRadius: 4 }} />
|
||||
<span style={{ fontSize: "var(--text-base)", fontWeight: 700, color: "var(--color-mint)" }}>{selectedTpl.name_ko}</span>
|
||||
<LicenseBadge license={selectedTpl.license} />
|
||||
</span>
|
||||
)}
|
||||
{!tplOpen && !selectedTpl && (
|
||||
<span style={{ fontSize: "var(--text-base)", color: "var(--color-text-gray-500)" }}>템플릿을 선택하세요</span>
|
||||
)}
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5"
|
||||
strokeLinecap="round" strokeLinejoin="round"
|
||||
style={{ marginLeft: "auto", color: "var(--color-text-gray-400)", transition: "transform 0.2s", transform: tplOpen ? "rotate(180deg)" : "none" }}>
|
||||
<path d="m6 9 6 6 6-6" />
|
||||
</svg>
|
||||
</button>
|
||||
{tplOpen && categories.filter((c) => c.id !== USER_CATEGORY).map((c) => {
|
||||
const items = templates.filter((t) => t.category === c.id);
|
||||
if (items.length === 0) return null;
|
||||
return (
|
||||
<div key={c.id} style={{ marginTop: "1.25rem" }}>
|
||||
<p style={{
|
||||
margin: "0 0 0.6rem", fontSize: "var(--text-sm)", fontWeight: 700,
|
||||
color: "var(--color-text-gray-400)",
|
||||
}}>
|
||||
{c.label}
|
||||
<span style={{ marginLeft: "0.5rem", fontWeight: 500, color: "var(--color-text-gray-500)" }}>
|
||||
{items.length}종
|
||||
</span>
|
||||
</p>
|
||||
<div style={{ display: "grid", gridTemplateColumns: "repeat(5, 1fr)", gap: "0.75rem" }}>
|
||||
{items.map(renderCard)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
|
||||
{/* 내 레퍼런스 — 목록이 비어도 업로드 타일은 보여야 하므로 /categories가 아니라
|
||||
upload-hint의 enabled로 렌더한다 */}
|
||||
{tplOpen && hint?.enabled && (
|
||||
<div style={{ marginTop: "1.25rem" }}>
|
||||
<p style={{
|
||||
margin: "0 0 0.6rem", fontSize: "var(--text-sm)", fontWeight: 700,
|
||||
color: "var(--color-text-gray-400)",
|
||||
}}>
|
||||
내 레퍼런스
|
||||
<span style={{ marginLeft: "0.5rem", fontWeight: 500, color: "var(--color-text-gray-500)" }}>
|
||||
직접 올린 이미지의 화법으로 변환합니다
|
||||
</span>
|
||||
</p>
|
||||
<div style={{ display: "grid", gridTemplateColumns: "repeat(5, 1fr)", gap: "0.75rem" }}>
|
||||
{templates.filter((t) => t.category === USER_CATEGORY).map(renderCard)}
|
||||
<button onClick={() => refInput.current?.click()} disabled={refBusy}
|
||||
className="btn-select"
|
||||
style={{
|
||||
padding: "0.5rem", display: "flex", flexDirection: "column",
|
||||
alignItems: "center", justifyContent: "center", gap: "0.6rem",
|
||||
minHeight: 200, borderStyle: "dashed",
|
||||
}}>
|
||||
{refBusy ? (
|
||||
<>
|
||||
<div className="gen-spinner" style={{ width: 26, height: 26, borderWidth: 3 }} />
|
||||
<span style={{ fontSize: "var(--text-sm)", fontWeight: 600 }}>화풍 분석 중…</span>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<span style={{ fontSize: 26, lineHeight: 1, fontWeight: 300 }}>+</span>
|
||||
<span style={{ fontSize: "var(--text-sm)", fontWeight: 700 }}>레퍼런스 추가</span>
|
||||
<span style={{ fontSize: "var(--text-xs)", color: "var(--color-text-gray-500)", whiteSpace: "normal", lineHeight: 1.4 }}>
|
||||
긴 변 {hint.min_long_edge}px 이상 권장
|
||||
</span>
|
||||
</>
|
||||
)}
|
||||
</button>
|
||||
<input ref={refInput} type="file" accept="image/jpeg,image/png,image/webp,image/gif"
|
||||
style={{ display: "none" }}
|
||||
onChange={(e) => { const f = e.target.files?.[0]; if (f) uploadReference(f); }} />
|
||||
</div>
|
||||
<div style={{ marginTop: "0.75rem" }}><UserReferenceNotice /></div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 경고는 실제로 고른 순간에만. 항상 떠 있으면 아무도 안 읽는다 */}
|
||||
{selectedTpl && selectedTpl.license === "internal-only" && (
|
||||
<div style={{ marginTop: "1.25rem" }}>
|
||||
<InternalOnlyWarning note={selectedTpl.license_note} />
|
||||
</div>
|
||||
)}
|
||||
{selectedTpl?.attribution && (
|
||||
<p style={{
|
||||
margin: "0.75rem 0 0", fontSize: "var(--text-xs)",
|
||||
color: "var(--color-text-gray-500)", lineHeight: 1.6,
|
||||
}}>
|
||||
레퍼런스 출처 · {selectedTpl.attribution}
|
||||
</p>
|
||||
)}
|
||||
|
||||
{/* 입력(=원본)과 결과, 같은 크기의 4:5 박스 */}
|
||||
<div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: "var(--spacing-page-md)", marginTop: "2rem" }}>
|
||||
<div>
|
||||
<p className="eyebrow" style={{ margin: "0 0 0.75rem" }}>내 포스터</p>
|
||||
<PosterDropzone file={file} onFile={setFile} />
|
||||
</div>
|
||||
<div>
|
||||
<p className="eyebrow" style={{ margin: "0 0 0.75rem" }}>결과</p>
|
||||
{job?.status === "done" && job.artifacts.image ? (
|
||||
<div className="card-inner" style={{
|
||||
aspectRatio: "4 / 5", maxWidth: 400, margin: "0 auto", overflow: "hidden",
|
||||
display: "flex", alignItems: "center", justifyContent: "center", padding: 0,
|
||||
}}>
|
||||
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||
<img src={job.artifacts.image} alt="변환 결과" style={{ width: "100%", height: "100%", objectFit: "contain" }} />
|
||||
</div>
|
||||
) : (
|
||||
<div className="card-inner" style={{
|
||||
aspectRatio: "4 / 5", maxWidth: 400, margin: "0 auto",
|
||||
display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", gap: "1rem",
|
||||
}}>
|
||||
{running && <div className="gen-spinner" style={{ width: 48, height: 48, borderWidth: 4 }} />}
|
||||
<span style={{ fontSize: "var(--text-base)", color: running ? "var(--color-text-gray-300)" : "var(--color-text-gray-500)" }}>
|
||||
{running ? "변환 중 (30초 안팎)" : "변환 결과가 여기에 표시됩니다"}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
{job?.status === "done" && job.artifacts.image && (
|
||||
<div style={{ display: "flex", justifyContent: "center", marginTop: "0.75rem" }}>
|
||||
<a href={job.artifacts.image} download className="btn-tonal-mint">PNG 다운로드</a>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p className="eyebrow" style={{ margin: "1.5rem 0 0.75rem" }}>출력 포맷</p>
|
||||
<div style={{ display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: "0.75rem" }}>
|
||||
{formats.map((f) => (
|
||||
<button key={f.id} onClick={() => setFormat(f.id)}
|
||||
className={format === f.id ? "btn-select selected" : "btn-select"}>
|
||||
{f.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div style={{ display: "flex", justifyContent: "center", marginTop: "2rem" }}>
|
||||
<button className="btn-cta" disabled={!file || !selected || busy || !!running} onClick={submit}>
|
||||
{running ? "변환 중…" : busy ? "업로드 중…" : "스타일 변환"}
|
||||
</button>
|
||||
</div>
|
||||
{error && <p style={{ color: "#ff7a7a", fontSize: "var(--text-sm)", marginTop: "0.75rem", textAlign: "center" }}>{error}</p>}
|
||||
{job?.status === "failed" && job.error && (
|
||||
<pre className="card-inner" style={{
|
||||
fontSize: "var(--text-sm)", whiteSpace: "pre-wrap", color: "var(--color-text-gray-400)",
|
||||
marginTop: "1rem", maxHeight: 200, overflow: "auto",
|
||||
}}>{job.error.detail}</pre>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user