Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[No QA] Prevent double translation of hint #26727

Merged
merged 4 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/AddressSearch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const propTypes = {
onBlur: PropTypes.func,

/** Error text to display */
errorText: PropTypes.string,
errorText: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.object]))]),

/** Hint text to display */
hint: PropTypes.string,
Expand Down
7 changes: 4 additions & 3 deletions src/pages/iou/WaypointEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import * as Transaction from '../../libs/actions/Transaction';
import * as ValidationUtils from '../../libs/ValidationUtils';
import ROUTES from '../../ROUTES';
import transactionPropTypes from '../../components/transactionPropTypes';
import * as ErrorUtils from '../../libs/ErrorUtils';

const propTypes = {
/** The transactionID of the IOU */
Expand Down Expand Up @@ -104,13 +105,13 @@ function WaypointEditor({transactionID, route: {params: {iouType = '', waypointI
const errors = {};
const waypointValue = values[`waypoint${waypointIndex}`] || '';
if (isOffline && waypointValue !== '' && !ValidationUtils.isValidAddress(waypointValue)) {
errors[`waypoint${waypointIndex}`] = 'bankAccount.error.address';
ErrorUtils.addErrorMessage(errors, `waypoint${waypointIndex}`, 'bankAccount.error.address');
}

// If the user is online and they are trying to save a value without using the autocomplete, show an error message instructing them to use a selected address instead.
// That enables us to save the address with coordinates when it is selected
if (!isOffline && waypointValue !== '' && waypointAddress !== waypointValue) {
errors[`waypoint${waypointIndex}`] = 'distance.errors.selectSuggestedAddress';
ErrorUtils.addErrorMessage(errors, `waypoint${waypointIndex}`, 'distance.errors.selectSuggestedAddress');
hayata-suenaga marked this conversation as resolved.
Show resolved Hide resolved
}

return errors;
Expand Down Expand Up @@ -204,7 +205,7 @@ function WaypointEditor({transactionID, route: {params: {iouType = '', waypointI
<AddressSearch
inputID={`waypoint${waypointIndex}`}
ref={(e) => (textInput.current = e)}
hint={!isOffline ? translate('distance.errors.selectSuggestedAddress') : ''}
hint={!isOffline ? 'distance.errors.selectSuggestedAddress' : ''}
containerStyles={[styles.mt4]}
label={translate('distance.address')}
defaultValue={waypointAddress}
Expand Down
Loading