mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 20:29:06 +00:00
- Migrated all 29 files from api-types.ts to use reflector-api.d.ts directly
- Removed $SourceKind manual enum in favor of OpenAPI-generated types
- Fixed unrelated Spinner component TypeScript error in AuthWrapper.tsx
- All imports now use: import type { components } from "path/to/reflector-api"
- Deleted api-types.ts file completely
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/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,
|
|
};
|
|
}
|