From cd66d498abb27cda767d242befdd9f67dc2b9aca Mon Sep 17 00:00:00 2001 From: gunshiz Date: Tue, 8 Sep 2026 18:39:39 +0700 Subject: [PATCH] feat : add searchbar to admin --- components/admin/structured-dashboard.tsx | 35 ++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/components/admin/structured-dashboard.tsx b/components/admin/structured-dashboard.tsx index 43eedb9..6626752 100644 --- a/components/admin/structured-dashboard.tsx +++ b/components/admin/structured-dashboard.tsx @@ -7,6 +7,7 @@ import { PlusIcon, RefreshCwIcon, RotateCcwIcon, + SearchIcon, XCircleIcon, Trash2Icon, } from "lucide-react"; @@ -41,6 +42,11 @@ import { EmptyHeader, EmptyTitle, } from "@/components/ui/empty"; +import { + InputGroup, + InputGroupAddon, + InputGroupInput, +} from "@/components/ui/input-group"; import { Spinner } from "@/components/ui/spinner"; import { useAdminPresence } from "@/hooks/use-presence"; import type { CatalogSyncJob } from "@/lib/catalog/sync"; @@ -71,6 +77,7 @@ export function StructuredDashboard({ }) { const router = useRouter(); const [pending, startTransition] = useTransition(); + const [query, setQuery] = useState(""); const [syncJob, setSyncJob] = useState(null); const presence = useAdminPresence(null); const catalogReady = Boolean(catalogVersion); @@ -81,6 +88,12 @@ export function StructuredDashboard({ ); const syncJobId = syncJob?.id; const syncJobStatus = syncJob?.status; + const normalizedQuery = query.trim().toLowerCase(); + const filteredGuides = guides.filter((guide) => + `${guide.name} ${guide.characterKey} ${guide.overview}` + .toLowerCase() + .includes(normalizedQuery), + ); useEffect(() => { if (!syncJobId || !syncJobStatus || ["completed", "unchanged", "cancelled", "error"].includes(syncJobStatus)) return; @@ -187,8 +200,21 @@ export function StructuredDashboard({ ) : null} {guides.length ? ( + + + + + setQuery(event.target.value)} + placeholder="ค้นหาตัวละคร…" + aria-label="ค้นหาตัวละคร" + /> + + ) : null} + {filteredGuides.length ? (
- {guides.map((guide) => ( + {filteredGuides.map((guide) => ( ))}
+ ) : guides.length ? ( + + + ไม่พบตัวละคร + ลองค้นหาด้วยชื่อตัวละครอื่น + + ) : (