Skip to content

Commit 704de20

Browse files
christian-byrneChristian Byrne
andauthored
fix: remove unsafe type assertions in subscription credits (#6536)
## Summary Removes unsafe `as any` type assertions from subscription credits composable now that the OpenAPI spec has been updated with the missing balance breakdown fields. The `GetCustomerBalance` API response now includes: - `cloud_credit_balance_micros` - Monthly subscription credits - `prepaid_balance_micros` - Pre-paid top-up credits These fields were previously accessed with `as any` because they weren't in the TypeScript type definitions. With the OpenAPI spec update (PR #6531), these fields are now properly typed. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-6536-fix-remove-unsafe-type-assertions-in-subscription-credits-29f6d73d365081ffae52cc85c01c139b) by [Unito](https://www.unito.io) Co-authored-by: Christian Byrne <[email protected]>
1 parent feda2d4 commit 704de20

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/platform/cloud/subscription/composables/useSubscriptionCredits.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ export function useSubscriptionCredits() {
2323
})
2424

2525
const monthlyBonusCredits = computed(() => {
26-
const balance = authStore.balance as any
27-
if (!balance?.cloud_credit_balance_micros) return '0.00'
26+
if (!authStore.balance?.cloud_credit_balance_micros) return '0.00'
2827
try {
29-
return formatMetronomeCurrency(balance.cloud_credit_balance_micros, 'usd')
28+
return formatMetronomeCurrency(
29+
authStore.balance.cloud_credit_balance_micros,
30+
'usd'
31+
)
3032
} catch (error) {
3133
console.error(
3234
'[useSubscriptionCredits] Error formatting monthly bonus credits:',
@@ -37,10 +39,12 @@ export function useSubscriptionCredits() {
3739
})
3840

3941
const prepaidCredits = computed(() => {
40-
const balance = authStore.balance as any
41-
if (!balance?.prepaid_balance_micros) return '0.00'
42+
if (!authStore.balance?.prepaid_balance_micros) return '0.00'
4243
try {
43-
return formatMetronomeCurrency(balance.prepaid_balance_micros, 'usd')
44+
return formatMetronomeCurrency(
45+
authStore.balance.prepaid_balance_micros,
46+
'usd'
47+
)
4448
} catch (error) {
4549
console.error(
4650
'[useSubscriptionCredits] Error formatting prepaid credits:',

0 commit comments

Comments
 (0)