show credits

This commit is contained in:
jaehwang committed 2026-09-16 10:46:33 +09:00
1 parent d59304f833
commit 49b4178453
8 files changed
+115 -13

No files matched your search

+2
View File
@@ -1,6 +1,7 @@
import type { Metadata } from "next";
import Link from "next/link";
import Ado2Logo from "@/components/ado2-logo";
import AccountBadge from "@/components/account-badge";
import AuthGate from "@/components/auth-gate";
import NavLink from "@/components/nav-link";
import { FEATURES } from "@/lib/features";
@@ -19,6 +20,7 @@ export default function Ado2Layout({ children }: { children: React.ReactNode })
<Ado2Logo height={20} />
<span className="sidebar-product">MOVING POSTER</span>
</Link>
<AccountBadge />
</div>
<nav className="sidebar-menu">
<NavLink href="/" icon="video">무빙포스터</NavLink>
+2 -1
View File
@@ -5,6 +5,7 @@ import Link from "next/link";
import { useRouter } from "next/navigation";
import { apiFetch, type Job } from "@/lib/api";
import { useMe } from "@/lib/auth";
import { FEATURES } from "@/lib/features";
import { GATE_META, type PlayreelJob } from "@/lib/playreel";
/* 무빙포스터 진입 — 두 갈래 (MOVING_POSTER_ENTRY_PLAN.md §1·§5) */
@@ -64,7 +65,7 @@ export default function HomePage() {
<p className="page-subtitle">가진 것에 따라 고르세요. 둘 다 9:16 세로 영상으로 완성됩니다.</p>
<div className="entry-stack">
{ENTRIES.map((e) => (
{ENTRIES.filter((e) => FEATURES.playreelEntry || e.href !== "/playreel").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">
+7 -1
View File
@@ -6,6 +6,8 @@ import { useRouter } from "next/navigation";
import PosterDropzone from "@/components/poster-dropzone";
import { useRequireLogin } from "@/components/auth-gate";
import { apiFetch } from "@/lib/api";
import { refreshMe } from "@/lib/auth";
import { FEATURES } from "@/lib/features";
export default function HomePage() {
const router = useRouter();
@@ -26,6 +28,8 @@ export default function HomePage() {
fd.append("poster", file);
fd.append("name", name);
const { id } = await apiFetch<{ id: string }>("/api/f1/jobs", { method: "POST", body: fd });
// 남은 개수가 하나 줄었다
refreshMe();
router.push(`/poster/${id}`);
} catch (e) {
setError((e as Error).message);
@@ -51,7 +55,9 @@ export default function HomePage() {
<button className="btn-cta btn-lg" disabled={!file || busy} onClick={submit}>
{busy ? "업로드 중…" : "숏폼 만들기"}
</button>
<p className="note">공연 상품페이지 주소가 있나요? <Link href="/playreel">상품페이지로 시작하면 캐스팅·일정까지 담깁니다 →</Link></p>
{FEATURES.playreelEntry && (
<p className="note">공연 상품페이지 주소가 있나요? <Link href="/playreel">상품페이지로 시작하면 캐스팅·일정까지 담깁니다 →</Link></p>
)}
</div>
</div>
+3 -1
View File
@@ -7,7 +7,7 @@ import { apiFetch } from "@/lib/api";
import { GATE_META, parseGoodsId, type PlayreelJob } from "@/lib/playreel";
import { AutoApprovePanel } from "@/components/auto-approve";
import { useRequireLogin } from "@/components/auth-gate";
import { useMe } from "@/lib/auth";
import { refreshMe, useMe } from "@/lib/auth";
const STATUS_LABEL: Record<string, string> = {
queued: "대기 중", running: "만드는 중", awaiting_review: "검수 대기", failed: "실패", done: "완료",
@@ -50,6 +50,8 @@ export default function PlayreelStartPage() {
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ url: url.trim() }),
});
// 남은 개수가 하나 줄었다
refreshMe();
router.push(`/playreel/${id}`);
} catch (e) {
setError((e as Error).message);
+35
View File
@@ -103,6 +103,41 @@ body { margin: 0; -webkit-font-smoothing: antialiased; letter-spacing: -0.006em;
z-index: 50;
}
.sidebar-logo { padding: 1.5rem 1.5rem 0.5rem; }
/* 로고 아래 로그인 상태 */
.account-badge {
display: flex;
align-items: baseline;
gap: 0.5rem;
margin-top: 0.6rem;
min-width: 0;
}
.account-badge-name {
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-size: var(--text-xs);
color: var(--color-text-gray-400);
}
.account-badge-quota {
flex: none;
font-size: var(--text-xs);
font-weight: 700;
color: var(--color-mint);
}
.account-badge-link {
flex: none;
padding: 0;
border: none;
background: none;
cursor: pointer;
font-family: var(--font);
font-size: var(--text-xs);
color: var(--color-mint);
}
.account-badge-link:hover { text-decoration: underline; }
.sidebar-menu { flex: 1; padding: 0 0.75rem; margin-top: 1rem; overflow-y: auto; }
.sidebar-item {
display: flex;
+35
View File
@@ -0,0 +1,35 @@
"use client";
/** 사이드바 로고 아래에 붙는 로그인 상태. 누구로 들어와 있는지와 나가는 길 */
import { useRouter } from "next/navigation";
import { signOut, useMe } from "@/lib/auth";
export default function AccountBadge() {
const router = useRouter();
const { me, setMe } = useMe();
if (me === null) return null;
if (me === false) {
return (
<button type="button" className="account-badge-link"
onClick={() => router.push("/login")}>
로그인
</button>
);
}
return (
<div className="account-badge">
<span className="account-badge-name" title={me.email}>{me.name || me.email}</span>
<span className="account-badge-quota" title="남은 크레딧">
{me.jobs_left}/{me.job_limit}
</span>
<button type="button" className="account-badge-link"
onClick={() => { signOut().then(() => setMe(false)).then(() => router.push("/")); }}>
로그아웃
</button>
</div>
);
}
+28 -9
View File
@@ -8,7 +8,7 @@
* GIS 스크립트는 여기서 붙인다. 로그인 화면에 오기 전에는 서드파티 요청을 만들지 않는다.
*/
import { useEffect, useState } from "react";
import { useEffect, useSyncExternalStore } from "react";
import { apiFetch } from "@/lib/api";
const SCRIPT_URL = "https://accounts.google.com/gsi/client?hl=ko";
@@ -105,18 +105,37 @@ export const signIn = (credential: string) =>
export const signOut = () => apiFetch<{ ok: boolean }>("/api/auth/logout", { method: "POST" });
// 로그인 정보는 화면 여러 곳이 같이 본다 — 사이드바 배지와 페이지가 따로 들고 있으면
// 한쪽에서 갱신해도 다른 쪽이 옛 값을 그린다. 한 군데 두고 나눠 쓴다
let cached: Me | null | false = null;
const listeners = new Set<() => void>();
function publish(next: Me | null | false) {
cached = next;
listeners.forEach((notify) => notify());
}
function subscribe(notify: () => void) {
listeners.add(notify);
return () => { listeners.delete(notify); };
}
/** 서버에 다시 물어본다. 잡을 만든 뒤처럼 남은 개수가 바뀌는 자리에서 부른다 */
export function refreshMe(): Promise<void> {
return apiFetch<Me>("/api/auth/me")
.then((me) => publish(me))
.catch(() => publish(false));
}
export const setMe = publish;
/** 로그인 여부. null 이면 아직 확인 중, false 면 로그아웃 상태 */
export function useMe() {
const [me, setMe] = useState<Me | null | false>(null);
const refresh = () =>
apiFetch<Me>("/api/auth/me").then(setMe).catch(() => setMe(false));
const me = useSyncExternalStore(subscribe, () => cached, () => null);
useEffect(() => {
// eslint-disable-next-line react-hooks/set-state-in-effect -- 최초 1회 확인
refresh();
// eslint-disable-next-line react-hooks/exhaustive-deps
if (cached === null) refreshMe();
}, []);
return { me, refresh, setMe };
return { me, refresh: refreshMe, setMe: publish };
}
+3 -1
View File
@@ -3,9 +3,11 @@
* 백엔드에 대응하는 API가 없는 화면을 여기서 끈다 — 페이지 코드는 그대로 두고
* 네비게이션에서 감추고 본문 대신 안내를 띄운다.
*
* styling /studio — /api/f2 없음
* styling /studio — /api/f2 없음
* playreelEntry — 무빙포스터 화면에서 롱컷으로 넘어가는 자리. 임시로 닫아둠
*/
export const FEATURES = {
styling: false,
archive: true,
playreelEntry: false,
} as const;