Skip to content

Commit

Permalink
fix: typing issues for payment amount (#517)
Browse files Browse the repository at this point in the history
  • Loading branch information
UncleSamtoshi authored Jun 28, 2022
1 parent 92ac4de commit 58c8a2f
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions app/hooks/user-hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,11 @@ export const useMySubscription = (): UseMyUpdates => {
)

const convertPaymentAmount = React.useCallback(
(paymentAmount, toCurrency) => {
(paymentAmount, toCurrency: WalletCurrency) => {
if (cachedPrice === 0) {
return NaN
}

if (paymentAmount.currency === toCurrency) {
return {
amount: Math.round(paymentAmount.amount),
currency: paymentAmount.currency,
amount: NaN,
currency: toCurrency,
}
}

Expand All @@ -168,6 +164,7 @@ export const useMySubscription = (): UseMyUpdates => {
currency: WalletCurrency.USD,
}
}

if (
paymentAmount.currency === WalletCurrency.USD &&
toCurrency === WalletCurrency.BTC
Expand All @@ -177,6 +174,11 @@ export const useMySubscription = (): UseMyUpdates => {
currency: WalletCurrency.BTC,
}
}

return {
amount: Math.round(paymentAmount.amount),
currency: paymentAmount.currency,
}
},
[cachedPrice],
)
Expand All @@ -185,7 +187,7 @@ export const useMySubscription = (): UseMyUpdates => {

const convertPaymentAmountToPrimaryCurrency = (
paymentAmount: PaymentAmount<WalletCurrency>,
) => convertPaymentAmount(paymentAmount, primaryCurrency)
) => convertPaymentAmount(paymentAmount, primaryCurrency as WalletCurrency)

if (data?.myUpdates?.update) {
if (data.myUpdates.update.type === "Price") {
Expand Down

0 comments on commit 58c8a2f

Please sign in to comment.