diff --git a/src/App.js b/src/App.js index 1ad6448..af8a886 100644 --- a/src/App.js +++ b/src/App.js @@ -101,7 +101,7 @@ function App() { /> diff --git a/src/Components/Case/CaseDetailsPage.js b/src/Components/Case/CaseDetailsPage.js index b84d836..1072cac 100644 --- a/src/Components/Case/CaseDetailsPage.js +++ b/src/Components/Case/CaseDetailsPage.js @@ -38,8 +38,8 @@ const CaseDetailsPage = () => { const handleNavigate = (docId, caseId) => { //documentId, responseGenerations, caseId, documentType let documentType = "interrogatories"; - const documentId = docId; - navigate(`/documents/${documentId}/${documentType}/${caseId}`); + + navigate(`/documents/${docId}/${documentType}/${caseId}`); }; const handleNavEdit = (documentId, reqType, caseId) => { diff --git a/src/Components/Document/DocumentListPage.js b/src/Components/Document/DocumentListPage.js index 951b52d..4ecc5ba 100644 --- a/src/Components/Document/DocumentListPage.js +++ b/src/Components/Document/DocumentListPage.js @@ -22,7 +22,7 @@ import "../../styles/doclist-page.scss"; const DocumentListPage = ({ perPage }) => { const size = window.innerWidth < 440; - const { documentId, documentType, caseId } = useParams(); + const { docId, documentType, caseId } = useParams(); const [isMobile, setIsMobile] = useState(size); const { appState } = useContext(AppContext); const count = useRef(null); @@ -33,7 +33,6 @@ const DocumentListPage = ({ perPage }) => { const [allResponseDocs, setAllResponseDocs] = useState(null); const [allRequestDocs, setAllRequestDocs] = useState(null); const [totalPages, setTotalPages] = useState(1); - const [docId, setDocId] = useState(documentId); const { group } = appState; const [page, setPage] = useState(1); const [order, setOrder] = useState("parentCaseName"); @@ -43,6 +42,7 @@ const DocumentListPage = ({ perPage }) => { const [selectedDocumentType, setSelectedDocumentType] = useState(); const [showModal, setShowModal] = useState(false); const [verbValue, setVerbValue] = useState(1); + const apiUrl = process.env.NODE_ENV === "development" ? process.env.REACT_APP_API_DEV @@ -61,36 +61,17 @@ const DocumentListPage = ({ perPage }) => { }; }, []); - async function generateResponsesCombined() { - if (!docId) { + async function generateResponses(docId) { + /* + if (responsesCreated > 0) { return; } - const docType = String(documentType); - const isRequests = false; - - try { - fetch( - `${apiUrl}/genResponseFromArrayCombined/${docId}/${docType}/${isRequests}`, - { - method: "GET", - } - ) - .then(function (response) { - return response.json(); - }) - .catch((err) => console.log(err)); - } catch (err) { - console.log("err", err); - } - } - - async function generateResponses() { - if (!docId) { - return; - } - const docId = String(documentId); - const docType = String(documentType); +*/ + console.log("docId in generate responses", docId); + //const docType = String(documentType); + //TODO: remove isRequests var const isRequests = false; + const docType = "interrogatories"; try { fetch( `${apiUrl}/genResponseFromArray/${docId}/${docType}/${isRequests}`, @@ -101,7 +82,6 @@ const DocumentListPage = ({ perPage }) => { .then(function (response) { return response.json(); }) - .catch((err) => console.log(err)); } catch (err) { console.log("err", err); @@ -109,22 +89,13 @@ const DocumentListPage = ({ perPage }) => { } useEffect(() => { - if (!documentId || !documentType) { + if (!documentId) { return; } - if (documentType == "combined-numbered") { - try { - const res = generateResponsesCombined(documentId, documentType); - } catch (err) { - console.log(err); - } - } else { - try { - const res = generateResponses(documentId, documentType); - } catch (err) { - console.log(err); - } - } + console.log("useEffect fired in doc list to gen responses"); + generateResponses(documentId).then((response) => { + console.log("response", response); + }); }, [documentId]); function getRequests() { @@ -298,18 +269,22 @@ const DocumentListPage = ({ perPage }) => { {allResponseDocs === null && allRequestDocs === null ? (
Loading...
) : null} -
-
Discovery Request Documents
-
-
- + {allRequestDocs != null && allRequestDocs.length > 0 ? ( +
+
Discovery Request Documents
+
+
+ +
-
+ ) : ( + <> + )}
{allRequestDocs?.length > 0 ? ( allRequestDocs @@ -335,18 +310,22 @@ const DocumentListPage = ({ perPage }) => { <> )}
-
-
Discovery Response Documents
-
-
- + {allResponseDocs != null && allResponseDocs.length > 0 ? ( +
+
Discovery Response Documents
+
+
+ +
-
+ ) : ( + <> + )}
{allResponseDocs?.length > 0 ? ( allResponseDocs @@ -474,15 +453,6 @@ export default DocumentListPage;
) : null} - - - - - - - - -
Response Verbosity