www: fix loading of past transcript before the user is authenticated

This commit is contained in:
2023-10-24 20:23:10 +02:00
committed by Mathieu Virbel
parent 220b9811af
commit 93ba1b450c
5 changed files with 31 additions and 29 deletions

View File

@@ -1,11 +1,7 @@
import { useEffect, useState } from "react";
import {
V1TranscriptGetRequest,
V1TranscriptsCreateRequest,
} from "../api/apis/DefaultApi";
import { DefaultApi, V1TranscriptGetRequest } from "../api/apis/DefaultApi";
import { GetTranscript } from "../api";
import { useError } from "../(errors)/errorContext";
import getApi from "../lib/getApi";
type Transcript = {
response: GetTranscript | null;
@@ -13,15 +9,14 @@ type Transcript = {
error: Error | null;
};
const useTranscript = (id: string | null): Transcript => {
const useTranscript = (api: DefaultApi, id: string | null): Transcript => {
const [response, setResponse] = useState<GetTranscript | null>(null);
const [loading, setLoading] = useState<boolean>(false);
const [error, setErrorState] = useState<Error | null>(null);
const { setError } = useError();
const api = getApi();
const getTranscript = (id: string | null) => {
if (!id) throw new Error("Transcript ID is required to get transcript");
if (!id) return;
setLoading(true);
const requestParameters: V1TranscriptGetRequest = {