mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-30 00:52:42 +03:00
added beneficiary remove method
This commit is contained in:
parent
97d55c57a7
commit
98436fe1f2
@ -22,6 +22,7 @@ interface BeneficiarySelectionContentProps {
|
||||
powerDown?: boolean;
|
||||
powerDownBeneficiaries?: Beneficiary[];
|
||||
handleSaveBeneficiary?: (beneficiaries: Beneficiary[]) => void;
|
||||
handleRemoveBeneficiary?: (beneficiary: Beneficiary) => void;
|
||||
}
|
||||
|
||||
const BeneficiarySelectionContent = ({
|
||||
@ -30,6 +31,7 @@ const BeneficiarySelectionContent = ({
|
||||
powerDown,
|
||||
powerDownBeneficiaries,
|
||||
handleSaveBeneficiary,
|
||||
handleRemoveBeneficiary,
|
||||
}: BeneficiarySelectionContentProps) => {
|
||||
const intl = useIntl();
|
||||
const dispatch = useAppDispatch();
|
||||
@ -306,8 +308,13 @@ const BeneficiarySelectionContent = ({
|
||||
|
||||
const _onRemovePress = () => {
|
||||
beneficiaries[0].weight = beneficiaries[0].weight + item.weight;
|
||||
beneficiaries.splice(index, 1);
|
||||
const removedBeneficiary = beneficiaries.splice(index, 1);
|
||||
setBeneficiaries([...beneficiaries]);
|
||||
console.log('removedBeneficiary : ', removedBeneficiary);
|
||||
if(handleRemoveBeneficiary){
|
||||
handleRemoveBeneficiary(removedBeneficiary[0]);
|
||||
return;
|
||||
}
|
||||
_saveBeneficiaries(beneficiaries);
|
||||
};
|
||||
|
||||
|
@ -185,6 +185,17 @@ class PowerDownView extends Component {
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const _handleRemoveBeneficiary = (beneficiary) => {
|
||||
if (beneficiary) {
|
||||
const beneficiaryAccount = {
|
||||
username: beneficiary.account,
|
||||
percent: beneficiary.weight / 100,
|
||||
autoPowerUp: beneficiary.autoPowerUp,
|
||||
};
|
||||
this._removeDestinationAccount(beneficiaryAccount);
|
||||
}
|
||||
};
|
||||
return (
|
||||
<View style={styles.beneficiaryContainer}>
|
||||
<BeneficiarySelectionContent
|
||||
@ -192,6 +203,7 @@ class PowerDownView extends Component {
|
||||
powerDown={true}
|
||||
powerDownBeneficiaries={powerDownBeneficiaries}
|
||||
handleSaveBeneficiary={_handleSaveBeneficiary}
|
||||
handleRemoveBeneficiary={_handleRemoveBeneficiary}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user