From 3df1cf79dfcadf22f9b2e9b9cd7f17141b40d269 Mon Sep 17 00:00:00 2001 From: neil-marcellini Date: Mon, 4 Sep 2023 14:22:07 -0700 Subject: [PATCH 1/3] Prevent double translation of hint --- src/pages/iou/WaypointEditor.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pages/iou/WaypointEditor.js b/src/pages/iou/WaypointEditor.js index 68e85a34746d..ef2a7b307834 100644 --- a/src/pages/iou/WaypointEditor.js +++ b/src/pages/iou/WaypointEditor.js @@ -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 */ @@ -110,7 +111,7 @@ function WaypointEditor({transactionID, route: {params: {iouType = '', waypointI // 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; @@ -204,7 +205,7 @@ function WaypointEditor({transactionID, route: {params: {iouType = '', waypointI (textInput.current = e)} - hint={!isOffline ? translate('distance.errors.selectSuggestedAddress') : ''} + hint={!isOffline ? 'distance.errors.selectSuggestedAddress' : ''} containerStyles={[styles.mt4]} label={translate('distance.address')} defaultValue={waypointAddress} From 0f359e16c883c7c3dab2b1082813990e5dc832ba Mon Sep 17 00:00:00 2001 From: neil-marcellini Date: Tue, 12 Sep 2023 16:52:58 -0700 Subject: [PATCH 2/3] Update errorText prop type --- src/components/AddressSearch/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/AddressSearch/index.js b/src/components/AddressSearch/index.js index 1697dddba805..d40751a4a1fe 100644 --- a/src/components/AddressSearch/index.js +++ b/src/components/AddressSearch/index.js @@ -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, From 7e632df0f4675bd82e45c4a68f123702d11dc246 Mon Sep 17 00:00:00 2001 From: neil-marcellini Date: Tue, 12 Sep 2023 17:08:50 -0700 Subject: [PATCH 3/3] Use addErrorMessage for all errors --- src/pages/iou/WaypointEditor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/iou/WaypointEditor.js b/src/pages/iou/WaypointEditor.js index ef2a7b307834..f01667ee1845 100644 --- a/src/pages/iou/WaypointEditor.js +++ b/src/pages/iou/WaypointEditor.js @@ -105,7 +105,7 @@ 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.