mirror of
https://github.com/OpenSignLabs/OpenSign.git
synced 2026-10-01 14:04:59 +02:00
Merge branch 'staging' of https://github.com/OpenSignLabs/OpenSign into raktima-patch-2
This commit is contained in:
@@ -477,7 +477,7 @@
|
|||||||
"role-not-found": "Role not found.",
|
"role-not-found": "Role not found.",
|
||||||
"do-not-access": "You don't have access, please contact the admin.",
|
"do-not-access": "You don't have access, please contact the admin.",
|
||||||
"add-admin": "Add admin",
|
"add-admin": "Add admin",
|
||||||
"opensign-setup": "Opensign Setup",
|
"opensign-setup": "OpenSign Setup",
|
||||||
"join-discord": "Join our discord server",
|
"join-discord": "Join our discord server",
|
||||||
"admin-already-exist": "Admin already exist.",
|
"admin-already-exist": "Admin already exist.",
|
||||||
"password-update-alert-1": "Password updated successfully.",
|
"password-update-alert-1": "Password updated successfully.",
|
||||||
@@ -533,7 +533,7 @@
|
|||||||
"filed-required-correctly": "Please fill required details correctly.",
|
"filed-required-correctly": "Please fill required details correctly.",
|
||||||
"admin-created": "Admin created",
|
"admin-created": "Admin created",
|
||||||
"invalid-masterkey": "Invalid masterkey",
|
"invalid-masterkey": "Invalid masterkey",
|
||||||
"opensign-Setup": "Opensign Setup",
|
"opensign-Setup": "OpenSign Setup",
|
||||||
"master-key": " Master key",
|
"master-key": " Master key",
|
||||||
"profile-update-alert": "Profile updated successfully.",
|
"profile-update-alert": "Profile updated successfully.",
|
||||||
"date": "Date",
|
"date": "Date",
|
||||||
@@ -595,7 +595,7 @@
|
|||||||
"Recently sent for signatures": "This is a list of documents you've sent to other parties for signature.",
|
"Recently sent for signatures": "This is a list of documents you've sent to other parties for signature.",
|
||||||
"Drafts": "This are documents you have started but have not finalized for sending.",
|
"Drafts": "This are documents you have started but have not finalized for sending.",
|
||||||
"public-template": "This video demonstrates how to set up your personalized public profile, such as ‘https://opensign.me/your-username’. You’ll also learn how to customize your tagline and make your templates available for public signing."
|
"public-template": "This video demonstrates how to set up your personalized public profile, such as ‘https://opensign.me/your-username’. You’ll also learn how to customize your tagline and make your templates available for public signing."
|
||||||
},
|
},
|
||||||
"enter-email-plaholder": "Add an email address and hit enter",
|
"enter-email-plaholder": "Add an email address and hit enter",
|
||||||
"success-email-alert": "Email sent successfully!",
|
"success-email-alert": "Email sent successfully!",
|
||||||
"expired-doc-title": "Expired Document",
|
"expired-doc-title": "Expired Document",
|
||||||
@@ -646,6 +646,7 @@
|
|||||||
"copy-code":"COPY",
|
"copy-code":"COPY",
|
||||||
"copied-code":"COPIED",
|
"copied-code":"COPIED",
|
||||||
"Installation":"Installation",
|
"Installation":"Installation",
|
||||||
"Usage" :"Usage"
|
"Usage" :"Usage",
|
||||||
|
"unauthorized-modal":"You don't have permission to perform this action, please contact {{adminName}}<{{adminEmail}}>."
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -476,7 +476,7 @@
|
|||||||
"role-not-found": "Rôle introuvable.",
|
"role-not-found": "Rôle introuvable.",
|
||||||
"do-not-access": "Vous n'y avez pas accès, veuillez contacter l'administrateur.",
|
"do-not-access": "Vous n'y avez pas accès, veuillez contacter l'administrateur.",
|
||||||
"add-admin": "Ajouter un administrateur",
|
"add-admin": "Ajouter un administrateur",
|
||||||
"opensign-setup": "Configuration d'Opensign",
|
"opensign-setup": "Configuration d'OpenSign",
|
||||||
"join-discord": "Rejoignez notre serveur Discord",
|
"join-discord": "Rejoignez notre serveur Discord",
|
||||||
"admin-already-exist": "L'administrateur existe déjà.",
|
"admin-already-exist": "L'administrateur existe déjà.",
|
||||||
"password-update-alert-1": "Mot de passe mis à jour avec succès.",
|
"password-update-alert-1": "Mot de passe mis à jour avec succès.",
|
||||||
@@ -532,7 +532,7 @@
|
|||||||
"filed-required-correctly": "Veuillez remplir correctement les informations requises.",
|
"filed-required-correctly": "Veuillez remplir correctement les informations requises.",
|
||||||
"admin-created": "Administrateur créé",
|
"admin-created": "Administrateur créé",
|
||||||
"invalid-masterkey": "Clé principale invalide",
|
"invalid-masterkey": "Clé principale invalide",
|
||||||
"opensign-Setup": "Configuration d'Opensign",
|
"opensign-Setup": "Configuration d'OpenSign",
|
||||||
"master-key": "La clef maitresse",
|
"master-key": "La clef maitresse",
|
||||||
"profile-update-alert": "Mise à jour du profil réussie.",
|
"profile-update-alert": "Mise à jour du profil réussie.",
|
||||||
"date": "Date",
|
"date": "Date",
|
||||||
@@ -646,6 +646,7 @@
|
|||||||
"copy-code":"COPIE",
|
"copy-code":"COPIE",
|
||||||
"copied-code":"COPIÉ",
|
"copied-code":"COPIÉ",
|
||||||
"Installation":"Installation",
|
"Installation":"Installation",
|
||||||
"Usage" :"Usage"
|
"Usage" :"Usage",
|
||||||
|
"unauthorized-modal":"Vous n'êtes pas autorisé à effectuer cette action, veuillez contacter {{adminName}}<{{adminEmail}}>."
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,12 @@ const BulkSendUi = (props) => {
|
|||||||
const [isQuotaReached, setIsQuotaReached] = useState(false);
|
const [isQuotaReached, setIsQuotaReached] = useState(false);
|
||||||
const [isLoader, setIsLoader] = useState(false);
|
const [isLoader, setIsLoader] = useState(false);
|
||||||
const [isFreePlan, setIsFreePlan] = useState(false);
|
const [isFreePlan, setIsFreePlan] = useState(false);
|
||||||
|
const [admin, setAdmin] = useState({
|
||||||
|
objectId: "",
|
||||||
|
name: "",
|
||||||
|
email: "",
|
||||||
|
isAdmin: true
|
||||||
|
});
|
||||||
const allowedSigners = 50;
|
const allowedSigners = 50;
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
signatureExist();
|
signatureExist();
|
||||||
@@ -41,6 +47,27 @@ const BulkSendUi = (props) => {
|
|||||||
setIsLoader(true);
|
setIsLoader(true);
|
||||||
try {
|
try {
|
||||||
const subscription = await fetchSubscription();
|
const subscription = await fetchSubscription();
|
||||||
|
const extUser =
|
||||||
|
localStorage.getItem("Extand_Class") &&
|
||||||
|
JSON.parse(localStorage.getItem("Extand_Class"))?.[0];
|
||||||
|
if (
|
||||||
|
subscription?.adminId &&
|
||||||
|
extUser?.objectId === subscription?.adminId
|
||||||
|
) {
|
||||||
|
setAdmin((obj) => ({
|
||||||
|
...obj,
|
||||||
|
objectId: subscription?.adminId,
|
||||||
|
isAdmin: true
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
setAdmin((obj) => ({
|
||||||
|
...obj,
|
||||||
|
isAdmin: false,
|
||||||
|
name: extUser?.CreatedBy?.name,
|
||||||
|
email: extUser?.CreatedBy?.email
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
setAdmin((obj) => ({ ...obj, objectId: subscription?.adminId }));
|
||||||
if (subscription?.plan === "freeplan") {
|
if (subscription?.plan === "freeplan") {
|
||||||
setIsFreePlan(true);
|
setIsFreePlan(true);
|
||||||
}
|
}
|
||||||
@@ -69,6 +96,7 @@ const BulkSendUi = (props) => {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setIsBulkAvailable(true);
|
setIsBulkAvailable(true);
|
||||||
|
setAdmin((obj) => ({ ...obj, isAdmin: true }));
|
||||||
const getPlaceholder = props.item?.Placeholders;
|
const getPlaceholder = props.item?.Placeholders;
|
||||||
const checkIsSignatureExistt = getPlaceholder?.every((placeholderObj) =>
|
const checkIsSignatureExistt = getPlaceholder?.every((placeholderObj) =>
|
||||||
placeholderObj?.placeHolder?.some((holder) =>
|
placeholderObj?.placeHolder?.some((holder) =>
|
||||||
@@ -417,46 +445,57 @@ const BulkSendUi = (props) => {
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<form onSubmit={handleAddOnQuickSubmit} className="p-3">
|
<>
|
||||||
<p className="flex justify-center text-center mx-2 mb-3 text-base op-text-accent font-medium">
|
{admin?.isAdmin ? (
|
||||||
{t("additional-credits")}
|
<form onSubmit={handleAddOnQuickSubmit} className="p-3">
|
||||||
</p>
|
<p className="flex justify-center text-center mx-2 mb-3 text-base op-text-accent font-medium">
|
||||||
<div className="mb-3 flex justify-between">
|
{t("additional-credits")}
|
||||||
<label
|
</p>
|
||||||
htmlFor="quantity"
|
<div className="mb-3 flex justify-between">
|
||||||
className="block text-xs text-gray-700 font-semibold"
|
<label
|
||||||
>
|
htmlFor="quantity"
|
||||||
{t("quantityofcredits")}
|
className="block text-xs text-gray-700 font-semibold"
|
||||||
<span className="text-[red] text-[13px]">*</span>
|
>
|
||||||
</label>
|
{t("quantityofcredits")}
|
||||||
<select
|
<span className="text-[red] text-[13px]">*</span>
|
||||||
value={amount.quantity}
|
</label>
|
||||||
onChange={(e) => handlePricePerQuick(e)}
|
<select
|
||||||
name="quantity"
|
value={amount.quantity}
|
||||||
className="op-select op-select-bordered op-select-sm focus:outline-none hover:border-base-content w-1/4 text-xs"
|
onChange={(e) => handlePricePerQuick(e)}
|
||||||
required
|
name="quantity"
|
||||||
>
|
className="op-select op-select-bordered op-select-sm focus:outline-none hover:border-base-content w-1/4 text-xs"
|
||||||
{quantityList.length > 0 &&
|
required
|
||||||
quantityList.map((x) => (
|
>
|
||||||
<option key={x} value={x}>
|
{quantityList.length > 0 &&
|
||||||
{x}
|
quantityList.map((x) => (
|
||||||
</option>
|
<option key={x} value={x}>
|
||||||
))}
|
{x}
|
||||||
</select>
|
</option>
|
||||||
</div>
|
))}
|
||||||
<div className="mb-3 flex justify-between">
|
</select>
|
||||||
<label className="block text-xs text-gray-700 font-semibold">
|
</div>
|
||||||
{t("Price")} (1 * {amount.priceperbulksend})
|
<div className="mb-3 flex justify-between">
|
||||||
</label>
|
<label className="block text-xs text-gray-700 font-semibold">
|
||||||
<div className="w-1/4 flex justify-center items-center text-sm">
|
{t("Price")} (1 * {amount.priceperbulksend})
|
||||||
USD {amount.price}
|
</label>
|
||||||
|
<div className="w-1/4 flex justify-center items-center text-sm">
|
||||||
|
USD {amount.price}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<hr className="text-base-content mb-3" />
|
||||||
|
<button className="op-btn op-btn-primary w-full mt-2">
|
||||||
|
{t("Proceed")}
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
) : (
|
||||||
|
<div className="mx-8 mt-4 mb-8 flex justify-center text-center items-center font-medium break-all">
|
||||||
|
{t("unauthorized-modal", {
|
||||||
|
adminName: admin?.name,
|
||||||
|
adminEmail: admin?.email
|
||||||
|
})}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
)}
|
||||||
<hr className="text-base-content mb-3" />
|
</>
|
||||||
<button className="op-btn op-btn-primary w-full mt-2">
|
|
||||||
{t("Proceed")}
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ const Header = ({ showSidebar }) => {
|
|||||||
const { t, i18n } = useTranslation();
|
const { t, i18n } = useTranslation();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { width } = useWindowSize();
|
const { width } = useWindowSize();
|
||||||
let username = localStorage.getItem("username");
|
const username = localStorage.getItem("username") || "";
|
||||||
const image = localStorage.getItem("profileImg") || dp;
|
const image = localStorage.getItem("profileImg") || dp;
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
const [isSubscribe, setIsSubscribe] = useState(true);
|
const [isSubscribe, setIsSubscribe] = useState(true);
|
||||||
@@ -26,6 +26,7 @@ const Header = ({ showSidebar }) => {
|
|||||||
const [applogo, setAppLogo] = useState(
|
const [applogo, setAppLogo] = useState(
|
||||||
localStorage.getItem("appLogo") || " "
|
localStorage.getItem("appLogo") || " "
|
||||||
);
|
);
|
||||||
|
const [emailUsed, setEmailUsed] = useState(0);
|
||||||
|
|
||||||
const toggleDropdown = () => {
|
const toggleDropdown = () => {
|
||||||
setIsOpen(!isOpen);
|
setIsOpen(!isOpen);
|
||||||
@@ -47,6 +48,13 @@ const Header = ({ showSidebar }) => {
|
|||||||
}
|
}
|
||||||
setIsTeam(subscribe);
|
setIsTeam(subscribe);
|
||||||
setIsSubscribe(subscribe.isValid);
|
setIsSubscribe(subscribe.isValid);
|
||||||
|
try {
|
||||||
|
const extUser = await Parse.Cloud.run("getUserDetails");
|
||||||
|
const MonthlyFreeEmails = extUser?.get("MonthlyFreeEmails") || 0;
|
||||||
|
setEmailUsed(MonthlyFreeEmails);
|
||||||
|
} catch (err) {
|
||||||
|
console.log("err in while fetching monthlyfreeEmails", err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,6 +203,14 @@ const Header = ({ showSidebar }) => {
|
|||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
className="mt-3 z-[1] p-2 shadow op-menu op-menu-sm op-dropdown-content text-base-content bg-base-100 rounded-box w-52"
|
className="mt-3 z-[1] p-2 shadow op-menu op-menu-sm op-dropdown-content text-base-content bg-base-100 rounded-box w-52"
|
||||||
>
|
>
|
||||||
|
{isEnableSubscription && isTeam?.plan === "freeplan" && (
|
||||||
|
<li className="cursor-pointer">
|
||||||
|
<span>
|
||||||
|
<i className="fa-light fa-envelope"></i> Email used:{" "}
|
||||||
|
{emailUsed}/20
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
)}
|
||||||
<li onClick={() => openInNewTab("https://docs.opensignlabs.com")}>
|
<li onClick={() => openInNewTab("https://docs.opensignlabs.com")}>
|
||||||
<span>
|
<span>
|
||||||
<i className="fa-light fa-book"></i> {t("docs")}
|
<i className="fa-light fa-book"></i> {t("docs")}
|
||||||
|
|||||||
@@ -357,7 +357,7 @@ function DriveBody(props) {
|
|||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
handleMenuItemClick("Download", data);
|
handleMenuItemClick("Download", data);
|
||||||
}}
|
}}
|
||||||
className="fa-light fa-download mr-[8px] op-text-primary"
|
className="fa-light fa-download mr-[8px] op-text-primary cursor-pointer"
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
></i>
|
></i>
|
||||||
</td>
|
</td>
|
||||||
@@ -370,7 +370,11 @@ function DriveBody(props) {
|
|||||||
{/* folder */}
|
{/* folder */}
|
||||||
<div
|
<div
|
||||||
data-tut={props.dataTutSeventh}
|
data-tut={props.dataTutSeventh}
|
||||||
onClick={() => handleOnclikFolder(data)}
|
onClick={() => {
|
||||||
|
if (!rename) {
|
||||||
|
handleOnclikFolder(data);
|
||||||
|
}
|
||||||
|
}}
|
||||||
className="cursor-pointer"
|
className="cursor-pointer"
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
@@ -383,7 +387,6 @@ function DriveBody(props) {
|
|||||||
{rename === data.objectId ? (
|
{rename === data.objectId ? (
|
||||||
<input
|
<input
|
||||||
onFocus={() => {
|
onFocus={() => {
|
||||||
inputRef.current.setSelectionRange(0, 0);
|
|
||||||
const input = inputRef.current;
|
const input = inputRef.current;
|
||||||
if (input) {
|
if (input) {
|
||||||
input.select();
|
input.select();
|
||||||
@@ -395,9 +398,8 @@ function DriveBody(props) {
|
|||||||
onKeyDown={(e) => handleEnterPress(e, data)}
|
onKeyDown={(e) => handleEnterPress(e, data)}
|
||||||
ref={inputRef}
|
ref={inputRef}
|
||||||
defaultValue={renameValue}
|
defaultValue={renameValue}
|
||||||
// value={renameValue}
|
|
||||||
onChange={(e) => setRenameValue(e.target.value)}
|
onChange={(e) => setRenameValue(e.target.value)}
|
||||||
className="w-[100px] border-[1.5px] border-black rounded-sm text-[10px]"
|
className="op-input op-input-bordered op-input-xs w-[100px] focus:outline-none hover:border-base-content text-[10px]"
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<span className="fileName">{data.Name}</span>
|
<span className="fileName">{data.Name}</span>
|
||||||
@@ -423,7 +425,11 @@ function DriveBody(props) {
|
|||||||
</ContextMenu.Root>
|
</ContextMenu.Root>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<HoverCard.Root openDelay={0} closeDelay={100}>
|
<HoverCard.Root
|
||||||
|
open={rename ? false : undefined}
|
||||||
|
openDelay={0}
|
||||||
|
closeDelay={100}
|
||||||
|
>
|
||||||
<HoverCard.Trigger asChild>
|
<HoverCard.Trigger asChild>
|
||||||
<div>
|
<div>
|
||||||
<ContextMenu.Root>
|
<ContextMenu.Root>
|
||||||
@@ -432,7 +438,11 @@ function DriveBody(props) {
|
|||||||
{/* pdf */}
|
{/* pdf */}
|
||||||
<div
|
<div
|
||||||
data-tut={props.dataTutSixth}
|
data-tut={props.dataTutSixth}
|
||||||
onClick={() => checkPdfStatus(data)}
|
onClick={() => {
|
||||||
|
if (!rename) {
|
||||||
|
checkPdfStatus(data);
|
||||||
|
}
|
||||||
|
}}
|
||||||
className="cursor-pointer"
|
className="cursor-pointer"
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
@@ -447,7 +457,6 @@ function DriveBody(props) {
|
|||||||
autoFocus={true}
|
autoFocus={true}
|
||||||
type="text"
|
type="text"
|
||||||
onFocus={() => {
|
onFocus={() => {
|
||||||
inputRef.current.setSelectionRange(0, 0);
|
|
||||||
const input = inputRef.current;
|
const input = inputRef.current;
|
||||||
if (input) {
|
if (input) {
|
||||||
input.select();
|
input.select();
|
||||||
@@ -457,9 +466,8 @@ function DriveBody(props) {
|
|||||||
onKeyDown={(e) => handleEnterPress(e, data)}
|
onKeyDown={(e) => handleEnterPress(e, data)}
|
||||||
ref={inputRef}
|
ref={inputRef}
|
||||||
defaultValue={renameValue}
|
defaultValue={renameValue}
|
||||||
// value={renameValue}
|
|
||||||
onChange={(e) => setRenameValue(e.target.value)}
|
onChange={(e) => setRenameValue(e.target.value)}
|
||||||
className="w-[100px] border-[1.5px] border-black rounded-sm text-[10px]"
|
className="op-input op-input-bordered op-input-xs w-[100px] focus:outline-none hover:border-base-content text-[10px]"
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<span className="fileName">{data.Name}</span>
|
<span className="fileName">{data.Name}</span>
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ export async function fetchSubscription(
|
|||||||
? { contactId: contactObjId }
|
? { contactId: contactObjId }
|
||||||
: { extUserId: extUser };
|
: { extUserId: extUser };
|
||||||
const tenatRes = await axios.post(url, params, { headers: headers });
|
const tenatRes = await axios.post(url, params, { headers: headers });
|
||||||
let plan, status, billingDate;
|
let plan, status, billingDate, adminId;
|
||||||
if (isGuestSign) {
|
if (isGuestSign) {
|
||||||
plan = tenatRes.data?.result?.result?.plan;
|
plan = tenatRes.data?.result?.result?.plan;
|
||||||
status = tenatRes.data?.result?.result?.isSubscribed;
|
status = tenatRes.data?.result?.result?.isSubscribed;
|
||||||
@@ -64,12 +64,13 @@ export async function fetchSubscription(
|
|||||||
plan = tenatRes.data?.result?.result?.PlanCode;
|
plan = tenatRes.data?.result?.result?.PlanCode;
|
||||||
billingDate = tenatRes.data?.result?.result?.Next_billing_date?.iso;
|
billingDate = tenatRes.data?.result?.result?.Next_billing_date?.iso;
|
||||||
const allowedUsers = tenatRes.data?.result?.result?.AllowedUsers || 0;
|
const allowedUsers = tenatRes.data?.result?.result?.AllowedUsers || 0;
|
||||||
|
adminId = tenatRes?.data?.result?.result?.ExtUserPtr?.objectId;
|
||||||
localStorage.setItem("allowedUsers", allowedUsers);
|
localStorage.setItem("allowedUsers", allowedUsers);
|
||||||
}
|
}
|
||||||
return { plan, billingDate, status };
|
return { plan, billingDate, status, adminId };
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log("Err in fetch subscription", err);
|
console.log("Err in fetch subscription", err);
|
||||||
return { plan: "", billingDate: "" };
|
return { plan: "", billingDate: "", status: "", adminId: "" };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,22 +123,22 @@ export async function checkIsSubscribed() {
|
|||||||
try {
|
try {
|
||||||
const res = await fetchSubscription();
|
const res = await fetchSubscription();
|
||||||
if (res.plan === "freeplan") {
|
if (res.plan === "freeplan") {
|
||||||
return { plan: res.plan, isValid: false };
|
return { plan: res.plan, isValid: false, adminId: res?.adminId };
|
||||||
} else if (res.billingDate) {
|
} else if (res.billingDate) {
|
||||||
const plan = validplan[res.plan] || false;
|
const plan = validplan[res.plan] || false;
|
||||||
if (plan && new Date(res.billingDate) > new Date()) {
|
if (plan && new Date(res.billingDate) > new Date()) {
|
||||||
return { plan: res.plan, isValid: true };
|
return { plan: res.plan, isValid: true, adminId: res?.adminId };
|
||||||
} else if (new Date(res.billingDate) > new Date()) {
|
} else if (new Date(res.billingDate) > new Date()) {
|
||||||
return { plan: res.plan, isValid: true };
|
return { plan: res.plan, isValid: true, adminId: res?.adminId };
|
||||||
} else {
|
} else {
|
||||||
return { plan: res.plan, isValid: false };
|
return { plan: res.plan, isValid: false, adminId: res?.adminId };
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return { plan: res.plan, isValid: false };
|
return { plan: res.plan, isValid: false, adminId: res?.adminId };
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log("Err in fetch subscription", err);
|
console.log("Err in fetch subscription", err);
|
||||||
return { plan: "no-plan", isValid: false };
|
return { plan: "no-plan", isValid: false, adminId: "" };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ const dashboardJson = [
|
|||||||
queryType: "",
|
queryType: "",
|
||||||
class: "contracts_Document",
|
class: "contracts_Document",
|
||||||
query:
|
query:
|
||||||
'where={"Type":{"#*ne":"Folder"},"Signers":{"#*exists":true,"#*ne":[]},"Placeholders":{"#*ne":null},"IsCompleted":{"#*ne":true},"IsDeclined":{"#*ne":true},"IsArchive":{"#*ne":true},"CreatedBy":{"__type":"Pointer","className":"_User","objectId":"#UserId.objectId#"},"ExpiryDate":{"#*gt":{"__type":"#Date#","iso":"#today#"}}}&count=1',
|
'where={"Type":{"#*ne":"Folder"},"Signers":{"#*exists":true,"#*ne":[]},"Placeholders":{"#*ne":null},"SignedUrl":{"#*ne":null},"IsCompleted":{"#*ne":true},"IsDeclined":{"#*ne":true},"IsArchive":{"#*ne":true},"CreatedBy":{"__type":"Pointer","className":"_User","objectId":"#UserId.objectId#"},"ExpiryDate":{"#*gt":{"__type":"#Date#","iso":"#today#"}}}&count=1',
|
||||||
key: "count",
|
key: "count",
|
||||||
Redirect_type: "Report",
|
Redirect_type: "Report",
|
||||||
Redirect_id: "1MwEuxLEkF",
|
Redirect_id: "1MwEuxLEkF",
|
||||||
|
|||||||
@@ -21,9 +21,16 @@ function GenerateToken() {
|
|||||||
const [isLoader, setIsLoader] = useState(true);
|
const [isLoader, setIsLoader] = useState(true);
|
||||||
const [isModal, setIsModal] = useState({
|
const [isModal, setIsModal] = useState({
|
||||||
generateapi: false,
|
generateapi: false,
|
||||||
buyapis: false
|
buyapis: false,
|
||||||
|
unauthorized: false
|
||||||
|
});
|
||||||
|
const [isSubscribe, setIsSubscribe] = useState({
|
||||||
|
plan: "",
|
||||||
|
isValid: false,
|
||||||
|
adminId: "",
|
||||||
|
adminName: "",
|
||||||
|
adminEmail: ""
|
||||||
});
|
});
|
||||||
const [isSubscribe, setIsSubscribe] = useState({ plan: "", isValid: false });
|
|
||||||
const [isAlert, setIsAlert] = useState({ type: "success", msg: "" });
|
const [isAlert, setIsAlert] = useState({ type: "success", msg: "" });
|
||||||
const [isTour, setIsTour] = useState(false);
|
const [isTour, setIsTour] = useState(false);
|
||||||
const [amount, setAmount] = useState({
|
const [amount, setAmount] = useState({
|
||||||
@@ -139,10 +146,24 @@ function GenerateToken() {
|
|||||||
if (isSubscribe?.plan === "freeplan" && isEnableSubscription) {
|
if (isSubscribe?.plan === "freeplan" && isEnableSubscription) {
|
||||||
setIsTour(true);
|
setIsTour(true);
|
||||||
} else {
|
} else {
|
||||||
setIsModal((obj) => ({ ...obj, buyapis: !obj.buyapis }));
|
const extUser =
|
||||||
|
localStorage.getItem("Extand_Class") &&
|
||||||
|
JSON.parse(localStorage.getItem("Extand_Class"))?.[0];
|
||||||
|
if (isSubscribe?.adminId && extUser?.objectId === isSubscribe?.adminId) {
|
||||||
|
setIsModal((obj) => ({ ...obj, buyapis: !obj.buyapis }));
|
||||||
|
} else {
|
||||||
|
setIsSubscribe((obj) => ({
|
||||||
|
...obj,
|
||||||
|
adminName: extUser?.CreatedBy?.name,
|
||||||
|
adminEmail: extUser?.CreatedBy?.email
|
||||||
|
}));
|
||||||
|
setIsModal((obj) => ({ ...obj, unauthorized: !obj.unauthorized }));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
const handleCloseModal = () => {
|
||||||
|
setIsModal({ generateapi: false, buyapis: false, unauthorized: false });
|
||||||
|
};
|
||||||
const handlePricePerAPIs = (e) => {
|
const handlePricePerAPIs = (e) => {
|
||||||
const quantity = e.target?.value;
|
const quantity = e.target?.value;
|
||||||
const price =
|
const price =
|
||||||
@@ -374,7 +395,7 @@ function GenerateToken() {
|
|||||||
<ModalUi
|
<ModalUi
|
||||||
isOpen={isModal.buyapis}
|
isOpen={isModal.buyapis}
|
||||||
title={"Buy Credits"}
|
title={"Buy Credits"}
|
||||||
handleClose={handleBuyAPIsModal}
|
handleClose={handleCloseModal}
|
||||||
>
|
>
|
||||||
{isFormLoader && (
|
{isFormLoader && (
|
||||||
<div className="absolute w-full h-full inset-0 flex justify-center items-center bg-base-content/30 z-50">
|
<div className="absolute w-full h-full inset-0 flex justify-center items-center bg-base-content/30 z-50">
|
||||||
@@ -419,6 +440,18 @@ function GenerateToken() {
|
|||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
</ModalUi>
|
</ModalUi>
|
||||||
|
<ModalUi
|
||||||
|
isOpen={isModal.unauthorized}
|
||||||
|
title={"Unauthorized"}
|
||||||
|
handleClose={handleCloseModal}
|
||||||
|
>
|
||||||
|
<div className="m-8 flex justify-center text-center items-center font-medium break-all">
|
||||||
|
{t("unauthorized-modal", {
|
||||||
|
adminName: isSubscribe?.adminName,
|
||||||
|
adminEmail: isSubscribe?.adminEmail
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</ModalUi>
|
||||||
</div>
|
</div>
|
||||||
{isEnableSubscription && isSubscribe?.plan === "freeplan" && (
|
{isEnableSubscription && isSubscribe?.plan === "freeplan" && (
|
||||||
<div data-tut="apisubscribe">
|
<div data-tut="apisubscribe">
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
import { combineReducers } from "redux";
|
|
||||||
import infoReducer from "./infoReducer";
|
|
||||||
import ShowTenant from "./ShowTenant";
|
|
||||||
import TourStepsReducer from "./TourStepsReducer";
|
|
||||||
import showHeader from "./showHeader";
|
|
||||||
|
|
||||||
export default combineReducers({
|
|
||||||
appInfo: infoReducer,
|
|
||||||
TourSteps: TourStepsReducer,
|
|
||||||
ShowTenant,
|
|
||||||
showHeader
|
|
||||||
});
|
|
||||||
@@ -475,7 +475,7 @@
|
|||||||
"role-not-found": "Role not found.",
|
"role-not-found": "Role not found.",
|
||||||
"do-not-access": "You don't have access, please contact the admin.",
|
"do-not-access": "You don't have access, please contact the admin.",
|
||||||
"add-admin": "Add admin",
|
"add-admin": "Add admin",
|
||||||
"opensign-setup": "Opensign Setup",
|
"opensign-setup": "OpenSign Setup",
|
||||||
"join-discord": "Join our discord server",
|
"join-discord": "Join our discord server",
|
||||||
"admin-already-exist": "Admin already exist.",
|
"admin-already-exist": "Admin already exist.",
|
||||||
"password-update-alert-1": "Password updated successfully.",
|
"password-update-alert-1": "Password updated successfully.",
|
||||||
@@ -531,7 +531,7 @@
|
|||||||
"filed-required-correctly": "Please fill required details correctly.",
|
"filed-required-correctly": "Please fill required details correctly.",
|
||||||
"admin-created": "Admin created",
|
"admin-created": "Admin created",
|
||||||
"invalid-masterkey": "Invalid masterkey",
|
"invalid-masterkey": "Invalid masterkey",
|
||||||
"opensign-Setup": "Opensign Setup",
|
"opensign-Setup": "OpenSign Setup",
|
||||||
"master-key": " Master key",
|
"master-key": " Master key",
|
||||||
"profile-update-alert": "Profile updated successfully.",
|
"profile-update-alert": "Profile updated successfully.",
|
||||||
"date": "Date",
|
"date": "Date",
|
||||||
@@ -631,6 +631,7 @@
|
|||||||
"quotamailselfsign": "You've reached your limit of 20 emails for this month. Upgrade now to continue sending emails directly.",
|
"quotamailselfsign": "You've reached your limit of 20 emails for this month. Upgrade now to continue sending emails directly.",
|
||||||
"quotamail": "You've reached your limit of 20 signature request emails for this month. Upgrade now to continue sending emails directly.",
|
"quotamail": "You've reached your limit of 20 signature request emails for this month. Upgrade now to continue sending emails directly.",
|
||||||
"quotamailTip":"Tip: You can still sign unlimited documents by manually sharing the signing request links below.",
|
"quotamailTip":"Tip: You can still sign unlimited documents by manually sharing the signing request links below.",
|
||||||
"quotamailhead":"Quota Reached"
|
"quotamailhead":"Quota Reached",
|
||||||
|
"unauthorized-modal":"You don't have permission to perform this action, please contact {{adminName}}<{{adminEmail}}>."
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -474,7 +474,7 @@
|
|||||||
"role-not-found": "Rôle introuvable.",
|
"role-not-found": "Rôle introuvable.",
|
||||||
"do-not-access": "Vous n'y avez pas accès, veuillez contacter l'administrateur.",
|
"do-not-access": "Vous n'y avez pas accès, veuillez contacter l'administrateur.",
|
||||||
"add-admin": "Ajouter un administrateur",
|
"add-admin": "Ajouter un administrateur",
|
||||||
"opensign-setup": "Configuration d'Opensign",
|
"opensign-setup": "Configuration d'OpenSign",
|
||||||
"join-discord": "Rejoignez notre serveur Discord",
|
"join-discord": "Rejoignez notre serveur Discord",
|
||||||
"admin-already-exist": "L'administrateur existe déjà.",
|
"admin-already-exist": "L'administrateur existe déjà.",
|
||||||
"password-update-alert-1": "Mot de passe mis à jour avec succès.",
|
"password-update-alert-1": "Mot de passe mis à jour avec succès.",
|
||||||
@@ -530,7 +530,7 @@
|
|||||||
"filed-required-correctly": "Veuillez remplir correctement les informations requises.",
|
"filed-required-correctly": "Veuillez remplir correctement les informations requises.",
|
||||||
"admin-created": "Administrateur créé",
|
"admin-created": "Administrateur créé",
|
||||||
"invalid-masterkey": "Clé principale invalide",
|
"invalid-masterkey": "Clé principale invalide",
|
||||||
"opensign-Setup": "Configuration d'Opensign",
|
"opensign-Setup": "Configuration d'OpenSign",
|
||||||
"master-key": "La clef maitresse",
|
"master-key": "La clef maitresse",
|
||||||
"profile-update-alert": "Mise à jour du profil réussie.",
|
"profile-update-alert": "Mise à jour du profil réussie.",
|
||||||
"date": "Date",
|
"date": "Date",
|
||||||
@@ -631,6 +631,7 @@
|
|||||||
"quotamailselfsign": "Vous avez atteint votre limite de 20 e-mails pour ce mois. Mettez à niveau maintenant pour continuer à envoyer des e-mails directement.",
|
"quotamailselfsign": "Vous avez atteint votre limite de 20 e-mails pour ce mois. Mettez à niveau maintenant pour continuer à envoyer des e-mails directement.",
|
||||||
"quotamail": "Vous avez atteint votre limite de 20 e-mails de demande de signature pour ce mois. Mettez à niveau maintenant pour continuer à envoyer des e-mails directement.",
|
"quotamail": "Vous avez atteint votre limite de 20 e-mails de demande de signature pour ce mois. Mettez à niveau maintenant pour continuer à envoyer des e-mails directement.",
|
||||||
"quotamailTip":"Astuce : Vous pouvez toujours signer un nombre illimité de documents en partageant manuellement les liens de demande de signature ci-dessous.",
|
"quotamailTip":"Astuce : Vous pouvez toujours signer un nombre illimité de documents en partageant manuellement les liens de demande de signature ci-dessous.",
|
||||||
"quotamailhead":"Quota atteint"
|
"quotamailhead":"Quota atteint",
|
||||||
|
"unauthorized-modal":"Vous n'êtes pas autorisé à effectuer cette action, veuillez contacter {{adminName}}<{{adminEmail}}>."
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,15 +103,15 @@ export const updateMailCount = async (extUserId, plan, monthchange) => {
|
|||||||
if (plan === 'freeplan') {
|
if (plan === 'freeplan') {
|
||||||
if (monthchange) {
|
if (monthchange) {
|
||||||
contractUser.set('LastEmailCountReset', new Date());
|
contractUser.set('LastEmailCountReset', new Date());
|
||||||
contractUser.set('MontlyfreeEmails', 1);
|
contractUser.set('MonthlyFreeEmails', 1);
|
||||||
} else {
|
} else {
|
||||||
if (contractUser?.get('MontlyfreeEmails')) {
|
if (contractUser?.get('MonthlyFreeEmails')) {
|
||||||
contractUser.increment('MontlyfreeEmails', 1);
|
contractUser.increment('MonthlyFreeEmails', 1);
|
||||||
if (contractUser?.get('LastEmailCountReset')) {
|
if (contractUser?.get('LastEmailCountReset')) {
|
||||||
contractUser.set('LastEmailCountReset', new Date());
|
contractUser.set('LastEmailCountReset', new Date());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
contractUser.set('MontlyfreeEmails', 1);
|
contractUser.set('MonthlyFreeEmails', 1);
|
||||||
contractUser.set('LastEmailCountReset', new Date());
|
contractUser.set('LastEmailCountReset', new Date());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,10 @@ export default async function saveSubscription(request, response) {
|
|||||||
const Next_billing_date = request.body?.data?.subscription?.next_billing_at;
|
const Next_billing_date = request.body?.data?.subscription?.next_billing_at;
|
||||||
const planCode = request.body?.data?.subscription?.plan?.plan_code;
|
const planCode = request.body?.data?.subscription?.plan?.plan_code;
|
||||||
const addons = request.body?.data?.subscription?.addons || [];
|
const addons = request.body?.data?.subscription?.addons || [];
|
||||||
|
const event = request.body?.data?.event_type || '';
|
||||||
const credits = planCredits?.[planCode] || 0;
|
const credits = planCredits?.[planCode] || 0;
|
||||||
let existAddon = 0;
|
const isTeamPlan = planCode?.includes('team');
|
||||||
|
let newAddons = 0;
|
||||||
if (addons?.length > 0) {
|
if (addons?.length > 0) {
|
||||||
let allowedUsersMonthly = 0;
|
let allowedUsersMonthly = 0;
|
||||||
let allowedUsersYearly = 0;
|
let allowedUsersYearly = 0;
|
||||||
@@ -22,11 +24,11 @@ export default async function saveSubscription(request, response) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (allowedUsersMonthly > 0 || allowedUsersYearly > 0) {
|
if (allowedUsersMonthly > 0 || allowedUsersYearly > 0) {
|
||||||
existAddon = allowedUsersMonthly + allowedUsersYearly + 1;
|
newAddons = allowedUsersMonthly + allowedUsersYearly + 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (planCode === 'teams-yearly' || planCode === 'teams-monthly' || planCode === 'team-weekly') {
|
if (planCode === 'teams-yearly' || planCode === 'teams-monthly' || planCode === 'team-weekly') {
|
||||||
existAddon = 1;
|
newAddons = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -42,6 +44,7 @@ export default async function saveSubscription(request, response) {
|
|||||||
});
|
});
|
||||||
const subscription = await subcriptionCls.first({ useMasterKey: true });
|
const subscription = await subcriptionCls.first({ useMasterKey: true });
|
||||||
if (subscription) {
|
if (subscription) {
|
||||||
|
const _resSub = JSON.parse(JSON.stringify(subscription));
|
||||||
const updateSubscription = new Parse.Object('contracts_Subscriptions');
|
const updateSubscription = new Parse.Object('contracts_Subscriptions');
|
||||||
updateSubscription.id = subscription.id;
|
updateSubscription.id = subscription.id;
|
||||||
updateSubscription.set('SubscriptionId', SubscriptionId);
|
updateSubscription.set('SubscriptionId', SubscriptionId);
|
||||||
@@ -52,27 +55,81 @@ export default async function saveSubscription(request, response) {
|
|||||||
updateSubscription.unset('Next_billing_date');
|
updateSubscription.unset('Next_billing_date');
|
||||||
}
|
}
|
||||||
updateSubscription.set('PlanCode', planCode);
|
updateSubscription.set('PlanCode', planCode);
|
||||||
if (existAddon > 0) {
|
if (newAddons > 0) {
|
||||||
updateSubscription.set('AllowedUsers', parseInt(existAddon));
|
updateSubscription.set('AllowedUsers', parseInt(newAddons));
|
||||||
|
}
|
||||||
|
let existAddon = 0;
|
||||||
|
let allowedUsersMonthly = 0;
|
||||||
|
let allowedUsersYearly = 0;
|
||||||
|
_resSub.SubscriptionDetails?.data?.subscription?.addons?.forEach(item => {
|
||||||
|
if (item.addon_code === 'extra-teams-users-monthly') {
|
||||||
|
allowedUsersMonthly += item.quantity;
|
||||||
|
} else if (item.addon_code === 'extra-teams-users-yearly') {
|
||||||
|
allowedUsersYearly += item.quantity;
|
||||||
|
} else if (item.addon_code === 'extra-users') {
|
||||||
|
allowedUsersMonthly += item.quantity;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (allowedUsersMonthly > 0 || allowedUsersYearly > 0) {
|
||||||
|
existAddon = allowedUsersMonthly + allowedUsersYearly + 1; // + 1 is Admin user
|
||||||
|
} else {
|
||||||
|
if (
|
||||||
|
planCode === 'teams-yearly' ||
|
||||||
|
planCode === 'teams-monthly' ||
|
||||||
|
planCode === 'team-weekly'
|
||||||
|
) {
|
||||||
|
existAddon = 1; // 1 is Admin user
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const isSameAsPrevPlan = subscription?.get('PlanCode') === planCode;
|
const isSameAsPrevPlan = subscription?.get('PlanCode') === planCode;
|
||||||
if (isSameAsPrevPlan) {
|
if (isSameAsPrevPlan) {
|
||||||
const planCredits = subscription?.get('PlanCredits');
|
const planCredits = subscription?.get('PlanCredits');
|
||||||
|
const existAllowedCredits = subscription?.get('AllowedCredits') || 0;
|
||||||
if (planCredits) {
|
if (planCredits) {
|
||||||
updateSubscription.set('AllowedCredits', planCredits);
|
const oldAddons = existAddon;
|
||||||
|
const substractedAddon = newAddons - oldAddons;
|
||||||
|
if (isTeamPlan && substractedAddon > 0) {
|
||||||
|
const newCredits = existAllowedCredits + substractedAddon * planCredits;
|
||||||
|
updateSubscription.set('AllowedCredits', newCredits);
|
||||||
|
if (event === 'subscription_created') {
|
||||||
|
updateSubscription.set('PlanCredits', credits);
|
||||||
|
}
|
||||||
|
} else if (isTeamPlan) {
|
||||||
|
const existCredits = existAddon * planCredits;
|
||||||
|
updateSubscription.set('AllowedCredits', existCredits);
|
||||||
|
if (event === 'subscription_created') {
|
||||||
|
updateSubscription.set('PlanCredits', credits);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
updateSubscription.set('AllowedCredits', planCredits);
|
||||||
|
if (event === 'subscription_created') {
|
||||||
|
updateSubscription.set('PlanCredits', credits);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (credits > 0) {
|
if (credits > 0) {
|
||||||
updateSubscription.set('AllowedCredits', credits);
|
if (isTeamPlan) {
|
||||||
updateSubscription.set('PlanCredits', credits);
|
const newCredits = newAddons * credits;
|
||||||
|
updateSubscription.set('AllowedCredits', newCredits);
|
||||||
|
updateSubscription.set('PlanCredits', credits);
|
||||||
|
} else {
|
||||||
|
updateSubscription.set('AllowedCredits', credits);
|
||||||
|
updateSubscription.set('PlanCredits', credits);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (credits > 0) {
|
if (credits > 0) {
|
||||||
updateSubscription.set('AllowedCredits', credits);
|
if (isTeamPlan) {
|
||||||
updateSubscription.set('PlanCredits', credits);
|
const newCredits = newAddons * credits;
|
||||||
|
updateSubscription.set('AllowedCredits', newCredits);
|
||||||
|
updateSubscription.set('PlanCredits', credits);
|
||||||
|
} else {
|
||||||
|
updateSubscription.set('AllowedCredits', credits);
|
||||||
|
updateSubscription.set('PlanCredits', credits);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await updateSubscription.save(null, { useMasterKey: true });
|
await updateSubscription.save(null, { useMasterKey: true });
|
||||||
return response.status(200).json({ status: 'update subscription!' });
|
return response.status(200).json({ status: 'update subscription!' });
|
||||||
} else {
|
} else {
|
||||||
@@ -100,11 +157,18 @@ export default async function saveSubscription(request, response) {
|
|||||||
createSubscription.unset('Next_billing_date');
|
createSubscription.unset('Next_billing_date');
|
||||||
}
|
}
|
||||||
createSubscription.set('PlanCode', planCode);
|
createSubscription.set('PlanCode', planCode);
|
||||||
if (existAddon > 0) {
|
if (newAddons > 0) {
|
||||||
createSubscription.set('AllowedUsers', parseInt(existAddon));
|
createSubscription.set('AllowedUsers', parseInt(newAddons));
|
||||||
}
|
}
|
||||||
if (credits > 0) {
|
if (credits > 0) {
|
||||||
createSubscription.set('AllowedCredits', credits);
|
if (isTeamPlan) {
|
||||||
|
const totalCredits = parseInt(newAddons) * credits;
|
||||||
|
createSubscription.set('AllowedCredits', totalCredits);
|
||||||
|
createSubscription.set('PlanCredits', credits);
|
||||||
|
} else {
|
||||||
|
createSubscription.set('AllowedCredits', credits);
|
||||||
|
createSubscription.set('PlanCredits', credits);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
await createSubscription.save(null, { useMasterKey: true });
|
await createSubscription.save(null, { useMasterKey: true });
|
||||||
return response.status(200).json({ status: 'create subscription!' });
|
return response.status(200).json({ status: 'create subscription!' });
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
import { planCredits } from '../../Utils.js';
|
||||||
export default async function BuyAddonUsers(request) {
|
export default async function BuyAddonUsers(request) {
|
||||||
const users = request.params.users;
|
const users = request.params.users;
|
||||||
if (!request?.user) {
|
if (!request?.user) {
|
||||||
@@ -88,10 +89,15 @@ export default async function BuyAddonUsers(request) {
|
|||||||
);
|
);
|
||||||
const subscriptionInfo = { data: updatedSubscription.data };
|
const subscriptionInfo = { data: updatedSubscription.data };
|
||||||
const allowedUsers = quantity + 1;
|
const allowedUsers = quantity + 1;
|
||||||
|
const existAllowedCredits = _resSub?.AllowedCredits || 0;
|
||||||
|
const credits = resSub?.PlanCredits || planCredits[plan_code];
|
||||||
|
const newAllowedCredits = users * credits;
|
||||||
|
const totalCredits = existAllowedCredits + newAllowedCredits;
|
||||||
const updateSub = new Parse.Object('contracts_Subscriptions');
|
const updateSub = new Parse.Object('contracts_Subscriptions');
|
||||||
updateSub.id = resSub.id;
|
updateSub.id = resSub.id;
|
||||||
updateSub.set('SubscriptionDetails', subscriptionInfo);
|
updateSub.set('SubscriptionDetails', subscriptionInfo);
|
||||||
updateSub.set('AllowedUsers', allowedUsers);
|
updateSub.set('AllowedUsers', allowedUsers);
|
||||||
|
updateSub.set('AllowedCredits', totalCredits);
|
||||||
const resupdateSub = await updateSub.save(null, { useMasterKey: true });
|
const resupdateSub = await updateSub.save(null, { useMasterKey: true });
|
||||||
return { status: 'success', addon: allowedUsers };
|
return { status: 'success', addon: allowedUsers };
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -243,6 +243,7 @@ export default function reportJson(id, userId) {
|
|||||||
reportName: 'Recent signature requests',
|
reportName: 'Recent signature requests',
|
||||||
params: {
|
params: {
|
||||||
Type: { $ne: 'Folder' },
|
Type: { $ne: 'Folder' },
|
||||||
|
SignedUrl: { $ne: null },
|
||||||
IsCompleted: { $ne: true },
|
IsCompleted: { $ne: true },
|
||||||
IsDeclined: { $ne: true },
|
IsDeclined: { $ne: true },
|
||||||
IsArchive: { $ne: true },
|
IsArchive: { $ne: true },
|
||||||
|
|||||||
@@ -8,8 +8,10 @@ export default async function saveSubscription(request) {
|
|||||||
const body = subscription;
|
const body = subscription;
|
||||||
const Next_billing_date = subscription.data.subscription.next_billing_at;
|
const Next_billing_date = subscription.data.subscription.next_billing_at;
|
||||||
const planCode = subscription.data.subscription.plan.plan_code;
|
const planCode = subscription.data.subscription.plan.plan_code;
|
||||||
|
const event = subscription?.data?.event_type || '';
|
||||||
const credits = planCredits?.[planCode] || 0;
|
const credits = planCredits?.[planCode] || 0;
|
||||||
let existAddon = 0;
|
const isTeamPlan = planCode?.includes('team');
|
||||||
|
let newAddons = 0;
|
||||||
try {
|
try {
|
||||||
const userRes = await axios.get(serverUrl + '/users/me', {
|
const userRes = await axios.get(serverUrl + '/users/me', {
|
||||||
headers: {
|
headers: {
|
||||||
@@ -47,7 +49,7 @@ export default async function saveSubscription(request) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (allowedUsersMonthly > 0 || allowedUsersYearly > 0) {
|
if (allowedUsersMonthly > 0 || allowedUsersYearly > 0) {
|
||||||
existAddon = allowedUsersMonthly + allowedUsersYearly + 1;
|
newAddons = allowedUsersMonthly + allowedUsersYearly + 1; // + 1 is Admin user
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (
|
if (
|
||||||
@@ -55,39 +57,90 @@ export default async function saveSubscription(request) {
|
|||||||
planCode === 'teams-monthly' ||
|
planCode === 'teams-monthly' ||
|
||||||
planCode === 'team-weekly'
|
planCode === 'team-weekly'
|
||||||
) {
|
) {
|
||||||
existAddon = 1;
|
newAddons = 1; // 1 is Admin user
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// const existAddon = addons.reduce((acc, curr) => acc + curr.quantity, 1);
|
|
||||||
if (resSubscription) {
|
if (resSubscription) {
|
||||||
|
const _resSub = JSON.parse(JSON.stringify(resSubscription));
|
||||||
const updateSubscription = new Parse.Object('contracts_Subscriptions');
|
const updateSubscription = new Parse.Object('contracts_Subscriptions');
|
||||||
updateSubscription.id = resSubscription.id;
|
updateSubscription.id = resSubscription.id;
|
||||||
updateSubscription.set('SubscriptionId', SubscriptionId);
|
updateSubscription.set('SubscriptionId', SubscriptionId);
|
||||||
updateSubscription.set('SubscriptionDetails', body);
|
updateSubscription.set('SubscriptionDetails', body);
|
||||||
updateSubscription.set('Next_billing_date', new Date(Next_billing_date));
|
updateSubscription.set('Next_billing_date', new Date(Next_billing_date));
|
||||||
updateSubscription.set('PlanCode', planCode);
|
updateSubscription.set('PlanCode', planCode);
|
||||||
if (existAddon > 0) {
|
if (newAddons > 0) {
|
||||||
updateSubscription.set('AllowedUsers', parseInt(existAddon));
|
updateSubscription.set('AllowedUsers', parseInt(newAddons));
|
||||||
|
}
|
||||||
|
let existAddon = 0;
|
||||||
|
let allowedUsersMonthly = 0;
|
||||||
|
let allowedUsersYearly = 0;
|
||||||
|
_resSub.SubscriptionDetails?.data?.subscription?.addons?.forEach(item => {
|
||||||
|
if (item.addon_code === 'extra-teams-users-monthly') {
|
||||||
|
allowedUsersMonthly += item.quantity;
|
||||||
|
} else if (item.addon_code === 'extra-teams-users-yearly') {
|
||||||
|
allowedUsersYearly += item.quantity;
|
||||||
|
} else if (item.addon_code === 'extra-users') {
|
||||||
|
allowedUsersMonthly += item.quantity;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (allowedUsersMonthly > 0 || allowedUsersYearly > 0) {
|
||||||
|
existAddon = allowedUsersMonthly + allowedUsersYearly + 1; // + 1 is Admin user
|
||||||
|
} else {
|
||||||
|
if (
|
||||||
|
planCode === 'teams-yearly' ||
|
||||||
|
planCode === 'teams-monthly' ||
|
||||||
|
planCode === 'team-weekly'
|
||||||
|
) {
|
||||||
|
existAddon = 1; // 1 is Admin user
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const isSameAsPrevPlan = resSubscription?.get('PlanCode') === planCode;
|
const isSameAsPrevPlan = resSubscription?.get('PlanCode') === planCode;
|
||||||
if (isSameAsPrevPlan) {
|
if (isSameAsPrevPlan) {
|
||||||
const planCredits = resSubscription?.get('PlanCredits');
|
const planCredits = resSubscription?.get('PlanCredits');
|
||||||
|
const existAllowedCredits = resSubscription?.get('AllowedCredits') || 0;
|
||||||
if (planCredits) {
|
if (planCredits) {
|
||||||
updateSubscription.set('AllowedCredits', planCredits);
|
const oldAddons = existAddon;
|
||||||
|
const substractedAddon = newAddons - oldAddons;
|
||||||
|
if (isTeamPlan && substractedAddon > 0) {
|
||||||
|
const newCredits = existAllowedCredits + substractedAddon * planCredits;
|
||||||
|
updateSubscription.set('AllowedCredits', newCredits);
|
||||||
|
if (event === 'subscription_created') {
|
||||||
|
updateSubscription.set('PlanCredits', credits);
|
||||||
|
}
|
||||||
|
} else if (isTeamPlan) {
|
||||||
|
const existCredits = existAddon * planCredits;
|
||||||
|
updateSubscription.set('AllowedCredits', existCredits);
|
||||||
|
if (event === 'subscription_created') {
|
||||||
|
updateSubscription.set('PlanCredits', credits);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
updateSubscription.set('AllowedCredits', planCredits);
|
||||||
|
if (event === 'subscription_created') {
|
||||||
|
updateSubscription.set('PlanCredits', credits);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (credits > 0) {
|
if (isTeamPlan) {
|
||||||
|
const newCredits = newAddons * credits;
|
||||||
|
updateSubscription.set('AllowedCredits', newCredits);
|
||||||
|
updateSubscription.set('PlanCredits', credits);
|
||||||
|
} else {
|
||||||
updateSubscription.set('AllowedCredits', credits);
|
updateSubscription.set('AllowedCredits', credits);
|
||||||
updateSubscription.set('PlanCredits', credits);
|
updateSubscription.set('PlanCredits', credits);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (credits > 0) {
|
if (credits > 0) {
|
||||||
updateSubscription.set('AllowedCredits', credits);
|
if (isTeamPlan) {
|
||||||
updateSubscription.set('PlanCredits', credits);
|
const newCredits = newAddons * credits;
|
||||||
|
updateSubscription.set('AllowedCredits', newCredits);
|
||||||
|
updateSubscription.set('PlanCredits', credits);
|
||||||
|
} else {
|
||||||
|
updateSubscription.set('AllowedCredits', credits);
|
||||||
|
updateSubscription.set('PlanCredits', credits);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await updateSubscription.save(null, { useMasterKey: true });
|
await updateSubscription.save(null, { useMasterKey: true });
|
||||||
return { status: 'update subscription!' };
|
return { status: 'update subscription!' };
|
||||||
} else {
|
} else {
|
||||||
@@ -111,12 +164,18 @@ export default async function saveSubscription(request) {
|
|||||||
});
|
});
|
||||||
createSubscription.set('Next_billing_date', new Date(Next_billing_date));
|
createSubscription.set('Next_billing_date', new Date(Next_billing_date));
|
||||||
createSubscription.set('PlanCode', planCode);
|
createSubscription.set('PlanCode', planCode);
|
||||||
if (existAddon > 0) {
|
if (newAddons > 0) {
|
||||||
createSubscription.set('AllowedUsers', parseInt(existAddon));
|
createSubscription.set('AllowedUsers', parseInt(newAddons));
|
||||||
}
|
}
|
||||||
if (credits > 0) {
|
if (credits > 0) {
|
||||||
createSubscription.set('AllowedCredits', credits);
|
if (isTeamPlan) {
|
||||||
createSubscription.set('PlanCredits', credits);
|
const totalCredits = parseInt(newAddons) * credits;
|
||||||
|
createSubscription.set('AllowedCredits', totalCredits);
|
||||||
|
createSubscription.set('PlanCredits', credits);
|
||||||
|
} else {
|
||||||
|
createSubscription.set('AllowedCredits', credits);
|
||||||
|
createSubscription.set('PlanCredits', credits);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
await createSubscription.save(null, { useMasterKey: true });
|
await createSubscription.save(null, { useMasterKey: true });
|
||||||
return { status: 'create subscription!' };
|
return { status: 'create subscription!' };
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ async function sendmailv3(req) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Plan && Plan === 'freeplan') {
|
if (Plan && Plan === 'freeplan') {
|
||||||
let MontlyfreeEmails = _extRes?.MontlyfreeEmails || 0;
|
let MonthlyFreeEmails = _extRes?.MonthlyFreeEmails || 0;
|
||||||
if (_extRes?.LastEmailCountReset?.iso) {
|
if (_extRes?.LastEmailCountReset?.iso) {
|
||||||
const lastDate = new Date(_extRes?.LastEmailCountReset?.iso);
|
const lastDate = new Date(_extRes?.LastEmailCountReset?.iso);
|
||||||
const newDate = new Date();
|
const newDate = new Date();
|
||||||
@@ -225,7 +225,7 @@ async function sendmailv3(req) {
|
|||||||
const nonCustomMail = await sendMailProvider(req, Plan, true);
|
const nonCustomMail = await sendMailProvider(req, Plan, true);
|
||||||
return nonCustomMail;
|
return nonCustomMail;
|
||||||
} else {
|
} else {
|
||||||
if (MontlyfreeEmails >= 20) {
|
if (MonthlyFreeEmails >= 20) {
|
||||||
return { status: 'quota-reached' };
|
return { status: 'quota-reached' };
|
||||||
} else {
|
} else {
|
||||||
const nonCustomMail = await sendMailProvider(req, Plan);
|
const nonCustomMail = await sendMailProvider(req, Plan);
|
||||||
|
|||||||
Reference in New Issue
Block a user