From f697539fc038554909f8bc9f898da5a39aeda67f Mon Sep 17 00:00:00 2001 From: Kenneth Jannette Date: Wed, 17 Jan 2024 11:11:15 -0600 Subject: [PATCH] more --- package-lock.json | 16 ++++++++-------- src/Components/Document/DocEditPage.js | 25 ++++++++++++++----------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/package-lock.json b/package-lock.json index f9505c1..c8c7cbc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7849,14 +7849,6 @@ "tslib": "^2.0.3" } }, - "node_modules/dotenv": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", - "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==", - "engines": { - "node": ">=10" - } - }, "node_modules/dotenv-expand": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/dotenv-expand/-/dotenv-expand-5.1.0.tgz", @@ -15972,6 +15964,14 @@ } } }, + "node_modules/react-scripts/node_modules/dotenv": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", + "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==", + "engines": { + "node": ">=10" + } + }, "node_modules/react-spinners": { "version": "0.13.8", "resolved": "https://registry.npmjs.org/react-spinners/-/react-spinners-0.13.8.tgz", diff --git a/src/Components/Document/DocEditPage.js b/src/Components/Document/DocEditPage.js index c7a2d6d..98c1756 100644 --- a/src/Components/Document/DocEditPage.js +++ b/src/Components/Document/DocEditPage.js @@ -54,6 +54,11 @@ const DocEditPage = () => { const zipCode = group ? group.zipCode : null; const telephone = group ? group.telephone : null; + const apiUrl = + process.env.NODE_ENV === "development" + ? process.env.REACT_APP_API_DEV + : process.env.REACT_APP_API_PROD; + const displayCopy = state === "New York" ? docEditCopy.NewYork @@ -90,8 +95,6 @@ const DocEditPage = () => { } }; - const baseUrl = "http://localhost:4000"; - const headerString = documentType === "interrogatories" ? ( "Response to Interrogatories" @@ -212,7 +215,7 @@ const DocEditPage = () => { const docType = String(documentType); try { const response = await fetch( - `${baseUrl}/getParsedRequests/${documentId}/${docType}`, + `${apiUrl}/getParsedRequests/${documentId}/${docType}`, { method: "GET", } @@ -231,7 +234,7 @@ const DocEditPage = () => { async function getCompletions(docId) { const docType = String(documentType); - const response = await fetch(`${baseUrl}/completions/${docId}/${docType}`, { + const response = await fetch(`${apiUrl}/completions/${docId}/${docType}`, { method: "GET", }); const req = await response.json(); @@ -254,7 +257,7 @@ const DocEditPage = () => { try { setIsLoading(true); fetch( - `${baseUrl}/genResponseFromArrayCombined/${documentId}/${docType}/${isRequests}`, + `${apiUrl}/genResponseFromArrayCombined/${documentId}/${docType}/${isRequests}`, { method: "GET", } @@ -293,7 +296,7 @@ const DocEditPage = () => { try { setIsLoading(true); fetch( - `${baseUrl}/genResponseFromArray/${documentId}/${docType}/${isRequests}`, + `${apiUrl}/genResponseFromArray/${documentId}/${docType}/${isRequests}`, { method: "GET", } @@ -327,7 +330,7 @@ const DocEditPage = () => { obj["requests"] = responses; const data = JSON.stringify(obj); try { - const response = await fetch(`${baseUrl}/storecompletions`, { + const response = await fetch(`${apiUrl}/storecompletions`, { method: "POST", headers: { "Content-Type": "application/json" }, json: true, @@ -351,7 +354,7 @@ const DocEditPage = () => { async function cleanUpDocx() { const docId = documentId; const reqType = documentType; - fetch(`${baseUrl}/cleanUpDocx/${docId}/${reqType}`, { + fetch(`${apiUrl}/cleanUpDocx/${docId}/${reqType}`, { method: "GET", }) .then((response) => { @@ -365,7 +368,7 @@ const DocEditPage = () => { async function getDocx() { const docId = documentId; const reqType = documentType; - fetch(`${baseUrl}/getDocx/${docId}/${reqType}`, { + fetch(`${apiUrl}/getDocx/${docId}/${reqType}`, { method: "GET", }).then((response) => { response.blob().then((blob) => { @@ -398,7 +401,7 @@ const DocEditPage = () => { : null; try { - const response = await fetch(`${baseUrl}/genDocx/${docId}/${reqType}`, { + const response = await fetch(`${apiUrl}/genDocx/${docId}/${reqType}`, { method: "POST", headers: { Accept: "application/json", @@ -450,7 +453,7 @@ const DocEditPage = () => { obj["requests"] = responses; const data = JSON.stringify(obj); try { - const response = await fetch(`${baseUrl}/storeeditedcompletions`, { + const response = await fetch(`${apiUrl}/storeeditedcompletions`, { method: "POST", headers: { "Content-Type": "application/json" }, json: true,