mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-21 12:49:06 +00:00
More robust error handling & Display errors to user
This commit is contained in:
@@ -1,19 +1,18 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { DefaultApi, V1TranscriptsCreateRequest } from "../api/apis/DefaultApi";
|
||||
import { GetTranscript } from "../api";
|
||||
import getApi from "../lib/getApi";
|
||||
import { useError } from "../(errors)/errorContext";
|
||||
|
||||
type UseTranscript = {
|
||||
response: GetTranscript | null;
|
||||
loading: boolean;
|
||||
error: string | null;
|
||||
createTranscript: () => void;
|
||||
};
|
||||
|
||||
const useTranscript = (api: DefaultApi): UseTranscript => {
|
||||
const [response, setResponse] = useState<GetTranscript | null>(null);
|
||||
const [loading, setLoading] = useState<boolean>(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const { setError } = useError();
|
||||
|
||||
const createTranscript = () => {
|
||||
setLoading(true);
|
||||
@@ -48,7 +47,7 @@ const useTranscript = (api: DefaultApi): UseTranscript => {
|
||||
createTranscript();
|
||||
}, []);
|
||||
|
||||
return { response, loading, error, createTranscript };
|
||||
return { response, loading, createTranscript };
|
||||
};
|
||||
|
||||
export default useTranscript;
|
||||
|
||||
Reference in New Issue
Block a user