more
This commit is contained in:
@@ -20,9 +20,11 @@ const CaseDetailsPage = () => {
|
|||||||
const [showCreateModal, setShowCreateModal] = useState();
|
const [showCreateModal, setShowCreateModal] = useState();
|
||||||
const [showConfirmModal, setShowConfirmModal] = useState();
|
const [showConfirmModal, setShowConfirmModal] = useState();
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
const [docsAllowed, setDocsAllowed] = useState(null);
|
||||||
const { appState } = useContext(AppContext);
|
const { appState } = useContext(AppContext);
|
||||||
const { group } = appState;
|
const { group } = appState;
|
||||||
const appUserId = group ? group.appUserId : null;
|
const appUserId = group ? group.appUserId : null;
|
||||||
|
const fbUserId = group ? group.fbAuthUid : null;
|
||||||
const message =
|
const message =
|
||||||
"Parsing document. Please be patient, this may take several minutes.";
|
"Parsing document. Please be patient, this may take several minutes.";
|
||||||
|
|
||||||
@@ -51,19 +53,20 @@ const CaseDetailsPage = () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchData = async () => {
|
const fetchData = async () => {
|
||||||
try {
|
try {
|
||||||
const docRef = doc(db, "users", "MrKTceLzUKMGHGkiBvhn3cWML8j2");
|
const docRef = doc(db, "users", fbUserId);
|
||||||
const response = await getDoc(docRef).then(function (doc) {
|
const response = await getDoc(docRef).then(function (doc) {
|
||||||
doc.exists ? setTemp(doc.data()) : console.log("No such document!");
|
doc.exists ? setTemp(doc.data()) : console.log("No such document!");
|
||||||
|
setDocsAllowed(temp.docsAllowedPerMonth);
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
fetchData();
|
fetchData();
|
||||||
}, []);
|
}, [fbUserId]);
|
||||||
|
|
||||||
const handleUploadDoc = () => {
|
const handleUploadDoc = () => {
|
||||||
const allowed = Number(temp.docsAllowed);
|
const allowed = Number(docsAllowed);
|
||||||
const generated = Number(temp.docsGenerated);
|
const generated = Number(temp.docsGenerated);
|
||||||
if (allowed - generated > 0) {
|
if (allowed - generated > 0) {
|
||||||
setShowUploadModal(true);
|
setShowUploadModal(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user