mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 20:29:06 +00:00
- Replace @hey-api/openapi-ts with openapi-typescript and openapi-react-query - Generate TypeScript types from OpenAPI spec - Set up React Query infrastructure with QueryClientProvider - Migrate all API hooks to use React Query patterns - Maintain backward compatibility for existing components - Remove old API infrastructure and dependencies
52 lines
1.2 KiB
TypeScript
52 lines
1.2 KiB
TypeScript
// Wrapper for backward compatibility
|
|
import { SearchResult, SourceKind } from "../../api";
|
|
import { useTranscriptsSearch } from "../../lib/api-hooks";
|
|
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,
|
|
};
|
|
}
|