Skip to content

Commit

Permalink
Merge pull request #14344 from Expensify/cmartins-translateSendMoneyB…
Browse files Browse the repository at this point in the history
…utton

Translate IOU buttons
  • Loading branch information
youssef-lr authored Jan 20, 2023
2 parents 5aabd37 + 3b7d72a commit f586e02
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
14 changes: 7 additions & 7 deletions src/components/ButtonWithMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ButtonWithMenu extends PureComponent {
super(props);

this.state = {
selectedItem: props.options[0],
selectedItemIndex: 0,
isMenuVisible: false,
};
}
Expand All @@ -53,15 +53,15 @@ class ButtonWithMenu extends PureComponent {
}

render() {
const selectedItemText = this.state.selectedItem.text;
const selectedItem = this.props.options[this.state.selectedItemIndex];
return (
<View>
{this.props.options.length > 1 ? (
<ButtonWithDropdown
buttonText={selectedItemText}
buttonText={selectedItem.text}
isLoading={this.props.isLoading}
isDisabled={this.props.isDisabled}
onButtonPress={event => this.props.onPress(event, this.state.selectedItem.value)}
onButtonPress={event => this.props.onPress(event, selectedItem.value)}
onDropdownPress={() => {
this.setMenuVisibility(true);
}}
Expand All @@ -72,7 +72,7 @@ class ButtonWithMenu extends PureComponent {
isDisabled={this.props.isDisabled}
style={[styles.w100]}
isLoading={this.props.isLoading}
text={selectedItemText}
text={selectedItem.text}
onPress={event => this.props.onPress(event, this.props.options[0].value)}
pressOnEnter
/>
Expand All @@ -84,10 +84,10 @@ class ButtonWithMenu extends PureComponent {
onItemSelected={() => this.setMenuVisibility(false)}
anchorPosition={styles.createMenuPositionRightSidepane}
headerText={this.props.menuHeaderText}
menuItems={_.map(this.props.options, item => ({
menuItems={_.map(this.props.options, (item, index) => ({
...item,
onSelected: () => {
this.setState({selectedItem: item});
this.setState({selectedItemIndex: index});
},
}))}
/>
Expand Down
28 changes: 17 additions & 11 deletions src/components/IOUConfirmationList.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,6 @@ class IOUConfirmationList extends Component {
...participant, selected: true,
}));

this.splitOrRequestOptions = [{
text: props.translate(props.hasMultipleParticipants ? 'iou.split' : 'iou.request', {
amount: props.numberFormat(
props.iouAmount,
{style: 'currency', currency: props.iou.selectedCurrencyCode},
),
}),
value: props.hasMultipleParticipants ? CONST.IOU.IOU_TYPE.SPLIT : CONST.IOU.IOU_TYPE.REQUEST,
}];

this.state = {
participants: formattedParticipants,
};
Expand All @@ -119,6 +109,22 @@ class IOUConfirmationList extends Component {
this.confirm = this.confirm.bind(this);
}

/**
* Get the confirmation button options
* @returns {Array}
*/
getSplitOrRequestOptions() {
return [{
text: this.props.translate(this.props.hasMultipleParticipants ? 'iou.split' : 'iou.request', {
amount: this.props.numberFormat(
this.props.iouAmount,
{style: 'currency', currency: this.props.iou.selectedCurrencyCode},
),
}),
value: this.props.hasMultipleParticipants ? CONST.IOU.IOU_TYPE.SPLIT : CONST.IOU.IOU_TYPE.REQUEST,
}];
}

/**
* Get selected participants
* @returns {Array}
Expand Down Expand Up @@ -309,7 +315,7 @@ class IOUConfirmationList extends Component {
<ButtonWithMenu
isDisabled={shouldDisableButton}
onPress={(_event, value) => this.confirm(value)}
options={this.splitOrRequestOptions}
options={this.getSplitOrRequestOptions()}
/>
)}
/>
Expand Down

0 comments on commit f586e02

Please sign in to comment.