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
39 changes: 23 additions & 16 deletions apps/OpenSign/src/components/BulkSendUi.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const BulkSendUi = (props) => {
price: (75.0).toFixed(2),
quantity: 500,
priceperbulksend: 0.15,
totalQuickSend: 0
totalcredits: 0
});
const [isQuotaReached, setIsQuotaReached] = useState(false);
const [isLoader, setIsLoader] = useState(false);
Expand All @@ -44,11 +44,16 @@ const BulkSendUi = (props) => {
if (subscription?.plan === "freeplan") {
setIsFreePlan(true);
}
const allowedquicksend = await Parse.Cloud.run("allowedquicksend");
if (allowedquicksend > 0) {
setIsBulkAvailable(true);
const resCredits = await Parse.Cloud.run("allowedcredits");
if (resCredits) {
const allowedcredits = resCredits?.allowedcredits || 0;
const addoncredits = resCredits?.addoncredits || 0;
const totalcredits = allowedcredits + addoncredits;
if (totalcredits > 0) {
setIsBulkAvailable(true);
}
setAmount((obj) => ({ ...obj, totalcredits: totalcredits }));
}
setAmount((obj) => ({ ...obj, totalQuickSend: allowedquicksend }));
const getPlaceholder = props.item?.Placeholders;
const checkIsSignatureExistt = getPlaceholder?.every((placeholderObj) =>
placeholderObj?.placeHolder?.some((holder) =>
Expand Down Expand Up @@ -121,7 +126,7 @@ const BulkSendUi = (props) => {
const handleAddForm = (e) => {
e.preventDefault();
// Check if the quick send limit has been reached
if (isEnableSubscription && forms.length >= amount.totalQuickSend) {
if (isEnableSubscription && forms.length >= amount.totalcredits) {
setIsQuotaReached(true);
} else {
if (forms?.length < allowedForm) {
Expand Down Expand Up @@ -244,8 +249,8 @@ const BulkSendUi = (props) => {
e.stopPropagation();
setIsSubmit(true);
try {
const resAddon = await Parse.Cloud.run("buyquicksend", {
quicksend: amount.quantity
const resAddon = await Parse.Cloud.run("buycredits", {
credits: amount.quantity
});
if (resAddon) {
const _resAddon = JSON.parse(JSON.stringify(resAddon));
Expand All @@ -257,7 +262,7 @@ const BulkSendUi = (props) => {
quantity: 500,
priceperbulksend: 0.15,
price: (75.0).toFixed(2),
totalQuickSend: _resAddon.addon
totalcredits: _resAddon.addon
}));
}
}
Expand Down Expand Up @@ -345,13 +350,15 @@ const BulkSendUi = (props) => {
))}
</div>
<div className="flex flex-col mx-4 mb-4 gap-3">
<button
onClick={handleAddForm}
className="op-btn op-btn-primary focus:outline-none"
>
<i className="fa-light fa-plus"></i>{" "}
<span>{t("add-new")}</span>
</button>
{isEnableSubscription && (
<button
onClick={handleAddForm}
className="op-btn op-btn-primary focus:outline-none"
>
<i className="fa-light fa-plus"></i>{" "}
<span>{t("add-new")}</span>
</button>
)}
<button
type="submit"
className="op-btn op-btn-accent focus:outline-none"
Expand Down
23 changes: 16 additions & 7 deletions apps/OpenSign/src/pages/GenerateToken.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ function GenerateToken() {
const [amount, setAmount] = useState({
quantity: 500,
priceperapi: 0.15,
totalapis: 0,
allowedcredits: 0,
addoncredits: 0,
price: (75.0).toFixed(2)
});
const [isFormLoader, setIsFormLoader] = useState(false);
Expand Down Expand Up @@ -59,8 +60,12 @@ function GenerateToken() {
};
const res = await axios.post(url, {}, { headers: headers });
if (res) {
const allowedapis = await Parse.Cloud.run("allowedapis");
setAmount((obj) => ({ ...obj, totalapis: allowedapis }));
const resCredits = await Parse.Cloud.run("allowedcredits");
setAmount((obj) => ({
...obj,
allowedcredits: resCredits.allowedcredits,
addoncredits: resCredits.addoncredits
}));
SetApiToken(res?.data?.result?.result);
}
const body = { email: Parse?.User?.current()?.getEmail() || "" };
Expand Down Expand Up @@ -142,8 +147,8 @@ function GenerateToken() {
e.stopPropagation();
setIsFormLoader(true);
try {
const resAddon = await Parse.Cloud.run("buyapis", {
apis: amount.quantity
const resAddon = await Parse.Cloud.run("buycredits", {
credits: amount.quantity
});
if (resAddon) {
const _resAddon = JSON.parse(JSON.stringify(resAddon));
Expand All @@ -153,7 +158,7 @@ function GenerateToken() {
quantity: 500,
priceperapi: 0.15,
price: (75.0).toFixed(2),
totalapis: _resAddon.addon
addoncredits: _resAddon.addon
}));
}
}
Expand Down Expand Up @@ -293,7 +298,11 @@ function GenerateToken() {
</li>
<div className="text-xs md:text-[15px] my-4">
<span className="font-medium">{t("remainingapis")}</span>{" "}
{amount.totalapis}
{amount.allowedcredits}
</div>
<div className="text-xs md:text-[15px] my-4">
<span className="font-medium">Addon credits: </span>{" "}
{amount.addoncredits}
</div>
<hr />
</ul>
Expand Down
14 changes: 12 additions & 2 deletions apps/OpenSign/src/primitives/GetReportDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -1456,7 +1456,13 @@ const ReportTable = (props) => {
<i className={act.btnIcon}></i>
{act.btnLabel && (
<span className="uppercase font-medium">
{t(`btnLabel.${act.btnLabel}`)}
{act.btnLabel.includes(
"Quick send"
) && isEnableSubscription
? "Bulk Send"
: `${t(
`btnLabel.${act.btnLabel}`
)}`}
</span>
)}
{isOption[item.objectId] &&
Expand Down Expand Up @@ -1783,7 +1789,11 @@ const ReportTable = (props) => {
{isBulkSend[item.objectId] && (
<ModalUi
isOpen
title={t("quick-send")}
title={
isEnableSubscription
? "Bulk send"
: t("quick-send")
}
handleClose={() => setIsBulkSend({})}
>
{isLoader[item.objectId] ? (
Expand Down
Loading