more
This commit is contained in:
@@ -156,42 +156,46 @@ const DocEditPage = (props) => {
|
||||
}
|
||||
}
|
||||
|
||||
async function getParsedRequests(docId, zib) {
|
||||
async function getParsedRequests(docId, docType) {
|
||||
try {
|
||||
fetch(`${apiUrl}/v1/get-parsed-requests/${documentId}/${zib}`, {
|
||||
const response = await fetch(
|
||||
`${apiUrl}/getParsedRequests/${docId}/${docType}`,
|
||||
{
|
||||
method: "GET",
|
||||
})
|
||||
.then(function (response) {
|
||||
return response.json();
|
||||
})
|
||||
.then((data) => {
|
||||
const respArray = data[0].responses;
|
||||
const result = respArray?.map((item, index) => {
|
||||
let obj = {};
|
||||
obj["showInputEle"] = false;
|
||||
obj["resp"] = item.text;
|
||||
obj["index"] = index;
|
||||
return obj;
|
||||
});
|
||||
setParsedRogs(result);
|
||||
});
|
||||
}
|
||||
);
|
||||
const res = await response.json();
|
||||
return res;
|
||||
} catch (err) {
|
||||
console.log("Error occured:", err);
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (!documentId) {
|
||||
return;
|
||||
}
|
||||
getParsedRequests(documentId, docType)
|
||||
.then((data) => {
|
||||
console.log(
|
||||
"-------------------------data in useEffect for getParsedRequests",
|
||||
data
|
||||
);
|
||||
})
|
||||
.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}`,
|
||||
`${apiUrl}/v1/get-parsed-requests/${docId}/${docType}`,
|
||||
{
|
||||
method: "GET",
|
||||
}
|
||||
);
|
||||
const req = await response.json();
|
||||
console.log("req", req);
|
||||
return req;
|
||||
}
|
||||
|
||||
@@ -218,21 +222,32 @@ const DocEditPage = (props) => {
|
||||
}
|
||||
|
||||
getCompletions(documentId, docType)
|
||||
.then((data) => {})
|
||||
.then((data) => {
|
||||
console.log("data in getCompletions", data);
|
||||
})
|
||||
.catch((err) => console.log(err));
|
||||
}, [documentId, docType]);
|
||||
|
||||
/*
|
||||
useEffect(() => {
|
||||
if (!documentId || !docType) {
|
||||
return;
|
||||
}
|
||||
|
||||
getParsedRequests(documentId, docType)
|
||||
.then((data) => {})
|
||||
.catch((err) => console.log(err));
|
||||
.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) => {
|
||||
setParsedRogs(resp);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log("Error getting parsed requestas:", err);
|
||||
});
|
||||
}, [documentId, docType]);
|
||||
*/
|
||||
|
||||
async function postEditedResponses(docId, docType) {
|
||||
let obj = {};
|
||||
obj["type"] = docType;
|
||||
@@ -436,7 +451,7 @@ const DocEditPage = (props) => {
|
||||
const handleBack = () => {
|
||||
navigate(`/documents`);
|
||||
};
|
||||
|
||||
console.log("parsedrogs", parsedRogs);
|
||||
const editingContent = () => {
|
||||
return (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user