From 5a26e5c2ee2133ee5944c6d896412dad77aea641 Mon Sep 17 00:00:00 2001 From: prafull-opensignlabs Date: Fri, 6 Sep 2024 11:56:54 +0530 Subject: [PATCH 1/2] refactor: validaiton --- .../customRoute/v1/routes/CreateDocumentWithTemplate.js | 5 ++++- .../customRoute/v1/routes/createDocumentwithCoordinate.js | 5 ++++- apps/OpenSignServer/cloud/parsefunction/createBatchDocs.js | 6 +++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/apps/OpenSignServer/cloud/customRoute/v1/routes/CreateDocumentWithTemplate.js b/apps/OpenSignServer/cloud/customRoute/v1/routes/CreateDocumentWithTemplate.js index dcca4ba24..a682e8787 100644 --- a/apps/OpenSignServer/cloud/customRoute/v1/routes/CreateDocumentWithTemplate.js +++ b/apps/OpenSignServer/cloud/customRoute/v1/routes/CreateDocumentWithTemplate.js @@ -81,6 +81,7 @@ export default async function createDocumentWithTemplate(request, response) { objectId: extUser.get('TenantId').id, }); subscription.include('ExtUserPtr'); + subscription.greaterThanOrEqualTo('Next_billing_date', new Date()); const resSub = await subscription.first({ useMasterKey: true }); if (resSub) { const _resSub = JSON.parse(JSON.stringify(resSub)); @@ -404,7 +405,9 @@ export default async function createDocumentWithTemplate(request, response) { .json({ error: 'Quota reached, Please buy credits and try again later.' }); } } else { - return response.status(400).json({ error: 'Please buy subscriptions.' }); + return response.status(400).json({ + error: 'Please purchase or renew your subscription.', + }); } } else { return response.status(405).json({ error: 'Invalid API Token!' }); diff --git a/apps/OpenSignServer/cloud/customRoute/v1/routes/createDocumentwithCoordinate.js b/apps/OpenSignServer/cloud/customRoute/v1/routes/createDocumentwithCoordinate.js index cb6a95e29..b69655c8b 100644 --- a/apps/OpenSignServer/cloud/customRoute/v1/routes/createDocumentwithCoordinate.js +++ b/apps/OpenSignServer/cloud/customRoute/v1/routes/createDocumentwithCoordinate.js @@ -95,6 +95,7 @@ export default async function createDocumentwithCoordinate(request, response) { objectId: extUser.get('TenantId').id, }); subscription.include('ExtUserPtr'); + subscription.greaterThanOrEqualTo('Next_billing_date', new Date()); const resSub = await subscription.first({ useMasterKey: true }); if (resSub) { const _resSub = JSON.parse(JSON.stringify(resSub)); @@ -422,7 +423,9 @@ export default async function createDocumentwithCoordinate(request, response) { .json({ error: 'Quota reached, Please buy credits and try again later.' }); } } else { - return response.status(400).json({ error: 'Please buy subscriptions.' }); + return response.status(400).json({ + error: 'Please purchase or renew your subscription.', + }); } } else { return response.status(405).json({ error: 'Invalid API Token!' }); diff --git a/apps/OpenSignServer/cloud/parsefunction/createBatchDocs.js b/apps/OpenSignServer/cloud/parsefunction/createBatchDocs.js index f6ba12a4f..0742fdd4e 100644 --- a/apps/OpenSignServer/cloud/parsefunction/createBatchDocs.js +++ b/apps/OpenSignServer/cloud/parsefunction/createBatchDocs.js @@ -211,6 +211,7 @@ export default async function createBatchDocs(request) { objectId: _resExt.TenantId.objectId, }); subscription.include('ExtUserPtr'); + subscription.greaterThanOrEqualTo('Next_billing_date', new Date()); const resSub = await subscription.first({ useMasterKey: true }); if (resSub) { const _resSub = JSON.parse(JSON.stringify(resSub)); @@ -240,7 +241,10 @@ export default async function createBatchDocs(request) { ); } } else { - throw new Parse.Error(Parse.Error.INVALID_QUERY, 'Please buy subscriptions.'); + throw new Parse.Error( + Parse.Error.INVALID_QUERY, + 'Please purchase or renew your subscription.' + ); } } else { const response = await axios.post('batch', { requests: requests[0] }, parseConfig); From 980e713735f205ae0c18c7b6791e26d09c7aaefe Mon Sep 17 00:00:00 2001 From: prafull-opensignlabs Date: Fri, 6 Sep 2024 14:47:57 +0530 Subject: [PATCH 2/2] refactor: validation --- .../public/locales/en/translation.json | 6 ++--- .../public/locales/fr/translation.json | 6 ++--- apps/OpenSign/src/components/BulkSendUi.js | 4 ++- apps/OpenSign/src/components/Header.js | 25 +++++++++++------ .../src/components/pdf/EmailComponent.js | 10 +------ apps/OpenSign/src/pages/SignyourselfPdf.js | 27 ++++--------------- apps/OpenSign/src/primitives/QuotaCard.js | 7 ++--- .../src/script/locales/en/translation.json | 6 ++--- .../src/script/locales/fr/translation.json | 6 ++--- .../cloud/parsefunction/sendMailv3.js | 2 +- 10 files changed, 43 insertions(+), 56 deletions(-) diff --git a/apps/OpenSign/public/locales/en/translation.json b/apps/OpenSign/public/locales/en/translation.json index 017fdef3b..13e25721a 100644 --- a/apps/OpenSign/public/locales/en/translation.json +++ b/apps/OpenSign/public/locales/en/translation.json @@ -631,9 +631,9 @@ "decline-by":"Declined/revoked by", "document-declined": "Document declined", "Add-Webhook":"Add Webhook", - "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.", - "quotamailTip":"Tip: You can still sign unlimited documents by manually sharing the signing request links below.", + "quotamailinfo": "You can send upto 15 signature request emails every month. Upgrade now to send unlimited signing requests directly.", + "quotamail": "You've reached your limit of 15 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.", "quotamailhead":"Quota Reached", "unauthorized-modal":"You don't have permission to perform this action, please contact {{adminName}}<{{adminEmail}}>." diff --git a/apps/OpenSign/public/locales/fr/translation.json b/apps/OpenSign/public/locales/fr/translation.json index e90ffc42c..6881d7fdd 100644 --- a/apps/OpenSign/public/locales/fr/translation.json +++ b/apps/OpenSign/public/locales/fr/translation.json @@ -631,9 +631,9 @@ "decline-by" :"Refusé/révoqué par", "document-declined":"document refusé", "Add-Webhook":"Ajouter Webhook", - "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.", - "quotamailTip":"Astuce : Vous pouvez toujours signer un nombre illimité de documents en partageant manuellement les liens de demande de signature ci-dessous.", + "quotamailinfo": "Vous pouvez envoyer jusqu'à 15 e-mails de demande de signature chaque mois. Mettez à niveau maintenant pour envoyer directement des demandes de signature illimitées.", + "quotamail": "Vous avez atteint votre limite de 15 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.", "quotamailhead":"Quota atteint", "unauthorized-modal":"Vous n'êtes pas autorisé à effectuer cette action, veuillez contacter {{adminName}}<{{adminEmail}}>." diff --git a/apps/OpenSign/src/components/BulkSendUi.js b/apps/OpenSign/src/components/BulkSendUi.js index 6e42344a5..8c588d299 100644 --- a/apps/OpenSign/src/components/BulkSendUi.js +++ b/apps/OpenSign/src/components/BulkSendUi.js @@ -77,7 +77,9 @@ const BulkSendUi = (props) => { const addoncredits = resCredits?.addoncredits || 0; const totalcredits = allowedcredits + addoncredits; if (totalcredits > 0) { - setIsBulkAvailable(true); + if (subscription?.plan !== "freeplan") { + setIsBulkAvailable(true); + } } setAmount((obj) => ({ ...obj, totalcredits: totalcredits })); } diff --git a/apps/OpenSign/src/components/Header.js b/apps/OpenSign/src/components/Header.js index 22340a834..4ecef1754 100644 --- a/apps/OpenSign/src/components/Header.js +++ b/apps/OpenSign/src/components/Header.js @@ -13,6 +13,8 @@ import { import { isEnableSubscription, isStaging } from "../constant/const"; import { validplan } from "../json/plansArr"; import { useTranslation } from "react-i18next"; +import ModalUi from "../primitives/ModalUi"; +import QuotaCard from "../primitives/QuotaCard"; const Header = ({ showSidebar }) => { const { t, i18n } = useTranslation(); @@ -27,6 +29,7 @@ const Header = ({ showSidebar }) => { localStorage.getItem("appLogo") || " " ); const [emailUsed, setEmailUsed] = useState(0); + const [isModal, setIsModal] = useState(false); const toggleDropdown = () => { setIsOpen(!isOpen); @@ -111,6 +114,9 @@ const Header = ({ showSidebar }) => { const handleNavigation = () => { navigate("/subscription"); }; + const handleMailUsed = () => { + setIsModal(!isModal); + }; return (
{isEnableSubscription && ( @@ -203,14 +209,6 @@ const Header = ({ showSidebar }) => { 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" > - {isEnableSubscription && isTeam?.plan === "freeplan" && ( -
  • - - Email used:{" "} - {emailUsed}/20 - -
  • - )}
  • openInNewTab("https://docs.opensignlabs.com")}> {t("docs")} @@ -241,6 +239,14 @@ const Header = ({ showSidebar }) => { Console
  • + {isEnableSubscription && isTeam?.plan === "freeplan" && ( +
  • + + + {emailUsed}/20 sent this month + +
  • + )}
  • {" "} @@ -251,6 +257,9 @@ const Header = ({ showSidebar }) => {
  • + + + ); }; diff --git a/apps/OpenSign/src/components/pdf/EmailComponent.js b/apps/OpenSign/src/components/pdf/EmailComponent.js index f0404439c..83b61fb40 100644 --- a/apps/OpenSign/src/components/pdf/EmailComponent.js +++ b/apps/OpenSign/src/components/pdf/EmailComponent.js @@ -15,8 +15,7 @@ function EmailComponent({ sender, setIsAlert, extUserId, - activeMailAdapter, - planCode + activeMailAdapter }) { const { t } = useTranslation(); const [emailList, setEmailList] = useState([]); @@ -51,7 +50,6 @@ function EmailComponent({ recipient: emailList[i], subject: `${sender.name} has signed the doc - ${pdfName}`, from: sender.email, - plan: planCode, html: "
    - isAlert.alertMessage === "quotareached" - ? false - : setIsAlert({ isShow: false, alertMessage: "" }) + setIsAlert({ isShow: false, alertMessage: "" }) } > - {isAlert.alertMessage === "quotareached" ? ( - - setIsAlert({ isShow: false, alertMessage: "" }) - } - /> - ) : ( -
    -

    {isAlert.alertMessage}

    -
    - )} +
    +

    {isAlert.alertMessage}

    +
    {/* this modal is used show this document is already sign */} @@ -1343,7 +1327,6 @@ function SignYourSelf() { setIsAlert={setIsAlert} extUserId={extUserId} activeMailAdapter={activeMailAdapter} - planCode={isSubscribe?.plan} /> {/* pdf header which contain funish back button */}
    { +const QuotaCard = ({ isPaidInfo, handlClose }) => { const { t } = useTranslation(); const navigate = useNavigate(); - return isSignyourself ? ( + return isPaidInfo ? ( <>
    {

    {t("upgrade-to") + " Paid " + t("plan")}

    -

    {t("quotamailselfsign")}

    +

    {t("quotamailinfo")}

    +

    {t("quotamailTip")}