This commit is contained in:
Kenneth Jannette
2024-03-12 02:36:55 -05:00
parent 830e731a4e
commit 5f9df675ee

View File

@@ -262,7 +262,7 @@ const DocEditPage = (props) => {
async function createAndReturnDocx() {
setIsBusy(true);
const response = await handleCreateDocx();
if (response.status === 200) {
if (response?.status === 200) {
setTimeout(getDocx, 5000);
setTimeout(cleanUpDocx, 10000);
} else {
@@ -287,6 +287,16 @@ const DocEditPage = (props) => {
});
}
async function postDocxData(obj) {
const docId = documentId;
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() {
console.log("handleCreateDocx FIRED ------------------------------->");
// TODO: compare to see if any changes made before gen, save those
@@ -307,20 +317,7 @@ const DocEditPage = (props) => {
? fetchedCase?.clientPosition
: null;
try {
console.log(
"--------------------------------->try block, apiURL",
apiUrl
);
const response = await fetch(
`${apiUrl}/v1/generate-request-docx/${docId}`,
{
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
},
body: JSON.stringify({
const obj = {
caseCaption1: captionOne,
caseCaption2: captionTwo,
caseNumber: caseNum,
@@ -338,13 +335,32 @@ const DocEditPage = (props) => {
state: state,
tel: telephone,
venue: venued,
}),
};
try {
const res = postDocxData(obj);
console.log("res to first post", res);
} 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;
} catch (error) {
console.error("Error sending responses to the server:", error);
}
*/
}
const handleConfirmReport = () => {