Initial commit
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
import Link from "next/link";
|
||||
import { notFound } from "next/navigation";
|
||||
import { ArrowLeft, Trash2 } from "lucide-react";
|
||||
import { getSeriesBySlug, listImages } from "@/lib/db/queries";
|
||||
import { MasonryGrid } from "@/components/grid/MasonryGrid";
|
||||
import { RegisterVisible } from "@/components/select/RegisterVisible";
|
||||
import { FilterBar } from "@/components/grid/FilterBar";
|
||||
import { resolveSort } from "@/lib/sortServer";
|
||||
import { deleteSeries, renameSeries } from "@/app/actions/entities";
|
||||
import { EntityRenameInline } from "@/components/entities/EntityRenameInline";
|
||||
import { parseFilterCriteria, statusToFlags } from "@/lib/filters";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export default async function SeriesPage({
|
||||
params,
|
||||
searchParams,
|
||||
}: {
|
||||
params: Promise<{ slug: string }>;
|
||||
searchParams: Promise<Record<string, string | string[] | undefined>>;
|
||||
}) {
|
||||
const { slug } = await params;
|
||||
const sp = await searchParams;
|
||||
const sort = await resolveSort(typeof sp.sort === "string" ? sp.sort : undefined);
|
||||
const search = (typeof sp.q === "string" ? sp.q.trim() : "") || undefined;
|
||||
const criteria = parseFilterCriteria(sp);
|
||||
const s = getSeriesBySlug(decodeURIComponent(slug));
|
||||
if (!s) notFound();
|
||||
const items = listImages({
|
||||
seriesId: s.id,
|
||||
sort,
|
||||
search,
|
||||
...statusToFlags(criteria.status),
|
||||
marks: criteria.marks,
|
||||
actressIds: criteria.ids.actresses,
|
||||
actressMode: criteria.mode.actresses,
|
||||
studioIds: criteria.ids.studios,
|
||||
seriesIds: criteria.ids.series,
|
||||
genreIds: criteria.ids.genres,
|
||||
genreMode: criteria.mode.genres,
|
||||
collectionIds: criteria.ids.collections,
|
||||
collectionMode: criteria.mode.collections,
|
||||
tagIds: criteria.ids.tags,
|
||||
tagMode: criteria.mode.tags,
|
||||
categoryIds: criteria.ids.categories,
|
||||
categoryMode: criteria.mode.categories,
|
||||
});
|
||||
|
||||
const remove = async () => {
|
||||
"use server";
|
||||
await deleteSeries(s.id);
|
||||
};
|
||||
|
||||
const rename = async (name: string) => {
|
||||
"use server";
|
||||
return await renameSeries(s.id, name);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="max-w-[1600px] mx-auto px-6 py-6 fade-in">
|
||||
<Link href="/series" className="inline-flex items-center gap-1 text-sm text-[var(--color-fg-dim)] hover:text-[var(--color-fg)] mb-4">
|
||||
<ArrowLeft className="w-4 h-4" /> All series
|
||||
</Link>
|
||||
<div className="mb-4">
|
||||
<div className="flex items-center gap-2">
|
||||
<h1 className="text-3xl font-semibold tracking-tight mb-1">{s.name}</h1>
|
||||
<EntityRenameInline initialName={s.name} onRename={rename} redirectBase="/series/" />
|
||||
<form action={remove}>
|
||||
<button className="flex items-center gap-1.5 text-xs px-2 py-1 rounded-lg glass text-[var(--color-fg-muted)] hover:text-[var(--color-coral)] hover:border-[var(--color-coral)]/30">
|
||||
<Trash2 className="w-3.5 h-3.5" /> Delete
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
<p className="text-[var(--color-fg-dim)]">{items.length} cover{items.length === 1 ? "" : "s"}</p>
|
||||
</div>
|
||||
<FilterBar current={{ kind: "series", name: s.name }} criteria={criteria} sort={sort} />
|
||||
<RegisterVisible ids={items.map((i) => i.id)} />
|
||||
<MasonryGrid images={items} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
import Link from "next/link";
|
||||
import { listAllSeries } from "@/lib/db/queries";
|
||||
import { createSeriesAction } from "@/app/actions/entities";
|
||||
import { Film, Plus, ArrowDownAZ, Hash } from "lucide-react";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export default async function SeriesIndexPage({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams: Promise<Record<string, string | string[] | undefined>>;
|
||||
}) {
|
||||
const sp = await searchParams;
|
||||
const sort: "az" | "count" = sp.sort === "count" ? "count" : "az";
|
||||
const raw = listAllSeries();
|
||||
const items = sort === "count"
|
||||
? [...raw].sort((a, b) => b.count - a.count || a.name.localeCompare(b.name))
|
||||
: [...raw].sort((a, b) => a.name.localeCompare(b.name));
|
||||
return (
|
||||
<div className="max-w-[1600px] mx-auto px-6 py-6 fade-in">
|
||||
<div className="flex items-center justify-between mb-6">
|
||||
<div>
|
||||
<h1 className="text-3xl font-semibold tracking-tight">Series</h1>
|
||||
<p className="text-[var(--color-fg-dim)] mt-1">{items.length} total</p>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="flex items-center rounded-lg glass overflow-hidden text-xs">
|
||||
<Link
|
||||
href="/series"
|
||||
className={cn(
|
||||
"flex items-center gap-1 px-2.5 py-1.5",
|
||||
sort === "az"
|
||||
? "bg-[var(--color-cyan)] text-black font-medium"
|
||||
: "text-[var(--color-fg-dim)] hover:text-[var(--color-fg)] hover:bg-[var(--color-glass)]",
|
||||
)}
|
||||
title="Sort A → Z"
|
||||
>
|
||||
<ArrowDownAZ className="w-3.5 h-3.5" /> A-Z
|
||||
</Link>
|
||||
<Link
|
||||
href="/series?sort=count"
|
||||
className={cn(
|
||||
"flex items-center gap-1 px-2.5 py-1.5",
|
||||
sort === "count"
|
||||
? "bg-[var(--color-cyan)] text-black font-medium"
|
||||
: "text-[var(--color-fg-dim)] hover:text-[var(--color-fg)] hover:bg-[var(--color-glass)]",
|
||||
)}
|
||||
title="Sort by cover count"
|
||||
>
|
||||
<Hash className="w-3.5 h-3.5" /> Count
|
||||
</Link>
|
||||
</div>
|
||||
<form action={createSeriesAction} className="flex items-center gap-2">
|
||||
<input
|
||||
name="name"
|
||||
placeholder="New series"
|
||||
required
|
||||
maxLength={120}
|
||||
className="glass rounded-lg px-3 py-1.5 text-sm outline-none focus:border-[var(--color-cyan)] w-56"
|
||||
/>
|
||||
<button className="flex items-center gap-1 text-sm px-3 py-1.5 rounded-lg bg-[var(--color-cyan)] text-black font-medium">
|
||||
<Plus className="w-4 h-4" /> Create
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{items.length === 0 ? (
|
||||
<div className="glass rounded-2xl p-card text-center">
|
||||
<Film className="w-8 h-8 mx-auto text-[var(--color-fg-dim)] mb-label" />
|
||||
<p className="text-[var(--color-fg-dim)]">No series yet. Create one above or add from any cover.</p>
|
||||
</div>
|
||||
) : (
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3">
|
||||
{items.map((s) => (
|
||||
<Link key={s.id} href={`/series/${s.slug}`} className="glass glass-hover rounded-xl p-4 flex items-center justify-between gap-3">
|
||||
<span className="font-medium truncate">{s.name}</span>
|
||||
<span className="text-xs font-mono text-[var(--color-fg-muted)] tabular-nums">{s.count}</span>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user