diff --git a/apps/OpenSign/src/json/plansArr.json b/apps/OpenSign/src/json/plansArr.json index 90ab47bdc..f372d7493 100644 --- a/apps/OpenSign/src/json/plansArr.json +++ b/apps/OpenSign/src/json/plansArr.json @@ -1,65 +1,63 @@ [ - { - "planName": "SELF HOSTED", - "currency": "", - "price": "Free", - "subtitle": "Free for life One click install.", - "btnText": "Visit github", - "url": "https://github.com/opensignlabs/opensign", - "target": "_blank", - "benefits": [ - "Sign Unlimited Documents", - "S3 Doc Storage", - "Unlimited Guest Signers", - "Unlimited completion certificates", - "Unique Code(OTP) verification for guest signers", - "Expiring docs & reject signature support", - "PDF Template Creation(coming soon)", - "Audit Trails", - "API support", - "Add-ons support(coming soon)", - "Self hosted cloud infrastructure", - "Free for lifetime", - "Community support" - ] - }, - { - "planName": "THANKS PLAN", - "currency": "$", - "price": "29.99", - "subtitle": "Use code 'FREEBETA' to get this for free(First 1000 users)", - "btnText": "Subscribe", - "url": "https://subscriptions.zoho.in/subscribe/ef798486e6a0a11ea65f2bae8f2af901dbadf3175d495584fd25b9af5d2f2b9e/thanks", - "target": "_self", - "benefits": [ - "Sign Unlimited Documents", - "Unlimited Secure Doc Storage with OpenSign™ Drive", - "Unlimited Guest Signers", - "Unlimited completion certificates", - "Unique Code(OTP) verification for guest signers", - "Expiring docs & reject signature support", - "PDF Template Creation(coming soon)", - "Audit Trails", - "API support", - "Add-ons support(coming soon)", - "Self hosted cloud infrastructure" - ] - }, - { - "planName": "ENTERPRISE", - "currency": "", - "price": "Request Price", - "subtitle": "Customization available Priority support.", - "btnText": "Contact us", - "url": "https://www.opensignlabs.com/contact-us", - "target": "_blank", - "benefits": [ - "All features", - "Custom domain", - "Whitelabeling", - "Uptime SLA", - "SSO support", - "24/7 support" - ] - } -] \ No newline at end of file + { + "planName": "Free Plan", + "currency": "", + "price": "Free", + "subtitle": "Free for life.", + "btnText": "Subscribe", + "url": "", + "target": "_blank", + "benefits": [ + "Sign Unlimited Documents", + "S3 Doc Storage", + "Unlimited Guest Signers", + "Unlimited completion certificates", + "Unique Code(OTP) verification for guest signers", + "Expiring docs & reject signature support", + "PDF Template Creation", + "Audit Trails", + "API support", + "Free for lifetime", + "Community support" + ] + }, + { + "planName": "THANKS PLAN", + "currency": "$", + "price": "29.99", + "subtitle": "Use code 'FREEBETA' to get this for free(First 1000 users)", + "btnText": "Subscribe", + "url": "https://subscriptions.zoho.in/subscribe/ef798486e6a0a11ea65f2bae8f2af901dbadf3175d495584fd25b9af5d2f2b9e/thanks", + "target": "_self", + "benefits": [ + "Sign Unlimited Documents", + "Unlimited Secure Doc Storage with OpenSign™ Drive", + "Unlimited Guest Signers", + "Unlimited completion certificates", + "Unique Code(OTP) verification for guest signers", + "Expiring docs & reject signature support", + "PDF Template Creation(coming soon)", + "Audit Trails", + "API support", + "Add-ons support(coming soon)", + "Self hosted cloud infrastructure" + ] + }, + { + "planName": "ENTERPRISE", + "currency": "", + "price": "Request Price", + "subtitle": "Customization available Priority support.", + "btnText": "Contact us", + "url": "https://www.opensignlabs.com/contact-us", + "target": "_blank", + "benefits": [ + "All features", + "Custom domain", + "Whitelabeling", + "Uptime SLA", + "SSO support", + "24/7 support" + ] + } +] diff --git a/apps/OpenSign/src/layout/HomeLayout.js b/apps/OpenSign/src/layout/HomeLayout.js index 8da57af4b..2686d5e92 100644 --- a/apps/OpenSign/src/layout/HomeLayout.js +++ b/apps/OpenSign/src/layout/HomeLayout.js @@ -52,14 +52,16 @@ const HomeLayout = () => { email: currentUser.get("email") }); if (isEnableSubscription) { + const freeplan = user?.get("Plan") && user?.get("Plan"); const billingDate = user?.get("Next_billing_date") && user?.get("Next_billing_date"); - - if (billingDate) { + if (freeplan === "freeplan") { + setIsUserValid(true); + setIsLoader(false); + } else if (billingDate) { if (billingDate > new Date()) { setIsUserValid(true); setIsLoader(false); - return true; } else { navigate(`/subscription`); } @@ -69,7 +71,6 @@ const HomeLayout = () => { } else { setIsUserValid(true); setIsLoader(false); - return true; } } const showSidebar = () => { diff --git a/apps/OpenSign/src/pages/Login.js b/apps/OpenSign/src/pages/Login.js index 8ddccaa1c..1d73c0bda 100644 --- a/apps/OpenSign/src/pages/Login.js +++ b/apps/OpenSign/src/pages/Login.js @@ -254,10 +254,15 @@ function Login() { "userDetails", JSON.stringify(LocalUserDetails) ); + const freeplan = + results[0].get("Plan") && + results[0].get("Plan"); const billingDate = results[0].get("Next_billing_date") && results[0].get("Next_billing_date"); - if (billingDate) { + if (freeplan === "freeplan") { + navigate(redirectUrl); + } else if (billingDate) { if (billingDate > new Date()) { localStorage.removeItem( "userDetails" @@ -809,7 +814,13 @@ function Login() { const billingDate = results[0].get("Next_billing_date") && results[0].get("Next_billing_date"); - if (billingDate) { + const freeplan = + results[0]?.get("Plan") && + results[0]?.get("Plan"); + + if (freeplan === "freeplan") { + navigate(redirectUrl); + } else if (billingDate) { if (billingDate > new Date()) { localStorage.removeItem("userDetails"); // Redirect to the appropriate URL after successful login diff --git a/apps/OpenSign/src/pages/PdfRequestFiles.js b/apps/OpenSign/src/pages/PdfRequestFiles.js index d063a3c35..efea4e25a 100644 --- a/apps/OpenSign/src/pages/PdfRequestFiles.js +++ b/apps/OpenSign/src/pages/PdfRequestFiles.js @@ -134,9 +134,12 @@ function PdfRequestFiles() { const user = await Parse.Cloud.run("getUserDetails", { email: email }); + const freeplan = user?.get("Plan") && user?.get("Plan"); const billingDate = user?.get("Next_billing_date") && user?.get("Next_billing_date"); - if (billingDate) { + if (freeplan === "freeplan") { + return true; + } else if (billingDate) { if (billingDate > new Date()) { return true; } else { diff --git a/apps/OpenSign/src/pages/PlaceHolderSign.js b/apps/OpenSign/src/pages/PlaceHolderSign.js index d46683711..d6ac2da45 100644 --- a/apps/OpenSign/src/pages/PlaceHolderSign.js +++ b/apps/OpenSign/src/pages/PlaceHolderSign.js @@ -183,9 +183,12 @@ function PlaceHolderSign() { const user = await Parse.Cloud.run("getUserDetails", { email: email }); + const freeplan = user?.get("Plan") && user?.get("Plan"); const billingDate = user?.get("Next_billing_date") && user?.get("Next_billing_date"); - if (billingDate) { + if (freeplan === "freeplan") { + return true; + } else if (billingDate) { if (billingDate > new Date()) { return true; } else { diff --git a/apps/OpenSign/src/pages/PlanSubscriptions.js b/apps/OpenSign/src/pages/PlanSubscriptions.js index 3a2e398bc..abae7edbc 100644 --- a/apps/OpenSign/src/pages/PlanSubscriptions.js +++ b/apps/OpenSign/src/pages/PlanSubscriptions.js @@ -1,9 +1,9 @@ import React, { useState, useEffect } from "react"; -// import { useNavigate } from "react-router"; -import { NavLink } from "react-router-dom"; +import { NavLink, useNavigate } from "react-router-dom"; import checkmark from "../assets/images/checkmark.png"; import plansArr from "../json/plansArr.json"; import Title from "../components/Title"; +import Parse from "parse"; const listItemStyle = { paddingLeft: "20px", // Add padding to create space for the image backgroundImage: `url(${checkmark})`, // Set your image as the list style image @@ -13,7 +13,7 @@ const listItemStyle = { }; const PlanSubscriptions = () => { - // const navigate = useNavigate(); + const navigate = useNavigate(); const [yearlyVisible, setYearlyVisible] = useState(false); const [isLoader, setIsLoader] = useState(true); @@ -36,14 +36,21 @@ const PlanSubscriptions = () => { phone; useEffect(() => { // if (localStorage.getItem("accesstoken")) { - setIsLoader(false); - setYearlyVisible(false); + setIsLoader(false); + setYearlyVisible(false); // } else { // navigate("/", { replace: true }); // } // eslint-disable-next-line }, []); + const handleFreePlan = async () => { + const params = { userId: Parse.User.current().id }; + const res = await Parse.Cloud.run("freesubscription", params); + if (res.status === "success") { + navigate("/"); + } + }; return ( <> @@ -82,10 +89,10 @@ const PlanSubscriptions = () => { <ul className=" flex flex-col md:flex-row h-full bg-white justify-center border-collapse border-[1px] border-gray-300"> {plansArr.map((item) => ( <li - className="flex flex-col md:my-0 text-center border-[1px] border-gray-300 w-[260px]" + className="flex flex-col md:my-0 text-center border-[1px] border-gray-300 max-w-[260px]" key={item.planName} > - <div className="p-2 flex flex-col justify-center items-center"> + <div className="p-2 flex flex-col justify-center items-center min-h-[320px]"> <h3 className="text-[#002862] uppercase"> {item.planName} </h3> @@ -128,19 +135,28 @@ const PlanSubscriptions = () => { </div> </div> - <NavLink - to={ - item.btnText === "Subscribe" - ? item.url + details - : item.url - } - className="bg-[#002862] w-full text-white py-2 rounded uppercase hover:no-underline hover:text-white" - target={item.target} - > - {item.btnText} - </NavLink> + {item.url ? ( + <NavLink + to={ + item.btnText === "Subscribe" + ? item.url + details + : item.url + } + className="bg-[#002862] w-full text-white py-2 rounded uppercase hover:no-underline hover:text-white cursor-pointer" + target={item.target} + > + {item.btnText} + </NavLink> + ) : ( + <button + className="bg-[#002862] w-full text-white py-2 rounded uppercase hover:no-underline hover:text-white cursor-pointer" + onClick={() => handleFreePlan()} + > + {item.btnText} + </button> + )} </div> - <hr className="w-full bg-gray-300 p-[.5px]" /> + <hr className="w-full bg-gray-300 h-[0.5px]" /> <ul className="mx-1 p-3 text-left break-words text-sm list-none"> {item.benefits.map((subitem, index) => ( <li style={listItemStyle} key={index} className="m-1"> diff --git a/apps/OpenSign/src/pages/TemplatePlaceholder.js b/apps/OpenSign/src/pages/TemplatePlaceholder.js index 93fef3bb4..db7e9d285 100644 --- a/apps/OpenSign/src/pages/TemplatePlaceholder.js +++ b/apps/OpenSign/src/pages/TemplatePlaceholder.js @@ -173,9 +173,12 @@ const TemplatePlaceholder = () => { const user = await Parse.Cloud.run("getUserDetails", { email: email }); + const freeplan = user?.get("Plan") && user?.get("Plan"); const billingDate = user?.get("Next_billing_date") && user?.get("Next_billing_date"); - if (billingDate) { + if (freeplan === "freeplan") { + return true; + } else if (billingDate) { if (billingDate > new Date()) { return true; } else { diff --git a/apps/OpenSignServer/cloud/main.js b/apps/OpenSignServer/cloud/main.js index d0838e72f..6e1141cdd 100644 --- a/apps/OpenSignServer/cloud/main.js +++ b/apps/OpenSignServer/cloud/main.js @@ -23,6 +23,7 @@ import TemplateAfterSave from './parsefunction/TemplateAfterSave.js'; import GetTemplate from './parsefunction/GetTemplate.js'; import savewebhook from './parsefunction/saveWebhook.js'; import callWebhook from './parsefunction/callWebhook.js'; +import SubscribeFree from './parsefunction/SubscribeFree.js'; Parse.Cloud.define('AddUserToRole', addUserToGroups); Parse.Cloud.define('UserGroups', getUserGroups); @@ -45,6 +46,7 @@ Parse.Cloud.define('getapitoken', getapitoken); Parse.Cloud.define('getTemplate', GetTemplate); Parse.Cloud.define('savewebhook', savewebhook); Parse.Cloud.define('callwebhook', callWebhook); +Parse.Cloud.define('freesubscription', SubscribeFree); Parse.Cloud.afterSave('contracts_Document', DocumentAftersave); Parse.Cloud.afterSave('contracts_Contactbook', ContactbookAftersave); Parse.Cloud.afterSave('contracts_Users', ContractUsersAftersave); diff --git a/apps/OpenSignServer/cloud/parsefunction/SubscribeFree.js b/apps/OpenSignServer/cloud/parsefunction/SubscribeFree.js new file mode 100644 index 000000000..2bcf48500 --- /dev/null +++ b/apps/OpenSignServer/cloud/parsefunction/SubscribeFree.js @@ -0,0 +1,27 @@ +export default async function SubscribeFree(request) { + const userId = request.params.userId; + const userPtr = { __type: 'Pointer', className: '_User', objectId: userId }; + try { + const extQuery = new Parse.Query('contracts_Users'); + extQuery.equalTo('UserId', userPtr); + const extUser = await extQuery.first({ useMasterKey: true }); + + if (extUser) { + try { + const extUpdate = new Parse.Object('contracts_Users'); + extUpdate.id = extUser.id; + extUpdate.set('Plan', { plan_code: 'freeplan' }); + const updatePlan = await extUpdate.save(null, { useMasterKey: true }); + return { status: 'success', result: 'subscribed!' }; + } catch (err) { + console.log('err ', err); + return { status: 'error', result: err.message }; + } + } else { + return { status: 'error', result: 'User not found!' }; + } + } catch (err) { + console.log('err ', err); + return { status: 'error', result: err.message }; + } +}