From 4978e9bc5ae5cb2c9420e7cc30392739b9fd91c8 Mon Sep 17 00:00:00 2001 From: Kenneth Jannette Date: Wed, 31 Jan 2024 12:27:06 -0600 Subject: [PATCH] more --- src/Components/Case/CaseTypePage.js | 134 +++++++++++++++++++++++++++ src/Components/Modals/CreateModal.js | 2 +- 2 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 src/Components/Case/CaseTypePage.js diff --git a/src/Components/Case/CaseTypePage.js b/src/Components/Case/CaseTypePage.js new file mode 100644 index 0000000..8ddf861 --- /dev/null +++ b/src/Components/Case/CaseTypePage.js @@ -0,0 +1,134 @@ +import React, { useEffect, useContext, useState } from "react"; +import { useNavigate } from "react-router-dom"; +import { DetailCard } from "../../pageElements/DetailCard.js"; +import Button from "../../pageElements/Button"; +import CreateModal from "../Modals/CreateModal.js"; +import UploadModal from "../Modals/UploadModal.js"; +import { db } from "../../firebase"; +import { useParams } from "react-router-dom"; +import { AppContext } from "../../Hooks/useContext/appContext.js"; +import LoadingSpinner from "../../pageElements/LoadingSpinner"; +import { doc, onSnapshot } from "firebase/firestore"; + +const CaseDetailsPage = () => { + const { caseId } = useParams(); + const [subCase, setSubCase] = useState(null); + const navigate = useNavigate(); + const [showUploadModal, setShowUploadModal] = useState(); + const [showCreateModal, setShowCreateModal] = useState(); + const [isLoading, setIsLoading] = useState(false); + const { appState } = useContext(AppContext); + const { group } = appState; + const appUserId = group ? group.appUserId : null; + const message = + "Parsing document. Please be patient, this may take several minutes."; + + const handleNavigate = () => { + navigate("/documents"); + }; + + const handleBack = () => { + navigate("/cases"); + }; + + function getCase() { + const docRef = doc(db, "cases", caseId); + const unsub = onSnapshot(docRef, (snapshot) => { + if (snapshot.exists() && snapshot.data().ownerId === appUserId) { + setSubCase({ ...snapshot.data(), id: snapshot.id }); + } else { + setSubCase(null); + } + }); + return unsub; + } + + useEffect(getCase, [caseId, appUserId]); + + const handleSuccess = () => { + setIsLoading(true); + setShowUploadModal(false); + setTimeout(handleNavigate, 40000); + }; + + const ButtonContent = () => { + return ( +
+
+
+
+
+
+ + ); + }; + + if (!group) { + return null; + } + + const HeadingContent = () => { + return ( +
+

Case Details:

+
+

+ {subCase?.caption} v. {subCase?.captionTwo} +

+
+

Index Number:

+

{subCase?.caseNumber}

+
+
+
+ ); + }; + + const showUp = showUploadModal && subCase !== null ? true : false; + const showCreate = showCreateModal && subCase !== null ? true : false; + return ( +
+ {isLoading ? : null} + {!isLoading ? : null} + {!isLoading ? ( + showUp ? ( + + ) : null + ) : null} + {!isLoading ? ( + showCreate ? ( + + ) : null + ) : null} + {!isLoading ? ( + subCase !== null ? ( + + ) : null + ) : null} + {!isLoading ? : null} +
+ ); +}; + +export default CaseDetailsPage; diff --git a/src/Components/Modals/CreateModal.js b/src/Components/Modals/CreateModal.js index dbc5881..9cd098b 100644 --- a/src/Components/Modals/CreateModal.js +++ b/src/Components/Modals/CreateModal.js @@ -103,7 +103,7 @@ const CreateModal = ({ setShowModal, caseData }) => { try { saveCaseData(dataValues).then((res) => { const caseId = res; - navigate(`/casedetails/${caseId}`); + navigate(`/casetype/${caseId}`); }); } catch (err) { console.log(err);