diff --git a/src/Components/Common/RichTextEditor/AudioRecorder.tsx b/src/Components/Common/RichTextEditor/AudioRecorder.tsx index befd2e6f33f..caaeb5f928b 100644 --- a/src/Components/Common/RichTextEditor/AudioRecorder.tsx +++ b/src/Components/Common/RichTextEditor/AudioRecorder.tsx @@ -8,7 +8,7 @@ const AudioRecorder = ({ modalOpenForAudio, setModalOpenForAudio, }: { - setFile: React.Dispatch>; + setFile: (file: File) => void; modalOpenForAudio: boolean; setModalOpenForAudio: React.Dispatch>; }) => { @@ -23,7 +23,7 @@ const AudioRecorder = ({ type: audioBlob.type, }); setFile(f); - audioBlobExists && setAudioBlobExists(false); + deleteAudioBlob(); }; useEffect(() => { @@ -84,7 +84,6 @@ const AudioRecorder = ({ setAudioBlobExists(false); setAudioResetRecording(true); setModalOpenForAudio(false); - setFile(null); }; return ( diff --git a/src/Components/Common/RichTextEditor/CameraCaptureModal.tsx b/src/Components/Common/RichTextEditor/CameraCaptureModal.tsx index 4c0f3b238b5..55661cfc71f 100644 --- a/src/Components/Common/RichTextEditor/CameraCaptureModal.tsx +++ b/src/Components/Common/RichTextEditor/CameraCaptureModal.tsx @@ -12,7 +12,7 @@ const CameraCaptureModal = ({ }: { open: boolean; onClose: () => void; - setFile: React.Dispatch>; + setFile: (file: File) => void; }) => { const [previewImage, setPreviewImage] = useState(null); const webRef = useRef(null); @@ -51,6 +51,7 @@ const CameraCaptureModal = ({ }; const onUpload = () => { + if (!capture) return; setFile(capture); onClose(); }; diff --git a/src/Components/Common/RichTextEditor/RichTextEditor.tsx b/src/Components/Common/RichTextEditor/RichTextEditor.tsx index 704343cb4db..00a10e7e18d 100644 --- a/src/Components/Common/RichTextEditor/RichTextEditor.tsx +++ b/src/Components/Common/RichTextEditor/RichTextEditor.tsx @@ -24,7 +24,7 @@ import { CreateFileResponse } from "../../Patient/models"; interface RichTextEditorProps { initialMarkdown?: string; onChange: (markdown: string) => void; - onAddNote: () => void; + onAddNote: () => Promise; isAuthorized?: boolean; } @@ -819,6 +819,7 @@ const RichTextEditor: React.FC = ({ id="add_doctor_note_button" onClick={async () => { const id = await onAddNote(); + if (!id) return; for (const file of tempFiles) { await handleFileUpload(file, id); }