mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-21 20:59:05 +00:00
feat: complete migration from @hey-api/openapi-ts to openapi-react-query
- 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
This commit is contained in:
@@ -1,45 +1,30 @@
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
import { useError } from "../../(errors)/errorContext";
|
||||
import { CreateTranscript, GetTranscript } from "../../lib/api-types";
|
||||
import useApi from "../../lib/useApi";
|
||||
import { useTranscriptCreate } from "../../lib/api-hooks";
|
||||
|
||||
type UseCreateTranscript = {
|
||||
transcript: GetTranscript | null;
|
||||
loading: boolean;
|
||||
error: Error | null;
|
||||
create: (transcriptCreationDetails: CreateTranscript) => void;
|
||||
create: (transcriptCreationDetails: CreateTranscript) => Promise<void>;
|
||||
};
|
||||
|
||||
const useCreateTranscript = (): UseCreateTranscript => {
|
||||
const [transcript, setTranscript] = useState<GetTranscript | null>(null);
|
||||
const [loading, setLoading] = useState<boolean>(false);
|
||||
const [error, setErrorState] = useState<Error | null>(null);
|
||||
const { setError } = useError();
|
||||
const api = useApi();
|
||||
const createMutation = useTranscriptCreate();
|
||||
|
||||
const create = (transcriptCreationDetails: CreateTranscript) => {
|
||||
if (loading || !api) return;
|
||||
const create = async (transcriptCreationDetails: CreateTranscript) => {
|
||||
if (createMutation.isPending) return;
|
||||
|
||||
setLoading(true);
|
||||
|
||||
api
|
||||
.v1TranscriptsCreate({ requestBody: transcriptCreationDetails })
|
||||
.then((transcript) => {
|
||||
setTranscript(transcript);
|
||||
setLoading(false);
|
||||
})
|
||||
.catch((err) => {
|
||||
setError(
|
||||
err,
|
||||
"There was an issue creating a transcript, please try again.",
|
||||
);
|
||||
setErrorState(err);
|
||||
setLoading(false);
|
||||
});
|
||||
await createMutation.mutateAsync({
|
||||
body: transcriptCreationDetails,
|
||||
});
|
||||
};
|
||||
|
||||
return { transcript, loading, error, create };
|
||||
return {
|
||||
transcript: createMutation.data || null,
|
||||
loading: createMutation.isPending,
|
||||
error: createMutation.error as Error | null,
|
||||
create,
|
||||
};
|
||||
};
|
||||
|
||||
export default useCreateTranscript;
|
||||
|
||||
Reference in New Issue
Block a user