mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 12:19:06 +00:00
implement done button
This commit is contained in:
@@ -233,7 +233,9 @@ async def transcript_update(
|
||||
user: Annotated[Optional[auth.UserInfo], Depends(auth.current_user_optional)],
|
||||
):
|
||||
user_id = user["sub"] if user else None
|
||||
transcript = await transcripts_controller.get_by_id(transcript_id, user_id=user_id)
|
||||
transcript = await transcripts_controller.get_by_id_for_http(
|
||||
transcript_id, user_id=user_id
|
||||
)
|
||||
if not transcript:
|
||||
raise HTTPException(status_code=404, detail="Transcript not found")
|
||||
values = info.dict(exclude_unset=True)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"use client";
|
||||
import { useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import TopicHeader from "./topicHeader";
|
||||
import TopicWords from "./topicWords";
|
||||
import TopicPlayer from "./topicPlayer";
|
||||
@@ -8,6 +8,10 @@ import useTopicWithWords from "../../useTopicWithWords";
|
||||
import ParticipantList from "./participantList";
|
||||
import { GetTranscriptTopic } from "../../../../api";
|
||||
import { SelectedText, selectedTextIsTimeSlice } from "./types";
|
||||
import getApi from "../../../../lib/getApi";
|
||||
import useTranscript from "../../useTranscript";
|
||||
import { useError } from "../../../../(errors)/errorContext";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
export type TranscriptCorrect = {
|
||||
params: {
|
||||
@@ -18,12 +22,32 @@ export type TranscriptCorrect = {
|
||||
export default function TranscriptCorrect({
|
||||
params: { transcriptId },
|
||||
}: TranscriptCorrect) {
|
||||
const api = getApi();
|
||||
const transcript = useTranscript(transcriptId);
|
||||
const stateCurrentTopic = useState<GetTranscriptTopic>();
|
||||
const [currentTopic, _sct] = stateCurrentTopic;
|
||||
const stateSelectedText = useState<SelectedText>();
|
||||
const [selectedText, _sst] = stateSelectedText;
|
||||
const topicWithWords = useTopicWithWords(currentTopic?.id, transcriptId);
|
||||
const participants = useParticipants(transcriptId);
|
||||
const { setError } = useError();
|
||||
const router = useRouter();
|
||||
|
||||
const markAsDone = () => {
|
||||
if (transcript.response && !transcript.response.reviewed) {
|
||||
api
|
||||
?.v1TranscriptUpdate({
|
||||
transcriptId,
|
||||
updateTranscript: { reviewed: true },
|
||||
})
|
||||
.then(() => {
|
||||
router.push(`/transcripts/${transcriptId}`);
|
||||
})
|
||||
.catch((e) => {
|
||||
setError(e, "Error marking as done");
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="h-full grid grid-cols-2 gap-4">
|
||||
@@ -55,14 +79,26 @@ export default function TranscriptCorrect({
|
||||
<div></div>
|
||||
)}
|
||||
{participants.response && (
|
||||
<ParticipantList
|
||||
{...{
|
||||
transcriptId,
|
||||
participants,
|
||||
topicWithWords,
|
||||
stateSelectedText,
|
||||
}}
|
||||
/>
|
||||
<div className="h-full flex flex-col justify-between">
|
||||
<ParticipantList
|
||||
{...{
|
||||
transcriptId,
|
||||
participants,
|
||||
topicWithWords,
|
||||
stateSelectedText,
|
||||
}}
|
||||
/>
|
||||
{!transcript.response?.reviewed && (
|
||||
<div className="flex flex-row justify-end">
|
||||
<button
|
||||
className="p-2 px-4 rounded bg-green-400"
|
||||
onClick={markAsDone}
|
||||
>
|
||||
Done
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -8,11 +8,11 @@ import { shouldShowError } from "../../lib/errorUtils";
|
||||
type ErrorTranscript = {
|
||||
error: Error;
|
||||
loading: false;
|
||||
response: any;
|
||||
response: null;
|
||||
};
|
||||
|
||||
type LoadingTranscript = {
|
||||
response: any;
|
||||
response: null;
|
||||
loading: true;
|
||||
error: false;
|
||||
};
|
||||
|
||||
@@ -67,7 +67,6 @@ export const useWebSockets = (transcriptId: string | null): UseWebSockets => {
|
||||
title: "Topic 1: Introduction to Quantum Mechanics",
|
||||
transcript:
|
||||
"A brief overview of quantum mechanics and its principles.",
|
||||
duration: 10,
|
||||
segments: [
|
||||
{
|
||||
speaker: 1,
|
||||
|
||||
@@ -103,6 +103,12 @@ export interface GetTranscript {
|
||||
* @memberof GetTranscript
|
||||
*/
|
||||
participants: any | null;
|
||||
/**
|
||||
*
|
||||
* @type {any}
|
||||
* @memberof GetTranscript
|
||||
*/
|
||||
reviewed: any | null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,6 +129,7 @@ export function instanceOfGetTranscript(value: object): boolean {
|
||||
isInstance = isInstance && "sourceLanguage" in value;
|
||||
isInstance = isInstance && "targetLanguage" in value;
|
||||
isInstance = isInstance && "participants" in value;
|
||||
isInstance = isInstance && "reviewed" in value;
|
||||
|
||||
return isInstance;
|
||||
}
|
||||
@@ -153,6 +160,7 @@ export function GetTranscriptFromJSONTyped(
|
||||
sourceLanguage: json["source_language"],
|
||||
targetLanguage: json["target_language"],
|
||||
participants: json["participants"],
|
||||
reviewed: json["reviewed"],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -178,5 +186,6 @@ export function GetTranscriptToJSON(value?: GetTranscript | null): any {
|
||||
source_language: value.sourceLanguage,
|
||||
target_language: value.targetLanguage,
|
||||
participants: value.participants,
|
||||
reviewed: value.reviewed,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -61,6 +61,12 @@ export interface UpdateTranscript {
|
||||
* @memberof UpdateTranscript
|
||||
*/
|
||||
participants?: any | null;
|
||||
/**
|
||||
*
|
||||
* @type {any}
|
||||
* @memberof UpdateTranscript
|
||||
*/
|
||||
reviewed?: any | null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,6 +103,7 @@ export function UpdateTranscriptFromJSONTyped(
|
||||
participants: !exists(json, "participants")
|
||||
? undefined
|
||||
: json["participants"],
|
||||
reviewed: !exists(json, "reviewed") ? undefined : json["reviewed"],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -115,5 +122,6 @@ export function UpdateTranscriptToJSON(value?: UpdateTranscript | null): any {
|
||||
long_summary: value.longSummary,
|
||||
share_mode: value.shareMode,
|
||||
participants: value.participants,
|
||||
reviewed: value.reviewed,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user