@@ -101,18 +101,10 @@ function BillingInfo({
101101 ( subscription ) => subscription . type === "USAGE" ,
102102 ) ;
103103
104- // only plan and usage subscriptions are considered for now
105- const totalUsd = getAllSubscriptionsTotal (
106- subscriptions . filter ( ( sub ) => sub . type === "PLAN" || sub . type === "USAGE" ) ,
107- ) ;
108-
109104 return (
110105 < div >
111106 { planSubscription && (
112- < SubscriptionOverview
113- subscription = { planSubscription }
114- title = "Plan Cost"
115- />
107+ < SubscriptionOverview subscription = { planSubscription } />
116108 ) }
117109
118110 { usageSubscription && (
@@ -124,28 +116,23 @@ function BillingInfo({
124116 />
125117 </ >
126118 ) }
127-
128- < Separator className = "my-4" />
129-
130- < div className = "flex items-center justify-between gap-6" >
131- < h5 className = "font-medium text-lg" > Total Upcoming Bill</ h5 >
132- < p className = "text-foreground" > { totalUsd } </ p >
133- </ div >
134119 </ div >
135120 ) ;
136121}
137122
138123function SubscriptionOverview ( props : {
139124 subscription : TeamSubscription ;
140- title : string ;
125+ title ? : string ;
141126} ) {
142127 const { subscription } = props ;
143128
144129 return (
145130 < div >
146131 < div className = "flex items-center justify-between gap-6" >
147132 < div >
148- < h5 className = "font-medium text-lg" > { props . title } </ h5 >
133+ { props . title && (
134+ < h5 className = "font-medium text-lg" > { props . title } </ h5 >
135+ ) }
149136 < p className = "text-muted-foreground text-sm lg:text-base" >
150137 { format (
151138 new Date ( props . subscription . currentPeriodStart ) ,
@@ -159,7 +146,7 @@ function SubscriptionOverview(props: {
159146 </ p >
160147 </ div >
161148
162- < p className = "text-muted- foreground" >
149+ < p className = "text-foreground" >
163150 { formatCurrencyAmount (
164151 subscription . upcomingInvoice . amount || 0 ,
165152 subscription . upcomingInvoice . currency ,
@@ -170,21 +157,6 @@ function SubscriptionOverview(props: {
170157 ) ;
171158}
172159
173- function getAllSubscriptionsTotal ( subscriptions : TeamSubscription [ ] ) {
174- let totalCents = 0 ;
175- let currency = "USD" ;
176-
177- for ( const subscription of subscriptions ) {
178- const amount = subscription . upcomingInvoice . amount ;
179- currency = subscription . upcomingInvoice . currency ;
180- if ( amount ) {
181- totalCents += amount ;
182- }
183- }
184-
185- return formatCurrencyAmount ( totalCents , currency ) ;
186- }
187-
188160function formatCurrencyAmount ( centsAmount : number , currency : string ) {
189161 return new Intl . NumberFormat ( undefined , {
190162 style : "currency" ,
0 commit comments