more
This commit is contained in:
@@ -29,7 +29,7 @@ const DocEditPage = (props) => {
|
||||
const [docType, setDocType] = useState(null);
|
||||
const [fetchedCase, setFetchedCase] = useState(null);
|
||||
const [parsedRogs, setParsedRogs] = useState(null);
|
||||
const [responses, setResponses] = useState();
|
||||
const [responses, setResponses] = useState([]);
|
||||
const [showInputEle, setShowInputEle] = useState(true);
|
||||
const { appState } = useContext(AppContext);
|
||||
const { group } = appState;
|
||||
@@ -168,9 +168,8 @@ const DocEditPage = (props) => {
|
||||
method: "GET",
|
||||
}
|
||||
);
|
||||
console.log("response in get parsed ", response);
|
||||
const res = await response.json();
|
||||
|
||||
const res = await response.json();
|
||||
return res;
|
||||
} catch (err) {
|
||||
console.log("getParsedRequests Error occured:", err);
|
||||
@@ -178,16 +177,13 @@ const DocEditPage = (props) => {
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (!documentId) {
|
||||
if (!documentId || !docType) {
|
||||
return;
|
||||
}
|
||||
getParsedRequests(documentId, docType)
|
||||
.then((data) => {
|
||||
console.log(
|
||||
"-------------------------data in useEffect for getParsedRequests",
|
||||
data
|
||||
);
|
||||
const resp = data[0].responses.map((item, index) => {
|
||||
const resp = data[0].responses ? data[0].responses : null;
|
||||
const foo = resp?.map((item, index) => {
|
||||
// NEVER CHANGE THIS:
|
||||
return { showInputEle: false, resp: item.text, index: index };
|
||||
});
|
||||
@@ -196,21 +192,6 @@ const DocEditPage = (props) => {
|
||||
.catch((err) => console.log(err));
|
||||
}, [documentId]);
|
||||
|
||||
async function getCompletions(docId, docType) {
|
||||
if (!docId || !docType) {
|
||||
return;
|
||||
}
|
||||
const response = await fetch(
|
||||
`${apiUrl}/v1/get-completions/${docId}/${docType}`,
|
||||
{
|
||||
method: "GET",
|
||||
}
|
||||
);
|
||||
const resp = await response.json();
|
||||
console.log("req getCompletions", resp);
|
||||
return resp;
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (!documentId) {
|
||||
return;
|
||||
@@ -233,18 +214,75 @@ const DocEditPage = (props) => {
|
||||
getCase(caseId);
|
||||
}, [caseId, documentId]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!documentId || !docType) {
|
||||
async function getCompletions(docId, docType) {
|
||||
if (!docId || !docType) {
|
||||
return;
|
||||
}
|
||||
console.log("docId, docType", docId, docType);
|
||||
const response = await fetch(
|
||||
`${apiUrl}/v1/get-completions/${docId}/${docType}`,
|
||||
{
|
||||
method: "GET",
|
||||
}
|
||||
);
|
||||
const resp = await response.json();
|
||||
return resp;
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getCompletions(documentId, docType)
|
||||
.then((data) => {
|
||||
//console.log("data in getCompletions", data);
|
||||
const respond = data[0].responses.length > 2 ? data[0].responses : null;
|
||||
const resp = respond?.map((item, index) => {
|
||||
// NEVER CHANGE THIS:
|
||||
return { showInputEle: false, resp: item.text, index: index };
|
||||
});
|
||||
setResponses(resp);
|
||||
})
|
||||
.catch((err) => console.log(err));
|
||||
}, [documentId, docType]);
|
||||
console.log("responses", responses);
|
||||
/*
|
||||
async function getOutgoingRequests(documentId) {
|
||||
console.log("getOutgoingRequests fired--------------------");
|
||||
if (!documentId) {
|
||||
return;
|
||||
}
|
||||
const docType = String(documentType);
|
||||
const docId = String(documentId);
|
||||
const response = await fetch(
|
||||
`${apiUrl}/v1/get-outgoing-requests/${docId}/${docType}`,
|
||||
{
|
||||
method: "GET",
|
||||
}
|
||||
);
|
||||
const req = await response.json();
|
||||
return req;
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (!documentId) {
|
||||
return;
|
||||
}
|
||||
getOutgoingRequests(documentId)
|
||||
.then((data) => {
|
||||
console.log(
|
||||
"-------------------------data[0].requests",
|
||||
data[0].requests
|
||||
);
|
||||
const merged = [...foundationRogs, ...data[0].requests];
|
||||
const resp = merged?.map((item, index) => {
|
||||
// NEVER CHANGE THIS:
|
||||
return { showInputEle: false, text: item.text, index: index };
|
||||
});
|
||||
if (resp.length > 10) {
|
||||
setRequests(resp);
|
||||
setProdReq(standardProd);
|
||||
}
|
||||
})
|
||||
.catch((err) => console.log(err));
|
||||
}, [documentId]);
|
||||
*/
|
||||
async function postEditedResponses(docId, docType) {
|
||||
let obj = {};
|
||||
obj["type"] = docType;
|
||||
|
||||
Reference in New Issue
Block a user