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