Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions frontend/src/app/(main)/auctions/auctions.css
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,6 @@
color: var(--au-red);
animation: fq-beat 1s infinite;
}
.fq-au-row.is-closed {
opacity: 0.6;
}
.fq-au-go {
font-size: 20px;
font-weight: 800;
Expand Down
57 changes: 31 additions & 26 deletions frontend/src/app/(main)/auctions/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { IntroGate } from "@/lib/intro";
import Chip from "@/components/casino/Chip";
import Odometer from "@/components/casino/Odometer";
import LoadError from "@/components/LoadError";
import PastToggle from "@/components/PastToggle";
import Tabs from "@/components/Tabs";
import { api } from "@/lib/api";
import { useAuth } from "@/lib/auth";
Expand All @@ -19,13 +20,14 @@ import { nextBoundary, useRefreshAt } from "@/lib/schedule";
import type { AuctionDetail, AuctionPage, AuctionStatus, AuctionSummary, MyBidPage } from "@/lib/types";
import "./auctions.css";

type F = "ALL" | "MINE" | AuctionStatus;
const ORDER: Record<AuctionStatus, number> = { OPEN: 0, SCHEDULED: 1, CLOSED: 2 };
type F = "ALL" | "MINE" | Exclude<AuctionStatus, "CLOSED">;

export default function AuctionsPage() {
const now = useNow();
const [f, setF] = useState<F>("ALL");
const [showPast, setShowPast] = useState(false);
const { profile } = useAuth();
// 상태를 넘기지 않으면 서버가 등록 순서의 역순(최신순)으로 준다. 화면에서는 순서를 바꾸지 않는다
const load = () => api<AuctionPage>("/api/auctions?size=40").then((r) => r.items);
const { data, error, setData } = useLoad(load);
// 시작이나 마감 시각이 지나면 서버가 바꾼 상태를 다시 읽는다. 화면을 연 시점의 예정이 남지 않게 한다
Expand All @@ -38,26 +40,31 @@ export default function AuctionsPage() {
);
const prices = { data: Object.fromEntries((liveDetails.data ?? []).map((d) => [d.auctionId, d.highestBid?.amount ?? d.startingPriceAmount])) as Record<number, number> };
const mine = useLoad(() => (profile ? api<MyBidPage>("/api/me/bids?size=100").then((r) => r.items) : Promise.resolve([])), [profile?.memberId]);
const sorted = [...(data ?? [])].sort((a, b) => ORDER[a.status] - ORDER[b.status] || +new Date(a.endsAt) - +new Date(b.endsAt));
const count = (x: F) => data?.filter((a) => x === "ALL" || a.status === x).length;
// 끝난 경매는 체크했을 때만 같은 최신순 자리에 어둡게 섞여 보인다
const sorted = (data ?? []).filter((a) => showPast || a.status !== "CLOSED");
const match = (x: F, a: AuctionSummary) => x === "ALL" || a.status === x;
const shown = sorted.filter((a) => match(f, a));
const count = (x: F) => (data ? sorted.filter((a) => match(x, a)).length : undefined);

return (
<div className="fq-au">
<IntroGate>{data && liveDetails.data ? <AuctionShow live={liveDetails.data} now={now} listId="#auction-list" /> : <div className="fq-skel" style={{ height: "80vh" }} />}</IntroGate>

<div id="auction-list" style={{ scrollMarginTop: 20, marginTop: 28 }} />
<Tabs
label="경매 필터"
value={f}
onChange={setF}
items={[
{ value: "ALL", label: "전체", count: count("ALL") },
{ value: "OPEN", label: "LIVE", count: count("OPEN") },
{ value: "SCHEDULED", label: "예정", count: count("SCHEDULED") },
{ value: "CLOSED", label: "종료", count: count("CLOSED") },
...(profile ? [{ value: "MINE" as const, label: "내 입찰", count: mine.data?.length ?? 0 }] : []),
]}
/>
<div className="fq-list-bar">
<Tabs
label="경매 필터"
value={f}
onChange={setF}
items={[
{ value: "ALL", label: "전체", count: count("ALL") },
{ value: "OPEN", label: "LIVE", count: count("OPEN") },
{ value: "SCHEDULED", label: "예정", count: count("SCHEDULED") },
...(profile ? [{ value: "MINE" as const, label: "내 입찰", count: mine.data?.length ?? 0 }] : []),
]}
/>
{f === "MINE" ? null : <PastToggle checked={showPast} onChange={setShowPast} count={data?.filter((a) => a.status === "CLOSED").length} />}
</div>

<div className="fq-section" style={{ marginTop: 22 }}>
{error ? (
Expand Down Expand Up @@ -95,14 +102,12 @@ export default function AuctionsPage() {
)
) : data ? (
<ul className="fq-au-rows">
{sorted
.filter((a) => f === "ALL" || a.status === f)
.map((a, i) => (
<li key={a.auctionId}>
<Row a={a} lot={String(sorted.indexOf(a) + 1).padStart(2, "0")} now={now} price={prices.data?.[a.auctionId]} delay={i * 70} />
</li>
))}
{sorted.filter((a) => f === "ALL" || a.status === f).length === 0 ? (
{shown.map((a, i) => (
<li key={a.auctionId}>
<Row a={a} lot={String(sorted.indexOf(a) + 1).padStart(2, "0")} now={now} price={prices.data?.[a.auctionId]} delay={i * 70} />
</li>
))}
{shown.length === 0 ? (
<li className="fq-card is-pad fq-empty">
<LineArt kind="chip" />
<p>해당하는 경매가 없어요.</p>
Expand All @@ -118,11 +123,11 @@ export default function AuctionsPage() {
);
}

/** lot은 정렬된 전체 목록에서의 순번이다. 필터를 바꿔도 같은 경매는 같은 번호를 유지한다 */
/** lot은 지금 보이는 전체 목록에서의 순번이다. 탭을 바꿔도 같은 경매는 같은 번호를 유지한다 */
function Row({ a, lot, now, price, delay }: { a: AuctionSummary; lot: string; now: number; price?: number; delay: number }) {
const urgent = a.status === "OPEN" && msLeft(a.endsAt, now) < 15 * 60_000;
return (
<Link className={`fq-au-row is-${a.status.toLowerCase()}${urgent ? " is-urgent" : ""}`} href={`/auctions/detail?id=${a.auctionId}`} style={{ animationDelay: `${delay}ms` }}>
<Link className={`fq-au-row is-${a.status.toLowerCase()}${a.status === "CLOSED" ? " fq-past" : ""}${urgent ? " is-urgent" : ""}`} href={`/auctions/detail?id=${a.auctionId}`} style={{ animationDelay: `${delay}ms` }}>
<span className="fq-au-lot">{lot}</span>
<Chip seed={a.auctionId} top="LOT" big={lot} size={64} still />
<div className="fq-au-main">
Expand Down
63 changes: 46 additions & 17 deletions frontend/src/app/(main)/concerts/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
"use client";

import DomainBox from "@/components/finale/DomainBox";
import LineArt from "@/components/LineArt";
import { useState } from "react";
import { CardSkeletons, ConcertCard } from "@/components/Cards";
import PastToggle from "@/components/PastToggle";
import Tabs from "@/components/Tabs";
import LoadError from "@/components/LoadError";
import { api } from "@/lib/api";
Expand All @@ -19,41 +21,68 @@ function splitTitle(title: string) {
return { head: head || title, rest: rest.join(" ") };
}

type F = "ALL" | "ON_SALE" | "UPCOMING" | "ENDED";
type F = "ALL" | "ON_SALE" | "UPCOMING";

/** 공연 기간 마지막 날이 오늘(이 기기 날짜)보다 앞이면 지난 공연이다 */
function isPast(c: ConcertDetail, today: string) {
return !!c.periodEndDate && c.periodEndDate < today;
}
/** 이 기기 기준 오늘 날짜 (YYYY-MM-DD) */
function localToday() {
const d = new Date();
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
}

export default function ConcertsPage() {
const [f, setF] = useState<F>("ALL");
const [showPast, setShowPast] = useState(false);
const now = useNow();
// 서버가 등록일 최신순으로 준다. 화면에서는 순서를 바꾸지 않는다
const load = () => api<ConcertPage>("/api/concerts?size=40").then((r) => r.content);
const { data, error, setData } = useLoad(load);
// 예매 오픈과 마감은 시각으로 바로 바꾸고, 그 뒤 서버 판매 상태를 다시 읽는다
const sale = (c: ConcertDetail) => concertSale(c, now);
useRefreshAt(nextBoundary((data ?? []).flatMap((c) => (c.saleStatus === "ENDED" ? [] : [c.saleStatus === "UPCOMING" ? c.bookingOpensAt : c.bookingClosesAt])), now), () => load().then(setData));
// 연출에 세울 대표 공연: 예매 중인 공연이 있으면 그 공연, 없으면 첫 공연
const star = data?.find((c) => sale(c) === "ON_SALE") ?? data?.[0];
const today = localToday();
const live = (data ?? []).filter((c) => !isPast(c, today));
const past = (data ?? []).filter((c) => isPast(c, today));
// 연출에 세울 대표 공연: 예매 중인 공연이 있으면 그 공연, 없으면 끝나지 않은 첫 공연
const star = live.find((c) => sale(c) === "ON_SALE") ?? live[0] ?? data?.[0];
const perfs = useLoad<PerformanceInfo[]>(() => (star ? api<PerformanceInfo[]>(`/api/concerts/${star.concertId}/performances`) : Promise.resolve([])), [star?.concertId]);
const starList = [...(perfs.data ?? [])].sort((a, b) => +new Date(a.startsAt) - +new Date(b.startsAt));
const starName = star ? splitTitle(star.title) : null;
const list = (data ?? []).filter((c) => f === "ALL" || sale(c) === f);
const count = (x: Exclude<F, "ALL">) => data?.filter((c) => sale(c) === x).length;
const match = (x: F, c: ConcertDetail) => x === "ALL" || sale(c) === x;
// 지난 공연은 전체 탭에서만, 체크했을 때 같은 최신순 자리에 어둡게 섞여 보인다
const list = (data ?? []).filter((c) => (isPast(c, today) ? showPast && f === "ALL" : match(f, c)));
const count = (x: F) => (data ? live.filter((c) => match(x, c)).length + (x === "ALL" && showPast ? past.length : 0) : undefined);
return (
<>
<IntroGate><ConcertShow seed={star?.concertId ?? 1} name={starName} onSale={!!star && sale(star) === "ON_SALE"} list={starList} skipTo="#concert-list" /></IntroGate>
<div id="concert-list" style={{ scrollMarginTop: 20 }} />
<p className="fq-lead">좌석을 직접 골라 예매하는 지정석 공연이에요.</p>
<Tabs
label="공연 필터"
value={f}
onChange={setF}
items={[
{ value: "ALL", label: "전체", count: data?.length },
{ value: "ON_SALE", label: "예매 중", count: count("ON_SALE") },
{ value: "UPCOMING", label: "예매 예정", count: count("UPCOMING") },
{ value: "ENDED", label: "예매 종료", count: count("ENDED") },
]}
/>
<div className="fq-list-bar">
<Tabs
label="공연 필터"
value={f}
onChange={setF}
items={[
{ value: "ALL", label: "전체", count: count("ALL") },
{ value: "ON_SALE", label: "예매 중", count: count("ON_SALE") },
{ value: "UPCOMING", label: "예매 예정", count: count("UPCOMING") },
]}
/>
<PastToggle checked={showPast} onChange={setShowPast} count={data ? past.length : undefined} />
</div>
<div className="fq-section" style={{ marginTop: 22 }}>
{error ? <LoadError error={error} /> : data ? <div className="fq-grid">{list.map((c) => <ConcertCard key={c.concertId} c={c} />)}</div> : <CardSkeletons />}
{error ? (
<LoadError error={error} />
) : !data ? (
<CardSkeletons />
) : list.length === 0 ? (
<div className="fq-card is-pad fq-empty"><LineArt kind="card" /><p>해당하는 공연이 없어요.</p></div>
) : (
<div className="fq-grid">{list.map((c) => <ConcertCard key={c.concertId} c={c} past={isPast(c, today)} />)}</div>
)}
</div>
<DomainBox domain="concert" />
</>
Expand Down
9 changes: 6 additions & 3 deletions frontend/src/app/(main)/drops/drops.css
Original file line number Diff line number Diff line change
Expand Up @@ -431,16 +431,19 @@
opacity: clamp(0, var(--p) * 2.2 - 0.3, 1);
transform: translateY(calc((1 - clamp(0, var(--p) * 2.2 - 0.3, 1)) * 30px));
}
/* 지난 드롭은 전원이 꺼진 화면처럼 흑백으로 어둡게. 가리키면 조금 켜진다 */
.fq-dl-archive-card .fq-poster {
filter: grayscale(1) brightness(0.8);
filter: grayscale(1) brightness(0.45);
transition: filter 0.5s var(--ux-ease);
}
.fq-dl-archive-card:hover .fq-poster {
filter: grayscale(0.2);
.fq-dl-archive-card:hover .fq-poster,
.fq-dl-archive-card:focus-visible .fq-poster {
filter: grayscale(0.7) brightness(0.75);
}
.fq-dl-archive-card b {
font-size: 15px;
font-weight: 800;
color: var(--ux-ink-3);
}
.fq-dl-archive-card small {
font-size: 12.5px;
Expand Down
31 changes: 17 additions & 14 deletions frontend/src/app/(main)/drops/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { useEffect, useRef, useState } from "react";
import { firstWord } from "@/components/Cards";
import ChapterHud from "@/components/chapter/ChapterHud";
import LoadError from "@/components/LoadError";
import PastToggle from "@/components/PastToggle";
import Poster, { PALETTES } from "@/components/Poster";
import Tabs from "@/components/Tabs";
import { api } from "@/lib/api";
Expand All @@ -20,8 +21,8 @@ import type { DropItem, DropPage } from "@/lib/types";
import { dropSale } from "@/lib/schedule";
import "./drops.css";

type F = "ALL" | "ON_SALE" | "UPCOMING" | "ENDED";
type State = Exclude<F, "ALL">;
type F = "ALL" | "ON_SALE" | "UPCOMING";
type State = Exclude<F, "ALL"> | "ENDED";
type Row = { d: DropItem; s: State };

/** 서버 상태와 시각으로 지금 상태를 정한다. 화면을 연 시점의 UPCOMING이 오픈 뒤에도 남지 않게 시각을 따른다 */
Expand All @@ -31,26 +32,28 @@ function productWord(title: string) {
const words = (title.split(">").pop() ?? title).trim().split(/\s+/).filter((w) => !["공식", "투어", "한정판", "세트"].includes(w));
return words[0] ?? firstWord(title);
}
const ORDER: Record<State, number> = { ON_SALE: 0, UPCOMING: 1, ENDED: 2 };
const colorOf = (dropId: number) => PALETTES[(dropId + 1) % PALETTES.length];

/**
* 드롭 목록. 장 네 개로 이어지는 긴 스크롤 화면이다.
* 1) 커튼: 화면이 고정된 채 물결 커튼이 끝까지 내려오고 제목이 커졌다가 걷힌다.
* 2) 진열대: 카드마다 멈춰 서고, 멈춘 동안 무대가 그 카드 색으로 물들며 뒤로 큰 상품 이름이 흐른다.
* 3) 다음 드롭: 오픈 예정 드롭을 화면 가득한 카운트다운으로 보여 준다.
* 4) 지난 드롭: 끝난 드롭을 흑백으로 모은다.
* 4) 지난 드롭: 지난 이벤트도 보기를 체크하면 끝난 드롭을 꺼진 것처럼 어둡게 모은다.
*/
export default function DropsPage() {
const now = useNow();
const [f, setF] = useState<F>("ALL");
const { data, error } = useLoad(() => api<DropPage>("/api/drops").then((r) => r.items));
const all: Row[] = (data ?? []).map((d) => ({ d, s: stateOf(d, now) })).sort((a, b) => ORDER[a.s] - ORDER[b.s] || +new Date(a.d.opensAt) - +new Date(b.d.opensAt));
// 전체 보기에서는 끝난 드롭을 진열대 대신 아래 지난 드롭 장에 모은다
const rail = f === "ALL" ? all.filter((x) => x.s !== "ENDED") : all.filter((x) => x.s === f);
const [showPast, setShowPast] = useState(false);
// 서버가 등록일 최신순으로 준다. 화면에서는 순서를 바꾸지 않는다
const { data, error } = useLoad(() => api<DropPage>("/api/drops?sort=NEWEST").then((r) => r.items));
const all: Row[] = (data ?? []).map((d) => ({ d, s: stateOf(d, now) }));
// 끝난 드롭은 진열대에 올리지 않고, 체크했을 때만 아래 지난 드롭 장에 모은다
const rail = all.filter((x) => x.s !== "ENDED" && (f === "ALL" || x.s === f));
const ended = all.filter((x) => x.s === "ENDED");
const next = all.find((x) => x.s === "UPCOMING");
const count = (x: F) => (data ? (x === "ALL" ? all.length : all.filter((y) => y.s === x).length) : undefined);
// 다음 드롭은 목록 순서와 상관없이 가장 먼저 열리는 드롭이다
const next = all.filter((x) => x.s === "UPCOMING").sort((a, b) => +new Date(a.d.opensAt) - +new Date(b.d.opensAt))[0];
const count = (x: F) => (data ? all.filter((y) => y.s !== "ENDED" && (x === "ALL" || y.s === x)).length : undefined);
const live = count("ON_SALE") ?? 0;

return (
Expand All @@ -60,7 +63,7 @@ export default function DropsPage() {
<DropShow skipTo="#drops-list" />
</IntroGate>

<div id="drops-list" className="fq-dl-tabs">
<div id="drops-list" className="fq-dl-tabs fq-list-bar">
<Tabs
label="드롭 필터"
value={f}
Expand All @@ -69,9 +72,9 @@ export default function DropsPage() {
{ value: "ALL", label: "전체", count: count("ALL") },
{ value: "ON_SALE", label: "판매 중", count: count("ON_SALE") },
{ value: "UPCOMING", label: "오픈 예정", count: count("UPCOMING") },
{ value: "ENDED", label: "종료", count: count("ENDED") },
]}
/>
<PastToggle checked={showPast} onChange={setShowPast} count={data ? ended.length : undefined} />
</div>

{error ? (
Expand All @@ -91,7 +94,7 @@ export default function DropsPage() {

<div id="drops-after" />
{f === "ALL" && next ? <NextDrop row={next} now={now} /> : null}
{f === "ALL" && ended.length ? <Archive rows={ended} /> : null}
{showPast && ended.length ? <Archive rows={ended} /> : null}
<DomainBox domain="drop" />
</div>
);
Expand Down Expand Up @@ -325,7 +328,7 @@ function NextDrop({ row, now }: { row: Row; now: number }) {
);
}

/** 4장. 끝난 드롭을 흑백으로 모은다 */
/** 4장. 끝난 드롭을 꺼진 것처럼 어둡게 모은다 */
function Archive({ rows }: { rows: Row[] }) {
const ref = useRef<HTMLElement>(null);
useScrollProgress(ref, undefined, "enter");
Expand Down
Loading
Loading