diff --git a/src/Components/Case/CaseDetailsPage.js b/src/Components/Case/CaseDetailsPage.js index 428bb33..8ddf861 100644 --- a/src/Components/Case/CaseDetailsPage.js +++ b/src/Components/Case/CaseDetailsPage.js @@ -20,7 +20,8 @@ const CaseDetailsPage = () => { const { appState } = useContext(AppContext); const { group } = appState; const appUserId = group ? group.appUserId : null; - const message = "Parsing document. This may take several minutes."; + const message = + "Parsing document. Please be patient, this may take several minutes."; const handleNavigate = () => { navigate("/documents"); diff --git a/src/Components/Document/DocEditPage.js b/src/Components/Document/DocEditPage.js index a46e787..d5dc72d 100644 --- a/src/Components/Document/DocEditPage.js +++ b/src/Components/Document/DocEditPage.js @@ -6,13 +6,16 @@ import { Link, useNavigate } from "react-router-dom"; import EditElement from "../../pageElements/EditElement"; import { db } from "../../firebase"; import { + collection, updateDoc, onSnapshot, doc, getDoc, + setDoc, increment, } from "firebase/firestore"; import { AppContext } from "../../Hooks/useContext/appContext"; + import Button from "../../pageElements/Button"; import ConfirmModal from "../Modals/ConfirmModal"; import LoadingSpinner from "../../pageElements/LoadingSpinner"; @@ -35,6 +38,8 @@ const DocEditPage = () => { const [saveDocumentId, setSaveDocumentId] = useState(""); const [showSaveModal, setShowSaveModal] = useState(false); const [isLoading, setIsLoading] = useState(false); + const [isReport, setIsReport] = useState(false); + const [issueText, setIssueText] = useState(""); const [responsesCreated, setResponsesCreated] = useState( parseInt(responseGenerations) ); @@ -107,7 +112,6 @@ const DocEditPage = () => { const messages = [ "Generating responses. Please be patient, this may take several minutes.", - 'Do not click "back" on your browser.', ]; /* @@ -511,6 +515,31 @@ const DocEditPage = () => { setShowSaveModal(true); }; + const handleReport = () => { + setShowSaveModal(false); + setIsReport(false); + }; + + const handleConfirmReport = () => { + setShowSaveModal(true); + setIsReport(true); + }; + + async function reportDoc() { + const data = { + documentId: documentId, + caseId: caseId, + appUserId: appUserId, + issueDescription: issueText, + }; + try { + const reportRef = collection(db, "supportrequests"); + await setDoc(doc(reportRef, documentId), data); + } catch (err) { + console.log("Error saving case to db:", err); + } + } + const onScrollClick = () => { const bottom = window.document.scrollingElement.scrollHeight; const place = window.scrollY; @@ -544,7 +573,7 @@ const DocEditPage = () => { fetchedCase?.clientPosition == "Defendant" ? fetchedCase?.plaintiffParties : fetchedCase?.defendantParties; - console.log("parsedRogs", parsedRogs); + const editingContent = () => { return ( <> @@ -587,6 +616,12 @@ const DocEditPage = () => { ))} +
handleConfirmReport()} + > +
Report an issue
+
{/* TODO: add tooltip: "This will save the document and create a .docx file that will (be downloaded? saved somewhere?" */} @@ -615,7 +650,7 @@ const DocEditPage = () => {
- {showSaveModal && documentId !== null ? ( + {showSaveModal && !isReport && documentId !== null ? ( { } /> ) : null} + {showSaveModal && isReport && documentId !== null ? ( + + ) : null} ); }; diff --git a/src/Components/Modals/ConfirmModal.js b/src/Components/Modals/ConfirmModal.js index 0e86c23..62c2c94 100644 --- a/src/Components/Modals/ConfirmModal.js +++ b/src/Components/Modals/ConfirmModal.js @@ -1,19 +1,51 @@ +import { useState } from "react"; import Button from "../../pageElements/Button"; import Modal from "react-bootstrap/Modal"; +import TextInput from "../../pageElements/TextInput"; +import { db } from "../../firebase"; const ConfirmModal = ({ onCancel, onConfirm, buttonLabelText, modalText, isBusy, + isReport, + appUserId, + caseId, + documentId, + issueText, + setIssueText, + reportDoc, }) => { + console.log("isReport", isReport); + return ( - Confirmation + {isReport ? ( + Report an issue + ) : ( + Confirmation + )} - {modalText} + + {modalText} + {isReport ? ( +
+ setIssueText(e.target.value)} + label={issueText ? "" : "Description of issue"} + /> +
+ ) : ( + <> + )} +