changes types, assign to participant instead of speaker

This commit is contained in:
Sara
2023-12-12 13:29:55 +01:00
parent d8c4f29d72
commit c02c3b190c
7 changed files with 312 additions and 224 deletions

View File

@@ -1,6 +1,13 @@
import { useEffect, useState } from "react";
import { V1TranscriptGetTopicsWithWordsRequest } from "../../api/apis/DefaultApi";
import { GetTranscript, GetTranscriptTopicWithWords } from "../../api";
import {
V1TranscriptGetTopicsWithWordsPerSpeakerRequest,
V1TranscriptGetTopicsWithWordsRequest,
} from "../../api/apis/DefaultApi";
import {
GetTranscript,
GetTranscriptTopicWithWords,
GetTranscriptTopicWithWordsPerSpeaker,
} from "../../api";
import { useError } from "../../(errors)/errorContext";
import getApi from "../../lib/getApi";
import { shouldShowError } from "../../lib/errorUtils";
@@ -8,22 +15,22 @@ import { shouldShowError } from "../../lib/errorUtils";
type ErrorTopicWithWords = {
error: Error;
loading: false;
response: any;
response: null;
};
type LoadingTopicWithWords = {
response: any;
response: GetTranscriptTopicWithWordsPerSpeaker | null;
loading: true;
error: false;
};
type SuccessTopicWithWords = {
response: GetTranscriptTopicWithWords;
response: GetTranscriptTopicWithWordsPerSpeaker;
loading: false;
error: null;
};
type UseTopicWithWords = { refetch: () => void } & (
export type UseTopicWithWords = { refetch: () => void } & (
| ErrorTopicWithWords
| LoadingTopicWithWords
| SuccessTopicWithWords
@@ -33,7 +40,8 @@ const useTopicWithWords = (
topicId: string | null,
transcriptId: string,
): UseTopicWithWords => {
const [response, setResponse] = useState<GetTranscript | null>(null);
const [response, setResponse] =
useState<GetTranscriptTopicWithWordsPerSpeaker | null>(null);
const [loading, setLoading] = useState<boolean>(true);
const [error, setErrorState] = useState<Error | null>(null);
const { setError } = useError();
@@ -55,13 +63,14 @@ const useTopicWithWords = (
if (!transcriptId || !topicId || !api) return;
setLoading(true);
const requestParameters: V1TranscriptGetTopicsWithWordsRequest = {
const requestParameters: V1TranscriptGetTopicsWithWordsPerSpeakerRequest = {
transcriptId,
topicId,
};
api
.v1TranscriptGetTopicsWithWords(requestParameters)
.v1TranscriptGetTopicsWithWordsPerSpeaker(requestParameters)
.then((result) => {
setResponse(result.find((topic) => topic.id == topicId));
setResponse(result);
setLoading(false);
console.debug("Topics with words Loaded:", result);
})