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
70 lines
1.3 KiB
TypeScript
70 lines
1.3 KiB
TypeScript
import type { components } from "../../reflector-api";
|
|
import { useTranscriptGet } from "../../lib/api-hooks";
|
|
|
|
type GetTranscript = components["schemas"]["GetTranscript"];
|
|
|
|
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,
|
|
};
|
|
}
|
|
|
|
// Check if data is undefined or null
|
|
if (!data) {
|
|
return {
|
|
response: null,
|
|
loading: true,
|
|
error: false,
|
|
reload: refetch,
|
|
};
|
|
}
|
|
|
|
return {
|
|
response: data as GetTranscript,
|
|
loading: false,
|
|
error: null,
|
|
reload: refetch,
|
|
};
|
|
};
|
|
|
|
export default useTranscript;
|