fix: address CTO review feedback on quick-find search (GH #97, GRO-134)
- Remove unused makeSelectChain function from search.test.ts (lint blocker)
- Fix handleClientClick/handlePetClick to navigate to /admin/clients?highlight={id}
so the target client is identified in the URL rather than silently ignored
- Add console.warn for fetch errors in GlobalSearch instead of swallowing silently
Auth middleware verified: searchRouter is registered on the api Hono instance
which applies authMiddleware + resolveStaffMiddleware globally — no coverage gap.
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -34,16 +34,6 @@ vi.mock("@groombook/db", () => {
|
|||||||
const clients = tableProxy("clients");
|
const clients = tableProxy("clients");
|
||||||
const pets = tableProxy("pets");
|
const pets = tableProxy("pets");
|
||||||
|
|
||||||
function makeSelectChain(results: unknown[]): unknown {
|
|
||||||
const chain: Record<string, unknown> = {};
|
|
||||||
const terminal = () => Promise.resolve(results);
|
|
||||||
chain.from = () => chain;
|
|
||||||
chain.innerJoin = () => chain;
|
|
||||||
chain.where = () => chain;
|
|
||||||
chain.limit = terminal;
|
|
||||||
return chain;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
getDb: () => ({
|
getDb: () => ({
|
||||||
select: (_fields?: unknown) => {
|
select: (_fields?: unknown) => {
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ export function GlobalSearch() {
|
|||||||
setResults(data);
|
setResults(data);
|
||||||
setOpen(true);
|
setOpen(true);
|
||||||
}
|
}
|
||||||
} catch {
|
} catch (err) {
|
||||||
// ignore fetch errors
|
console.warn("GlobalSearch: fetch error", err);
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
@@ -83,13 +83,13 @@ export function GlobalSearch() {
|
|||||||
function handleClientClick(client: ClientResult) {
|
function handleClientClick(client: ClientResult) {
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
setQuery("");
|
setQuery("");
|
||||||
navigate("/admin/clients");
|
navigate(`/admin/clients?highlight=${client.id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handlePetClick(pet: PetResult) {
|
function handlePetClick(pet: PetResult) {
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
setQuery("");
|
setQuery("");
|
||||||
navigate("/admin/clients");
|
navigate(`/admin/clients?highlight=${pet.clientId}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const hasResults = results && (results.clients.length > 0 || results.pets.length > 0);
|
const hasResults = results && (results.clients.length > 0 || results.pets.length > 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user