From e27baeb7f4bdd4817e95db937c13ac32e0f2bac4 Mon Sep 17 00:00:00 2001 From: Koper Date: Mon, 30 Oct 2023 18:57:32 +0000 Subject: [PATCH] Finished UI --- www/app/[domain]/transcripts/finalSummary.tsx | 135 ++++++++++++------ .../[domain]/transcripts/transcriptTitle.tsx | 63 ++++++-- 2 files changed, 146 insertions(+), 52 deletions(-) diff --git a/www/app/[domain]/transcripts/finalSummary.tsx b/www/app/[domain]/transcripts/finalSummary.tsx index 9f8e4f82..b60a42cd 100644 --- a/www/app/[domain]/transcripts/finalSummary.tsx +++ b/www/app/[domain]/transcripts/finalSummary.tsx @@ -16,12 +16,12 @@ export default function FinalSummary(props: FinalSummaryProps) { const [isCopiedSummary, setIsCopiedSummary] = useState(false); const [isCopiedTranscript, setIsCopiedTranscript] = useState(false); const [isEditMode, setIsEditMode] = useState(false); + const [preEditSummary, setPreEditSummary] = useState(props.summary); const [editedSummary, setEditedSummary] = useState(props.summary); const api = getApi(props.protectedPath); const updateSummary = async (newSummary: string, transcriptId: string) => { try { - setEditedSummary(newSummary); const updatedTranscript = await api.v1TranscriptUpdate({ transcriptId, updateTranscript: { @@ -34,7 +34,7 @@ export default function FinalSummary(props: FinalSummaryProps) { } }; - const handleCopySummaryClick = () => { + const onCopySummaryClick = () => { let text_to_copy = finalSummaryRef.current?.innerText; text_to_copy && @@ -45,7 +45,7 @@ export default function FinalSummary(props: FinalSummaryProps) { }); }; - const handleCopyTranscriptClick = () => { + const onCopyTranscriptClick = () => { let text_to_copy = props.fullTranscript; text_to_copy && @@ -56,58 +56,113 @@ export default function FinalSummary(props: FinalSummaryProps) { }); }; - const handleEditMode = () => { - setIsEditMode(!isEditMode); + const onEditClick = () => { + setPreEditSummary(editedSummary); + setIsEditMode(true); + }; + + const onDiscardClick = () => { + setEditedSummary(preEditSummary); + setIsEditMode(false); + }; + + const onSaveClick = () => { + updateSummary(editedSummary, props.transcriptId); + setIsEditMode(false); + }; + + const handleTextAreaKeyDown = (e: React.KeyboardEvent) => { + if (e.key === "Escape") { + onDiscardClick(); + } + + if (e.key === "Enter" && e.shiftKey) { + onSaveClick(); + e.preventDefault(); // prevent the default action of adding a new line + } }; return ( -
+

Final Summary

+
- - - + {isEditMode && ( + <> + + + + )} + + {!isEditMode && ( + <> + + + + + )}
+ {isEditMode ? ( -