Skip to content

Commit bf4cc13

Browse files
committed
[dashboard] Differentiate usage-based upgrade UI for teams vs users
1 parent c07251f commit bf4cc13

File tree

2 files changed

+66
-8
lines changed

2 files changed

+66
-8
lines changed

components/dashboard/src/components/UsageBasedBillingConfig.tsx

Lines changed: 65 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { Elements, PaymentElement, useElements, useStripe } from "@stripe/react-
1212
import { AttributionId } from "@gitpod/gitpod-protocol/lib/attribution";
1313
import { Ordering } from "@gitpod/gitpod-protocol/lib/usage";
1414
import { ReactComponent as Spinner } from "../icons/Spinner.svg";
15+
import { ReactComponent as Check } from "../images/check-circle.svg";
1516
import { ThemeContext } from "../theme-context";
1617
import { PaymentContext } from "../payment-context";
1718
import { getGitpodService } from "../service/service";
@@ -27,6 +28,7 @@ interface Props {
2728

2829
export default function UsageBasedBillingConfig({ attributionId }: Props) {
2930
const location = useLocation();
31+
const { currency } = useContext(PaymentContext);
3032
const [showUpdateLimitModal, setShowUpdateLimitModal] = useState<boolean>(false);
3133
const [showBillingSetupModal, setShowBillingSetupModal] = useState<boolean>(false);
3234
const [stripeSubscriptionId, setStripeSubscriptionId] = useState<string | undefined>();
@@ -168,7 +170,10 @@ export default function UsageBasedBillingConfig({ attributionId }: Props) {
168170

169171
const showSpinner = !attributionId || isLoadingStripeSubscription || !!pendingStripeSubscription;
170172
const showBalance = !showSpinner && !(AttributionId.parse(attributionId)?.kind === "team" && !stripeSubscriptionId);
171-
const showUpgradeBilling = !showSpinner && !stripeSubscriptionId;
173+
const showUpgradeTeam =
174+
!showSpinner && AttributionId.parse(attributionId)?.kind === "team" && !stripeSubscriptionId;
175+
const showUpgradeUser =
176+
!showSpinner && AttributionId.parse(attributionId)?.kind === "user" && !stripeSubscriptionId;
172177
const showManageBilling = !showSpinner && !!stripeSubscriptionId;
173178

174179
const updateUsageLimit = async (newLimit: number) => {
@@ -244,15 +249,70 @@ export default function UsageBasedBillingConfig({ attributionId }: Props) {
244249
</div>
245250
</div>
246251
)}
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>
252+
{showUpgradeTeam && (
253+
<div className="flex flex-col mt-4 h-32 p-4 rounded-xl bg-gray-50 dark:bg-gray-900">
254+
<div className="uppercase text-sm text-gray-400 dark:text-gray-500">Upgrade Plan</div>
255+
<div className="text-xl font-semibold flex-grow text-gray-600 dark:text-gray-400">
256+
Pay-as-you-go
257+
</div>
258+
<div className="mt-4 flex space-x-1 text-gray-400 dark:text-gray-500">
259+
<Check className="m-0.5 w-5 h-5" />
260+
<div className="flex flex-col">
261+
<span>
262+
36¢ for 10 credits or 1 hour of Standard workspace usage.{" "}
263+
<a href="https://www.gitpod.io/docs/configure/billing/usage-based-billing">
264+
Learn more about credits
265+
</a>
266+
</span>
267+
</div>
268+
</div>
251269
<button className="self-end" onClick={() => setShowBillingSetupModal(true)}>
252270
Upgrade Plan
253271
</button>
254272
</div>
255273
)}
274+
{showUpgradeUser && (
275+
<div className="flex flex-col mt-4 h-32 p-4 rounded-xl bg-gray-50 dark:bg-gray-900">
276+
<div className="uppercase text-sm text-gray-400 dark:text-gray-500">Current Plan</div>
277+
<div className="text-xl font-semibold flex-grow text-gray-600 dark:text-gray-400">Free</div>
278+
<div className="mt-4 flex space-x-1 text-gray-400 dark:text-gray-500">
279+
<Check className="m-0.5 w-5 h-5 text-orange-500" />
280+
<div className="flex flex-col">
281+
<span className="font-bold">500 credits</span>
282+
<span>
283+
50 hours of Standard workspace usage.{" "}
284+
<a href="https://www.gitpod.io/docs/configure/billing/usage-based-billing">
285+
Learn more about credits
286+
</a>
287+
</span>
288+
</div>
289+
</div>
290+
<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">
291+
<div className="uppercase text-sm text-gray-400 dark:text-gray-500">Upgrade Plan</div>
292+
<div className="text-xl font-semibold flex-grow text-gray-500 dark:text-gray-400">
293+
{currency === "EUR" ? "€" : "$"}9 / month
294+
</div>
295+
<div className="mt-4 flex space-x-1 text-gray-400 dark:text-gray-500">
296+
<Check className="m-0.5 w-5 h-5" />
297+
<div className="flex flex-col">
298+
<span className="font-bold">1,000 credits</span>
299+
</div>
300+
</div>
301+
<div className="mt-2 flex space-x-1 text-gray-400 dark:text-gray-500">
302+
<Check className="m-0.5 w-5 h-5" />
303+
<div className="flex flex-col">
304+
<span className="font-bold">Pay-as-you-go after 1,000 credits</span>
305+
<span>36¢ for 10 credits or 1 hour of Standard workspace usage.</span>
306+
</div>
307+
</div>
308+
<div className="mt-5 flex flex-col">
309+
<button className="self-end" onClick={() => setShowBillingSetupModal(true)}>
310+
Upgrade Plan
311+
</button>
312+
</div>
313+
</div>
314+
</div>
315+
)}
256316
{showManageBilling && (
257317
<div className="max-w-xl flex space-x-4">
258318
<div className="flex-grow flex flex-col mt-4 h-32 p-4 rounded-xl bg-gray-50 dark:bg-gray-900">
Lines changed: 1 addition & 3 deletions
Loading

0 commit comments

Comments
 (0)