Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apps/OpenSign/src/components/AddUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
27 changes: 18 additions & 9 deletions apps/OpenSign/src/pages/UserList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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"} />
Expand Down Expand Up @@ -482,6 +490,7 @@ const UserList = () => {
<AddUser
setIsAlert={setIsAlert}
handleUserData={handleUserData}
handleBuyUsers={handleBuyUsers}
closePopup={() => handleModal("form")}
setFormHeader={setFormHeader}
/>
Expand Down