Fix build errors
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { notFound } from 'next/navigation';
|
||||
import Link from 'next/link';
|
||||
import { Register } from '@/utils/register_parser';
|
||||
import RegisterDetail from '@/app/registers/RegisterDetail';
|
||||
import {Container, Row} from "react-bootstrap";
|
||||
import { getRegisters } from '@/services/register.service';
|
||||
|
||||
@@ -62,7 +62,6 @@ export default function ZxdbExplorer({
|
||||
const json: Paged<Item> = await res.json();
|
||||
setData(json);
|
||||
} catch (e) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(e);
|
||||
setData({ items: [], page: 1, pageSize, total: 0 });
|
||||
} finally {
|
||||
|
||||
@@ -91,7 +91,6 @@ export default function EntriesExplorer({
|
||||
const json: Paged<Item> = await res.json();
|
||||
setData(json);
|
||||
} catch (e) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(e);
|
||||
setData({ items: [], page: 1, pageSize, total: 0 });
|
||||
} finally {
|
||||
@@ -105,7 +104,6 @@ export default function EntriesExplorer({
|
||||
setData(initial);
|
||||
setPage(initial.page);
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [initial]);
|
||||
|
||||
// Client fetch when filters/paging/sort change; also keep URL in sync
|
||||
|
||||
@@ -68,7 +68,7 @@ export type EntryDetailData = {
|
||||
}[];
|
||||
};
|
||||
|
||||
export default function EntryDetailClient({ data }: { data: EntryDetailData }) {
|
||||
export default function EntryDetailClient({ data }: { data: EntryDetailData | null }) {
|
||||
if (!data) return <div className="alert alert-warning">Not found</div>;
|
||||
|
||||
return (
|
||||
|
||||
@@ -17,10 +17,14 @@ export default function LabelDetailClient({ id, initial, initialTab, initialQ }:
|
||||
const router = useRouter();
|
||||
// Names are now delivered by SSR payload to minimize pop-in.
|
||||
|
||||
if (!initial || !initial.label) return <div className="alert alert-warning">Not found</div>;
|
||||
// Hooks must be called unconditionally
|
||||
const current = useMemo<Paged<Item> | null>(
|
||||
() => (tab === "authored" ? initial?.authored : initial?.published) ?? null,
|
||||
[initial, tab]
|
||||
);
|
||||
const totalPages = useMemo(() => (current ? Math.max(1, Math.ceil(current.total / current.pageSize)) : 1), [current]);
|
||||
|
||||
const current = useMemo(() => (tab === "authored" ? initial.authored : initial.published), [initial, tab]);
|
||||
const totalPages = useMemo(() => Math.max(1, Math.ceil(current.total / current.pageSize)), [current]);
|
||||
if (!initial || !initial.label) return <div className="alert alert-warning">Not found</div>;
|
||||
|
||||
return (
|
||||
<div>
|
||||
@@ -98,19 +102,19 @@ export default function LabelDetailClient({ id, initial, initialTab, initialQ }:
|
||||
</div>
|
||||
|
||||
<div className="d-flex align-items-center gap-2 mt-2">
|
||||
<span>Page {current.page} / {totalPages}</span>
|
||||
<span>Page {current ? current.page : 1} / {totalPages}</span>
|
||||
<div className="ms-auto d-flex gap-2">
|
||||
<Link
|
||||
className={`btn btn-sm btn-outline-secondary ${current.page <= 1 ? "disabled" : ""}`}
|
||||
aria-disabled={current.page <= 1}
|
||||
href={`/zxdb/labels/${id}?${(() => { const p = new URLSearchParams(); p.set("tab", tab); if (q) p.set("q", q); p.set("page", String(Math.max(1, current.page - 1))); return p.toString(); })()}`}
|
||||
className={`btn btn-sm btn-outline-secondary ${current && current.page <= 1 ? "disabled" : ""}`}
|
||||
aria-disabled={current ? current.page <= 1 : true}
|
||||
href={`/zxdb/labels/${id}?${(() => { const p = new URLSearchParams(); p.set("tab", tab); if (q) p.set("q", q); p.set("page", String(Math.max(1, (current ? current.page : 1) - 1))); return p.toString(); })()}`}
|
||||
>
|
||||
Prev
|
||||
</Link>
|
||||
<Link
|
||||
className={`btn btn-sm btn-outline-secondary ${current.page >= totalPages ? "disabled" : ""}`}
|
||||
aria-disabled={current.page >= totalPages}
|
||||
href={`/zxdb/labels/${id}?${(() => { const p = new URLSearchParams(); p.set("tab", tab); if (q) p.set("q", q); p.set("page", String(Math.min(totalPages, current.page + 1))); return p.toString(); })()}`}
|
||||
className={`btn btn-sm btn-outline-secondary ${current && current.page >= totalPages ? "disabled" : ""}`}
|
||||
aria-disabled={current ? current.page >= totalPages : true}
|
||||
href={`/zxdb/labels/${id}?${(() => { const p = new URLSearchParams(); p.set("tab", tab); if (q) p.set("q", q); p.set("page", String(Math.min(totalPages, (current ? current.page : 1) + 1))); return p.toString(); })()}`}
|
||||
>
|
||||
Next
|
||||
</Link>
|
||||
|
||||
@@ -104,7 +104,6 @@ export default function ReleasesExplorer({
|
||||
const json: Paged<Item> = await res.json();
|
||||
setData(json);
|
||||
} catch (e) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(e);
|
||||
setData({ items: [], page: 1, pageSize, total: 0 });
|
||||
} finally {
|
||||
@@ -117,7 +116,6 @@ export default function ReleasesExplorer({
|
||||
setData(initial);
|
||||
setPage(initial.page);
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [initial]);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -141,7 +139,6 @@ export default function ReleasesExplorer({
|
||||
}
|
||||
updateUrl(page);
|
||||
fetchData(q, page);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [page, year, sort, dLanguageId, dMachinetypeId, filetypeId, schemetypeId, sourcetypeId, casetypeId, isDemo]);
|
||||
|
||||
function onSubmit(e: React.FormEvent) {
|
||||
@@ -286,7 +283,7 @@ export default function ReleasesExplorer({
|
||||
<label className="form-check-label" htmlFor="demoCheck">Demo only</label>
|
||||
</div>
|
||||
<div className="col-auto">
|
||||
<select className="form-select" value={sort} onChange={(e) => { setSort(e.target.value); setPage(1); }}>
|
||||
<select className="form-select" value={sort} onChange={(e) => { setSort(e.target.value as typeof sort); setPage(1); }}>
|
||||
<option value="year_desc">Sort: Newest</option>
|
||||
<option value="year_asc">Sort: Oldest</option>
|
||||
<option value="title">Sort: Title</option>
|
||||
|
||||
Reference in New Issue
Block a user