|
1 | 1 | <script lang="ts"> |
2 | | - import type { V1Subscription } from "@rilldata/web-admin/client"; |
3 | | - import { |
4 | | - getBillingCycleDates, |
5 | | - getBillingStatsForOrg, |
6 | | - getPlanCredits, |
7 | | - } from "@rilldata/web-admin/features/billing/plans/selectors"; |
8 | 2 | import PlanContainer from "@rilldata/web-admin/features/billing/plans/PlanContainer.svelte"; |
9 | | - import { formatCredit } from "@rilldata/web-admin/features/billing/plans/utils.ts"; |
10 | | - import CostAndUsage from "@rilldata/web-admin/features/billing/plans/modules/CostAndUsage.svelte"; |
11 | 3 |
|
12 | 4 | let { |
13 | | - organization, |
14 | | - subscription, |
15 | 5 | billingPortalUrl, |
16 | 6 | }: { |
17 | | - organization: string; |
18 | | - subscription: V1Subscription; |
19 | 7 | billingPortalUrl: string | undefined; |
20 | 8 | } = $props(); |
21 | | -
|
22 | | - let billingStats = $derived(getBillingStatsForOrg(organization)); |
23 | | - let dailyRunRate = $derived( |
24 | | - $billingStats.prodDailyCost + $billingStats.devDailyCost, |
25 | | - ); |
26 | | -
|
27 | | - // Pro plan credit + post-credit estimate. Available credit is hard-zero |
28 | | - // until the billing usage API exposes the remaining trial credit balance. |
29 | | - let planCredits = $derived(getPlanCredits(organization, undefined)); |
30 | | - let { availableCredit } = $derived($planCredits); |
31 | | - let proEstimatedCost = $derived(Math.max(dailyRunRate - availableCredit, 0)); |
32 | | -
|
33 | | - // Billing cycle |
34 | | - let { formattedPeriodStart, formattedPeriodEnd, formattedDueDate } = $derived( |
35 | | - getBillingCycleDates(subscription), |
36 | | - ); |
37 | 9 | </script> |
38 | 10 |
|
39 | 11 | <PlanContainer badge="Pro" description="Usage based pricing"> |
|
63 | 35 | $0.15/unit/hr · $1/GB storage/mo. Cancel anytime. |
64 | 36 | {/snippet} |
65 | 37 |
|
66 | | - <div class="pro-stats"> |
67 | | - <div class="pro-stat-col"> |
68 | | - <span class="pro-stat-label">Current period estimate</span> |
69 | | - <span class="pro-stat-amount text-fg-secondary" |
70 | | - >{formatCredit(dailyRunRate)}</span |
71 | | - > |
72 | | - <span class="pro-stat-sub"> |
73 | | - {formattedPeriodStart} – {formattedPeriodEnd} |
74 | | - </span> |
75 | | - </div> |
76 | | - <div class="pro-stat-col border-l pl-6"> |
77 | | - <span class="pro-stat-label">Available credit</span> |
78 | | - <span class="pro-stat-amount text-green-700" |
79 | | - >{formatCredit(availableCredit)}</span |
80 | | - > |
81 | | - <span class="credit-pill"> |
82 | | - <svg viewBox="0 0 12 12" fill="none" class="w-3 h-3 shrink-0"> |
83 | | - <path |
84 | | - d="M10 3L4.5 8.5 2 6" |
85 | | - stroke="currentColor" |
86 | | - stroke-width="1.5" |
87 | | - stroke-linecap="round" |
88 | | - stroke-linejoin="round" |
89 | | - /> |
90 | | - </svg> |
91 | | - Trial credit applied to your bill |
92 | | - </span> |
93 | | - </div> |
94 | | - <div class="pro-stat-col border-l pl-6"> |
95 | | - <span class="pro-stat-label">Estimated cost after applied credit</span> |
96 | | - <span class="pro-stat-amount text-fg-primary" |
97 | | - >{formatCredit(proEstimatedCost)}</span |
98 | | - > |
99 | | - {#if formattedDueDate} |
100 | | - <span class="pro-stat-sub">Due {formattedDueDate}</span> |
101 | | - {/if} |
102 | | - </div> |
| 38 | + <div class="text-sm text-fg-tertiary mt-4 pb-4"> |
| 39 | + You'll be billed monthly based on usage at $0.15/compute unit/hr and $1/GB |
| 40 | + storage/mo. |
103 | 41 | </div> |
104 | | - |
105 | | - {#snippet footer()} |
106 | | - <CostAndUsage {organization} /> |
107 | | - {/snippet} |
108 | 42 | </PlanContainer> |
109 | 43 |
|
110 | 44 | <style lang="postcss"> |
111 | | - .pro-stats { |
112 | | - @apply flex gap-6 mt-4 pt-4 border-t; |
113 | | - min-height: 92px; |
114 | | - } |
115 | | -
|
116 | | - .pro-stat-col { |
117 | | - @apply flex flex-col gap-2 flex-1 justify-center; |
118 | | - } |
119 | | -
|
120 | | - .pro-stat-label { |
121 | | - @apply text-xs font-semibold text-fg-tertiary; |
122 | | - line-height: 1; |
123 | | - } |
124 | | -
|
125 | | - .pro-stat-amount { |
126 | | - @apply text-4xl font-semibold leading-none; |
127 | | - } |
128 | | -
|
129 | | - .pro-stat-sub { |
130 | | - @apply text-sm font-medium text-fg-tertiary; |
131 | | - line-height: 1; |
132 | | - } |
133 | | -
|
134 | | - .credit-pill { |
135 | | - @apply inline-flex items-center gap-1 text-sm font-medium text-green-700 bg-green-50 rounded-full px-2.5 py-1; |
136 | | - } |
137 | | -
|
138 | 45 | .pricing-link-top { |
139 | 46 | @apply inline-flex items-center gap-1; |
140 | 47 | @apply text-sm font-medium text-primary-600 no-underline; |
|
0 commit comments