From 7c79c7d007b64114b406d6fd58808080276ae95d Mon Sep 17 00:00:00 2001 From: isra el Date: Sun, 16 Mar 2025 17:57:08 +0300 Subject: [PATCH] chore(web): improve my-account page ui --- .../(components)/account-settings.tsx | 48 +++++++++++++++---- 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/web/app/(app)/dashboard/(components)/account-settings.tsx b/web/app/(app)/dashboard/(components)/account-settings.tsx index faa968b..16590a6 100644 --- a/web/app/(app)/dashboard/(components)/account-settings.tsx +++ b/web/app/(app)/dashboard/(components)/account-settings.tsx @@ -229,16 +229,44 @@ export default function AccountSettings() {

) + // Format price with currency symbol + const formatPrice = (amount: number | null | undefined, currency: string | null | undefined) => { + if (amount == null || currency == null) return 'Free'; + + const formatter = new Intl.NumberFormat('en-US', { + style: 'currency', + currency: currency.toUpperCase() || 'USD', + minimumFractionDigits: 2, + }); + + return formatter.format(amount / 100); + }; + + const getBillingInterval = (interval: string | null | undefined) => { + if (!interval) return ''; + return interval.toLowerCase() === 'month' ? 'monthly' : 'yearly'; + }; + return (

- {currentSubscription?.plan?.name} + {currentSubscription?.plan?.name || 'Free Plan'}

-

- Current subscription -

+
+

+ Current subscription +

+ {currentSubscription?.amount > 0 && ( + + {formatPrice(currentSubscription?.amount, currentSubscription?.currency)} + {currentSubscription?.recurringInterval && ( + / {getBillingInterval(currentSubscription?.recurringInterval)} + )} + + )} +
@@ -264,7 +292,7 @@ export default function AccountSettings() { day: 'numeric', year: 'numeric', }) - : '-:-'} + : 'N/A'}

@@ -284,7 +312,7 @@ export default function AccountSettings() { day: 'numeric', year: 'numeric', }) - : '-:-'} + : 'N/A'}

@@ -301,7 +329,7 @@ export default function AccountSettings() {

{currentSubscription?.plan?.dailyLimit === -1 ? 'Unlimited' - : currentSubscription?.plan?.dailyLimit} + : currentSubscription?.plan?.dailyLimit || '0'} {currentSubscription?.plan?.dailyLimit === -1 && ( @@ -325,7 +353,7 @@ export default function AccountSettings() {

{currentSubscription?.plan?.monthlyLimit === -1 ? 'Unlimited' - : currentSubscription?.plan?.monthlyLimit?.toLocaleString()} + : currentSubscription?.plan?.monthlyLimit?.toLocaleString() || '0'} {currentSubscription?.plan?.monthlyLimit === -1 && ( @@ -347,7 +375,7 @@ export default function AccountSettings() {

{currentSubscription?.plan?.bulkSendLimit === -1 ? 'Unlimited' - : currentSubscription?.plan?.bulkSendLimit} + : currentSubscription?.plan?.bulkSendLimit || '0'} {currentSubscription?.plan?.bulkSendLimit === -1 && ( @@ -369,7 +397,7 @@ export default function AccountSettings() {

- {currentSubscription?.plan?.name?.toLowerCase() === 'free' ? ( + {(!currentSubscription?.plan?.name || currentSubscription?.plan?.name?.toLowerCase() === 'free') ? (