Sorted show

This commit is contained in:
Nik Afiq 2025-11-05 16:17:40 +09:00
parent 71ab2cfe86
commit 78887105fe

View File

@ -69,7 +69,8 @@ export default function ShowsPage() {
const res = await fetch(GET_URL, { cache: "no-store" });
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const data = (await res.json()) as Show[];
if (!cancelled) setShows(data);
data.sort((a, b) => a.id - b.id); // ASC
setShows(data);
} catch (e: any) {
if (!cancelled) setError(e.message || "番組一覧の取得に失敗しました。");
} finally {
@ -131,7 +132,10 @@ export default function ShowsPage() {
<button
key={s.id}
className={`show-card ${selectedId === s.id ? "selected" : ""}`}
onClick={() => setSelectedId(s.id)}
onClick={() => {
setSelectedId(s.id);
setStartTime(s.start_time.slice(0, 5));
}}
>
<div className="title">{s.ep_num}{s.ep_title}</div>
<div className="season subtle">{s.season_name}</div>