@@ -6,15 +6,7 @@ import { useParams } from "react-router-dom";
|
|||||||
import { Link, useNavigate } from "react-router-dom";
|
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 { doc, getDoc } from "firebase/firestore";
|
||||||
collection,
|
|
||||||
updateDoc,
|
|
||||||
onSnapshot,
|
|
||||||
doc,
|
|
||||||
getDoc,
|
|
||||||
setDoc,
|
|
||||||
increment,
|
|
||||||
} 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";
|
||||||
@@ -270,7 +262,7 @@ const DocEditPage = (props) => {
|
|||||||
async function createAndReturnDocx() {
|
async function createAndReturnDocx() {
|
||||||
setIsBusy(true);
|
setIsBusy(true);
|
||||||
const response = await handleCreateDocx();
|
const response = await handleCreateDocx();
|
||||||
if (response.status === 200) {
|
if (response?.status === 200) {
|
||||||
setTimeout(getDocx, 5000);
|
setTimeout(getDocx, 5000);
|
||||||
setTimeout(cleanUpDocx, 10000);
|
setTimeout(cleanUpDocx, 10000);
|
||||||
} else {
|
} else {
|
||||||
@@ -295,7 +287,19 @@ const DocEditPage = (props) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function postDocxData(obj) {
|
||||||
|
const docId = documentId;
|
||||||
|
console.log("obj", obj);
|
||||||
|
const response = await fetch(`${apiUrl}/v1/store-docx-data/${docId}`, {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify(obj),
|
||||||
|
});
|
||||||
|
console.log("res~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", response);
|
||||||
|
//return res;
|
||||||
|
}
|
||||||
|
|
||||||
async function handleCreateDocx() {
|
async function handleCreateDocx() {
|
||||||
|
console.log("handleCreateDocx FIRED ------------------------------->");
|
||||||
// TODO: compare to see if any changes made before gen, save those
|
// TODO: compare to see if any changes made before gen, save those
|
||||||
const docId = documentId;
|
const docId = documentId;
|
||||||
const leadAttorneys = fetchedCase?.leadAttorneys
|
const leadAttorneys = fetchedCase?.leadAttorneys
|
||||||
@@ -313,12 +317,11 @@ const DocEditPage = (props) => {
|
|||||||
const clientPosition = fetchedCase?.clientPosition
|
const clientPosition = fetchedCase?.clientPosition
|
||||||
? fetchedCase?.clientPosition
|
? fetchedCase?.clientPosition
|
||||||
: null;
|
: null;
|
||||||
|
const currentRequestType = docType;
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`${apiUrl}/genDocx/${docId}/${reqType}`, {
|
const response = await fetch(`${apiUrl}/v1/store-docx-data/${docId}`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
Accept: "application/json",
|
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
@@ -326,6 +329,7 @@ const DocEditPage = (props) => {
|
|||||||
caseCaption2: captionTwo,
|
caseCaption2: captionTwo,
|
||||||
caseNumber: caseNum,
|
caseNumber: caseNum,
|
||||||
clientPosition: clientPosition,
|
clientPosition: clientPosition,
|
||||||
|
currentRequestType: currentRequestType,
|
||||||
defendant: defendants,
|
defendant: defendants,
|
||||||
firm: lawFirm,
|
firm: lawFirm,
|
||||||
firmCity: city,
|
firmCity: city,
|
||||||
@@ -341,10 +345,40 @@ const DocEditPage = (props) => {
|
|||||||
venue: venued,
|
venue: venued,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
if (response.status === 200) {
|
||||||
|
const response = await fetch(
|
||||||
|
`${apiUrl}/v1/generate-request-docx/${docId}`,
|
||||||
|
{
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
Accept: "application/json",
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.log("err inpostDocxData", err);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
try {
|
||||||
|
const response = await fetch(
|
||||||
|
`${apiUrl}/v1/generate-request-docx/${docId}`,
|
||||||
|
{
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
Accept: "application/json",
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
return response;
|
return response;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error sending responses to the server:", error);
|
console.error("Error sending responses to the server:", error);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleConfirmReport = () => {
|
const handleConfirmReport = () => {
|
||||||
@@ -437,8 +471,6 @@ const DocEditPage = (props) => {
|
|||||||
navigate(`/documents`);
|
navigate(`/documents`);
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log("parsedRogs", parsedRogs);
|
|
||||||
console.log("responses", responses);
|
|
||||||
const editingContent = () => {
|
const editingContent = () => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -552,8 +584,7 @@ const DocEditPage = (props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const readyToEdit = fetchedCase && responses.length > 1;
|
const readyToEdit = fetchedCase && responses.length > 1;
|
||||||
console.log("readyToEdit", readyToEdit);
|
|
||||||
console.log("fetchedCase", fetchedCase);
|
|
||||||
return isLoading ? (
|
return isLoading ? (
|
||||||
<LoadingSpinner message={messages[0]} />
|
<LoadingSpinner message={messages[0]} />
|
||||||
) : isBusy ? (
|
) : isBusy ? (
|
||||||
|
|||||||
Reference in New Issue
Block a user