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: Annotated[Optional[auth.UserInfo], Depends(auth.current_user_optional)],
|
||||||
):
|
):
|
||||||
user_id = user["sub"] if user else None
|
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:
|
if not transcript:
|
||||||
raise HTTPException(status_code=404, detail="Transcript not found")
|
raise HTTPException(status_code=404, detail="Transcript not found")
|
||||||
values = info.dict(exclude_unset=True)
|
values = info.dict(exclude_unset=True)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import { useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import TopicHeader from "./topicHeader";
|
import TopicHeader from "./topicHeader";
|
||||||
import TopicWords from "./topicWords";
|
import TopicWords from "./topicWords";
|
||||||
import TopicPlayer from "./topicPlayer";
|
import TopicPlayer from "./topicPlayer";
|
||||||
@@ -8,6 +8,10 @@ import useTopicWithWords from "../../useTopicWithWords";
|
|||||||
import ParticipantList from "./participantList";
|
import ParticipantList from "./participantList";
|
||||||
import { GetTranscriptTopic } from "../../../../api";
|
import { GetTranscriptTopic } from "../../../../api";
|
||||||
import { SelectedText, selectedTextIsTimeSlice } from "./types";
|
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 = {
|
export type TranscriptCorrect = {
|
||||||
params: {
|
params: {
|
||||||
@@ -18,12 +22,32 @@ export type TranscriptCorrect = {
|
|||||||
export default function TranscriptCorrect({
|
export default function TranscriptCorrect({
|
||||||
params: { transcriptId },
|
params: { transcriptId },
|
||||||
}: TranscriptCorrect) {
|
}: TranscriptCorrect) {
|
||||||
|
const api = getApi();
|
||||||
|
const transcript = useTranscript(transcriptId);
|
||||||
const stateCurrentTopic = useState<GetTranscriptTopic>();
|
const stateCurrentTopic = useState<GetTranscriptTopic>();
|
||||||
const [currentTopic, _sct] = stateCurrentTopic;
|
const [currentTopic, _sct] = stateCurrentTopic;
|
||||||
const stateSelectedText = useState<SelectedText>();
|
const stateSelectedText = useState<SelectedText>();
|
||||||
const [selectedText, _sst] = stateSelectedText;
|
const [selectedText, _sst] = stateSelectedText;
|
||||||
const topicWithWords = useTopicWithWords(currentTopic?.id, transcriptId);
|
const topicWithWords = useTopicWithWords(currentTopic?.id, transcriptId);
|
||||||
const participants = useParticipants(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 (
|
return (
|
||||||
<div className="h-full grid grid-cols-2 gap-4">
|
<div className="h-full grid grid-cols-2 gap-4">
|
||||||
@@ -55,14 +79,26 @@ export default function TranscriptCorrect({
|
|||||||
<div></div>
|
<div></div>
|
||||||
)}
|
)}
|
||||||
{participants.response && (
|
{participants.response && (
|
||||||
<ParticipantList
|
<div className="h-full flex flex-col justify-between">
|
||||||
{...{
|
<ParticipantList
|
||||||
transcriptId,
|
{...{
|
||||||
participants,
|
transcriptId,
|
||||||
topicWithWords,
|
participants,
|
||||||
stateSelectedText,
|
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>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ import { shouldShowError } from "../../lib/errorUtils";
|
|||||||
type ErrorTranscript = {
|
type ErrorTranscript = {
|
||||||
error: Error;
|
error: Error;
|
||||||
loading: false;
|
loading: false;
|
||||||
response: any;
|
response: null;
|
||||||
};
|
};
|
||||||
|
|
||||||
type LoadingTranscript = {
|
type LoadingTranscript = {
|
||||||
response: any;
|
response: null;
|
||||||
loading: true;
|
loading: true;
|
||||||
error: false;
|
error: false;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -67,7 +67,6 @@ export const useWebSockets = (transcriptId: string | null): UseWebSockets => {
|
|||||||
title: "Topic 1: Introduction to Quantum Mechanics",
|
title: "Topic 1: Introduction to Quantum Mechanics",
|
||||||
transcript:
|
transcript:
|
||||||
"A brief overview of quantum mechanics and its principles.",
|
"A brief overview of quantum mechanics and its principles.",
|
||||||
duration: 10,
|
|
||||||
segments: [
|
segments: [
|
||||||
{
|
{
|
||||||
speaker: 1,
|
speaker: 1,
|
||||||
|
|||||||
@@ -103,6 +103,12 @@ export interface GetTranscript {
|
|||||||
* @memberof GetTranscript
|
* @memberof GetTranscript
|
||||||
*/
|
*/
|
||||||
participants: any | null;
|
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 && "sourceLanguage" in value;
|
||||||
isInstance = isInstance && "targetLanguage" in value;
|
isInstance = isInstance && "targetLanguage" in value;
|
||||||
isInstance = isInstance && "participants" in value;
|
isInstance = isInstance && "participants" in value;
|
||||||
|
isInstance = isInstance && "reviewed" in value;
|
||||||
|
|
||||||
return isInstance;
|
return isInstance;
|
||||||
}
|
}
|
||||||
@@ -153,6 +160,7 @@ export function GetTranscriptFromJSONTyped(
|
|||||||
sourceLanguage: json["source_language"],
|
sourceLanguage: json["source_language"],
|
||||||
targetLanguage: json["target_language"],
|
targetLanguage: json["target_language"],
|
||||||
participants: json["participants"],
|
participants: json["participants"],
|
||||||
|
reviewed: json["reviewed"],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,5 +186,6 @@ export function GetTranscriptToJSON(value?: GetTranscript | null): any {
|
|||||||
source_language: value.sourceLanguage,
|
source_language: value.sourceLanguage,
|
||||||
target_language: value.targetLanguage,
|
target_language: value.targetLanguage,
|
||||||
participants: value.participants,
|
participants: value.participants,
|
||||||
|
reviewed: value.reviewed,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,6 +61,12 @@ export interface UpdateTranscript {
|
|||||||
* @memberof UpdateTranscript
|
* @memberof UpdateTranscript
|
||||||
*/
|
*/
|
||||||
participants?: any | null;
|
participants?: any | null;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {any}
|
||||||
|
* @memberof UpdateTranscript
|
||||||
|
*/
|
||||||
|
reviewed?: any | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -97,6 +103,7 @@ export function UpdateTranscriptFromJSONTyped(
|
|||||||
participants: !exists(json, "participants")
|
participants: !exists(json, "participants")
|
||||||
? undefined
|
? undefined
|
||||||
: json["participants"],
|
: json["participants"],
|
||||||
|
reviewed: !exists(json, "reviewed") ? undefined : json["reviewed"],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,5 +122,6 @@ export function UpdateTranscriptToJSON(value?: UpdateTranscript | null): any {
|
|||||||
long_summary: value.longSummary,
|
long_summary: value.longSummary,
|
||||||
share_mode: value.shareMode,
|
share_mode: value.shareMode,
|
||||||
participants: value.participants,
|
participants: value.participants,
|
||||||
|
reviewed: value.reviewed,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user