diff --git a/web/ce/components/workspace/billing/comparison/root.tsx b/web/ce/components/workspace/billing/comparison/root.tsx index 9070dd354..469b9806d 100644 --- a/web/ce/components/workspace/billing/comparison/root.tsx +++ b/web/ce/components/workspace/billing/comparison/root.tsx @@ -1,4 +1,3 @@ -import { forwardRef } from "react"; import { observer } from "mobx-react"; // plane imports import { EProductSubscriptionEnum } from "@plane/constants"; @@ -10,52 +9,40 @@ import { PLANE_PLANS, TPlanePlans } from "@/constants/plans"; import { PlanDetail } from "./plan-detail"; type TPlansComparisonProps = { - isScrolled: boolean; isCompareAllFeaturesSectionOpen: boolean; getBillingFrequency: (subscriptionType: EProductSubscriptionEnum) => TBillingFrequency | undefined; setBillingFrequency: (subscriptionType: EProductSubscriptionEnum, frequency: TBillingFrequency) => void; setIsCompareAllFeaturesSectionOpen: React.Dispatch>; - setIsScrolled: React.Dispatch>; }; -export const PlansComparison = observer( - forwardRef(function PlansComparison( - props: TPlansComparisonProps, - ref: React.Ref - ) { - const { - isScrolled, - isCompareAllFeaturesSectionOpen, - getBillingFrequency, - setBillingFrequency, - setIsCompareAllFeaturesSectionOpen, - setIsScrolled, - } = props; - // plan details - const { planDetails } = PLANE_PLANS; +export const PlansComparison = observer((props: TPlansComparisonProps) => { + const { + isCompareAllFeaturesSectionOpen, + getBillingFrequency, + setBillingFrequency, + setIsCompareAllFeaturesSectionOpen, + } = props; + // plan details + const { planDetails } = PLANE_PLANS; - return ( - { - const currentPlanKey = planKey as TPlanePlans; - if (!shouldRenderPlanDetail(currentPlanKey)) return null; - return ( - setBillingFrequency(plan.id, frequency)} - /> - ); - })} - isSelfManaged - isScrolled={isScrolled} - isCompareAllFeaturesSectionOpen={isCompareAllFeaturesSectionOpen} - setIsCompareAllFeaturesSectionOpen={setIsCompareAllFeaturesSectionOpen} - setIsScrolled={setIsScrolled} - /> - ); - }) -); + return ( + { + const currentPlanKey = planKey as TPlanePlans; + if (!shouldRenderPlanDetail(currentPlanKey)) return null; + return ( + setBillingFrequency(plan.id, frequency)} + /> + ); + })} + isSelfManaged + isCompareAllFeaturesSectionOpen={isCompareAllFeaturesSectionOpen} + setIsCompareAllFeaturesSectionOpen={setIsCompareAllFeaturesSectionOpen} + /> + ); +}); diff --git a/web/ce/components/workspace/billing/root.tsx b/web/ce/components/workspace/billing/root.tsx index 6dd452134..c61b19643 100644 --- a/web/ce/components/workspace/billing/root.tsx +++ b/web/ce/components/workspace/billing/root.tsx @@ -1,4 +1,4 @@ -import { useEffect, useRef, useState } from "react"; +import { useState } from "react"; import { observer } from "mobx-react"; // plane imports import { @@ -16,8 +16,6 @@ import { getSubscriptionTextColor } from "@/components/workspace/billing/subscri import { PlansComparison } from "./comparison/root"; export const BillingRoot = observer(() => { - const [isScrolled, setIsScrolled] = useState(false); - const containerRef = useRef(null); const [isCompareAllFeaturesSectionOpen, setIsCompareAllFeaturesSectionOpen] = useState(false); const [productBillingFrequency, setProductBillingFrequency] = useState( DEFAULT_PRODUCT_BILLING_FREQUENCY @@ -43,33 +41,13 @@ export const BillingRoot = observer(() => { const setBillingFrequency = (subscriptionType: EProductSubscriptionEnum, frequency: TBillingFrequency): void => setProductBillingFrequency({ ...productBillingFrequency, [subscriptionType]: frequency }); - useEffect(() => { - const container = containerRef.current; - if (!container) return; - - const handleScroll = () => { - const scrollTop = container.scrollTop; - const isScrolled = isCompareAllFeaturesSectionOpen ? scrollTop > 0 : false; - setIsScrolled(isScrolled); - }; - - container.addEventListener("scroll", handleScroll); - return () => container.removeEventListener("scroll", handleScroll); - }, [isCompareAllFeaturesSectionOpen]); - return (
- -
+
@@ -89,13 +67,10 @@ export const BillingRoot = observer(() => {
All plans
); diff --git a/web/core/components/workspace/billing/comparison/base.tsx b/web/core/components/workspace/billing/comparison/base.tsx index b71ac0479..d653b14af 100644 --- a/web/core/components/workspace/billing/comparison/base.tsx +++ b/web/core/components/workspace/billing/comparison/base.tsx @@ -1,4 +1,3 @@ -import { forwardRef } from "react"; import { observer } from "mobx-react"; import { ArrowDown, ArrowUp } from "lucide-react"; // plane imports @@ -12,10 +11,8 @@ import { PlanFeatureDetail } from "./feature-detail"; type TPlansComparisonBaseProps = { planeDetails: React.ReactNode; isSelfManaged: boolean; - isScrolled: boolean; isCompareAllFeaturesSectionOpen: boolean; setIsCompareAllFeaturesSectionOpen: React.Dispatch>; - setIsScrolled: React.Dispatch>; }; export const shouldRenderPlanDetail = (planKey: TPlanePlans) => { @@ -26,138 +23,117 @@ export const shouldRenderPlanDetail = (planKey: TPlanePlans) => { return true; }; -export const PlansComparisonBase = observer( - forwardRef(function PlansComparisonBase( - props: TPlansComparisonBaseProps, - ref: React.Ref - ) { - const { - planeDetails, - isSelfManaged, - isScrolled, - isCompareAllFeaturesSectionOpen, - setIsCompareAllFeaturesSectionOpen, - setIsScrolled, - } = props; - // plan details - const { planDetails, planHighlights, planComparison } = PLANE_PLANS; - const numberOfPlansToRender = Object.keys(planDetails).filter((planKey) => - shouldRenderPlanDetail(planKey as TPlanePlans) - ).length; +export const PlansComparisonBase = observer((props: TPlansComparisonBaseProps) => { + const { planeDetails, isSelfManaged, isCompareAllFeaturesSectionOpen, setIsCompareAllFeaturesSectionOpen } = props; + // plan details + const { planDetails, planHighlights, planComparison } = PLANE_PLANS; + const numberOfPlansToRender = Object.keys(planDetails).filter((planKey) => + shouldRenderPlanDetail(planKey as TPlanePlans) + ).length; - const getSubscriptionType = (planKey: TPlanePlans) => planDetails[planKey].id; + const getSubscriptionType = (planKey: TPlanePlans) => planDetails[planKey].id; - return ( -
-
-
-
-
- {planeDetails} -
- {/* Plan Headers */} -
- {/* Plan Highlights */} -
-
Highlights
- {Object.entries(planHighlights).map( - ([planKey, highlights]) => - shouldRenderPlanDetail(planKey as TPlanePlans) && ( -
-
    - {highlights.map((highlight, index) => ( -
  • {highlight}
  • - ))} -
-
- ) - )} -
-
- - {/* Feature Comparison */} - {isCompareAllFeaturesSectionOpen && ( - <> - {planComparison.map((section, sectionIdx) => ( -
-

- {section.title} {section.comingSoon && } -

-
- {section.features.map((feature, featureIdx) => ( -
-
-
- {feature.title} {feature.comingSoon && } -
-
- {PLANS_LIST.map( - (planKey) => - shouldRenderPlanDetail(planKey) && ( -
- -
- ) - )} -
- ))} -
-
- ))} - + return ( +
+
+
+
+
+ {planeDetails}
- - {/* Toggle Button */} -
- -
+
Highlights
+ {Object.entries(planHighlights).map( + ([planKey, highlights]) => + shouldRenderPlanDetail(planKey as TPlanePlans) && ( +
+
    + {highlights.map((highlight, index) => ( +
  • {highlight}
  • + ))} +
+
+ ) + )} +
+ + + {/* Feature Comparison */} + {isCompareAllFeaturesSectionOpen && ( + <> + {planComparison.map((section, sectionIdx) => ( +
+

+ {section.title} {section.comingSoon && } +

+
+ {section.features.map((feature, featureIdx) => ( +
+
+
+ {feature.title} {feature.comingSoon && } +
+
+ {PLANS_LIST.map( + (planKey) => + shouldRenderPlanDetail(planKey) && ( +
+ +
+ ) + )} +
+ ))} +
+
+ ))} + + )} +
+ + {/* Toggle Button */} +
+
- ); - }) -); +
+ ); +});