mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 20:29:06 +00:00
- Migrated all components from useApi compatibility layer to direct React Query hooks - Added new hooks for participant operations, room meetings, and speaker operations - Updated all imports from old api module to api-types - Fixed TypeScript types and API endpoint signatures - Removed deprecated useApi.ts compatibility layer - Fixed SourceKind enum values to match OpenAPI spec - Added @ts-ignore for Zulip endpoints not in OpenAPI spec yet - Fixed all compilation errors and type issues
70 lines
1.5 KiB
TypeScript
70 lines
1.5 KiB
TypeScript
import { GetTranscriptTopicWithWordsPerSpeaker } from "../../lib/api-types";
|
|
import { useTranscriptTopicsWithWordsPerSpeaker } from "../../lib/api-hooks";
|
|
|
|
type ErrorTopicWithWords = {
|
|
error: Error;
|
|
loading: false;
|
|
response: null;
|
|
};
|
|
|
|
type LoadingTopicWithWords = {
|
|
response: GetTranscriptTopicWithWordsPerSpeaker | null;
|
|
loading: true;
|
|
error: false;
|
|
};
|
|
|
|
type SuccessTopicWithWords = {
|
|
response: GetTranscriptTopicWithWordsPerSpeaker;
|
|
loading: false;
|
|
error: null;
|
|
};
|
|
|
|
export type UseTopicWithWords = { refetch: () => void } & (
|
|
| ErrorTopicWithWords
|
|
| LoadingTopicWithWords
|
|
| SuccessTopicWithWords
|
|
);
|
|
|
|
const useTopicWithWords = (
|
|
topicId: string | undefined,
|
|
transcriptId: string,
|
|
): UseTopicWithWords => {
|
|
const {
|
|
data: response,
|
|
isLoading: loading,
|
|
error,
|
|
refetch,
|
|
} = useTranscriptTopicsWithWordsPerSpeaker(
|
|
transcriptId || null,
|
|
topicId || null,
|
|
);
|
|
|
|
// Type-safe return based on state
|
|
if (error) {
|
|
return {
|
|
error: error as Error,
|
|
loading: false,
|
|
response: null,
|
|
refetch,
|
|
} as ErrorTopicWithWords & { refetch: () => void };
|
|
}
|
|
|
|
if (loading || !response) {
|
|
return {
|
|
response: response || null,
|
|
loading: true,
|
|
error: false,
|
|
refetch,
|
|
} as LoadingTopicWithWords & { refetch: () => void };
|
|
}
|
|
|
|
return {
|
|
response,
|
|
loading: false,
|
|
error: null,
|
|
refetch,
|
|
} as SuccessTopicWithWords & { refetch: () => void };
|
|
};
|
|
|
|
export default useTopicWithWords;
|