From 68e708f62b93ffbe25454299477dd74c4f8e2377 Mon Sep 17 00:00:00 2001 From: Sara Date: Wed, 24 Jan 2024 13:57:16 +0100 Subject: [PATCH] player and share --- .../[transcriptId]/finalSummary.tsx | 162 ++++++++---------- .../transcripts/[transcriptId]/page.tsx | 33 ++-- www/app/[domain]/transcripts/player.tsx | 101 +++++++---- .../[domain]/transcripts/shareAndPrivacy.tsx | 148 ++++++++++++++++ www/app/[domain]/transcripts/shareCopy.tsx | 62 +++++++ www/app/[domain]/transcripts/shareLink.tsx | 120 +++---------- .../[domain]/transcripts/shareTranscript.tsx | 108 ------------ www/app/[domain]/transcripts/shareZulip.tsx | 30 ++++ www/app/[domain]/transcripts/topicList.tsx | 48 ++++-- www/app/providers.tsx | 2 +- www/app/styles/icons/pause.tsx | 14 ++ www/app/styles/icons/play.tsx | 12 ++ www/app/styles/recorder.js | 20 ++- www/app/{ => styles}/theme.ts | 54 +++--- 14 files changed, 516 insertions(+), 398 deletions(-) create mode 100644 www/app/[domain]/transcripts/shareAndPrivacy.tsx create mode 100644 www/app/[domain]/transcripts/shareCopy.tsx delete mode 100644 www/app/[domain]/transcripts/shareTranscript.tsx create mode 100644 www/app/[domain]/transcripts/shareZulip.tsx create mode 100644 www/app/styles/icons/pause.tsx create mode 100644 www/app/styles/icons/play.tsx rename www/app/{ => styles}/theme.ts (61%) diff --git a/www/app/[domain]/transcripts/[transcriptId]/finalSummary.tsx b/www/app/[domain]/transcripts/[transcriptId]/finalSummary.tsx index 8d7311f1..afde0aac 100644 --- a/www/app/[domain]/transcripts/[transcriptId]/finalSummary.tsx +++ b/www/app/[domain]/transcripts/[transcriptId]/finalSummary.tsx @@ -2,41 +2,50 @@ import { useEffect, useRef, useState } from "react"; import React from "react"; import Markdown from "react-markdown"; import "../../../styles/markdown.css"; -import { UpdateTranscript } from "../../../api"; +import { + GetTranscript, + GetTranscriptTopic, + UpdateTranscript, +} from "../../../api"; import useApi from "../../../lib/useApi"; -import useTranscript from "../useTranscript"; -import useTopics from "../useTopics"; -import { Box, Flex, IconButton, Modal, ModalContent } from "@chakra-ui/react"; -import { FaShare } from "react-icons/fa"; -import ShareTranscript from "../shareTranscript"; +import { + Flex, + Heading, + IconButton, + Button, + Textarea, + Spacer, +} from "@chakra-ui/react"; +import { FaPen } from "react-icons/fa"; +import { useError } from "../../../(errors)/errorContext"; +import ShareAndPrivacy from "../shareAndPrivacy"; type FinalSummaryProps = { - transcriptId: string; + transcriptResponse: GetTranscript; + topicsResponse: GetTranscriptTopic[]; }; export default function FinalSummary(props: FinalSummaryProps) { - const transcript = useTranscript(props.transcriptId); - const topics = useTopics(props.transcriptId); - const finalSummaryRef = useRef(null); const [isEditMode, setIsEditMode] = useState(false); const [preEditSummary, setPreEditSummary] = useState(""); const [editedSummary, setEditedSummary] = useState(""); - const [showShareModal, setShowShareModal] = useState(false); + const api = useApi(); + + const { setError } = useError(); useEffect(() => { - setEditedSummary(transcript.response?.long_summary || ""); - }, [transcript.response?.long_summary]); + setEditedSummary(props.transcriptResponse?.long_summary || ""); + }, [props.transcriptResponse?.long_summary]); - if (!topics.topics || !transcript.response) { + if (!props.topicsResponse || !props.transcriptResponse) { return null; } const updateSummary = async (newSummary: string, transcriptId: string) => { try { - const api = useApi(); const requestBody: UpdateTranscript = { long_summary: newSummary, }; @@ -47,6 +56,7 @@ export default function FinalSummary(props: FinalSummaryProps) { console.log("Updated long summary:", updatedTranscript); } catch (err) { console.error("Failed to update long summary:", err); + setError(err, "Failed to update long summary."); } }; @@ -61,7 +71,7 @@ export default function FinalSummary(props: FinalSummaryProps) { }; const onSaveClick = () => { - updateSummary(editedSummary, props.transcriptId); + updateSummary(editedSummary, props.transcriptResponse.id); setIsEditMode(false); }; @@ -77,86 +87,64 @@ export default function FinalSummary(props: FinalSummaryProps) { }; return ( -
-
-

- Final Summary -

+ + Summary -
- {isEditMode && ( - <> - - - - )} + {isEditMode && ( + <> + + + + + )} - {!isEditMode && ( - <> - - } - onClick={() => setShowShareModal(true)} - aria-label="Share" - /> - {showShareModal && ( - setShowShareModal(false)} - size="xl" - > - - - - - )} - - )} -
-
+ {!isEditMode && ( + <> + } + aria-label="Edit Summary" + onClick={onEditClick} + /> + + + + )} + {isEditMode ? ( -
-