set user in delegation screen when redirected from refer screen

This commit is contained in:
Sadaqat Ali 2022-02-18 09:59:54 +05:00
parent c339895faa
commit a338d362df
4 changed files with 20 additions and 6 deletions

View File

@ -39,6 +39,7 @@ class TransferContainer extends Component {
balance: props.navigation.getParam('balance', ''),
tokenAddress: props.navigation.getParam('tokenAddress', ''),
transferType: props.navigation.getParam('transferType', ''),
referredUsername: props.navigation.getParam('referredUsername'),
selectedAccount: props.currentAccount,
};
}
@ -230,7 +231,7 @@ class TransferContainer extends Component {
actionModalVisible,
dispatch,
} = this.props;
const { balance, fundType, selectedAccount, tokenAddress } = this.state;
const { balance, fundType, selectedAccount, tokenAddress, referredUsername } = this.state;
const transferType = navigation.getParam('transferType', '');
@ -246,6 +247,7 @@ class TransferContainer extends Component {
selectedAccount,
hivePerMVests,
actionModalVisible,
referredUsername,
fetchBalance: this.fetchBalance,
getAccountsWithUsername: this._getAccountsWithUsername,
transferToAccount: this._transferToAccount,

View File

@ -53,11 +53,11 @@ const ReferScreen = ({ navigation }) => {
});
};
const _handleDelegateHP = () => {
const _handleDelegateHP = (item: Referral) => {
console.log('delegate HP!');
navigate({
routeName: ROUTES.SCREENS.TRANSFER,
params: { transferType: 'delegate', fundType: 'HIVE_POWER' },
params: { transferType: 'delegate', fundType: 'HIVE_POWER', referredUsername: item.referredUsername },
});
};
const _renderPointsEarned = () => {
@ -121,9 +121,9 @@ const ReferScreen = ({ navigation }) => {
);
};
const _rightItemRenderer = () => {
const _rightItemRenderer = (item:Referral) => {
return (
<TouchableOpacity style={styles.rightItemRendererContainer} onPress={_handleDelegateHP}>
<TouchableOpacity style={styles.rightItemRendererContainer} onPress={() => _handleDelegateHP(item)}>
<Text style={styles.rightItemText}>
{intl.formatMessage({
id: 'refer.delegate_hp',
@ -144,7 +144,7 @@ const ReferScreen = ({ navigation }) => {
isBlackRightColor
isLoggedIn
leftItemRenderer={() => _leftItemRenderer(item)}
rightItemRenderer={_rightItemRenderer}
rightItemRenderer={() => _rightItemRenderer(item)}
/>
);
};

View File

@ -25,6 +25,7 @@ const Transfer = ({ navigation }) => (
actionModalVisible,
setWithdrawVestingRoute,
dispatch,
referredUsername,
}) => {
switch (transferType) {
case 'transfer_token':
@ -65,6 +66,7 @@ const Transfer = ({ navigation }) => (
hivePerMVests={hivePerMVests}
actionModalVisible={actionModalVisible}
dispatch={dispatch}
referredUsername={referredUsername}
/>
);
case 'power_down':

View File

@ -70,6 +70,16 @@ class DelegateScreen extends Component {
}
// Component Lifecycles
componentDidMount() {
const { referredUsername } = this.props;
if (referredUsername) {
console.log('----referredUsername---- : ', referredUsername);
this.setState({ destination: referredUsername, usersResult: [], step: 2 }, () => {
this._fetchReceivedVestingShare();
});
this.destinationTextInput.current?.blur();
}
}
componentDidUpdate(prevProps, prevState) {
if (prevState.from !== this.state.from) {
this._fetchReceivedVestingShare();