Refactor Artwork list table
This commit is contained in:
@ -165,9 +165,7 @@ type Filters = {
|
||||
name: string;
|
||||
slug: string;
|
||||
published: TriState;
|
||||
nsfw: TriState;
|
||||
needsWork: TriState;
|
||||
albumIds: string[];
|
||||
categoryIds: string[];
|
||||
};
|
||||
|
||||
@ -182,9 +180,7 @@ export function ArtworksTable() {
|
||||
name: "",
|
||||
slug: "",
|
||||
published: "any",
|
||||
nsfw: "any",
|
||||
needsWork: "any",
|
||||
albumIds: [],
|
||||
categoryIds: [],
|
||||
});
|
||||
|
||||
@ -194,9 +190,6 @@ export function ArtworksTable() {
|
||||
const [rows, setRows] = useState<ArtworkTableRow[]>([]);
|
||||
const [total, setTotal] = useState(0);
|
||||
|
||||
const [albumOptions, setAlbumOptions] = useState<
|
||||
{ id: string; name: string }[]
|
||||
>([]);
|
||||
const [categoryOptions, setCategoryOptions] = useState<
|
||||
{ id: string; name: string }[]
|
||||
>([]);
|
||||
@ -214,7 +207,6 @@ export function ArtworksTable() {
|
||||
useEffect(() => {
|
||||
startTransition(async () => {
|
||||
const res = await getArtworkFilterOptions();
|
||||
setAlbumOptions(res.albums);
|
||||
setCategoryOptions(res.categories);
|
||||
});
|
||||
}, []);
|
||||
@ -308,33 +300,6 @@ export function ArtworksTable() {
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: "gallery",
|
||||
header: "Gallery",
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm text-foreground/80">
|
||||
{row.original.gallery?.name ?? "—"}
|
||||
</span>
|
||||
),
|
||||
enableSorting: false,
|
||||
},
|
||||
{
|
||||
id: "albums",
|
||||
header: ({ column }) => <SortHeader title="Albums #" column={column} />,
|
||||
accessorKey: "albumsCount",
|
||||
cell: ({ row }) => (
|
||||
<div className="space-y-1">
|
||||
<div className="text-sm font-medium tabular-nums">
|
||||
{row.original.albumsCount}
|
||||
</div>
|
||||
{row.original.albums.length ? (
|
||||
<Chips items={row.original.albums} />
|
||||
) : (
|
||||
<span className="text-xs text-muted-foreground">—</span>
|
||||
)}
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: "categories",
|
||||
header: ({ column }) => (
|
||||
@ -454,7 +419,6 @@ export function ArtworksTable() {
|
||||
slug: debouncedSlug || undefined,
|
||||
published: filters.published,
|
||||
needsWork: filters.needsWork,
|
||||
albumIds: filters.albumIds.length ? filters.albumIds : undefined,
|
||||
categoryIds: filters.categoryIds.length
|
||||
? filters.categoryIds
|
||||
: undefined,
|
||||
@ -472,7 +436,6 @@ export function ArtworksTable() {
|
||||
debouncedSlug,
|
||||
filters.published,
|
||||
filters.needsWork,
|
||||
filters.albumIds,
|
||||
filters.categoryIds,
|
||||
]);
|
||||
|
||||
@ -548,16 +511,6 @@ export function ArtworksTable() {
|
||||
setPageIndex(0);
|
||||
}}
|
||||
/>
|
||||
) : colId === "albums" ? (
|
||||
<MultiSelectFilter
|
||||
placeholder="Albums…"
|
||||
options={albumOptions}
|
||||
value={filters.albumIds}
|
||||
onChange={(next) => {
|
||||
setFilters((f) => ({ ...f, albumIds: next }));
|
||||
setPageIndex(0);
|
||||
}}
|
||||
/>
|
||||
) : colId === "categories" ? (
|
||||
<MultiSelectFilter
|
||||
placeholder="Categories…"
|
||||
@ -721,9 +674,6 @@ export function ArtworksTable() {
|
||||
slug: debouncedSlug || undefined,
|
||||
published: filters.published,
|
||||
needsWork: filters.needsWork,
|
||||
albumIds: filters.albumIds.length
|
||||
? filters.albumIds
|
||||
: undefined,
|
||||
categoryIds: filters.categoryIds.length
|
||||
? filters.categoryIds
|
||||
: undefined,
|
||||
|
||||
Reference in New Issue
Block a user