feat: artist page toggle to show all release types (default studio-only)
This commit is contained in:
@@ -12,7 +12,7 @@ type Release = {
|
||||
state: string;
|
||||
currentQualityClass: number | null;
|
||||
};
|
||||
type Detail = { id: string; name: string; autoMonitorFuture: boolean; releases: Release[] };
|
||||
type Detail = { id: string; name: string; autoMonitorFuture: boolean; showAllTypes: boolean; releases: Release[] };
|
||||
|
||||
function badge(r: Release): string {
|
||||
if (r.currentQualityClass !== null) return `Have (q${r.currentQualityClass})`;
|
||||
@@ -43,11 +43,29 @@ export function DiscographyClient({ id }: { id: string }) {
|
||||
await fetch(`/api/releases/${r.id}/search`, { method: "POST" });
|
||||
refresh();
|
||||
}
|
||||
async function toggleShowAll() {
|
||||
if (!detail) return;
|
||||
await fetch(`/api/artists/${id}`, {
|
||||
method: "PATCH",
|
||||
headers: { "content-type": "application/json" },
|
||||
body: JSON.stringify({ showAllTypes: !detail.showAllTypes }),
|
||||
});
|
||||
refresh();
|
||||
}
|
||||
|
||||
if (!detail) return <p>Loading…</p>;
|
||||
return (
|
||||
<div>
|
||||
<h1>{detail.name}</h1>
|
||||
<label>
|
||||
<input
|
||||
type="checkbox"
|
||||
aria-label="show all release types"
|
||||
checked={detail.showAllTypes}
|
||||
onChange={toggleShowAll}
|
||||
/>{" "}
|
||||
Show all release types (live, compilations, singles…)
|
||||
</label>
|
||||
<ul>
|
||||
{detail.releases.map((r) => (
|
||||
<li key={r.id}>
|
||||
|
||||
Reference in New Issue
Block a user