-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30262 from software-mansion-labs/ts/CurrentWallet…
…Balance [TS migration] Migrate 'CurrentWalletBalance.js' component to TypeScript
- Loading branch information
Showing
2 changed files
with
30 additions
and
48 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react'; | ||
import {StyleProp, TextStyle} from 'react-native'; | ||
import {OnyxEntry, withOnyx} from 'react-native-onyx'; | ||
import * as CurrencyUtils from '@libs/CurrencyUtils'; | ||
import styles from '@styles/styles'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
import UserWallet from '@src/types/onyx/UserWallet'; | ||
import Text from './Text'; | ||
|
||
type CurrentWalletBalanceOnyxProps = { | ||
/** The user's wallet account */ | ||
userWallet: OnyxEntry<UserWallet>; | ||
}; | ||
|
||
type CurrentWalletBalanceProps = CurrentWalletBalanceOnyxProps & { | ||
balanceStyles?: StyleProp<TextStyle>; | ||
}; | ||
|
||
function CurrentWalletBalance({userWallet, balanceStyles}: CurrentWalletBalanceProps) { | ||
const formattedBalance = CurrencyUtils.convertToDisplayString(userWallet?.currentBalance ?? 0); | ||
return <Text style={[styles.pv5, styles.alignSelfCenter, styles.textHeadline, styles.textXXXLarge, balanceStyles]}>{formattedBalance}</Text>; | ||
} | ||
|
||
CurrentWalletBalance.displayName = 'CurrentWalletBalance'; | ||
|
||
export default withOnyx<CurrentWalletBalanceProps, CurrentWalletBalanceOnyxProps>({ | ||
userWallet: { | ||
key: ONYXKEYS.USER_WALLET, | ||
}, | ||
})(CurrentWalletBalance); |