From 3f4a5bf4bd62fa46013e7a29d715f325ecfeb23c Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Mon, 10 Mar 2025 12:17:57 +0000 Subject: [PATCH] Improve logic for upgrade and limits button --- .../Billing/UpgradeAccountModal.tsx | 74 +++++++++---------- src/components/Billing/VerifyUpgrade.tsx | 38 +++++----- .../GenerateCourse/AICourseLimit.tsx | 38 ++++++---- .../GenerateCourse/AILimitsPopup.tsx | 33 ++++++--- 4 files changed, 101 insertions(+), 82 deletions(-) diff --git a/src/components/Billing/UpgradeAccountModal.tsx b/src/components/Billing/UpgradeAccountModal.tsx index 47852f720..8039179f6 100644 --- a/src/components/Billing/UpgradeAccountModal.tsx +++ b/src/components/Billing/UpgradeAccountModal.tsx @@ -130,8 +130,8 @@ export function UpgradeAccountModal(props: UpgradeAccountModalProps) { return (
e.stopPropagation()}> @@ -140,16 +140,16 @@ export function UpgradeAccountModal(props: UpgradeAccountModalProps) { {loader} {!isLoading && !error && (
-
-

+
+

Unlock Premium Features

-

+

Supercharge your learning experience with premium benefits

-
+
{USER_SUBSCRIPTION_PLAN_PRICES.map((plan) => { const isCurrentPlanSelected = currentPlan?.priceId === plan.priceId; @@ -159,41 +159,41 @@ export function UpgradeAccountModal(props: UpgradeAccountModalProps) {
-

+

{isYearly ? 'Yearly Payment' : 'Monthly Payment'}

{isYearly && ( - + (2 months free) )}
{isYearly && ( - + Most Popular )}
{isYearly && ( -

+

$ {calculateYearlyPrice( USER_SUBSCRIPTION_PLAN_PRICES[0].amount, )}

)} -

+

${plan.amount}{' '} - + / {isYearly ? 'year' : 'month'}

@@ -204,7 +204,7 @@ export function UpgradeAccountModal(props: UpgradeAccountModalProps) {
{/* Benefits Section */} -
-
- +
+
+
-

+

Unlimited AI Course Generations

-

+

Generate as many custom courses as you need

-
- +
+
-

+

No Daily Limits on course features

-

+

Use all features without restrictions

-
- +
+
-

+

Unlimited Course Follow-ups

-

+

Ask as many questions as you need

-
- +
+
-

+

Early Access to Features

-

+

Be the first to try new tools and features

-
- +
+
-

+

Support Development

-

+

Help us continue building roadmap.sh

diff --git a/src/components/Billing/VerifyUpgrade.tsx b/src/components/Billing/VerifyUpgrade.tsx index a96673b0b..f59105fd0 100644 --- a/src/components/Billing/VerifyUpgrade.tsx +++ b/src/components/Billing/VerifyUpgrade.tsx @@ -13,7 +13,7 @@ type VerifyUpgradeProps = { export function VerifyUpgrade(props: VerifyUpgradeProps) { const { newPriceId } = props; - const { data: userBillingDetails, isFetching } = useQuery( + const { data: userBillingDetails } = useQuery( { ...billingDetailsOptions(), refetchInterval: 1000, @@ -42,32 +42,34 @@ export function VerifyUpgrade(props: VerifyUpgradeProps) { onClose={() => {}} bodyClassName="rounded-xl bg-white p-6" > -
- +
+

Subscription Activated

- -

+ +

Your subscription has been activated successfully.

-

- It might take a few minutes for the changes to reflect. We will{' '} +

+ It might take a minute for the changes to reflect. We will{' '} reload the page for you.

- {isFetching && ( -
- - Refreshing -
- )} +
+ + Please wait... +
-

- If it takes longer than expected, please{' '} - - contact us - . +

+ If it takes longer than expected, please email us at{' '} + + info@roadmap.sh + + .

); diff --git a/src/components/GenerateCourse/AICourseLimit.tsx b/src/components/GenerateCourse/AICourseLimit.tsx index 9c04c9535..e38fe91aa 100644 --- a/src/components/GenerateCourse/AICourseLimit.tsx +++ b/src/components/GenerateCourse/AICourseLimit.tsx @@ -30,6 +30,10 @@ export function AICourseLimit() { const totalPercentage = getPercentage(used, limit); + // has consumed 80% of the limit + const isNearLimit = used >= limit * 0.8; + const isPaidUser = userBillingDetails.status !== 'none'; + return ( <> + className="relative hidden h-full min-h-[38px] cursor-pointer items-center overflow-hidden rounded-lg border border-gray-300 px-3 py-1.5 text-sm hover:bg-gray-50 lg:flex" + > + + {totalPercentage}% of the daily limit used + +
+ + )} - {userBillingDetails.status === 'none' && ( + {!isPaidUser && ( <>
-

Daily Token Limit

+

Daily Limit

{formatCommaNumber(limit)}

@@ -60,25 +68,28 @@ export function AILimitsPopup(props: AILimitsPopupProps) {

- Limit resets every 24 hours. Consider upgrading for more tokens. + Limit resets every 24 hours.{' '} + {!isPaidUser && 'Consider upgrading for more tokens.'}

{/* Action Button */}
- + {!isPaidUser && ( + + )}