mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-21 12:49:06 +00:00
- Create constants.ts for RECORD_A_MEETING_URL - Add api-types.ts for backward compatible type exports - Update all imports from deleted api folder to new locations - Add missing React Query hooks for rooms and zulip operations - Create useApi compatibility layer for unmigrated components
58 lines
1.0 KiB
TypeScript
58 lines
1.0 KiB
TypeScript
import { GetTranscript } from "../../lib/api-types";
|
|
import { useTranscriptGet } from "../../lib/api-hooks";
|
|
|
|
type ErrorTranscript = {
|
|
error: Error;
|
|
loading: false;
|
|
response: null;
|
|
reload: () => void;
|
|
};
|
|
|
|
type LoadingTranscript = {
|
|
response: null;
|
|
loading: true;
|
|
error: false;
|
|
reload: () => void;
|
|
};
|
|
|
|
type SuccessTranscript = {
|
|
response: GetTranscript;
|
|
loading: false;
|
|
error: null;
|
|
reload: () => void;
|
|
};
|
|
|
|
const useTranscript = (
|
|
id: string | null,
|
|
): ErrorTranscript | LoadingTranscript | SuccessTranscript => {
|
|
const { data, isLoading, error, refetch } = useTranscriptGet(id);
|
|
|
|
// Map to the expected return format
|
|
if (isLoading) {
|
|
return {
|
|
response: null,
|
|
loading: true,
|
|
error: false,
|
|
reload: refetch,
|
|
};
|
|
}
|
|
|
|
if (error) {
|
|
return {
|
|
error: error as Error,
|
|
loading: false,
|
|
response: null,
|
|
reload: refetch,
|
|
};
|
|
}
|
|
|
|
return {
|
|
response: data as GetTranscript,
|
|
loading: false,
|
|
error: null,
|
|
reload: refetch,
|
|
};
|
|
};
|
|
|
|
export default useTranscript;
|