@@ -12,6 +12,7 @@ import { Elements, PaymentElement, useElements, useStripe } from "@stripe/react-
12
12
import { AttributionId } from "@gitpod/gitpod-protocol/lib/attribution" ;
13
13
import { Ordering } from "@gitpod/gitpod-protocol/lib/usage" ;
14
14
import { ReactComponent as Spinner } from "../icons/Spinner.svg" ;
15
+ import { ReactComponent as Check } from "../images/check-circle.svg" ;
15
16
import { ThemeContext } from "../theme-context" ;
16
17
import { PaymentContext } from "../payment-context" ;
17
18
import { getGitpodService } from "../service/service" ;
@@ -27,6 +28,7 @@ interface Props {
27
28
28
29
export default function UsageBasedBillingConfig ( { attributionId } : Props ) {
29
30
const location = useLocation ( ) ;
31
+ const { currency } = useContext ( PaymentContext ) ;
30
32
const [ showUpdateLimitModal , setShowUpdateLimitModal ] = useState < boolean > ( false ) ;
31
33
const [ showBillingSetupModal , setShowBillingSetupModal ] = useState < boolean > ( false ) ;
32
34
const [ stripeSubscriptionId , setStripeSubscriptionId ] = useState < string | undefined > ( ) ;
@@ -168,7 +170,10 @@ export default function UsageBasedBillingConfig({ attributionId }: Props) {
168
170
169
171
const showSpinner = ! attributionId || isLoadingStripeSubscription || ! ! pendingStripeSubscription ;
170
172
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 ;
172
177
const showManageBilling = ! showSpinner && ! ! stripeSubscriptionId ;
173
178
174
179
const updateUsageLimit = async ( newLimit : number ) => {
@@ -244,15 +249,70 @@ export default function UsageBasedBillingConfig({ attributionId }: Props) {
244
249
</ div >
245
250
</ div >
246
251
) }
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 >
251
269
< button className = "self-end" onClick = { ( ) => setShowBillingSetupModal ( true ) } >
252
270
Upgrade Plan
253
271
</ button >
254
272
</ div >
255
273
) }
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
+ ) }
256
316
{ showManageBilling && (
257
317
< div className = "max-w-xl flex space-x-4" >
258
318
< 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