Skip to content

🔥 The free & Open Source DocuSign alternative

fix: user count is not correct

prafull-opensignlabs5d245927c461
diff --git a/apps/OpenSign/src/components/AddUser.js b/apps/OpenSign/src/components/AddUser.js
index 1c41535c1..8c4f1f3e7 100644
--- a/apps/OpenSign/src/components/AddUser.js
+++ b/apps/OpenSign/src/components/AddUser.js
@@ -301,6 +301,9 @@ const AddUser = (props) => {
setAllowedUser(amount.quantity);
setPlanInfo((obj) => ({ ...obj, totalAllowedUser: _resAddon.addon }));
}
+ if (props.handleBuyUsers) {
+ props.handleBuyUsers(amount.quantity, _resAddon.addon);
+ }
}
} catch (err) {
console.log("Err in buy addon", err);
diff --git a/apps/OpenSign/src/pages/UserList.js b/apps/OpenSign/src/pages/UserList.js
index 8d1480aeb..15de405fa 100644
--- a/apps/OpenSign/src/pages/UserList.js
+++ b/apps/OpenSign/src/pages/UserList.js
@@ -124,11 +124,10 @@ const UserList = () => {
setAmount((prev) => ({ ...prev, price: subscribe.price }));
try {
const res = await Parse.Cloud.run("allowedusers");
- console.log("res ", res);
setUserCounts((obj) => ({
...obj,
- allowed: res,
- totalAllowed: subscribe?.totalAllowedUser || 0
+ allowed: parseInt(res),
+ totalAllowed: parseInt(subscribe?.totalAllowedUser) || 0
}));
} catch (err) {
console.log("err while get users", err);
@@ -207,9 +206,8 @@ const UserList = () => {
return "-";
}
};
- const handleClose = () => {
- setIsActiveModal({});
- };
+ const handleClose = () => setIsActiveModal({});
+
const handleToggleSubmit = async (user) => {
const index = userList.findIndex((obj) => obj.objectId === user.objectId);
if (index !== -1) {
@@ -248,16 +246,17 @@ const UserList = () => {
setIsBuyLoader(true);
try {
const resAddon = await Parse.Cloud.run("buyaddonusers", {
- users: amount.quantity
+ users: parseInt(amount.quantity)
});
if (resAddon) {
const _resAddon = JSON.parse(JSON.stringify(resAddon));
if (_resAddon.status === "success") {
setUserCounts((obj) => ({
...obj,
- allowed: obj.allowed + amount.quantity,
- totalAllowed: _resAddon.addon
+ allowed: parseInt(obj.allowed) + parseInt(amount.quantity),
+ totalAllowed: parseInt(_resAddon.addon)
}));
+ setAmount((obj) => ({ ...obj, quantity: 1 }));
}
}
} catch (err) {
@@ -274,6 +273,15 @@ const UserList = () => {
const price = e.target?.value > 0 ? isSubscribe.priceperUser * quantity : 0;
setAmount((prev) => ({ ...prev, quantity: quantity, price: price }));
};
+ const handleBuyUsers = (allowed, totalAllowed) => {
+ if (allowed && totalAllowed) {
+ setUserCounts((obj) => ({
+ ...obj,
+ allowed: parseInt(obj.allowed) + parseInt(allowed),
+ totalAllowed: parseInt(totalAllowed)
+ }));
+ }
+ };
return (
<div className="relative">
<Title title={isAdmin ? "Users" : "Page not found"} />
@@ -482,6 +490,7 @@ const UserList = () => {
<AddUser
setIsAlert={setIsAlert}
handleUserData={handleUserData}
+ handleBuyUsers={handleBuyUsers}
closePopup={() => handleModal("form")}
setFormHeader={setFormHeader}
/>