Skip to content

Commit 438c78e

Browse files
committed
[dashboard] Differentiate usage-based upgrade UI for teams vs users
1 parent 3da9476 commit 438c78e

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

components/dashboard/src/components/UsageBasedBillingConfig.tsx

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ interface Props {
2727

2828
export default function UsageBasedBillingConfig({ attributionId }: Props) {
2929
const location = useLocation();
30+
const { currency } = useContext(PaymentContext);
3031
const [showUpdateLimitModal, setShowUpdateLimitModal] = useState<boolean>(false);
3132
const [showBillingSetupModal, setShowBillingSetupModal] = useState<boolean>(false);
3233
const [stripeSubscriptionId, setStripeSubscriptionId] = useState<string | undefined>();
@@ -168,7 +169,10 @@ export default function UsageBasedBillingConfig({ attributionId }: Props) {
168169

169170
const showSpinner = !attributionId || isLoadingStripeSubscription || !!pendingStripeSubscription;
170171
const showBalance = !showSpinner && !(AttributionId.parse(attributionId)?.kind === "team" && !stripeSubscriptionId);
171-
const showUpgradeBilling = !showSpinner && !stripeSubscriptionId;
172+
const showUpgradeTeam =
173+
!showSpinner && AttributionId.parse(attributionId)?.kind === "team" && !stripeSubscriptionId;
174+
const showUpgradeUser =
175+
!showSpinner && AttributionId.parse(attributionId)?.kind === "user" && !stripeSubscriptionId;
172176
const showManageBilling = !showSpinner && !!stripeSubscriptionId;
173177

174178
const updateUsageLimit = async (newLimit: number) => {
@@ -244,15 +248,34 @@ export default function UsageBasedBillingConfig({ attributionId }: Props) {
244248
</div>
245249
</div>
246250
)}
247-
{showUpgradeBilling && (
248-
<div className="flex flex-col mt-4 h-32 p-4 rounded-xl bg-gray-100 dark:bg-gray-800">
249-
<div className="uppercase text-sm text-gray-400 dark:text-gray-500">Billing</div>
250-
<div className="text-xl font-semibold flex-grow text-gray-600 dark:text-gray-400">Inactive</div>
251+
{showUpgradeTeam && (
252+
<div className="flex flex-col mt-4 h-32 p-4 rounded-xl bg-gray-50 dark:bg-gray-900">
253+
<div className="uppercase text-sm text-gray-400 dark:text-gray-500">Upgrade Plan</div>
254+
<div className="text-xl font-semibold flex-grow text-gray-600 dark:text-gray-400">
255+
Pay-as-you-go
256+
</div>
251257
<button className="self-end" onClick={() => setShowBillingSetupModal(true)}>
252258
Upgrade Plan
253259
</button>
254260
</div>
255261
)}
262+
{showUpgradeUser && (
263+
<div className="flex flex-col mt-4 h-32 p-4 rounded-xl bg-gray-50 dark:bg-gray-900">
264+
<div className="uppercase text-sm text-gray-400 dark:text-gray-500">Current Plan</div>
265+
<div className="text-xl font-semibold flex-grow text-gray-600 dark:text-gray-400">Free</div>
266+
<div className="bg-gray-100 dark:bg-gray-800 border-t border-gray-200 dark:border-gray-800 -m-4 p-4 mt-4 rounded-b-xl">
267+
<div className="uppercase text-sm text-gray-400 dark:text-gray-500">Upgrade Plan</div>
268+
<div className="text-xl font-semibold flex-grow text-gray-600 dark:text-gray-400">
269+
{currency === "EUR" ? "€" : "$"}9 / month
270+
</div>
271+
<div className="flex flex-col">
272+
<button className="self-end" onClick={() => setShowBillingSetupModal(true)}>
273+
Upgrade Plan
274+
</button>
275+
</div>
276+
</div>
277+
</div>
278+
)}
256279
{showManageBilling && (
257280
<div className="max-w-xl flex space-x-4">
258281
<div className="flex-grow flex flex-col mt-4 h-32 p-4 rounded-xl bg-gray-50 dark:bg-gray-900">

0 commit comments

Comments
 (0)