This commit is contained in:
Kenneth Jannette
2024-03-11 01:57:59 -05:00
parent f30307ca14
commit 2a63102e6d
2 changed files with 25 additions and 26 deletions

View File

@@ -132,11 +132,6 @@ const DocEditPage = (props) => {
if (docSnap.exists()) {
const data = docSnap.data();
return data;
if (data.docType) {
let dtt = data.docType;
getParsedRequests(docId, dtt);
}
} else {
console.log("DB item does not exist");
}
@@ -162,7 +157,6 @@ const DocEditPage = (props) => {
}
async function getParsedRequests(docId, zib) {
console.log("zibbbt", zib);
try {
fetch(`${apiUrl}/v1/get-parsed-requests/${documentId}/${zib}`, {
method: "GET",
@@ -171,7 +165,6 @@ const DocEditPage = (props) => {
return response.json();
})
.then((data) => {
console.log("data", data);
const respArray = data[0].responses;
const result = respArray?.map((item, index) => {
let obj = {};
@@ -180,7 +173,6 @@ const DocEditPage = (props) => {
obj["index"] = index;
return obj;
});
console.log("result", result);
setParsedRogs(result);
});
} catch (err) {
@@ -189,10 +181,17 @@ const DocEditPage = (props) => {
}
async function getCompletions(docId, docType) {
const response = await fetch(`${apiUrl}/completions/${docId}/${docType}`, {
method: "GET",
});
if (!docId || !docType) {
return;
}
const response = await fetch(
`${apiUrl}/v1/get-completions/${docId}/${docType}`,
{
method: "GET",
}
);
const req = await response.json();
console.log("req", req);
return req;
}
@@ -201,8 +200,8 @@ const DocEditPage = (props) => {
return;
}
getDocument(documentId).then((data) => {
console.log("data document in useEffect", data);
setDocument(data);
setDocType(data.docType);
});
}, [documentId]);
@@ -214,24 +213,26 @@ const DocEditPage = (props) => {
}, [caseId, documentId]);
useEffect(() => {
if (!documentId) {
if (!documentId || !docType) {
return;
}
console.log("docType", docType);
getCompletions(documentId, docType)
.then((data) => {
const resp = data[0].responses.map((item, index) => {
// NEVER CHANGE THIS:
return { showInputEle: false, resp: item.text, index: index };
});
return resp;
})
.then((resp) => {
setResponses(resp);
})
.then((data) => {})
.catch((err) => console.log(err));
}, [documentId, docType]);
/*
useEffect(() => {
if (!documentId || !docType) {
return;
}
getParsedRequests(documentId, docType)
.then((data) => {})
.catch((err) => console.log(err));
}, [documentId, docType]);
*/
async function postEditedResponses(docId, docType) {
let obj = {};
obj["type"] = docType;
@@ -436,7 +437,6 @@ const DocEditPage = (props) => {
navigate(`/documents`);
};
console.log("responses", responses);
const editingContent = () => {
return (
<>