Refactor code

This commit is contained in:
2026-01-31 16:04:29 +01:00
parent eb8dcd54a8
commit c712f31759
15 changed files with 14 additions and 67 deletions

View File

@ -26,6 +26,7 @@ export default function RawCloseButton({ targetHref }: RawCloseButtonProps) {
onClick={() => router.push(targetHref)}
className="absolute top-4 right-4 z-50 rounded-md bg-background/80 p-2 hover:bg-background/60 transition"
title="Close full view (ESC)"
type="button"
>
<X className="w-6 h-6" />
</button>

View File

@ -25,7 +25,6 @@ type Tag = {
slug: string;
sortIndex: number;
parentId: string | null;
// these may exist, but we do NOT rely on them:
parent?: { id: string; name: string; slug: string; sortIndex: number } | null;
children?: { id: string; name: string; slug: string; sortIndex: number; parentId: string | null }[];
};
@ -65,7 +64,6 @@ export default function TagFilterDialog({
const byId = useMemo(() => new Map(tags.map((t) => [t.id, t])), [tags]);
// Build children mapping from the flat list: parentId -> Tag[]
const childrenByParentId = useMemo(() => {
const map = new Map<string, Tag[]>();
for (const t of tags) {
@ -74,7 +72,6 @@ export default function TagFilterDialog({
arr.push(t);
map.set(t.parentId, arr);
}
// sort each child list
for (const [k, arr] of map) {
map.set(k, arr.slice().sort(sortTags));
}
@ -101,7 +98,6 @@ export default function TagFilterDialog({
const s = new Set(prev);
if (next) {
s.add(parent.slug);
// when selecting parent, remove child selections (redundant)
for (const c of children) s.delete(c.slug);
} else {
s.delete(parent.slug);
@ -188,9 +184,6 @@ export default function TagFilterDialog({
/>
<div className="min-w-0">
<div className="truncate font-medium">{p.name}</div>
{/* <div className="text-xs text-muted-foreground">
{children.length ? "Parent tag" : "Tag"}
</div> */}
</div>
</Label>
@ -231,11 +224,6 @@ export default function TagFilterDialog({
{orphanChildren.length ? (
<div className="rounded-lg border p-4">
{/* <div className="mb-2 font-medium">Other tags</div> */}
{/* <div className="mb-3 text-xs text-muted-foreground">
These tags are not currently assigned to a visible parent.
</div> */}
<div className="grid grid-cols-1 gap-2 sm:grid-cols-2">
{orphanChildren.map((t) => {
const checked = selectedSet.has(t.slug);