feat: add validation of free plan

This commit is contained in:
prafull-opensignlabs
2024-03-28 13:57:37 +05:30
parent 74bfd39abc
commit 2762c3e170
9 changed files with 156 additions and 92 deletions
+62 -64
View File
@@ -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 <span style='background-color: yellow;'>'FREEBETA'</span> 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"
]
}
]
{
"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 <span style='background-color: yellow;'>'FREEBETA'</span> 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"
]
}
]
+5 -4
View File
@@ -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 = () => {
+13 -2
View File
@@ -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
+4 -1
View File
@@ -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 {
+4 -1
View File
@@ -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 {
+35 -19
View File
@@ -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 (
<>
<Title title={"Subscriptions"} />
@@ -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">
@@ -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 {
+2
View File
@@ -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);
@@ -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 };
}
}