From 7c71277759be6667efd95eee76f40045a06f06b4 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Thu, 1 Aug 2024 21:10:54 +0530 Subject: [PATCH] Inline --- .../pages/gallery/PlanSelector/index.tsx | 184 ++++++++++++++- .../gallery/PlanSelector/plans/index.tsx | 209 ------------------ 2 files changed, 183 insertions(+), 210 deletions(-) delete mode 100644 web/apps/photos/src/components/pages/gallery/PlanSelector/plans/index.tsx diff --git a/web/apps/photos/src/components/pages/gallery/PlanSelector/index.tsx b/web/apps/photos/src/components/pages/gallery/PlanSelector/index.tsx index ed3d34d3a0..3879d3667a 100644 --- a/web/apps/photos/src/components/pages/gallery/PlanSelector/index.tsx +++ b/web/apps/photos/src/components/pages/gallery/PlanSelector/index.tsx @@ -1,11 +1,14 @@ import log from "@/base/log"; import { bytesInGB, formattedStorageByteSize } from "@/new/photos/utils/units"; import { + FlexWrapper, FluidContainer, SpaceBetweenFlex, } from "@ente/shared/components/Container"; +import ArrowForward from "@mui/icons-material/ArrowForward"; import ChevronRight from "@mui/icons-material/ChevronRight"; import Close from "@mui/icons-material/Close"; +import Done from "@mui/icons-material/Done"; import { Button, ButtonProps, @@ -40,6 +43,7 @@ import { hasPaidSubscription, hasStripeSubscription, isOnFreePlan, + isPopularPlan, isSubscriptionActive, isSubscriptionCancelled, isUserSubscribedPlan, @@ -50,7 +54,6 @@ import { } from "utils/billing"; import { getLocalUserDetails } from "utils/user"; import { getTotalFamilyUsage, isPartOfFamily } from "utils/user/family"; -import Plans from "./plans"; interface PlanSelectorProps { modalView: boolean; @@ -448,6 +451,185 @@ const CustomToggleButton = styled(ToggleButton)(({ theme }) => ({ width: "97.433px", })); +interface PlansProps { + plansResponse: PlansResponse | undefined; + planPeriod: PLAN_PERIOD; + subscription: Subscription; + bonusData?: BonusData; + onPlanSelect: (plan: Plan) => void; + closeModal: () => void; +} + +const Plans = ({ + plansResponse, + planPeriod, + subscription, + bonusData, + onPlanSelect, + closeModal, +}: PlansProps) => { + const { freePlan, plans } = plansResponse ?? {}; + return ( + + {plans + ?.filter((plan) => plan.period === planPeriod) + ?.map((plan) => ( + + ))} + {!hasPaidSubscription(subscription) && + !hasAddOnBonus(bonusData) && + freePlan && ( + + )} + + ); +}; + +interface PlanRowProps { + plan: Plan; + subscription: Subscription; + onPlanSelect: (plan: Plan) => void; + disabled: boolean; + popular: boolean; +} + +function PlanRow({ + plan, + subscription, + onPlanSelect, + disabled, + popular, +}: PlanRowProps) { + const handleClick = () => { + !isUserSubscribedPlan(plan, subscription) && onPlanSelect(plan); + }; + + const PlanButton = disabled ? DisabledPlanButton : ActivePlanButton; + + return ( + + + + {bytesInGB(plan.storage)} + + + + {t("storage_unit.gb")} + + {popular && !hasPaidSubscription(subscription) && ( + {t("POPULAR")} + )} + + + + + + + {plan.price}{" "} + {" "} + + {`/ ${ + plan.period === PLAN_PERIOD.MONTH + ? t("MONTH_SHORT") + : t("YEAR") + }`} + + + + + + ); +} + +const PlanRowContainer = styled(FlexWrapper)(() => ({ + background: + "linear-gradient(268.22deg, rgba(256, 256, 256, 0.08) -3.72%, rgba(256, 256, 256, 0) 85.73%)", +})); + +const TopAlignedFluidContainer = styled(FluidContainer)` + align-items: flex-start; +`; + +const DisabledPlanButton = styled((props: ButtonProps) => ( +