Skip to content

🔥 The free & Open Source DocuSign alternative

fix: visibility of upgrade now button in header

prafull-opensignlabsd31910aefaf7
diff --git a/apps/OpenSign/src/components/Header.js b/apps/OpenSign/src/components/Header.js
index 17e5e2dcd..7f788fc71 100644
--- a/apps/OpenSign/src/components/Header.js
+++ b/apps/OpenSign/src/components/Header.js
@@ -4,7 +4,7 @@ import FullScreenButton from "./FullScreenButton";
import { useNavigate } from "react-router-dom";
import Parse from "parse";
import { useWindowSize } from "../hook/useWindowSize";
-import { openInNewTab } from "../constant/Utils";
+import { checkIsSubscribed, openInNewTab } from "../constant/Utils";
import { isEnableSubscription } from "../constant/const";
const Header = ({ showSidebar }) => {
@@ -21,31 +21,13 @@ const Header = ({ showSidebar }) => {
setIsOpen(!isOpen);
};
useEffect(() => {
- checkIsSubscribed();
+ checkSubscription();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
- async function checkIsSubscribed() {
- const currentUser = Parse.User.current();
- const user = await Parse.Cloud.run("getUserDetails", {
- email: currentUser.get("email")
- });
+ async function checkSubscription() {
if (isEnableSubscription) {
- const freeplan = user?.get("Plan") && user?.get("Plan").plan_code;
- const billingDate =
- user?.get("Next_billing_date") && user?.get("Next_billing_date");
- if (freeplan === "freeplan") {
- setIsSubscribe(true);
- } else if (billingDate) {
- if (billingDate > new Date()) {
- setIsSubscribe(true);
- } else {
- navigate(`/subscription`);
- }
- } else {
- navigate(`/subscription`);
- }
- } else {
- setIsSubscribe(true);
+ const getIsSubscribe = await checkIsSubscribed();
+ setIsSubscribe(getIsSubscribe);
}
}
const closeDropdown = () => {
@@ -113,7 +95,7 @@ const Header = ({ showSidebar }) => {
id="profile-menu"
className="flex justify-between items-center gap-x-3"
>
- {isSubscribe && (
+ {!isSubscribe && (
<div>
<button
className="text-xs bg-[#002864] p-2 text-white rounded shadow"
diff --git a/apps/OpenSign/src/constant/Utils.js b/apps/OpenSign/src/constant/Utils.js
index bd5b45b67..fa7099415 100644
--- a/apps/OpenSign/src/constant/Utils.js
+++ b/apps/OpenSign/src/constant/Utils.js
@@ -15,12 +15,6 @@ export const openInNewTab = (url) => {
//function to get subcripition details from Extand user class
export async function checkIsSubscribed() {
- // const tenantId = localStorage.getItem("TenantId");
- // const users = new Parse.Query("partners_Tenant");
- // users.equalTo("objectId", tenantId);
- // const res = await users.first();
- // const jsonRes = JSON.parse(JSON.stringify(res));
-
const extClass = localStorage.getItem("Extand_Class");
const jsonSender = JSON.parse(extClass);
const user = await Parse.Cloud.run("getUserDetails", {