mirror of
https://github.com/OpenSignLabs/OpenSign.git
synced 2026-08-17 21:25:54 +02:00
Merge pull request #1203 from OpenSignLabs/validation
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user