Merge pull request #131 from kjannette/nexx2

Nexx2
This commit is contained in:
S Jannette
2024-03-06 00:24:42 -06:00
committed by GitHub
4 changed files with 64 additions and 32 deletions

View File

@@ -341,7 +341,7 @@ const DocEditPage = () => {
obj["requests"] = responses;
const data = JSON.stringify(obj);
try {
const response = await fetch(`${apiUrl}/storecompletions`, {
const response = await fetch(`${apiUrl}/v1/store-edited-completions`, {
method: "POST",
headers: { "Content-Type": "application/json" },
json: true,

View File

@@ -116,6 +116,7 @@ const DocumentListPage = ({ perPage }) => {
};
const handleToggle = (val) => setVerbValue(val);
async function deleteFromStorage() {
const selectedDoc = allDocs.filter((doc) => {
return doc.documentId == selectedDocumentId;

View File

@@ -152,9 +152,9 @@ const RequestEditPage = () => {
async function createAndReturnDocx() {
window.scrollTo({ top: 0 });
setIsBusy(true);
//setIsBusy(true);
const response = await handleCreateDocx();
if (response.status === 200) {
if (response && response?.status === 200) {
setTimeout(getDocx, 5000);
setTimeout(cleanUpDocx, 10000);
} else {
@@ -174,8 +174,9 @@ const RequestEditPage = () => {
}
};
async function handleCreateDocx() {
// TODO: compare to see if any changes made before gen, save those
async function postEditedResponses() {
const mergedRequests = [...requests, ...prodReq];
const docId = documentId;
const leadAttorneys = fetchedCase?.leadAttorneys
? fetchedCase?.leadAttorneys
@@ -192,15 +193,7 @@ const RequestEditPage = () => {
const clientPosition = fetchedCase?.clientPosition
? fetchedCase?.clientPosition
: null;
try {
const response = await fetch(`${apiUrl}/genDocx/${docId}/${reqType}`, {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
},
body: JSON.stringify({
const caseInfo = {
caseCaption1: captionOne,
caseCaption2: captionTwo,
caseNumber: caseNum,
@@ -218,9 +211,48 @@ const RequestEditPage = () => {
state: state,
tel: telephone,
venue: venued,
}),
};
let obj = {};
obj["type"] = "interrogatories-out";
obj["id"] = docId;
obj["requests"] = mergedRequests;
obj["caseInfo"] = caseInfo;
const data = JSON.stringify(obj);
try {
const response = await fetch(`${apiUrl}/v1/store-edited-completions`, {
method: "POST",
headers: { "Content-Type": "application/json" },
json: true,
body: data,
});
return response;
} catch (error) {
console.error("Error sending responses to the server:", error);
}
}
async function handleCreateDocx() {
// TODO: compare to see if any changes made before gen, save those
const res = await postEditedResponses();
try {
const response = await fetch(
`${apiUrl}/v1/generate-request-docx/${docId}`,
{
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
},
body: JSON.stringify({
docId: docId,
}),
}
);
return response;
} catch (error) {
console.error("Error sending requests to the server:", error);
}

View File

@@ -103,7 +103,6 @@ const UploadModal = (props) => {
try {
if (radioValue === "complaint") {
if (clientPositiion === "Plaintiff") {
console.log("sending POST to: ", `${apiUrl}/v1/gen-disc-request-pl`);
const response = await fetch(`${apiUrl}/v1/gen-disc-request-pl`, {
method: "POST",
body: file,