mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 20:29:06 +00:00
- Renamed api-hooks.ts to apiHooks.ts to follow camelCase convention - Updated all 21 import statements across the codebase - Maintains consistency with other non-component files (apiClient.tsx, useAuthReady.ts, etc.) - Follows established naming pattern: PascalCase for components, camelCase for utilities/hooks
54 lines
1.3 KiB
TypeScript
54 lines
1.3 KiB
TypeScript
// Wrapper for backward compatibility
|
|
import type { components } from "../../reflector-api";
|
|
type SearchResult = components["schemas"]["SearchResult"];
|
|
type SourceKind = components["schemas"]["SourceKind"];
|
|
import { useTranscriptsSearch } from "../../lib/apiHooks";
|
|
import {
|
|
PaginationPage,
|
|
paginationPageTo0Based,
|
|
} from "../browse/_components/Pagination";
|
|
|
|
interface SearchFilters {
|
|
roomIds: readonly string[] | null;
|
|
sourceKind: SourceKind | null;
|
|
}
|
|
|
|
type UseSearchTranscriptsOptions = {
|
|
pageSize: number;
|
|
page: PaginationPage;
|
|
};
|
|
|
|
interface UseSearchTranscriptsReturn {
|
|
results: SearchResult[];
|
|
totalCount: number;
|
|
isLoading: boolean;
|
|
error: unknown;
|
|
reload: () => void;
|
|
}
|
|
|
|
export function useSearchTranscripts(
|
|
query: string = "",
|
|
filters: SearchFilters = { roomIds: null, sourceKind: null },
|
|
options: UseSearchTranscriptsOptions = {
|
|
pageSize: 20,
|
|
page: PaginationPage(1),
|
|
},
|
|
): UseSearchTranscriptsReturn {
|
|
const { pageSize, page } = options;
|
|
|
|
const { data, isLoading, error, refetch } = useTranscriptsSearch(query, {
|
|
limit: pageSize,
|
|
offset: paginationPageTo0Based(page) * pageSize,
|
|
room_id: filters.roomIds?.[0],
|
|
source_kind: filters.sourceKind || undefined,
|
|
});
|
|
|
|
return {
|
|
results: data?.results || [],
|
|
totalCount: data?.total || 0,
|
|
isLoading,
|
|
error,
|
|
reload: refetch,
|
|
};
|
|
}
|