diff --git a/src/Components/Case/CaseDetailsPage.js b/src/Components/Case/CaseDetailsPage.js index cb12ee0..631bdb0 100644 --- a/src/Components/Case/CaseDetailsPage.js +++ b/src/Components/Case/CaseDetailsPage.js @@ -20,9 +20,11 @@ const CaseDetailsPage = () => { const [showCreateModal, setShowCreateModal] = useState(); const [showConfirmModal, setShowConfirmModal] = useState(); const [isLoading, setIsLoading] = useState(false); + const [docsAllowed, setDocsAllowed] = useState(null); const { appState } = useContext(AppContext); const { group } = appState; const appUserId = group ? group.appUserId : null; + const fbUserId = group ? group.fbAuthUid : null; const message = "Parsing document. Please be patient, this may take several minutes."; @@ -51,19 +53,20 @@ const CaseDetailsPage = () => { useEffect(() => { const fetchData = async () => { try { - const docRef = doc(db, "users", "MrKTceLzUKMGHGkiBvhn3cWML8j2"); + const docRef = doc(db, "users", fbUserId); const response = await getDoc(docRef).then(function (doc) { doc.exists ? setTemp(doc.data()) : console.log("No such document!"); + setDocsAllowed(temp.docsAllowedPerMonth); }); } catch (err) { console.error(err); } }; fetchData(); - }, []); + }, [fbUserId]); const handleUploadDoc = () => { - const allowed = Number(temp.docsAllowed); + const allowed = Number(docsAllowed); const generated = Number(temp.docsGenerated); if (allowed - generated > 0) { setShowUploadModal(true);