30 行
734 B
TypeScript
30 行
734 B
TypeScript
import { apiRequestData } from "./http";
|
|
|
|
export type GlobalSearchHit = {
|
|
entityType:
|
|
| "employee"
|
|
| "announcement"
|
|
| "reimbursement"
|
|
| "leave"
|
|
| "purchase_request"
|
|
| "travel_request"
|
|
| "asset"
|
|
| "project"
|
|
| "contract_registry"
|
|
| "confidential_doc_ref"
|
|
| "weekly_report"
|
|
| "todo";
|
|
entityId: string;
|
|
title: string;
|
|
subtitle: string | null;
|
|
status: string | null;
|
|
href: string;
|
|
matchedBy: "exact" | "prefix" | "contains";
|
|
updatedAt: string | null;
|
|
};
|
|
|
|
export async function searchGlobal(q: string, limit = 10) {
|
|
const params = new URLSearchParams({ q, limit: String(limit) });
|
|
return apiRequestData<{ items: GlobalSearchHit[] }>(`/api/search?${params.toString()}`);
|
|
}
|