diff --git a/public/locales/de/translation.json b/public/locales/de/translation.json index c9009a7..77f6b39 100644 --- a/public/locales/de/translation.json +++ b/public/locales/de/translation.json @@ -129,6 +129,7 @@ "feedback": "Feedback", "paymentPlan": "Zahlungsplan", "paymentPlanTrailingDaysLeft": "{{daysLeft}} {{dayUnit}} verbleibend", + "paymentPlanTrailingEnded": "Demo abgelaufen", "paymentPlanUpgradeButton": "Jetzt upgraden" }, "dashboard": { @@ -526,6 +527,7 @@ "demoEndsIn": "Die Testversion endet in", "selectPlanToAccessFullFeatures": "Wählen Sie einen Plan, um auf alle Funktionen zuzugreifen." }, + "alertTrialEnded": "Ihre Testversion ist abgelaufen. Bitte wählen Sie einen Plan, um unsere Dienste weiterhin nutzen zu können.", "alertPlanCancelled": "Ihr Plan wurde gekündigt. Am Ende des Abrechnungszeitraums müssen Sie einen neuen Plan auswählen, um unsere Dienste weiterhin nutzen zu können.", "features": [ { diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index b1d7a5a..c9c7396 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -129,6 +129,7 @@ "feedback": "Feedback", "paymentPlan": "Payment plan", "paymentPlanTrailingDaysLeft": "{{daysLeft}} {{dayUnit}} left", + "paymentPlanTrailingEnded": "Trial period ended", "paymentPlanUpgradeButton": "Upgrade now" }, "dashboard": { @@ -535,6 +536,7 @@ "demoEndsIn": "Demo ends in", "selectPlanToAccessFullFeatures": "Select a plan to access all features." }, + "alertTrialEnded": "Trial period ended. Please select a plan to continue using our services.", "alertPlanCancelled": "Your plan has been cancelled. At the end of the billing period, you need to select a new plan to continue using our services.", "features": [ { diff --git a/src/Components/AppRoutes/index.js b/src/Components/AppRoutes/index.js index 8f7f506..252e585 100644 --- a/src/Components/AppRoutes/index.js +++ b/src/Components/AppRoutes/index.js @@ -4,6 +4,10 @@ import { lazy } from "react"; import { MySupsenseFallback } from "../MySupsenseFallback"; import { AuthenticationMethod } from "../../Pages/Authentication"; import Verification from "../../Pages/Verification"; +import { + hasTrailEnded, + useSideBarContext, +} from "../../Contexts/SideBarContext"; // Lazy-loaded components const Authentication = lazy(() => import("../../Pages/Authentication")); @@ -127,6 +131,8 @@ export function VerificationRoutes() { } export function AppRoutes({ setUserSession }) { + const sideBarContext = useSideBarContext(); + return ( - - - - } - /> + {!hasTrailEnded(sideBarContext.paymentPlanTrialEnd) && ( + <> + + + + } + /> - - - - } - /> + + + + } + /> - - - - } - /> + + + + } + /> - - - - } - /> + + + + } + /> - - - - } - /> + + + + } + /> + + )} { let groupStore = { label: store.name, icon: , children: [], key: `${Constants.ROUTE_PATHS.STORE.OVERVIEW}/${store.store_id}`, + disabled: isDisabled, }; if (sideBarContext.permissions.includes("settings")) { @@ -70,6 +77,7 @@ export function SideMenuContent({ label: t("sideMenu.store.settings"), icon: , key: `${Constants.ROUTE_PATHS.STORE.OVERVIEW}/${store.store_id}/${Constants.ROUTE_PATHS.STORE.SETTINGS}`, + disabled: isDisabled, }); } @@ -78,6 +86,7 @@ export function SideMenuContent({ label: t("sideMenu.store.employees"), icon: , key: `${Constants.ROUTE_PATHS.STORE.OVERVIEW}/${store.store_id}/${Constants.ROUTE_PATHS.STORE.EMPLOYEES}`, + disabled: isDisabled, }); } @@ -86,6 +95,7 @@ export function SideMenuContent({ label: t("sideMenu.store.services"), icon: , key: `${Constants.ROUTE_PATHS.STORE.OVERVIEW}/${store.store_id}/${Constants.ROUTE_PATHS.STORE.SERVICES}`, + disabled: isDisabled, }); } @@ -94,6 +104,7 @@ export function SideMenuContent({ label: t("sideMenu.store.calendar"), icon: , key: `${Constants.ROUTE_PATHS.STORE.OVERVIEW}/${store.store_id}/${Constants.ROUTE_PATHS.STORE.CALENDAR}`, + disabled: isDisabled, }); } @@ -174,10 +185,7 @@ export function SideMenuContent({ } }, [location.pathname]); - const daysLeft = Math.floor( - (new Date(sideBarContext.paymentPlanTrialEnd) - new Date()) / - (1000 * 60 * 60 * 24) - ); + const daysLeft = getDaysLeft(sideBarContext.paymentPlanTrialEnd); return (
3 ? AppStyle.colors.primary : "#e74c3c", + margin: 8, + }} styles={{ body: { padding: 10 } }} > @@ -246,13 +258,15 @@ export function SideMenuContent({ level={5} style={{ color: "#fff", textAlign: "center" }} > - {t("sideMenu.paymentPlanTrailingDaysLeft", { - daysLeft: daysLeft, - dayUnit: - daysLeft > 1 - ? t("common.unit.days") - : t("common.unit.day"), - })} + {daysLeft > 0 + ? t("sideMenu.paymentPlanTrailingDaysLeft", { + daysLeft: daysLeft, + dayUnit: + daysLeft > 1 || daysLeft === 0 + ? t("common.unit.days") + : t("common.unit.day"), + }) + : t("sideMenu.paymentPlanTrailingEnded")} diff --git a/src/Contexts/SideBarContext.js b/src/Contexts/SideBarContext.js index dc55605..84b71f7 100644 --- a/src/Contexts/SideBarContext.js +++ b/src/Contexts/SideBarContext.js @@ -49,3 +49,16 @@ export default function SideBarProvider({ children, options }) { ); } + +// used to disabled the store menu in the SideBar, the store routes in AppRoutes and change the color of the trail end popup in the SideBar +export function getDaysLeft(paymentPlanTrialEnd) { + return Math.floor( + (new Date(paymentPlanTrialEnd) - new Date()) / (1000 * 60 * 60 * 24) + ); +} + +export function hasTrailEnded(paymentPlanTrialEnd) { + if (!paymentPlanTrialEnd) return false; + + return getDaysLeft(paymentPlanTrialEnd) <= 0; +} diff --git a/src/Pages/PaymentPlan/index.js b/src/Pages/PaymentPlan/index.js index fb3b667..e9bc351 100644 --- a/src/Pages/PaymentPlan/index.js +++ b/src/Pages/PaymentPlan/index.js @@ -25,6 +25,7 @@ import { useEffect, useState } from "react"; import { ReactComponent as RocketLaunch } from "./rocket_launch_FILL1_wght400_GRAD0_opsz24.svg"; import { ReactComponent as Check } from "./task_alt_FILL0_wght400_GRAD0_opsz24.svg"; import CountUp from "react-countup"; +import { getDaysLeft } from "../../Contexts/SideBarContext"; const { useBreakpoint } = Grid; @@ -78,10 +79,23 @@ export default function PaymentPlan() { requestData.payment_plan_trial_end && !requestData.payment_plan_canceled_at ) { - const daysLeft = Math.floor( - (new Date(requestData.payment_plan_trial_end) - new Date()) / - (1000 * 60 * 60 * 24) - ); + const daysLeft = getDaysLeft(requestData.payment_plan_trial_end); + + if (daysLeft <= 0) { + return ( + + {t("paymentPlan.alertTrialEnded")} + + } + type="warning" + showIcon + closable + style={{ marginBottom: 12 }} + /> + ); + } return (