more
This commit is contained in:
@@ -6,13 +6,16 @@ import { Link, useNavigate } from "react-router-dom";
|
|||||||
import EditElement from "../../pageElements/EditElement";
|
import EditElement from "../../pageElements/EditElement";
|
||||||
import { db } from "../../firebase";
|
import { db } from "../../firebase";
|
||||||
import {
|
import {
|
||||||
|
collection,
|
||||||
updateDoc,
|
updateDoc,
|
||||||
onSnapshot,
|
onSnapshot,
|
||||||
doc,
|
doc,
|
||||||
getDoc,
|
getDoc,
|
||||||
|
setDoc,
|
||||||
increment,
|
increment,
|
||||||
} from "firebase/firestore";
|
} from "firebase/firestore";
|
||||||
import { AppContext } from "../../Hooks/useContext/appContext";
|
import { AppContext } from "../../Hooks/useContext/appContext";
|
||||||
|
|
||||||
import Button from "../../pageElements/Button";
|
import Button from "../../pageElements/Button";
|
||||||
import ConfirmModal from "../Modals/ConfirmModal";
|
import ConfirmModal from "../Modals/ConfirmModal";
|
||||||
import LoadingSpinner from "../../pageElements/LoadingSpinner";
|
import LoadingSpinner from "../../pageElements/LoadingSpinner";
|
||||||
@@ -36,6 +39,7 @@ const DocEditPage = () => {
|
|||||||
const [showSaveModal, setShowSaveModal] = useState(false);
|
const [showSaveModal, setShowSaveModal] = useState(false);
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [isReport, setIsReport] = useState(false);
|
const [isReport, setIsReport] = useState(false);
|
||||||
|
const [issueText, setIssueText] = useState("");
|
||||||
const [responsesCreated, setResponsesCreated] = useState(
|
const [responsesCreated, setResponsesCreated] = useState(
|
||||||
parseInt(responseGenerations)
|
parseInt(responseGenerations)
|
||||||
);
|
);
|
||||||
@@ -511,10 +515,28 @@ const DocEditPage = () => {
|
|||||||
setShowSaveModal(true);
|
setShowSaveModal(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleReport = () => {};
|
||||||
|
|
||||||
const handleConfirmReport = () => {
|
const handleConfirmReport = () => {
|
||||||
setShowSaveModal(true);
|
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 onScrollClick = () => {
|
||||||
const bottom = window.document.scrollingElement.scrollHeight;
|
const bottom = window.document.scrollingElement.scrollHeight;
|
||||||
const place = window.scrollY;
|
const place = window.scrollY;
|
||||||
@@ -548,7 +570,7 @@ const DocEditPage = () => {
|
|||||||
fetchedCase?.clientPosition == "Defendant"
|
fetchedCase?.clientPosition == "Defendant"
|
||||||
? fetchedCase?.plaintiffParties
|
? fetchedCase?.plaintiffParties
|
||||||
: fetchedCase?.defendantParties;
|
: fetchedCase?.defendantParties;
|
||||||
console.log("parsedRogs", parsedRogs);
|
|
||||||
const editingContent = () => {
|
const editingContent = () => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -625,7 +647,7 @@ const DocEditPage = () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{showSaveModal && documentId !== null ? (
|
{showSaveModal && !isReport && documentId !== null ? (
|
||||||
<ConfirmModal
|
<ConfirmModal
|
||||||
onCancel={handleCancelSave}
|
onCancel={handleCancelSave}
|
||||||
onConfirm={handleSave}
|
onConfirm={handleSave}
|
||||||
@@ -637,11 +659,17 @@ const DocEditPage = () => {
|
|||||||
) : null}
|
) : null}
|
||||||
{showSaveModal && isReport && documentId !== null ? (
|
{showSaveModal && isReport && documentId !== null ? (
|
||||||
<ConfirmModal
|
<ConfirmModal
|
||||||
|
isReport={isReport}
|
||||||
onCancel={handleCancelSave}
|
onCancel={handleCancelSave}
|
||||||
onConfirm={handleSave}
|
onConfirm={handleReport}
|
||||||
buttonLabelText="Confirm Save"
|
buttonLabelText="Report Issue"
|
||||||
|
documentId={documentId}
|
||||||
|
caseId={caseId}
|
||||||
|
appUserId={appUserId}
|
||||||
|
issuetext={issueText}
|
||||||
|
setIssueText={setIssueText}
|
||||||
modalText={
|
modalText={
|
||||||
"Are you sure? This will overrwrite any previously-saved edits."
|
"Please describe the issue. Other pertinent information will be automatically logged."
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
|
import { useState } from "react";
|
||||||
import Button from "../../pageElements/Button";
|
import Button from "../../pageElements/Button";
|
||||||
import Modal from "react-bootstrap/Modal";
|
import Modal from "react-bootstrap/Modal";
|
||||||
|
import TextInput from "../../pageElements/TextInput";
|
||||||
|
|
||||||
|
import { db } from "../../firebase";
|
||||||
const ConfirmModal = ({
|
const ConfirmModal = ({
|
||||||
onCancel,
|
onCancel,
|
||||||
onConfirm,
|
onConfirm,
|
||||||
@@ -8,13 +11,41 @@ const ConfirmModal = ({
|
|||||||
modalText,
|
modalText,
|
||||||
isBusy,
|
isBusy,
|
||||||
isReport,
|
isReport,
|
||||||
|
appUserId,
|
||||||
|
caseId,
|
||||||
|
documentId,
|
||||||
|
issueText,
|
||||||
|
setIssueText,
|
||||||
|
reportDoc,
|
||||||
}) => {
|
}) => {
|
||||||
|
console.log("isReport", isReport);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal show="true" onHide={onCancel} size="lg">
|
<Modal show="true" onHide={onCancel} size="lg">
|
||||||
<Modal.Header closeButton>
|
<Modal.Header closeButton>
|
||||||
|
{isReport ? (
|
||||||
|
<Modal.Title>Report issue</Modal.Title>
|
||||||
|
) : (
|
||||||
<Modal.Title>Confirmation</Modal.Title>
|
<Modal.Title>Confirmation</Modal.Title>
|
||||||
|
)}
|
||||||
</Modal.Header>
|
</Modal.Header>
|
||||||
<Modal.Body>{modalText}</Modal.Body>
|
<Modal.Body>
|
||||||
|
<span>{modalText}</span>
|
||||||
|
{isReport ? (
|
||||||
|
<div style={{ marginTop: "16px" }}>
|
||||||
|
<TextInput
|
||||||
|
key={"captionTwo"}
|
||||||
|
name={"captionTwo"}
|
||||||
|
value={issueText}
|
||||||
|
message={"data.captionTwo.message"}
|
||||||
|
onChange={(e) => setIssueText(e.target.value)}
|
||||||
|
label={issueText ? "" : "Issue description"}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<></>
|
||||||
|
)}
|
||||||
|
</Modal.Body>
|
||||||
<Modal.Footer>
|
<Modal.Footer>
|
||||||
<Button
|
<Button
|
||||||
disabled={isBusy}
|
disabled={isBusy}
|
||||||
|
|||||||
@@ -360,6 +360,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.docedit-report-link {
|
.docedit-report-link {
|
||||||
|
font-size: 0.95rem;
|
||||||
color: red;
|
color: red;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user