Skip to content

Commit

Permalink
Merge pull request #30262 from software-mansion-labs/ts/CurrentWallet…
Browse files Browse the repository at this point in the history
…Balance

[TS migration] Migrate 'CurrentWalletBalance.js' component to TypeScript
  • Loading branch information
luacmartins authored Nov 7, 2023
2 parents adc4d92 + 5a73734 commit 096fa33
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 48 deletions.
48 changes: 0 additions & 48 deletions src/components/CurrentWalletBalance.js

This file was deleted.

30 changes: 30 additions & 0 deletions src/components/CurrentWalletBalance.tsx
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);

0 comments on commit 096fa33

Please sign in to comment.