Skip to content

Commit 5f6a423

Browse files
Merge pull request #1203 from OpenSignLabs/validation
2 parents 17c96fb + 5d24592 commit 5f6a423

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

apps/OpenSign/src/components/AddUser.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,9 @@ const AddUser = (props) => {
301301
setAllowedUser(amount.quantity);
302302
setPlanInfo((obj) => ({ ...obj, totalAllowedUser: _resAddon.addon }));
303303
}
304+
if (props.handleBuyUsers) {
305+
props.handleBuyUsers(amount.quantity, _resAddon.addon);
306+
}
304307
}
305308
} catch (err) {
306309
console.log("Err in buy addon", err);

apps/OpenSign/src/pages/UserList.js

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,10 @@ const UserList = () => {
124124
setAmount((prev) => ({ ...prev, price: subscribe.price }));
125125
try {
126126
const res = await Parse.Cloud.run("allowedusers");
127-
console.log("res ", res);
128127
setUserCounts((obj) => ({
129128
...obj,
130-
allowed: res,
131-
totalAllowed: subscribe?.totalAllowedUser || 0
129+
allowed: parseInt(res),
130+
totalAllowed: parseInt(subscribe?.totalAllowedUser) || 0
132131
}));
133132
} catch (err) {
134133
console.log("err while get users", err);
@@ -207,9 +206,8 @@ const UserList = () => {
207206
return "-";
208207
}
209208
};
210-
const handleClose = () => {
211-
setIsActiveModal({});
212-
};
209+
const handleClose = () => setIsActiveModal({});
210+
213211
const handleToggleSubmit = async (user) => {
214212
const index = userList.findIndex((obj) => obj.objectId === user.objectId);
215213
if (index !== -1) {
@@ -248,16 +246,17 @@ const UserList = () => {
248246
setIsBuyLoader(true);
249247
try {
250248
const resAddon = await Parse.Cloud.run("buyaddonusers", {
251-
users: amount.quantity
249+
users: parseInt(amount.quantity)
252250
});
253251
if (resAddon) {
254252
const _resAddon = JSON.parse(JSON.stringify(resAddon));
255253
if (_resAddon.status === "success") {
256254
setUserCounts((obj) => ({
257255
...obj,
258-
allowed: obj.allowed + amount.quantity,
259-
totalAllowed: _resAddon.addon
256+
allowed: parseInt(obj.allowed) + parseInt(amount.quantity),
257+
totalAllowed: parseInt(_resAddon.addon)
260258
}));
259+
setAmount((obj) => ({ ...obj, quantity: 1 }));
261260
}
262261
}
263262
} catch (err) {
@@ -274,6 +273,15 @@ const UserList = () => {
274273
const price = e.target?.value > 0 ? isSubscribe.priceperUser * quantity : 0;
275274
setAmount((prev) => ({ ...prev, quantity: quantity, price: price }));
276275
};
276+
const handleBuyUsers = (allowed, totalAllowed) => {
277+
if (allowed && totalAllowed) {
278+
setUserCounts((obj) => ({
279+
...obj,
280+
allowed: parseInt(obj.allowed) + parseInt(allowed),
281+
totalAllowed: parseInt(totalAllowed)
282+
}));
283+
}
284+
};
277285
return (
278286
<div className="relative">
279287
<Title title={isAdmin ? "Users" : "Page not found"} />
@@ -482,6 +490,7 @@ const UserList = () => {
482490
<AddUser
483491
setIsAlert={setIsAlert}
484492
handleUserData={handleUserData}
493+
handleBuyUsers={handleBuyUsers}
485494
closePopup={() => handleModal("form")}
486495
setFormHeader={setFormHeader}
487496
/>

0 commit comments

Comments
 (0)