Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Minor refactor

Neeraj Guptabf1de7d783b5
diff --git a/apps/photos/src/components/Sidebar/SubscriptionStatus/index.tsx b/apps/photos/src/components/Sidebar/SubscriptionStatus/index.tsx
index 5fccc7291a..40f02bd1d0 100644
--- a/apps/photos/src/components/Sidebar/SubscriptionStatus/index.tsx
+++ b/apps/photos/src/components/Sidebar/SubscriptionStatus/index.tsx
@@ -69,6 +69,48 @@ export default function SubscriptionStatus({
return <></>;
}
+ const messages = [];
+ if (!hasAddOnBonus(userDetails.bonusData)) {
+ if (isSubscriptionActive(userDetails.subscription)) {
+ if (isOnFreePlan(userDetails.subscription)) {
+ messages.push(
+ <Trans
+ i18nKey={'FREE_SUBSCRIPTION_INFO'}
+ values={{
+ date: userDetails.subscription?.expiryTime,
+ }}
+ />
+ );
+ } else if (isSubscriptionCancelled(userDetails.subscription)) {
+ messages.push(
+ t('RENEWAL_CANCELLED_SUBSCRIPTION_INFO', {
+ date: userDetails.subscription?.expiryTime,
+ })
+ );
+ }
+ } else {
+ messages.push(
+ <Trans
+ i18nKey={'SUBSCRIPTION_EXPIRED_MESSAGE'}
+ components={{
+ a: <LinkButton onClick={handleClick} />,
+ }}
+ />
+ );
+ }
+ }
+
+ if (hasExceededStorageQuota(userDetails) && messages.length === 0) {
+ messages.push(
+ <Trans
+ i18nKey={'STORAGE_QUOTA_EXCEEDED_SUBSCRIPTION_INFO'}
+ components={{
+ a: <LinkButton onClick={handleClick} />,
+ }}
+ />
+ );
+ }
+
return (
<Box px={1} pt={0.5}>
<Typography
@@ -76,45 +118,7 @@ export default function SubscriptionStatus({
color={'text.muted'}
onClick={handleClick && handleClick}
sx={{ cursor: handleClick && 'pointer' }}>
- {isSubscriptionActive(userDetails.subscription) ? (
- isOnFreePlan(userDetails.subscription) ? (
- hasAddOnBonus(userDetails.bonusData) ? (
- ''
- ) : (
- <Trans
- i18nKey={'FREE_SUBSCRIPTION_INFO'}
- values={{
- date: userDetails.subscription?.expiryTime,
- }}
- />
- )
- ) : isSubscriptionCancelled(userDetails.subscription) &&
- !hasAddOnBonus(userDetails.bonusData) ? (
- t('RENEWAL_CANCELLED_SUBSCRIPTION_INFO', {
- date: userDetails.subscription?.expiryTime,
- })
- ) : (
- hasExceededStorageQuota(userDetails) && (
- <Trans
- i18nKey={
- 'STORAGE_QUOTA_EXCEEDED_SUBSCRIPTION_INFO'
- }
- components={{
- a: <LinkButton onClick={handleClick} />,
- }}
- />
- )
- )
- ) : (
- !hasAddOnBonus(userDetails.bonusData) && (
- <Trans
- i18nKey={'SUBSCRIPTION_EXPIRED_MESSAGE'}
- components={{
- a: <LinkButton onClick={handleClick} />,
- }}
- />
- )
- )}
+ {messages}
</Typography>
</Box>
);