Merge pull request #27 from kjannette/gem9

Gem9
This commit is contained in:
S Jannette
2024-01-17 11:36:54 -06:00
committed by GitHub
4 changed files with 42 additions and 25 deletions

16
package-lock.json generated
View File

@@ -7849,14 +7849,6 @@
"tslib": "^2.0.3" "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": { "node_modules/dotenv-expand": {
"version": "5.1.0", "version": "5.1.0",
"resolved": "https://registry.npmjs.org/dotenv-expand/-/dotenv-expand-5.1.0.tgz", "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": { "node_modules/react-spinners": {
"version": "0.13.8", "version": "0.13.8",
"resolved": "https://registry.npmjs.org/react-spinners/-/react-spinners-0.13.8.tgz", "resolved": "https://registry.npmjs.org/react-spinners/-/react-spinners-0.13.8.tgz",

View File

@@ -54,6 +54,11 @@ const DocEditPage = () => {
const zipCode = group ? group.zipCode : null; const zipCode = group ? group.zipCode : null;
const telephone = group ? group.telephone : 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 = const displayCopy =
state === "New York" state === "New York"
? docEditCopy.NewYork ? docEditCopy.NewYork
@@ -90,8 +95,6 @@ const DocEditPage = () => {
} }
}; };
const baseUrl = "http://localhost:4000";
const headerString = const headerString =
documentType === "interrogatories" ? ( documentType === "interrogatories" ? (
"Response to Interrogatories" "Response to Interrogatories"
@@ -212,7 +215,7 @@ const DocEditPage = () => {
const docType = String(documentType); const docType = String(documentType);
try { try {
const response = await fetch( const response = await fetch(
`${baseUrl}/getParsedRequests/${documentId}/${docType}`, `${apiUrl}/getParsedRequests/${documentId}/${docType}`,
{ {
method: "GET", method: "GET",
} }
@@ -231,7 +234,7 @@ const DocEditPage = () => {
async function getCompletions(docId) { async function getCompletions(docId) {
const docType = String(documentType); const docType = String(documentType);
const response = await fetch(`${baseUrl}/completions/${docId}/${docType}`, { const response = await fetch(`${apiUrl}/completions/${docId}/${docType}`, {
method: "GET", method: "GET",
}); });
const req = await response.json(); const req = await response.json();
@@ -246,11 +249,15 @@ const DocEditPage = () => {
let mode; let mode;
//TODO: remove isRequests var //TODO: remove isRequests var
const isRequests = false; const isRequests = false;
console.log(
"generateResponsesCombined docmentId docType",
documentId,
docType
);
try { try {
setIsLoading(true); setIsLoading(true);
fetch( fetch(
`${baseUrl}/genResponseFromArrayCombined/${documentId}/${docType}/${isRequests}`, `${apiUrl}/genResponseFromArrayCombined/${documentId}/${docType}/${isRequests}`,
{ {
method: "GET", method: "GET",
} }
@@ -289,7 +296,7 @@ const DocEditPage = () => {
try { try {
setIsLoading(true); setIsLoading(true);
fetch( fetch(
`${baseUrl}/genResponseFromArray/${documentId}/${docType}/${isRequests}`, `${apiUrl}/genResponseFromArray/${documentId}/${docType}/${isRequests}`,
{ {
method: "GET", method: "GET",
} }
@@ -323,7 +330,7 @@ const DocEditPage = () => {
obj["requests"] = responses; obj["requests"] = responses;
const data = JSON.stringify(obj); const data = JSON.stringify(obj);
try { try {
const response = await fetch(`${baseUrl}/storecompletions`, { const response = await fetch(`${apiUrl}/storecompletions`, {
method: "POST", method: "POST",
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
json: true, json: true,
@@ -347,7 +354,7 @@ const DocEditPage = () => {
async function cleanUpDocx() { async function cleanUpDocx() {
const docId = documentId; const docId = documentId;
const reqType = documentType; const reqType = documentType;
fetch(`${baseUrl}/cleanUpDocx/${docId}/${reqType}`, { fetch(`${apiUrl}/cleanUpDocx/${docId}/${reqType}`, {
method: "GET", method: "GET",
}) })
.then((response) => { .then((response) => {
@@ -361,7 +368,7 @@ const DocEditPage = () => {
async function getDocx() { async function getDocx() {
const docId = documentId; const docId = documentId;
const reqType = documentType; const reqType = documentType;
fetch(`${baseUrl}/getDocx/${docId}/${reqType}`, { fetch(`${apiUrl}/getDocx/${docId}/${reqType}`, {
method: "GET", method: "GET",
}).then((response) => { }).then((response) => {
response.blob().then((blob) => { response.blob().then((blob) => {
@@ -394,7 +401,7 @@ const DocEditPage = () => {
: null; : null;
try { try {
const response = await fetch(`${baseUrl}/genDocx/${docId}/${reqType}`, { const response = await fetch(`${apiUrl}/genDocx/${docId}/${reqType}`, {
method: "POST", method: "POST",
headers: { headers: {
Accept: "application/json", Accept: "application/json",
@@ -446,7 +453,7 @@ const DocEditPage = () => {
obj["requests"] = responses; obj["requests"] = responses;
const data = JSON.stringify(obj); const data = JSON.stringify(obj);
try { try {
const response = await fetch(`${baseUrl}/storeeditedcompletions`, { const response = await fetch(`${apiUrl}/storeeditedcompletions`, {
method: "POST", method: "POST",
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
json: true, json: true,

View File

@@ -32,11 +32,17 @@ const DocumentListPage = ({ perPage }) => {
const [page, setPage] = useState(1); const [page, setPage] = useState(1);
const [order, setOrder] = useState("parentCaseName"); const [order, setOrder] = useState("parentCaseName");
const appUserId = group ? group.appUserId : null; const appUserId = group ? group.appUserId : null;
const baseUrl = "http://localhost:4000";
const [isBusy, setIsBusy] = useState(false); const [isBusy, setIsBusy] = useState(false);
const [selectedDocumentType, setSelectedDocumentType] = useState(); const [selectedDocumentType, setSelectedDocumentType] = useState();
const [showModal, setShowModal] = useState(false); const [showModal, setShowModal] = useState(false);
const apiUrl =
process.env.NODE_ENV === "development"
? process.env.REACT_APP_API_DEV
: process.env.REACT_APP_API_PROD;
console.log("apiUrl", apiUrl);
useEffect(() => { useEffect(() => {
if (count.current == null) { if (count.current == null) {
setIsMobile(window.innerWidth < 440); setIsMobile(window.innerWidth < 440);
@@ -117,7 +123,7 @@ const DocumentListPage = ({ perPage }) => {
try { try {
const response = await fetch( const response = await fetch(
`${baseUrl}/deleteDoc/${selectedDocumentId}/${selectedDocumentType}/${respGens}`, `${apiUrl}/deleteDoc/${selectedDocumentId}/${selectedDocumentType}/${respGens}`,
{ {
method: "POST", method: "POST",
} }

View File

@@ -35,8 +35,11 @@ const UploadModal = (props) => {
const [docError, setShowDocError] = useState(""); const [docError, setShowDocError] = useState("");
const fileTypes = ["PDF"]; const fileTypes = ["PDF"];
const fileName = fileToParse ? fileToParse.name : undefined; const fileName = fileToParse ? fileToParse.name : undefined;
const baseUrl = "http://localhost:4000";
const navigate = useNavigate(); const apiUrl =
process.env.NODE_ENV === "development"
? process.env.REACT_APP_API_DEV
: process.env.REACT_APP_API_PROD;
async function saveToDb(uuidName) { async function saveToDb(uuidName) {
const data = { const data = {
@@ -67,7 +70,7 @@ const UploadModal = (props) => {
async function uploadFile(file) { async function uploadFile(file) {
try { try {
const response = await fetch(`${baseUrl}/parseNewDoc`, { const response = await fetch(`${apiUrl}/parseNewDoc`, {
method: "POST", method: "POST",
body: file, body: file,
}); });
@@ -223,6 +226,7 @@ const UploadModal = (props) => {
multiple={true} multiple={true}
handleChange={handleFileChange} handleChange={handleFileChange}
name="file" name="file"
types={fileTypes}
> >
<div className={fileToParse ? "drag-box filled" : "drag-box"}> <div className={fileToParse ? "drag-box filled" : "drag-box"}>
{fileToParse {fileToParse