@@ -124,18 +125,18 @@ const Header = ({ showSidebar }) => {
navigate("/subscription")}
+ onClick={() => handleNavigation()}
>
Upgrade Now
)}
- {!isTeam && isPro && (
+ {isTeam.isValid && !validplan[isTeam.plan] && (
PRO
)}
- {isTeam && (
+ {validplan[isTeam.plan] && (
TEAM
diff --git a/apps/OpenSign/src/components/pdf/EditTemplate.js b/apps/OpenSign/src/components/pdf/EditTemplate.js
index 480de22b5..93199c736 100644
--- a/apps/OpenSign/src/components/pdf/EditTemplate.js
+++ b/apps/OpenSign/src/components/pdf/EditTemplate.js
@@ -21,8 +21,8 @@ const EditTemplate = ({ template, onSuccess }) => {
}, []);
const fetchSubscription = async () => {
if (isEnableSubscription) {
- const getIsSubscribe = await checkIsSubscribed();
- setIsSubscribe(getIsSubscribe);
+ const subscribe = await checkIsSubscribed();
+ setIsSubscribe(subscribe.isValid);
}
};
const handleStrInput = (e) => {
diff --git a/apps/OpenSign/src/constant/Utils.js b/apps/OpenSign/src/constant/Utils.js
index fc6ba97a7..f504b2ad9 100644
--- a/apps/OpenSign/src/constant/Utils.js
+++ b/apps/OpenSign/src/constant/Utils.js
@@ -56,6 +56,8 @@ export async function fetchSubscription(
} else {
plan = tenatRes.data?.result?.result?.PlanCode;
billingDate = tenatRes.data?.result?.result?.Next_billing_date?.iso;
+ const allowedUsers = tenatRes.data?.result?.result?.AllowedUsers || 0;
+ localStorage.setItem("allowedUsers", allowedUsers);
}
return { plan, billingDate, status };
} catch (err) {
@@ -93,12 +95,14 @@ export async function fetchSubscriptionInfo() {
const plan_code =
tenatRes.data?.result?.result?.SubscriptionDetails?.data?.subscription
?.plan?.plan_code;
+ const totalAllowedUser = tenatRes.data?.result?.result?.AllowedUsers || 0;
return {
status: "success",
price: price,
totalPrice: totalPrice,
planId: planId,
- plan_code: plan_code
+ plan_code: plan_code,
+ totalAllowedUser: totalAllowedUser
};
}
} catch (err) {
@@ -111,41 +115,22 @@ export async function checkIsSubscribed() {
try {
const res = await fetchSubscription();
if (res.plan === "freeplan") {
- return false;
- } else if (res.billingDate) {
- if (new Date(res.billingDate) > new Date()) {
- return true;
- } else {
- return false;
- }
- } else {
- return false;
- }
- } catch (err) {
- console.log("Err in fetch subscription", err);
- return false;
- }
-}
-
-//function to get subcripition details from subscription class
-export async function checkIsSubscribedTeam() {
- try {
- const res = await fetchSubscription();
- if (res.plan === "freeplan") {
- return false;
+ return { plan: res.plan, isValid: false };
} else if (res.billingDate) {
const plan = validplan[res.plan] || false;
if (plan && new Date(res.billingDate) > new Date()) {
- return true;
+ return { plan: res.plan, isValid: true };
+ } else if (new Date(res.billingDate) > new Date()) {
+ return { plan: res.plan, isValid: true };
} else {
- return false;
+ return { plan: res.plan, isValid: false };
}
} else {
- return false;
+ return { plan: res.plan, isValid: false };
}
} catch (err) {
console.log("Err in fetch subscription", err);
- return false;
+ return { plan: "no-plan", isValid: false };
}
}
diff --git a/apps/OpenSign/src/constant/const.js b/apps/OpenSign/src/constant/const.js
index 4ac828514..2423354ed 100644
--- a/apps/OpenSign/src/constant/const.js
+++ b/apps/OpenSign/src/constant/const.js
@@ -9,5 +9,5 @@ export const isEnableSubscription =
process.env.REACT_APP_ENABLE_SUBSCRIPTION?.toLowerCase() === "true"
? true
: false;
-export const isStaging =
- window.location.origin === "https://staging-app.opensignlabs.com";
+export const isStaging = "http://localhost:3001";
+// window.location.origin === "https://staging-app.opensignlabs.com";
diff --git a/apps/OpenSign/src/index.css b/apps/OpenSign/src/index.css
index a0b01effb..a3fe178d4 100644
--- a/apps/OpenSign/src/index.css
+++ b/apps/OpenSign/src/index.css
@@ -26,7 +26,7 @@ body {
.op-bg-info {
@apply bg-info;
}
-.op-bg-success{
+.op-bg-success {
@apply bg-success;
}
.op-bg-warning {
@@ -43,14 +43,17 @@ body {
.op-text-info {
@apply text-info;
}
-.op-text-success{
+.op-text-accent {
+ @apply text-accent;
+}
+.op-text-success {
@apply text-success;
}
.op-text-warning {
@apply text-warning;
}
-.op-border-primary{
- @apply border-primary
+.op-border-primary {
+ @apply border-primary;
}
/* CSS for scrollbar customization */
* {
@@ -70,4 +73,4 @@ body {
*::-webkit-scrollbar-thumb {
background-color: gray;
border-radius: 10px;
-}
\ No newline at end of file
+}
diff --git a/apps/OpenSign/src/json/plansArr.js b/apps/OpenSign/src/json/plansArr.js
index 77a573e8a..0fb08c2d6 100644
--- a/apps/OpenSign/src/json/plansArr.js
+++ b/apps/OpenSign/src/json/plansArr.js
@@ -171,4 +171,72 @@ export const validplan = {
"enterprise-monthly": true,
"enterprise-yearly": true
};
+export const paidUrl = (plan) => {
+ const teamperiod = {
+ "team-weekly": "monthly",
+ "team-yearly": "yearly",
+ "teams-monthly": "monthly",
+ "teams-yearly": "yearly"
+ };
+ const period = teamperiod[plan] || "";
+ if (period) {
+ const extUser =
+ localStorage.getItem("Extand_Class") &&
+ JSON.parse(localStorage.getItem("Extand_Class"))?.[0];
+ const user = {
+ name: extUser?.Name,
+ email: extUser?.Email,
+ company: extUser?.Company,
+ phone: extUser?.Phone
+ };
+ // console.log("userDetails ", userDetails);
+ const fullname = user && user.name ? user.name.split(" ") : "";
+ const firstname = fullname?.[0]
+ ? "first_name=" + encodeURIComponent(fullname?.[0])
+ : "";
+ const lastname = fullname?.[1]
+ ? "&last_name=" + encodeURIComponent(fullname?.[1])
+ : "";
+ const name = firstname ? firstname + lastname : "";
+ const email =
+ user && user.email ? "&email=" + encodeURIComponent(user.email) : "";
+ const company =
+ user && user.company
+ ? "&company_name=" + encodeURIComponent(user.company)
+ : "";
+ const phone =
+ user && user.phone ? "&mobile=" + encodeURIComponent(user.phone) : "";
+ const allowedUsers = localStorage.getItem("allowedUsers");
+ const quantity = allowedUsers
+ ? isStaging
+ ? `addon_code%5B0%5D=extra-users&addon_quantity%5B0%5D=${allowedUsers}`
+ : `addon_code%5B0%5D=extra-teams-users-${period}&addon_quantity%5B0%5D=${allowedUsers}`
+ : "";
+
+ const details =
+ "?shipping_country_code=US&billing_country_code=US&billing_state_code=CA&" +
+ quantity +
+ name +
+ email +
+ company +
+ phone;
+
+ if (user) {
+ localStorage.setItem("userDetails", JSON.stringify(user));
+ }
+ const url = {
+ monthly: isStaging
+ ? "https://billing.zoho.in/subscribe/ed8097273a82b6bf39892c11a3bb3c381eb2705736014cfbdbde1ccf1c7a189d/team-weekly"
+ : "https://billing.opensignlabs.com/subscribe/ef798486e6a0a11ea65f2bae8f2af901237d0702bfaa959406306635d80f138c/teams-monthly",
+ yearly: isStaging
+ ? "https://billing.zoho.in/subscribe/ed8097273a82b6bf39892c11a3bb3c381eb2705736014cfbdbde1ccf1c7a189d/team-weekly"
+ : "https://billing.opensignlabs.com/subscribe/ef798486e6a0a11ea65f2bae8f2af9011a864994bbeeec71fcf106188630199d/teams-yearly"
+ };
+
+ const planurl = url[period] + details;
+ return planurl;
+ } else {
+ return "/subscription";
+ }
+};
export default plans;
diff --git a/apps/OpenSign/src/layout/HomeLayout.js b/apps/OpenSign/src/layout/HomeLayout.js
index 57c421e59..20ff7f680 100644
--- a/apps/OpenSign/src/layout/HomeLayout.js
+++ b/apps/OpenSign/src/layout/HomeLayout.js
@@ -11,9 +11,10 @@ import ModalUi from "../primitives/ModalUi";
import { useNavigate, useLocation, Outlet } from "react-router-dom";
import { isEnableSubscription } from "../constant/const";
import { useCookies } from "react-cookie";
-import { fetchSubscription } from "../constant/Utils";
+import { fetchSubscription, openInNewTab } from "../constant/Utils";
import Loader from "../primitives/Loader";
import { showHeader } from "../redux/reducers/showHeader";
+import { paidUrl } from "../json/plansArr";
const HomeLayout = () => {
const navigate = useNavigate();
@@ -86,7 +87,14 @@ const HomeLayout = () => {
domain: updateDomain
});
};
-
+ const handleNavigation = (plan) => {
+ const route = paidUrl(plan);
+ if (route === "/subscription") {
+ navigate(route);
+ } else {
+ openInNewTab(route, "_self");
+ }
+ };
async function checkIsSubscribed() {
if (isEnableSubscription) {
const res = await fetchSubscription();
@@ -98,10 +106,10 @@ const HomeLayout = () => {
setIsUserValid(true);
setIsLoader(false);
} else {
- navigate(`/subscription`);
+ handleNavigation(res.plan);
}
} else {
- navigate(`/subscription`);
+ handleNavigation(res.plan);
}
} else {
setIsUserValid(true);
diff --git a/apps/OpenSign/src/pages/Form.js b/apps/OpenSign/src/pages/Form.js
index 85ab925f7..4dca92c89 100644
--- a/apps/OpenSign/src/pages/Form.js
+++ b/apps/OpenSign/src/pages/Form.js
@@ -76,8 +76,8 @@ const Forms = (props) => {
}, []);
const fetchSubscription = async () => {
if (isEnableSubscription) {
- const getIsSubscribe = await checkIsSubscribed();
- setIsSubscribe(getIsSubscribe);
+ const subscribe = await checkIsSubscribed();
+ setIsSubscribe(subscribe.isValid);
}
};
diff --git a/apps/OpenSign/src/pages/GenerateToken.js b/apps/OpenSign/src/pages/GenerateToken.js
index 46cea098b..017404731 100644
--- a/apps/OpenSign/src/pages/GenerateToken.js
+++ b/apps/OpenSign/src/pages/GenerateToken.js
@@ -9,6 +9,7 @@ import Tooltip from "../primitives/Tooltip";
import Loader from "../primitives/Loader";
import SubscribeCard from "../primitives/SubscribeCard";
import Tour from "reactour";
+import { validplan } from "../json/plansArr";
const tourSteps = [
{
selector: '[data-tut="apisubscribe"]',
@@ -22,7 +23,7 @@ function GenerateToken() {
const [apiToken, SetApiToken] = useState("");
const [isLoader, setIsLoader] = useState(true);
const [isModal, setIsModal] = useState(false);
- const [isSubscribe, setIsSubscribe] = useState(false);
+ const [isSubscribe, setIsSubscribe] = useState({ plan: "", isValid: false });
const [isAlert, setIsAlert] = useState({ type: "success", msg: "" });
const [isTour, setIsTour] = useState(false);
useEffect(() => {
@@ -33,8 +34,8 @@ function GenerateToken() {
const fetchToken = async () => {
try {
if (isEnableSubscription) {
- const getIsSubscribe = await checkIsSubscribed();
- setIsSubscribe(getIsSubscribe);
+ const subscribe = await checkIsSubscribed();
+ setIsSubscribe(subscribe);
}
const url = parseBaseUrl + "functions/getapitoken";
const headers = {
@@ -55,7 +56,7 @@ function GenerateToken() {
};
const handleSubmit = async (e) => {
e.preventDefault();
- if (!isSubscribe && isEnableSubscription) {
+ if (!validplan[isSubscribe.plan] && isEnableSubscription) {
setIsTour(true);
} else {
setIsLoader(true);
@@ -123,7 +124,7 @@ function GenerateToken() {
- {!isSubscribe && isEnableSubscription && (
+ {!validplan[isSubscribe.plan] && isEnableSubscription && (
-
+
)}
>
diff --git a/apps/OpenSign/src/pages/Login.js b/apps/OpenSign/src/pages/Login.js
index fff744baa..f1b6ce976 100644
--- a/apps/OpenSign/src/pages/Login.js
+++ b/apps/OpenSign/src/pages/Login.js
@@ -16,6 +16,7 @@ import { fetchAppInfo } from "../redux/reducers/infoReducer";
import { showTenant } from "../redux/reducers/ShowTenant";
import { fetchSubscription, getAppLogo, openInNewTab } from "../constant/Utils";
import Loader from "../primitives/Loader";
+import { paidUrl } from "../json/plansArr";
function Login() {
const navigate = useNavigate();
const location = useLocation();
@@ -68,7 +69,14 @@ function Login() {
const { name, value } = event.target;
setState({ ...state, [name]: value });
};
-
+ const handlePaidRoute = (plan) => {
+ const route = paidUrl(plan);
+ if (route === "/subscription") {
+ navigate(route);
+ } else {
+ openInNewTab(route, "_self");
+ }
+ };
const handleSubmit = async (event) => {
localStorage.removeItem("accesstoken");
event.preventDefault();
@@ -139,9 +147,9 @@ function Login() {
JSON.stringify(LocalUserDetails)
);
const res = await fetchSubscription();
- const freeplan = res.plan;
+ const plan = res.plan;
const billingDate = res.billingDate;
- if (freeplan === "freeplan") {
+ if (plan === "freeplan") {
setState({ ...state, loading: false });
navigate(redirectUrl);
} else if (billingDate) {
@@ -152,11 +160,11 @@ function Login() {
navigate(redirectUrl);
} else {
setState({ ...state, loading: false });
- navigate(`/subscription`, { replace: true });
+ handlePaidRoute(plan);
}
} else {
setState({ ...state, loading: false });
- navigate(`/subscription`, { replace: true });
+ handlePaidRoute(plan);
}
} else {
setState({ ...state, loading: false });
@@ -311,9 +319,9 @@ function Login() {
localStorage.setItem("pageType", menu.pageType);
if (isEnableSubscription) {
const res = await fetchSubscription();
- const freeplan = res.plan;
+ const plan = res.plan;
const billingDate = res.billingDate;
- if (freeplan === "freeplan") {
+ if (plan === "freeplan") {
navigate(redirectUrl);
} else if (billingDate) {
if (new Date(billingDate) > new Date()) {
@@ -323,14 +331,14 @@ function Login() {
if (isFreeplan) {
navigate(redirectUrl);
} else {
- navigate(`/subscription`, { replace: true });
+ handlePaidRoute(plan);
}
}
} else {
if (isFreeplan) {
navigate(redirectUrl);
} else {
- navigate(`/subscription`, { replace: true });
+ handlePaidRoute(plan);
}
}
} else {
@@ -443,8 +451,8 @@ function Login() {
localStorage.setItem("userDetails", JSON.stringify(userInfo));
const res = await fetchSubscription();
const billingDate = res.billingDate;
- const freeplan = res.plan;
- if (freeplan === "freeplan") {
+ const plan = res.plan;
+ if (plan === "freeplan") {
navigate(redirectUrl);
} else if (billingDate) {
if (new Date(billingDate) > new Date()) {
@@ -452,10 +460,10 @@ function Login() {
// Redirect to the appropriate URL after successful login
navigate(redirectUrl);
} else {
- navigate(`/subscription`);
+ handlePaidRoute(plan);
}
} else {
- navigate(`/subscription`);
+ handlePaidRoute(plan);
}
} else {
// 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 48de2bcea..e421ccb78 100644
--- a/apps/OpenSign/src/pages/PdfRequestFiles.js
+++ b/apps/OpenSign/src/pages/PdfRequestFiles.js
@@ -30,7 +30,8 @@ import {
contactBook,
handleDownloadPdf,
handleToPrint,
- handleDownloadCertificate
+ handleDownloadCertificate,
+ openInNewTab
} from "../constant/Utils";
import LoaderWithMsg from "../primitives/LoaderWithMsg";
import HandleError from "../primitives/HandleError";
@@ -46,6 +47,7 @@ import { useSelector } from "react-redux";
import SignerListComponent from "../components/pdf/SignerListComponent";
import VerifyEmail from "../components/pdf/VerifyEmail";
import PdfZoom from "../components/pdf/PdfZoom";
+import { paidUrl } from "../json/plansArr";
function PdfRequestFiles(props) {
const [pdfDetails, setPdfDetails] = useState([]);
@@ -228,6 +230,15 @@ function PdfRequestFiles(props) {
const currentUser = JSON.parse(localuser);
await handleSendOTP(currentUser?.email);
};
+
+ const handleNavigation = (plan) => {
+ const route = paidUrl(plan);
+ if (route === "/subscription") {
+ window.location.href = route;
+ } else {
+ openInNewTab(route, "_self");
+ }
+ };
async function checkIsSubscribed(extUserId, contactId) {
const isGuestSign = isGuestSignFlow || false;
const res = await fetchSubscription(extUserId, contactId, isGuestSign);
@@ -244,7 +255,7 @@ function PdfRequestFiles(props) {
if (isGuestSign) {
setIsSubscriptionExpired(true);
} else {
- window.location.href = "/subscription";
+ handleNavigation(plan);
}
}
} else if (isGuestSign) {
@@ -258,7 +269,7 @@ function PdfRequestFiles(props) {
if (isGuestSign) {
setIsSubscriptionExpired(true);
} else {
- window.location.href = "/subscription";
+ handleNavigation(res.plan);
}
}
}
diff --git a/apps/OpenSign/src/pages/PlaceHolderSign.js b/apps/OpenSign/src/pages/PlaceHolderSign.js
index 237adaa71..a2019db72 100644
--- a/apps/OpenSign/src/pages/PlaceHolderSign.js
+++ b/apps/OpenSign/src/pages/PlaceHolderSign.js
@@ -34,7 +34,8 @@ import {
copytoData,
fetchSubscription,
convertPdfArrayBuffer,
- getContainerScale
+ getContainerScale,
+ openInNewTab
} from "../constant/Utils";
import RenderPdf from "../components/pdf/RenderPdf";
import { useNavigate } from "react-router-dom";
@@ -53,6 +54,7 @@ import Loader from "../primitives/Loader";
import { useSelector } from "react-redux";
import PdfZoom from "../components/pdf/PdfZoom";
import LottieWithLoader from "../primitives/DotLottieReact";
+import { paidUrl } from "../json/plansArr";
function PlaceHolderSign() {
const editorRef = useRef();
@@ -240,22 +242,29 @@ function PlaceHolderSign() {
return () => clearTimeout(timer);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [divRef.current, isHeader]);
-
+ const handleNavigation = (plan) => {
+ const route = paidUrl(plan);
+ if (route === "/subscription") {
+ navigate(route);
+ } else {
+ openInNewTab(route, "_self");
+ }
+ };
async function checkIsSubscribed() {
const res = await fetchSubscription();
- const freeplan = res.plan;
+ const plan = res.plan;
const billingDate = res.billingDate;
- if (freeplan === "freeplan") {
+ if (plan === "freeplan") {
return true;
} else if (billingDate) {
if (new Date(billingDate) > new Date()) {
setIsSubscribe(true);
return true;
} else {
- navigate(`/subscription`);
+ handleNavigation(plan);
}
} else {
- navigate(`/subscription`);
+ handleNavigation(plan);
}
}
//function for get document details
diff --git a/apps/OpenSign/src/pages/SSOVerify.js b/apps/OpenSign/src/pages/SSOVerify.js
index 2e8311b3e..b11740da1 100644
--- a/apps/OpenSign/src/pages/SSOVerify.js
+++ b/apps/OpenSign/src/pages/SSOVerify.js
@@ -3,11 +3,12 @@ import { useLocation, useNavigate } from "react-router-dom";
import Parse from "parse";
import { appInfo } from "../constant/appinfo";
import { isEnableSubscription } from "../constant/const";
-import { fetchSubscription } from "../constant/Utils";
+import { fetchSubscription, openInNewTab } from "../constant/Utils";
import { useDispatch } from "react-redux";
import { showTenant } from "../redux/reducers/ShowTenant";
import ModalUi from "../primitives/ModalUi";
import Loader from "../primitives/Loader";
+import { paidUrl } from "../json/plansArr";
const SSOVerify = () => {
const location = useLocation();
@@ -48,6 +49,14 @@ const SSOVerify = () => {
console.log("err", err.message);
}
};
+ const handlePaidRoute = (plan) => {
+ const route = paidUrl(plan);
+ if (route === "/subscription") {
+ navigate(route);
+ } else {
+ openInNewTab(route, "_self");
+ }
+ };
const checkExtUser = async (ssosign) => {
const params = { email: ssosign?.email };
try {
@@ -194,10 +203,10 @@ const SSOVerify = () => {
localStorage.removeItem("userDetails");
navigate(redirectUrl);
} else {
- navigate(`/subscription`, { replace: true });
+ handlePaidRoute(plan);
}
} else {
- navigate(`/subscription`, { replace: true });
+ handlePaidRoute(plan);
}
} else {
navigate(redirectUrl);
diff --git a/apps/OpenSign/src/pages/SignyourselfPdf.js b/apps/OpenSign/src/pages/SignyourselfPdf.js
index bc3c20383..82d436665 100644
--- a/apps/OpenSign/src/pages/SignyourselfPdf.js
+++ b/apps/OpenSign/src/pages/SignyourselfPdf.js
@@ -757,7 +757,7 @@ function SignYourSelf() {
if (
tenantDetails?.CompletionBody &&
tenantDetails?.CompletionSubject &&
- getIsSubscribe
+ getIsSubscribe.isValid
) {
isCustomCompletionMail = true;
}
diff --git a/apps/OpenSign/src/pages/TeamList.js b/apps/OpenSign/src/pages/TeamList.js
index 195913d84..2d02ca340 100644
--- a/apps/OpenSign/src/pages/TeamList.js
+++ b/apps/OpenSign/src/pages/TeamList.js
@@ -8,9 +8,10 @@ import ModalUi from "../primitives/ModalUi";
import pad from "../assets/images/pad.svg";
import AddTeam from "../components/AddTeam";
import { isEnableSubscription } from "../constant/const";
-import { checkIsSubscribedTeam } from "../constant/Utils";
+import { checkIsSubscribed } from "../constant/Utils";
import SubscribeCard from "../primitives/SubscribeCard";
import Title from "../components/Title";
+import { validplan } from "../json/plansArr";
const heading = ["Sr.No", "Name", "Parent Team", "Active"];
const actions = [
@@ -36,7 +37,7 @@ const TeamList = () => {
const [isActiveModal, setIsActiveModal] = useState({});
const [isAlert, setIsAlert] = useState({ type: "success", msg: "" });
const [isActLoader, setIsActLoader] = useState({});
- const [isSubscribe, setIsSubscribe] = useState(false);
+ const [isSubscribe, setIsSubscribe] = useState({ plan: "", isValid: false });
const [isEditModal, setIsEditModal] = useState({});
const [isAdmin, setIsAdmin] = useState(false);
const startIndex = (currentPage - 1) * recordperPage; // user per page
@@ -100,8 +101,8 @@ const TeamList = () => {
try {
setIsLoader(true);
if (isEnableSubscription) {
- const getIsSubscribe = await checkIsSubscribedTeam();
- setIsSubscribe(getIsSubscribe);
+ const subscribe = await checkIsSubscribed();
+ setIsSubscribe(subscribe);
}
const extUser = JSON.parse(localStorage.getItem("Extand_Class"))?.[0];
if (extUser) {
@@ -222,7 +223,7 @@ const TeamList = () => {
)}
- {isSubscribe && isEnableSubscription && !isLoader && (
+ {validplan[isSubscribe.plan] && isEnableSubscription && !isLoader && (
<>
{isAdmin ? (