Skip to content

Commit

Permalink
Merge pull request #26727 from Expensify/neil-fix-date-crash
Browse files Browse the repository at this point in the history
[No QA] Prevent double translation of hint
  • Loading branch information
Gonals authored Sep 21, 2023
2 parents 415504d + 7e632df commit f65c58e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
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');
}

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

0 comments on commit f65c58e

Please sign in to comment.