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;