From adf891bcbac5ba7c5f47587b2daa9eed2f0cf620 Mon Sep 17 00:00:00 2001 From: rahulramesha <71900764+rahulramesha@users.noreply.github.com> Date: Fri, 23 Aug 2024 18:00:15 +0530 Subject: [PATCH 1/2] [WEB-2150] fix: issue selection redirect alert (#5406) * fix issue selection redirect alert * change message content for user prompt --- web/core/hooks/use-multiple-select.ts | 11 +++++++++++ web/core/hooks/use-reload-confirmation.tsx | 12 ++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/web/core/hooks/use-multiple-select.ts b/web/core/hooks/use-multiple-select.ts index 278304c4fe..1e997bbfe1 100644 --- a/web/core/hooks/use-multiple-select.ts +++ b/web/core/hooks/use-multiple-select.ts @@ -3,6 +3,8 @@ import { useCallback, useEffect, useMemo } from "react"; // hooks import { useMultipleSelectStore } from "@/hooks/store"; +// +import useReloadConfirmations from "./use-reload-confirmation"; export type TEntityDetails = { entityID: string; @@ -52,6 +54,15 @@ export const useMultipleSelect = (props: Props) => { getEntityDetailsFromEntityID, } = useMultipleSelectStore(); + useReloadConfirmations( + selectedEntityIds && selectedEntityIds.length > 0, + "Are you sure you want to leave? Your current bulk operation selections will be lost.", + true, + () => { + clearSelection(); + } + ); + const groups = useMemo(() => Object.keys(entities), [entities]); const entitiesList: TEntityDetails[] = useMemo( diff --git a/web/core/hooks/use-reload-confirmation.tsx b/web/core/hooks/use-reload-confirmation.tsx index 998c5845d9..6ba324d148 100644 --- a/web/core/hooks/use-reload-confirmation.tsx +++ b/web/core/hooks/use-reload-confirmation.tsx @@ -1,8 +1,10 @@ import { useCallback, useEffect, useState } from "react"; //TODO: remove temp flag isActive later and use showAlert as the source of truth -const useReloadConfirmations = (isActive = true) => { - const [showAlert, setShowAlert] = useState(false); +const useReloadConfirmations = (isActive = true, message?: string, defaultShowAlert = false, onLeave?: () => void) => { + const [showAlert, setShowAlert] = useState(defaultShowAlert); + + const alertMessage = message ?? "Are you sure you want to leave? Changes you made may not be saved."; const handleBeforeUnload = useCallback( (event: BeforeUnloadEvent) => { @@ -28,8 +30,10 @@ const useReloadConfirmations = (isActive = true) => { const isAnchorTargetBlank = anchorElement.getAttribute("target") === "_blank"; if (isAnchorTargetBlank) return; // show confirm dialog - const leave = confirm("Are you sure you want to leave? Changes you made may not be saved."); - if (!leave) { + const isLeaving = confirm(alertMessage); + if (isLeaving) { + onLeave && onLeave(); + } else { event.preventDefault(); event.stopPropagation(); } From 700f3ee82393c5cbd4f1d5471daaca6de320ecaa Mon Sep 17 00:00:00 2001 From: Prateek Shourya Date: Fri, 23 Aug 2024 18:04:55 +0530 Subject: [PATCH 2/2] chore: pricing update. (#5410) --- .../workspace/upgrade/pro-plan-upgrade.tsx | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/web/ce/components/workspace/upgrade/pro-plan-upgrade.tsx b/web/ce/components/workspace/upgrade/pro-plan-upgrade.tsx index 1f8a64222b..9852f9ca6b 100644 --- a/web/ce/components/workspace/upgrade/pro-plan-upgrade.tsx +++ b/web/ce/components/workspace/upgrade/pro-plan-upgrade.tsx @@ -15,19 +15,33 @@ type TProPiceFrequency = "month" | "year"; type TProPlanPrice = { key: string; - price: string; + currency: string; + price: number; recurring: TProPiceFrequency; }; +// constants +export const calculateYearlyDiscount = (monthlyPrice: number, yearlyPricePerMonth: number): number => { + const monthlyCost = monthlyPrice * 12; + const yearlyCost = yearlyPricePerMonth * 12; + const amountSaved = monthlyCost - yearlyCost; + const discountPercentage = (amountSaved / monthlyCost) * 100; + return Math.floor(discountPercentage); +}; + const PRO_PLAN_PRICES: TProPlanPrice[] = [ - { key: "monthly", price: "$7", recurring: "month" }, - { key: "yearly", price: "$5", recurring: "year" }, + { key: "monthly", currency: "$", price: 8, recurring: "month" }, + { key: "yearly", currency: "$", price: 6, recurring: "year" }, ]; export const ProPlanUpgrade: FC = (props) => { const { basePlan, features, verticalFeatureList = false, extraFeatures } = props; // states const [selectedPlan, setSelectedPlan] = useState("month"); + // derived + const monthlyPrice = PRO_PLAN_PRICES.find((price) => price.recurring === "month")?.price ?? 0; + const yearlyPrice = PRO_PLAN_PRICES.find((price) => price.recurring === "year")?.price ?? 0; + const yearlyDiscount = calculateYearlyDiscount(monthlyPrice, yearlyPrice); // env const PRO_PLAN_MONTHLY_PAYMENT_URL = process.env.NEXT_PUBLIC_PRO_PLAN_MONTHLY_PAYMENT_URL ?? "https://plane.so/pro"; const PRO_PLAN_YEARLY_PAYMENT_URL = process.env.NEXT_PUBLIC_PRO_PLAN_YEARLY_PAYMENT_URL ?? "https://plane.so/pro"; @@ -55,7 +69,7 @@ export const ProPlanUpgrade: FC = (props) => { {price.recurring === "year" && ("Yearly" as string)} {price.recurring === "year" && ( - -28% + -{yearlyDiscount}% )} @@ -69,8 +83,8 @@ export const ProPlanUpgrade: FC = (props) => {
Plane Pro
- {price.recurring === "month" && "$7"} - {price.recurring === "year" && "$5"} + {price.currency} + {price.price}
a user per month