This commit is contained in:
Kenneth Jannette
2024-02-01 20:29:34 -06:00
parent ba55058934
commit 97e9e6590a

View File

@@ -8,11 +8,12 @@ import { db } from "../../firebase";
import { useParams } from "react-router-dom"; import { useParams } from "react-router-dom";
import { AppContext } from "../../Hooks/useContext/appContext.js"; import { AppContext } from "../../Hooks/useContext/appContext.js";
import LoadingSpinner from "../../pageElements/LoadingSpinner"; import LoadingSpinner from "../../pageElements/LoadingSpinner";
import { doc, onSnapshot } from "firebase/firestore"; import { doc, getDoc, onSnapshot } from "firebase/firestore";
const CaseDetailsPage = () => { const CaseDetailsPage = () => {
const { caseId } = useParams(); const { caseId } = useParams();
const [subCase, setSubCase] = useState(null); const [subCase, setSubCase] = useState(null);
const [temp, setTemp] = useState();
const navigate = useNavigate(); const navigate = useNavigate();
const [showUploadModal, setShowUploadModal] = useState(); const [showUploadModal, setShowUploadModal] = useState();
const [showCreateModal, setShowCreateModal] = useState(); const [showCreateModal, setShowCreateModal] = useState();
@@ -45,6 +46,30 @@ const CaseDetailsPage = () => {
useEffect(getCase, [caseId, appUserId]); useEffect(getCase, [caseId, appUserId]);
useEffect(() => {
const fetchData = async () => {
try {
const docRef = doc(db, "users", "MrKTceLzUKMGHGkiBvhn3cWML8j2");
const response = await getDoc(docRef).then(function (doc) {
doc.exists ? setTemp(doc.data()) : console.log("No such document!");
});
} catch (err) {
console.error(err);
}
};
fetchData();
}, []);
const handleUploadDoc = () => {
const allowed = Number(temp.docsAllowed);
const generated = Number(temp.docsGenerated);
if (allowed - generated > 0) {
console.log("greater than do some shit");
setShowUploadModal(true);
} else {
console.log("fuck you");
}
};
const handleSuccess = () => { const handleSuccess = () => {
setIsLoading(true); setIsLoading(true);
setShowUploadModal(false); setShowUploadModal(false);
@@ -70,7 +95,7 @@ const CaseDetailsPage = () => {
<div className="upload-button-box"> <div className="upload-button-box">
<Button <Button
className="p-2 mr-2 primary-button" className="p-2 mr-2 primary-button"
onClick={() => setShowUploadModal(true)} onClick={handleUploadDoc}
labelText="Upload Document" labelText="Upload Document"
/> />
</div> </div>