89 lines
3.4 KiB
TypeScript
89 lines
3.4 KiB
TypeScript
"use client";
|
|
|
|
import DisabledNotice from "@/components/disabled-notice";
|
|
import { FEATURES } from "@/lib/features";
|
|
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;
|
|
};
|
|
|
|
function PlayreelArchivePageInner() {
|
|
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>
|
|
);
|
|
}
|
|
|
|
|
|
export default function PlayreelArchivePage() {
|
|
if (!FEATURES.archive) return <DisabledNotice title="아카이브" backHref="/playreel" />;
|
|
return <PlayreelArchivePageInner />;
|
|
}
|