Files
reflector/www/app/(app)/transcripts/useSearchTranscripts.ts
Mathieu Virbel d479d9d4e6 refactor: rename api-hooks.ts to apiHooks.ts for consistency
- 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
2025-08-29 16:44:21 -06:00

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,
};
}