mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-26 19:09:52 +00:00
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 <c.byrne@comfy.org>
This commit is contained in:
@@ -23,10 +23,12 @@ export function useSubscriptionCredits() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const monthlyBonusCredits = computed(() => {
|
const monthlyBonusCredits = computed(() => {
|
||||||
const balance = authStore.balance as any
|
if (!authStore.balance?.cloud_credit_balance_micros) return '0.00'
|
||||||
if (!balance?.cloud_credit_balance_micros) return '0.00'
|
|
||||||
try {
|
try {
|
||||||
return formatMetronomeCurrency(balance.cloud_credit_balance_micros, 'usd')
|
return formatMetronomeCurrency(
|
||||||
|
authStore.balance.cloud_credit_balance_micros,
|
||||||
|
'usd'
|
||||||
|
)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(
|
console.error(
|
||||||
'[useSubscriptionCredits] Error formatting monthly bonus credits:',
|
'[useSubscriptionCredits] Error formatting monthly bonus credits:',
|
||||||
@@ -37,10 +39,12 @@ export function useSubscriptionCredits() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const prepaidCredits = computed(() => {
|
const prepaidCredits = computed(() => {
|
||||||
const balance = authStore.balance as any
|
if (!authStore.balance?.prepaid_balance_micros) return '0.00'
|
||||||
if (!balance?.prepaid_balance_micros) return '0.00'
|
|
||||||
try {
|
try {
|
||||||
return formatMetronomeCurrency(balance.prepaid_balance_micros, 'usd')
|
return formatMetronomeCurrency(
|
||||||
|
authStore.balance.prepaid_balance_micros,
|
||||||
|
'usd'
|
||||||
|
)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(
|
console.error(
|
||||||
'[useSubscriptionCredits] Error formatting prepaid credits:',
|
'[useSubscriptionCredits] Error formatting prepaid credits:',
|
||||||
|
|||||||
Reference in New Issue
Block a user