Skip to content

Commit

Permalink
fix: better subscription state text
Browse files Browse the repository at this point in the history
  • Loading branch information
moughxyz committed Dec 1, 2021
1 parent a8f949e commit fbafc13
Showing 1 changed file with 47 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,61 @@ const StatusText = observer(({ subscriptionState }: Props) => {
const { userSubscription, userSubscriptionName } = subscriptionState;
const expirationDate = new Date(
convertTimestampToMilliseconds(userSubscription!.endsAt)
).toLocaleString();
);
const expirationDateString = expirationDate.toLocaleString();
const expired = expirationDate.getTime() < new Date().getTime();
const canceled = userSubscription!.cancelled;

return userSubscription!.cancelled ? (
<Text className="mt-1">
Your{' '}
<span className="font-bold">
Standard Notes{userSubscriptionName ? ' ' : ''}
{userSubscriptionName}
</span>{' '}
subscription has been{' '}
<span className="font-bold">
canceled but will remain valid until {expirationDate}
</span>
. You may resubscribe below if you wish.
</Text>
) : (
if (canceled) {
return (
<Text className="mt-1">
Your{' '}
<span className="font-bold">
Standard Notes{userSubscriptionName ? ' ' : ''}
{userSubscriptionName}
</span>{' '}
subscription has been canceled
{' '}
{expired ? (
<span className="font-bold">
and expired on {expirationDateString}
</span>
) : (
<span className="font-bold">
but will remain valid until {expirationDateString}
</span>
)}
. You may resubscribe below if you wish.
</Text>
);
}

if (expired) {
return (
<Text className="mt-1">
Your{' '}
<span className="font-bold">
Standard Notes{userSubscriptionName ? ' ' : ''}
{userSubscriptionName}
</span>{' '}
subscription {' '}
<span className="font-bold">
expired on {expirationDateString}
</span>
. You may resubscribe below if you wish.
</Text>
);
}

return (
<Text className="mt-1">
Your{' '}
<span className="font-bold">
Standard Notes{userSubscriptionName ? ' ' : ''}
{userSubscriptionName}
</span>{' '}
subscription will be{' '}
<span className="font-bold">renewed on {expirationDate}</span>.
<span className="font-bold">renewed on {expirationDateString}</span>.
</Text>
);
});
Expand Down

0 comments on commit fbafc13

Please sign in to comment.