This commit is contained in:
Kenneth Jannette
2024-03-07 16:44:39 -06:00
parent 82acfb6f17
commit eefdd589d3
3 changed files with 33 additions and 11 deletions

View File

@@ -8,7 +8,13 @@ import Row from "react-bootstrap/Row";
import Col from "react-bootstrap/Col";
import Radiogroup from "../../pageElements/Radiogroup";
import { useNavigate } from "react-router-dom";
import { collection, setDoc, doc } from "firebase/firestore";
import {
collection,
setDoc,
doc,
updateDoc,
increment,
} from "firebase/firestore";
import { db } from "../../firebase";
import { v4 as uuidv4 } from "uuid";
import TextInput from "../../pageElements/TextInput";
@@ -30,6 +36,8 @@ const UploadModal = (props) => {
handleSuccess,
setIsLoading,
clientPositiion,
handleConfirmDocType,
fbUserId,
} = props;
const { caseId, caseNumber, jurisdiction, caption, captionTwo } = caseData;
const [docTitle, setDocTitle] = useState("");
@@ -65,6 +73,21 @@ const UploadModal = (props) => {
setRadioValue(e.value);
};
async function updateUserAccountDocsGenerated(fbUserId) {
await updateDoc(doc(db, "users", fbUserId), {
docsGenerated: increment(1),
});
}
async function updateRespGenerationCount(docId) {
if (!docId) {
return;
}
await updateDoc(doc(db, "documents", docId), {
responseGenerations: increment(1),
});
}
async function saveToDb(uuidName) {
const createdAt = new Date();
const data = {
@@ -84,6 +107,8 @@ const UploadModal = (props) => {
if (radioValue === "complaint") {
docType = "interrogatories-out";
data["docType"] = docType;
updateUserAccountDocsGenerated(fbUserId);
updateRespGenerationCount(uuidName);
}
try {