Files
reflector/www/app/(app)/transcripts/useParticipants.ts
Mathieu Virbel 7ddae5ddd5 refactor: remove api-types.ts compatibility layer
- 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
2025-08-29 16:35:33 -06:00

65 lines
1.3 KiB
TypeScript

import type { components } from "../../reflector-api";
type Participant = components["schemas"]["Participant"];
import { useTranscriptParticipants } from "../../lib/api-hooks";
type ErrorParticipants = {
error: Error;
loading: false;
response: null;
};
type LoadingParticipants = {
response: Participant[] | null;
loading: true;
error: null;
};
type SuccessParticipants = {
response: Participant[];
loading: boolean;
error: null;
};
export type UseParticipants = (
| ErrorParticipants
| LoadingParticipants
| SuccessParticipants
) & { refetch: () => void };
const useParticipants = (transcriptId: string): UseParticipants => {
const {
data: response,
isLoading: loading,
error,
refetch,
} = useTranscriptParticipants(transcriptId || null);
// Type-safe return based on state
if (error) {
return {
error: error as Error,
loading: false,
response: null,
refetch,
} as ErrorParticipants & { refetch: () => void };
}
if (loading || !response) {
return {
response: response || null,
loading: true,
error: null,
refetch,
} as LoadingParticipants & { refetch: () => void };
}
return {
response,
loading: false,
error: null,
refetch,
} as SuccessParticipants & { refetch: () => void };
};
export default useParticipants;