feat: table series avec UUID PK — migration complète backend + frontend
Migration DB (0070 + 0071): - Backup automatique de book_reading_progress avant migration - Crée table series (fusion de series_metadata) avec UUID PK - Ajoute series_id FK à books, external_metadata_links, anilist_series_links, available_downloads, download_detection_results - Supprime les colonnes TEXT legacy et la table series_metadata Backend API + Indexer: - Toutes les queries SQL migrées vers series_id FK + JOIN series - Routes /series/:name → /series/:series_id (UUID) - Nouvel endpoint GET /series/by-name/:name pour lookup par nom - match_title_volumes() factorisé entre prowlarr.rs et download_detection.rs - Fix scheduler.rs: settings → app_settings - OpenAPI mis à jour avec les nouveaux endpoints Frontend: - Routes /libraries/[id]/series/[name] → /series/[seriesId] - Tous les composants (Edit, Delete, MarkRead, Prowlarr, Metadata, ReadingStatus) utilisent seriesId - compressVolumes() pour afficher T1→3 au lieu de T1 T2 T3 - Titre release en entier (plus de truncate) dans available downloads Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -77,8 +77,8 @@ export default async function AuthorDetailPage({
|
||||
<div className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-4">
|
||||
{authorSeries.map((s) => (
|
||||
<Link
|
||||
key={`${s.library_id}-${s.name}`}
|
||||
href={`/libraries/${s.library_id}/series/${encodeURIComponent(s.name)}`}
|
||||
key={`${s.library_id}-${s.series_id}`}
|
||||
href={`/libraries/${s.library_id}/series/${s.series_id}`}
|
||||
className="group"
|
||||
>
|
||||
<div className="bg-card rounded-xl shadow-sm border border-border/60 overflow-hidden hover:shadow-md hover:-translate-y-1 transition-all duration-200">
|
||||
|
||||
@@ -76,10 +76,10 @@ export default async function BookDetailPage({
|
||||
<span className="text-muted-foreground">/</span>
|
||||
</>
|
||||
)}
|
||||
{book.series && (
|
||||
{book.series && book.series_id && (
|
||||
<>
|
||||
<Link
|
||||
href={`/libraries/${book.library_id}/series/${encodeURIComponent(book.series)}`}
|
||||
href={`/libraries/${book.library_id}/series/${book.series_id}`}
|
||||
className="text-muted-foreground hover:text-primary transition-colors"
|
||||
>
|
||||
{book.series}
|
||||
@@ -116,9 +116,9 @@ export default async function BookDetailPage({
|
||||
{book.author && (
|
||||
<p className="text-base text-muted-foreground">{book.author}</p>
|
||||
)}
|
||||
{book.series && (
|
||||
{book.series && book.series_id && (
|
||||
<Link
|
||||
href={`/libraries/${book.library_id}/series/${encodeURIComponent(book.series)}`}
|
||||
href={`/libraries/${book.library_id}/series/${book.series_id}`}
|
||||
className="inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-primary/10 text-primary text-xs border border-primary/30 font-medium"
|
||||
>
|
||||
{book.series}
|
||||
|
||||
@@ -134,8 +134,8 @@ export default async function BooksPage({
|
||||
<div className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 gap-4">
|
||||
{seriesHits.map((s) => (
|
||||
<Link
|
||||
key={`${s.library_id}-${s.name}`}
|
||||
href={`/libraries/${s.library_id}/series/${encodeURIComponent(s.name)}`}
|
||||
key={`${s.library_id}-${s.series_id}`}
|
||||
href={`/libraries/${s.library_id}/series/${s.series_id}`}
|
||||
className="group"
|
||||
>
|
||||
<div className="bg-card rounded-xl shadow-sm border border-border/60 overflow-hidden hover:shadow-md transition-shadow duration-200">
|
||||
|
||||
@@ -7,6 +7,7 @@ import { TorrentDownloadDto, LatestFoundPerLibraryDto } from "@/lib/api";
|
||||
import { Card, CardContent, CardHeader, CardTitle, Button, Icon } from "@/app/components/ui";
|
||||
import { QbittorrentProvider, QbittorrentDownloadButton } from "@/app/components/QbittorrentDownloadButton";
|
||||
import { useTranslation } from "@/lib/i18n/context";
|
||||
import { compressVolumes } from "@/lib/volumeRanges";
|
||||
import type { TranslationKey } from "@/lib/i18n/fr";
|
||||
|
||||
type TFunction = (key: TranslationKey, vars?: Record<string, string | number>) => string;
|
||||
@@ -260,7 +261,7 @@ function DownloadRow({ dl, onDeleted }: { dl: TorrentDownloadDto; onDeleted: ()
|
||||
<div className="flex-1 min-w-0">
|
||||
{/* Desktop: single row */}
|
||||
<div className="hidden sm:flex items-center gap-2">
|
||||
<Link href={`/libraries/${dl.library_id}/series/${encodeURIComponent(dl.series_name)}`} className="text-sm font-medium text-primary hover:underline truncate">{dl.series_name}</Link>
|
||||
<Link href={`/libraries/${dl.library_id}/series/${dl.series_id ?? encodeURIComponent(dl.series_name)}`} className="text-sm font-medium text-primary hover:underline truncate">{dl.series_name}</Link>
|
||||
<span className={`text-[10px] font-medium px-1.5 py-0.5 rounded-full ${statusClass(dl.status)}`}>
|
||||
{statusLabel(dl.status, t)}
|
||||
</span>
|
||||
@@ -275,7 +276,7 @@ function DownloadRow({ dl, onDeleted }: { dl: TorrentDownloadDto; onDeleted: ()
|
||||
{/* Mobile: stacked */}
|
||||
<div className="sm:hidden">
|
||||
<div className="flex items-center gap-1.5">
|
||||
<Link href={`/libraries/${dl.library_id}/series/${encodeURIComponent(dl.series_name)}`} className="text-sm font-medium text-primary hover:underline truncate">{dl.series_name}</Link>
|
||||
<Link href={`/libraries/${dl.library_id}/series/${dl.series_id ?? encodeURIComponent(dl.series_name)}`} className="text-sm font-medium text-primary hover:underline truncate">{dl.series_name}</Link>
|
||||
<span className={`text-[10px] font-medium px-1.5 py-0.5 rounded-full shrink-0 ${statusClass(dl.status)}`}>
|
||||
{statusLabel(dl.status, t)}
|
||||
</span>
|
||||
@@ -389,7 +390,7 @@ function AvailableLibraryCard({ lib, onDeleted }: { lib: LatestFoundPerLibraryDt
|
||||
<div key={r.id} className="rounded-lg border border-border/40 bg-background/60 p-2 sm:p-3">
|
||||
<div className="flex items-center justify-between gap-2 mb-1.5">
|
||||
<Link
|
||||
href={`/libraries/${lib.library_id}/series/${encodeURIComponent(r.series_name)}`}
|
||||
href={`/libraries/${lib.library_id}/series/${r.series_id ?? encodeURIComponent(r.series_name)}`}
|
||||
className="font-semibold text-xs sm:text-sm text-primary hover:underline truncate"
|
||||
>
|
||||
{r.series_name}
|
||||
@@ -403,11 +404,11 @@ function AvailableLibraryCard({ lib, onDeleted }: { lib: LatestFoundPerLibraryDt
|
||||
{groupReleasesByTitle(r.available_releases).map((group) => (
|
||||
<div key={group.title} className="rounded bg-muted/30 overflow-hidden">
|
||||
{/* Title + matched volumes (shown once) */}
|
||||
<div className="flex items-center gap-2 py-1 px-2">
|
||||
<p className="text-[11px] sm:text-xs font-mono text-foreground truncate flex-1" title={group.title}>{group.title}</p>
|
||||
<div className="flex flex-wrap items-center gap-1 shrink-0">
|
||||
{group.items[0].matched_missing_volumes.map(vol => (
|
||||
<span key={vol} className="text-[10px] px-1 py-0.5 rounded-full bg-success/20 text-success font-medium">T{vol}</span>
|
||||
<div className="py-1 px-2">
|
||||
<p className="text-[11px] sm:text-xs font-mono text-foreground break-all">{group.title}</p>
|
||||
<div className="flex flex-wrap items-center gap-1 mt-1">
|
||||
{compressVolumes(group.items[0].matched_missing_volumes).map(range => (
|
||||
<span key={range} className="text-[10px] px-1 py-0.5 rounded-full bg-success/20 text-success font-medium">{range}</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Card, CardHeader, CardTitle, CardDescription, CardContent, StatBox } fr
|
||||
import { QbittorrentProvider, QbittorrentDownloadButton } from "@/app/components/QbittorrentDownloadButton";
|
||||
import type { DownloadDetectionReportDto, DownloadDetectionResultDto } from "@/lib/api";
|
||||
import type { TranslateFunction } from "@/lib/i18n/dictionaries";
|
||||
import { compressVolumes } from "@/lib/volumeRanges";
|
||||
|
||||
export function DownloadDetectionReportCard({ report, t }: { report: DownloadDetectionReportDto; t: TranslateFunction }) {
|
||||
return (
|
||||
@@ -69,7 +70,7 @@ export function DownloadDetectionResultsCard({ results, libraryId, qbConfigured,
|
||||
<div className="flex items-center justify-between gap-2 mb-2">
|
||||
{libraryId ? (
|
||||
<Link
|
||||
href={`/libraries/${libraryId}/series/${encodeURIComponent(r.series_name)}`}
|
||||
href={`/libraries/${libraryId}/series/${r.series_id ?? encodeURIComponent(r.series_name)}`}
|
||||
className="font-semibold text-sm text-primary hover:underline truncate"
|
||||
>
|
||||
{r.series_name}
|
||||
@@ -97,10 +98,10 @@ export function DownloadDetectionResultsCard({ results, libraryId, qbConfigured,
|
||||
<span className="text-[10px] text-muted-foreground">
|
||||
{(release.size / 1024 / 1024).toFixed(0)} MB
|
||||
</span>
|
||||
<div className="flex items-center gap-1">
|
||||
{release.matched_missing_volumes.map((vol) => (
|
||||
<span key={vol} className="text-[10px] px-1.5 py-0.5 rounded-full bg-success/20 text-success font-medium">
|
||||
T.{vol}
|
||||
<div className="flex flex-wrap items-center gap-1">
|
||||
{compressVolumes(release.matched_missing_volumes).map((range) => (
|
||||
<span key={range} className="text-[10px] px-1.5 py-0.5 rounded-full bg-success/20 text-success font-medium">
|
||||
{range}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -51,7 +51,7 @@ export function MetadataBatchResultsCard({ results, libraryId, t }: {
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
{libraryId ? (
|
||||
<Link
|
||||
href={`/libraries/${libraryId}/series/${encodeURIComponent(r.series_name)}`}
|
||||
href={`/libraries/${libraryId}/series/${r.series_id ?? encodeURIComponent(r.series_name)}`}
|
||||
className="font-medium text-sm text-primary hover:underline truncate"
|
||||
>
|
||||
{r.series_name}
|
||||
@@ -157,7 +157,7 @@ export function MetadataRefreshChangesCard({ report, libraryId, t }: {
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
{libraryId ? (
|
||||
<Link
|
||||
href={`/libraries/${libraryId}/series/${encodeURIComponent(r.series_name)}`}
|
||||
href={`/libraries/${libraryId}/series/${r.series_id ?? encodeURIComponent(r.series_name)}`}
|
||||
className="font-medium text-sm text-primary hover:underline truncate"
|
||||
>
|
||||
{r.series_name}
|
||||
|
||||
@@ -51,7 +51,7 @@ export function ReadingStatusMatchResultsCard({ results, libraryId, t }: {
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
{libraryId ? (
|
||||
<Link
|
||||
href={`/libraries/${libraryId}/series/${encodeURIComponent(r.series_name)}`}
|
||||
href={`/libraries/${libraryId}/series/${r.series_id ?? encodeURIComponent(r.series_name)}`}
|
||||
className="font-medium text-sm text-primary hover:underline truncate"
|
||||
>
|
||||
{r.series_name}
|
||||
@@ -146,7 +146,7 @@ export function ReadingStatusPushResultsCard({ results, libraryId, t }: {
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
{libraryId ? (
|
||||
<Link
|
||||
href={`/libraries/${libraryId}/series/${encodeURIComponent(r.series_name)}`}
|
||||
href={`/libraries/${libraryId}/series/${r.series_id ?? encodeURIComponent(r.series_name)}`}
|
||||
className="font-medium text-sm text-primary hover:underline truncate"
|
||||
>
|
||||
{r.series_name}
|
||||
|
||||
@@ -33,28 +33,20 @@ export default async function SeriesDetailPage({
|
||||
params,
|
||||
searchParams,
|
||||
}: {
|
||||
params: Promise<{ id: string; name: string }>;
|
||||
params: Promise<{ id: string; seriesId: string }>;
|
||||
searchParams: Promise<{ [key: string]: string | string[] | undefined }>;
|
||||
}) {
|
||||
const { id, name } = await params;
|
||||
const { id, seriesId } = await params;
|
||||
const { t } = await getServerTranslations();
|
||||
const searchParamsAwaited = await searchParams;
|
||||
const page = typeof searchParamsAwaited.page === "string" ? parseInt(searchParamsAwaited.page) : 1;
|
||||
const limit = typeof searchParamsAwaited.limit === "string" ? parseInt(searchParamsAwaited.limit) : 50;
|
||||
|
||||
const seriesName = decodeURIComponent(name);
|
||||
|
||||
const [library, booksPage, seriesMeta, metadataLinks, readingStatusLink, prowlarrConfigured, qbConfigured, metadataProviders] = await Promise.all([
|
||||
const [library, seriesMeta, metadataLinks, readingStatusLink, prowlarrConfigured, qbConfigured, metadataProviders] = await Promise.all([
|
||||
fetchLibraries().then((libs) => libs.find((l) => l.id === id)),
|
||||
fetchBooks(id, seriesName, page, limit).catch(() => ({
|
||||
items: [] as BookDto[],
|
||||
total: 0,
|
||||
page: 1,
|
||||
limit,
|
||||
})),
|
||||
fetchSeriesMetadata(id, seriesName).catch(() => null as SeriesMetadataDto | null),
|
||||
getMetadataLink(id, seriesName).catch(() => [] as ExternalMetadataLinkDto[]),
|
||||
getReadingStatusLink(id, seriesName).catch(() => null as AnilistSeriesLinkDto | null),
|
||||
fetchSeriesMetadata(id, seriesId).catch(() => null as SeriesMetadataDto | null),
|
||||
getMetadataLink(id, seriesId).catch(() => [] as ExternalMetadataLinkDto[]),
|
||||
getReadingStatusLink(id, seriesId).catch(() => null as AnilistSeriesLinkDto | null),
|
||||
apiFetch<{ api_key?: string }>("/settings/prowlarr")
|
||||
.then(d => !!(d?.api_key?.trim()))
|
||||
.catch(() => false),
|
||||
@@ -64,6 +56,17 @@ export default async function SeriesDetailPage({
|
||||
apiFetch<{ comicvine?: { api_key?: string } }>("/settings/metadata_providers").catch(() => null),
|
||||
]);
|
||||
|
||||
// Get series name from metadata for display
|
||||
const seriesName = seriesMeta?.series_name ?? "";
|
||||
|
||||
// Fetch books using seriesId for the filter query
|
||||
const booksPage = await fetchBooks(id, seriesId, page, limit).catch(() => ({
|
||||
items: [] as BookDto[],
|
||||
total: 0,
|
||||
page: 1,
|
||||
limit,
|
||||
}));
|
||||
|
||||
const hiddenProviders: string[] = [];
|
||||
if (!metadataProviders?.comicvine?.api_key) hiddenProviders.push("comicvine");
|
||||
|
||||
@@ -228,12 +231,14 @@ export default async function SeriesDetailPage({
|
||||
|
||||
<div className="flex flex-wrap items-center gap-3">
|
||||
<MarkSeriesReadButton
|
||||
seriesId={seriesId}
|
||||
seriesName={seriesName}
|
||||
bookCount={booksPage.total}
|
||||
booksReadCount={booksReadCount}
|
||||
/>
|
||||
<EditSeriesForm
|
||||
libraryId={id}
|
||||
seriesId={seriesId}
|
||||
seriesName={seriesName}
|
||||
currentAuthors={seriesMeta?.authors ?? []}
|
||||
currentPublishers={seriesMeta?.publishers ?? []}
|
||||
@@ -261,13 +266,14 @@ export default async function SeriesDetailPage({
|
||||
/>
|
||||
<ReadingStatusModal
|
||||
libraryId={id}
|
||||
seriesId={seriesId}
|
||||
seriesName={seriesName}
|
||||
readingStatusProvider={library.reading_status_provider ?? null}
|
||||
existingLink={readingStatusLink}
|
||||
/>
|
||||
<DeleteSeriesButton
|
||||
libraryId={id}
|
||||
seriesName={seriesName}
|
||||
seriesId={seriesId}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -75,8 +75,8 @@ export default async function LibrarySeriesPage({
|
||||
<div className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-6">
|
||||
{series.map((s) => (
|
||||
<Link
|
||||
key={s.name}
|
||||
href={`/libraries/${id}/series/${encodeURIComponent(s.name)}`}
|
||||
key={s.series_id}
|
||||
href={`/libraries/${id}/series/${s.series_id}`}
|
||||
className="group"
|
||||
>
|
||||
<div className={`bg-card rounded-xl shadow-sm border border-border/60 overflow-hidden hover:shadow-md transition-shadow duration-200 ${s.books_read_count >= s.book_count ? "opacity-50" : ""}`}>
|
||||
@@ -98,6 +98,7 @@ export default async function LibrarySeriesPage({
|
||||
{t("series.readCount", { read: String(s.books_read_count), total: String(s.book_count), plural: s.book_count !== 1 ? "s" : "" })}
|
||||
</p>
|
||||
<MarkSeriesReadButton
|
||||
seriesId={s.series_id}
|
||||
seriesName={s.name}
|
||||
bookCount={s.book_count}
|
||||
booksReadCount={s.books_read_count}
|
||||
|
||||
@@ -124,7 +124,7 @@ export default async function SeriesPage({
|
||||
<>
|
||||
<div className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-4">
|
||||
{series.map((s) => (
|
||||
<div key={s.name} className="group relative">
|
||||
<div key={s.series_id} className="group relative">
|
||||
<div
|
||||
className={`bg-card rounded-xl shadow-sm border border-border/60 overflow-hidden group-hover:shadow-md group-hover:-translate-y-1 transition-all duration-200 ${
|
||||
s.books_read_count >= s.book_count ? "opacity-50" : ""
|
||||
@@ -149,6 +149,7 @@ export default async function SeriesPage({
|
||||
</p>
|
||||
<div className="relative z-20">
|
||||
<MarkSeriesReadButton
|
||||
seriesId={s.series_id}
|
||||
seriesName={s.name}
|
||||
bookCount={s.book_count}
|
||||
booksReadCount={s.books_read_count}
|
||||
@@ -190,7 +191,7 @@ export default async function SeriesPage({
|
||||
</div>
|
||||
{/* Link overlay covering the full card — below interactive elements */}
|
||||
<Link
|
||||
href={`/libraries/${s.library_id}/series/${encodeURIComponent(s.name)}`}
|
||||
href={`/libraries/${s.library_id}/series/${s.series_id}`}
|
||||
className="absolute inset-0 z-10 rounded-xl"
|
||||
aria-label={s.name === "unclassified" ? t("books.unclassified") : s.name}
|
||||
/>
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { NextResponse, NextRequest } from "next/server";
|
||||
import { apiFetch } from "@/lib/api";
|
||||
|
||||
type Params = Promise<{ libraryId: string; seriesName: string }>;
|
||||
type Params = Promise<{ libraryId: string; seriesId: string }>;
|
||||
|
||||
export async function GET(request: NextRequest, { params }: { params: Params }) {
|
||||
try {
|
||||
const { libraryId, seriesName } = await params;
|
||||
const { libraryId, seriesId } = await params;
|
||||
const data = await apiFetch(
|
||||
`/anilist/series/${libraryId}/${encodeURIComponent(seriesName)}`,
|
||||
`/anilist/series/${libraryId}/${seriesId}`,
|
||||
);
|
||||
return NextResponse.json(data);
|
||||
} catch (error) {
|
||||
@@ -18,10 +18,10 @@ export async function GET(request: NextRequest, { params }: { params: Params })
|
||||
|
||||
export async function POST(request: NextRequest, { params }: { params: Params }) {
|
||||
try {
|
||||
const { libraryId, seriesName } = await params;
|
||||
const { libraryId, seriesId } = await params;
|
||||
const body = await request.json();
|
||||
const data = await apiFetch(
|
||||
`/anilist/series/${libraryId}/${encodeURIComponent(seriesName)}/link`,
|
||||
`/anilist/series/${libraryId}/${seriesId}/link`,
|
||||
{ method: "POST", body: JSON.stringify(body) },
|
||||
);
|
||||
return NextResponse.json(data);
|
||||
@@ -33,9 +33,9 @@ export async function POST(request: NextRequest, { params }: { params: Params })
|
||||
|
||||
export async function DELETE(request: NextRequest, { params }: { params: Params }) {
|
||||
try {
|
||||
const { libraryId, seriesName } = await params;
|
||||
const { libraryId, seriesId } = await params;
|
||||
const data = await apiFetch(
|
||||
`/anilist/series/${libraryId}/${encodeURIComponent(seriesName)}/unlink`,
|
||||
`/anilist/series/${libraryId}/${seriesId}/unlink`,
|
||||
{ method: "DELETE" },
|
||||
);
|
||||
return NextResponse.json(data);
|
||||
@@ -1,17 +0,0 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { updateSeries } from "@/lib/api";
|
||||
|
||||
export async function PATCH(
|
||||
request: NextRequest,
|
||||
{ params }: { params: Promise<{ id: string; name: string }> }
|
||||
) {
|
||||
const { id, name } = await params;
|
||||
try {
|
||||
const body = await request.json();
|
||||
const data = await updateSeries(id, name, body);
|
||||
return NextResponse.json(data);
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : "Failed to update series";
|
||||
return NextResponse.json({ error: message }, { status: 500 });
|
||||
}
|
||||
}
|
||||
@@ -3,11 +3,11 @@ import { fetchSeriesMetadata } from "@/lib/api";
|
||||
|
||||
export async function GET(
|
||||
_request: NextRequest,
|
||||
{ params }: { params: Promise<{ id: string; name: string }> }
|
||||
{ params }: { params: Promise<{ id: string; seriesId: string }> }
|
||||
) {
|
||||
const { id, name } = await params;
|
||||
const { id, seriesId } = await params;
|
||||
try {
|
||||
const data = await fetchSeriesMetadata(id, name);
|
||||
const data = await fetchSeriesMetadata(id, seriesId);
|
||||
return NextResponse.json(data);
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : "Failed to fetch series metadata";
|
||||
@@ -0,0 +1,31 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { updateSeries, deleteSeries } from "@/lib/api";
|
||||
|
||||
export async function PATCH(
|
||||
request: NextRequest,
|
||||
{ params }: { params: Promise<{ id: string; seriesId: string }> }
|
||||
) {
|
||||
const { id, seriesId } = await params;
|
||||
try {
|
||||
const body = await request.json();
|
||||
const data = await updateSeries(id, seriesId, body);
|
||||
return NextResponse.json(data);
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : "Failed to update series";
|
||||
return NextResponse.json({ error: message }, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
export async function DELETE(
|
||||
_request: NextRequest,
|
||||
{ params }: { params: Promise<{ id: string; seriesId: string }> }
|
||||
) {
|
||||
const { id, seriesId } = await params;
|
||||
try {
|
||||
await deleteSeries(id, seriesId);
|
||||
return NextResponse.json({ deleted: true });
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : "Failed to delete series";
|
||||
return NextResponse.json({ error: message }, { status: 500 });
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import { useRouter } from "next/navigation";
|
||||
import { Button, Icon, Modal } from "./ui";
|
||||
import { useTranslation } from "@/lib/i18n/context";
|
||||
|
||||
export function DeleteSeriesButton({ libraryId, seriesName }: { libraryId: string; seriesName: string }) {
|
||||
export function DeleteSeriesButton({ libraryId, seriesId }: { libraryId: string; seriesId: string }) {
|
||||
const { t } = useTranslation();
|
||||
const router = useRouter();
|
||||
const [showConfirm, setShowConfirm] = useState(false);
|
||||
@@ -16,7 +16,7 @@ export function DeleteSeriesButton({ libraryId, seriesName }: { libraryId: strin
|
||||
setShowConfirm(false);
|
||||
try {
|
||||
const resp = await fetch(
|
||||
`/api/libraries/${libraryId}/series/${encodeURIComponent(seriesName)}`,
|
||||
`/api/libraries/${libraryId}/series/${seriesId}`,
|
||||
{ method: "DELETE" }
|
||||
);
|
||||
if (resp.ok) {
|
||||
|
||||
@@ -44,6 +44,7 @@ const SERIES_STATUS_VALUES = ["", "ongoing", "ended", "hiatus", "cancelled", "up
|
||||
|
||||
interface EditSeriesFormProps {
|
||||
libraryId: string;
|
||||
seriesId: string;
|
||||
seriesName: string;
|
||||
currentAuthors: string[];
|
||||
currentPublishers: string[];
|
||||
@@ -58,6 +59,7 @@ interface EditSeriesFormProps {
|
||||
|
||||
export function EditSeriesForm({
|
||||
libraryId,
|
||||
seriesId,
|
||||
seriesName,
|
||||
currentAuthors,
|
||||
currentPublishers,
|
||||
@@ -199,7 +201,7 @@ export function EditSeriesForm({
|
||||
}
|
||||
|
||||
const res = await fetch(
|
||||
`/api/libraries/${libraryId}/series/${encodeURIComponent(seriesName)}`,
|
||||
`/api/libraries/${libraryId}/series/${seriesId}`,
|
||||
{
|
||||
method: "PATCH",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
@@ -212,12 +214,7 @@ export function EditSeriesForm({
|
||||
return;
|
||||
}
|
||||
setIsOpen(false);
|
||||
|
||||
if (effectiveName !== seriesName) {
|
||||
router.push(`/libraries/${libraryId}/series/${encodeURIComponent(effectiveName)}` as any);
|
||||
} else {
|
||||
router.refresh();
|
||||
}
|
||||
router.refresh();
|
||||
} catch {
|
||||
setError(t("common.networkError"));
|
||||
}
|
||||
|
||||
@@ -5,12 +5,13 @@ import { useRouter } from "next/navigation";
|
||||
import { useTranslation } from "../../lib/i18n/context";
|
||||
|
||||
interface MarkSeriesReadButtonProps {
|
||||
seriesId: string;
|
||||
seriesName: string;
|
||||
bookCount: number;
|
||||
booksReadCount: number;
|
||||
}
|
||||
|
||||
export function MarkSeriesReadButton({ seriesName, bookCount, booksReadCount }: MarkSeriesReadButtonProps) {
|
||||
export function MarkSeriesReadButton({ seriesId, seriesName, bookCount, booksReadCount }: MarkSeriesReadButtonProps) {
|
||||
const { t } = useTranslation();
|
||||
const [loading, setLoading] = useState(false);
|
||||
const router = useRouter();
|
||||
@@ -27,7 +28,7 @@ export function MarkSeriesReadButton({ seriesName, bookCount, booksReadCount }:
|
||||
const res = await fetch("/api/series/mark-read", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ series: seriesName, status: targetStatus }),
|
||||
body: JSON.stringify({ series: seriesId, status: targetStatus }),
|
||||
});
|
||||
if (!res.ok) {
|
||||
const body = await res.json().catch(() => ({ error: res.statusText }));
|
||||
|
||||
@@ -6,6 +6,7 @@ import { Icon } from "./ui";
|
||||
import type { ProwlarrRelease, ProwlarrSearchResponse } from "../../lib/api";
|
||||
import { useTranslation } from "../../lib/i18n/context";
|
||||
import { QbittorrentProvider, QbittorrentDownloadButton } from "./QbittorrentDownloadButton";
|
||||
import { compressVolumes } from "@/lib/volumeRanges";
|
||||
|
||||
interface MissingBookItem {
|
||||
title: string | null;
|
||||
@@ -251,9 +252,9 @@ export function ProwlarrSearchModal({ seriesName, libraryId, missingBooks, initi
|
||||
</span>
|
||||
{hasMissing && (
|
||||
<div className="flex flex-wrap items-center gap-1 mt-1">
|
||||
{first.matchedMissingVolumes!.map((vol) => (
|
||||
<span key={vol} className="inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium bg-green-500/20 text-green-600">
|
||||
{t("prowlarr.missingVol", { vol })}
|
||||
{compressVolumes(first.matchedMissingVolumes!).map((range) => (
|
||||
<span key={range} className="inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium bg-green-500/20 text-green-600">
|
||||
{range}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -9,6 +9,7 @@ import type { AnilistMediaResultDto, AnilistSeriesLinkDto } from "../../lib/api"
|
||||
|
||||
interface ReadingStatusModalProps {
|
||||
libraryId: string;
|
||||
seriesId: string;
|
||||
seriesName: string;
|
||||
readingStatusProvider: string | null;
|
||||
existingLink: AnilistSeriesLinkDto | null;
|
||||
@@ -18,6 +19,7 @@ type ModalStep = "idle" | "searching" | "results" | "linked";
|
||||
|
||||
export function ReadingStatusModal({
|
||||
libraryId,
|
||||
seriesId,
|
||||
seriesName,
|
||||
readingStatusProvider,
|
||||
existingLink,
|
||||
@@ -67,7 +69,7 @@ export function ReadingStatusModal({
|
||||
setError(null);
|
||||
try {
|
||||
const resp = await fetch(
|
||||
`/api/anilist/series/${libraryId}/${encodeURIComponent(seriesName)}`,
|
||||
`/api/anilist/series/${libraryId}/${seriesId}`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
@@ -91,7 +93,7 @@ export function ReadingStatusModal({
|
||||
setError(null);
|
||||
try {
|
||||
const resp = await fetch(
|
||||
`/api/anilist/series/${libraryId}/${encodeURIComponent(seriesName)}`,
|
||||
`/api/anilist/series/${libraryId}/${seriesId}`,
|
||||
{ method: "DELETE" }
|
||||
);
|
||||
if (!resp.ok) throw new Error("Unlink failed");
|
||||
|
||||
Reference in New Issue
Block a user