π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Show BF add on with validtity
Neeraj Gupta1f698b550ec2
diff --git a/apps/photos/public/locales/en/translation.json b/apps/photos/public/locales/en/translation.jsonindex f24b507488..e53634f3c9 100644--- a/apps/photos/public/locales/en/translation.json+++ b/apps/photos/public/locales/en/translation.json@@ -157,6 +157,7 @@"RENEWAL_ACTIVE_SUBSCRIPTION_STATUS": "Renews on {{date, dateTime}}","RENEWAL_CANCELLED_SUBSCRIPTION_STATUS": "Ends on {{date, dateTime}}","RENEWAL_CANCELLED_SUBSCRIPTION_INFO": "Your subscription will be cancelled on {{date, dateTime}}",+ "ADD_ON_AVAILABLE_TILL": "Your {{storage, string}} add-on is valid till {{date, dateTime}}","STORAGE_QUOTA_EXCEEDED_SUBSCRIPTION_INFO": "You have exceeded your storage quota, please <a>upgrade</a>","SUBSCRIPTION_PURCHASE_SUCCESS": "<p>We've received your payment</p><p>Your subscription is valid till <strong>{{date, dateTime}}</strong></p>","SUBSCRIPTION_PURCHASE_CANCELLED": "Your purchase was canceled, please try again if you want to subscribe",diff --git a/apps/photos/src/components/pages/gallery/PlanSelector/card/free.tsx b/apps/photos/src/components/pages/gallery/PlanSelector/card/free.tsxindex 3e9bb5ad08..aedfda2677 100644--- a/apps/photos/src/components/pages/gallery/PlanSelector/card/free.tsx+++ b/apps/photos/src/components/pages/gallery/PlanSelector/card/free.tsx@@ -9,6 +9,7 @@ import Plans from '../plans';export default function FreeSubscriptionPlanSelectorCard({plans,subscription,+ bonusData,closeModal,planPeriod,togglePeriod,@@ -36,6 +37,7 @@ export default function FreeSubscriptionPlanSelectorCard({planPeriod={planPeriod}onPlanSelect={onPlanSelect}subscription={subscription}+ bonusData={bonusData}closeModal={closeModal}/></Stack>diff --git a/apps/photos/src/components/pages/gallery/PlanSelector/card/index.tsx b/apps/photos/src/components/pages/gallery/PlanSelector/card/index.tsxindex 5be0507b81..d7969504d5 100644--- a/apps/photos/src/components/pages/gallery/PlanSelector/card/index.tsx+++ b/apps/photos/src/components/pages/gallery/PlanSelector/card/index.tsx@@ -44,6 +44,13 @@ function PlanSelectorCard(props: Props) {);const galleryContext = useContext(GalleryContext);const appContext = useContext(AppContext);+ const bonusData = useMemo(() => {+ const userDetails = getLocalUserDetails();+ if (!userDetails) {+ return 0;+ }+ return userDetails.bonusData;+ }, []);const usage = useMemo(() => {const userDetails = getLocalUserDetails();@@ -170,6 +177,7 @@ function PlanSelectorCard(props: Props) {<PaidSubscriptionPlanSelectorCardplans={plans}subscription={subscription}+ bonusData={bonusData}closeModal={props.closeModal}planPeriod={planPeriod}togglePeriod={togglePeriod}@@ -181,6 +189,7 @@ function PlanSelectorCard(props: Props) {<FreeSubscriptionPlanSelectorCardplans={plans}subscription={subscription}+ bonusData={bonusData}closeModal={props.closeModal}planPeriod={planPeriod}togglePeriod={togglePeriod}diff --git a/apps/photos/src/components/pages/gallery/PlanSelector/plans/BfAddOnRow.tsx b/apps/photos/src/components/pages/gallery/PlanSelector/plans/BfAddOnRow.tsxnew file mode 100644index 0000000000..c3ac7313ba--- /dev/null+++ b/apps/photos/src/components/pages/gallery/PlanSelector/plans/BfAddOnRow.tsx@@ -0,0 +1,43 @@+import { Box, styled, Typography } from '@mui/material';+import { SpaceBetweenFlex } from '@ente/shared/components/Container';+import React from 'react';++import { Trans } from 'react-i18next';+import { makeHumanReadableStorage } from 'utils/billing';++const RowContainer = styled(SpaceBetweenFlex)(({ theme }) => ({+ gap: theme.spacing(1.5),+ padding: theme.spacing(1.5, 1),+ cursor: 'pointer',+ '&:hover .endIcon': {+ backgroundColor: 'rgba(255,255,255,0.08)',+ },+}));+export function BFAddOnRow({ bonusData, closeModal }) {+ return (+ <>+ {bonusData.storageBonuses.map((bonus) => {+ if (bonus.type.startsWith('ADD_ON')) {+ return (+ <RowContainer key={bonus.id} onClick={closeModal}>+ <Box>+ <Typography variant="small" color="text.muted">+ <Trans+ i18nKey={'ADD_ON_AVAILABLE_TILL'}+ values={{+ storage: makeHumanReadableStorage(+ bonus.storage+ ),+ date: bonus.validTill,+ }}+ />+ </Typography>+ </Box>+ </RowContainer>+ );+ }+ return null;+ })}+ </>+ );+}diff --git a/apps/photos/src/components/pages/gallery/PlanSelector/plans/index.tsx b/apps/photos/src/components/pages/gallery/PlanSelector/plans/index.tsxindex bfd13ecaf2..4b2d35713a 100644--- a/apps/photos/src/components/pages/gallery/PlanSelector/plans/index.tsx+++ b/apps/photos/src/components/pages/gallery/PlanSelector/plans/index.tsx@@ -2,6 +2,7 @@ import { FreePlanRow } from './FreePlanRow';import { Stack } from '@mui/material';import React from 'react';import {+ hasAddOnBonus,hasPaidSubscription,isPopularPlan,isUserSubscribedPlan,@@ -9,11 +10,14 @@ import {import { PlanRow } from './planRow';import { Plan, Subscription } from 'types/billing';import { PLAN_PERIOD } from 'constants/gallery';+import { BonusData } from 'types/user';+import { BFAddOnRow } from './BfAddOnRow';interface Iprops {plans: Plan[];planPeriod: PLAN_PERIOD;subscription: Subscription;+ bonusData?: BonusData;onPlanSelect: (plan: Plan) => void;closeModal: () => void;}@@ -22,6 +26,7 @@ const Plans = ({plans,planPeriod,subscription,+ bonusData,onPlanSelect,closeModal,}: Iprops) => (@@ -38,9 +43,12 @@ const Plans = ({onPlanSelect={onPlanSelect}/>))}- {!hasPaidSubscription(subscription) && (+ {!hasPaidSubscription(subscription) && !hasAddOnBonus(bonusData) && (<FreePlanRow closeModal={closeModal} />)}+ {hasAddOnBonus(bonusData) && (+ <BFAddOnRow bonusData={bonusData} closeModal={closeModal} />+ )}</Stack>);