From ad787810ac1f43afafbf0b88dde3b50fa09f5c0f Mon Sep 17 00:00:00 2001 From: b1tjoy <103875612+b1tjoy@users.noreply.github.com> Date: Thu, 24 Nov 2022 18:15:45 +0800 Subject: [PATCH 001/189] fix context menu when long press on url and email link --- .../BaseAnchorForCommentsOnly.js | 24 +++++++-- src/components/AnchorForCommentsOnly/index.js | 28 +++++++--- .../HTMLRenderers/ImageRenderer.js | 49 ++++++++++------- .../PreRenderer/BasePreRenderer.js | 45 +++++++++++++--- .../HTMLRenderers/PreRenderer/index.js | 15 +++++- .../index.js | 53 ++++++------------- .../index.native.js | 28 ++++------ src/components/PressableWithoutFocus.js | 11 +++- src/components/ReportActionItem/IOUAction.js | 11 ++++ src/components/ReportActionItem/IOUPreview.js | 44 ++++++++++++++- src/components/ShowContextMenuContext.js | 34 ++++++++++++ src/pages/home/report/ReportActionItem.js | 48 +++++++++++------ 12 files changed, 280 insertions(+), 110 deletions(-) create mode 100644 src/components/ShowContextMenuContext.js diff --git a/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly.js b/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly.js index 77cc720445f9..01152303296f 100644 --- a/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly.js +++ b/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly.js @@ -1,6 +1,7 @@ import _ from 'underscore'; import React from 'react'; import {StyleSheet} from 'react-native'; +import PropTypes from 'prop-types'; import lodashGet from 'lodash/get'; import Str from 'expensify-common/lib/str'; import Text from '../Text'; @@ -11,13 +12,28 @@ import Tooltip from '../Tooltip'; import canUseTouchScreen from '../../libs/canUseTouchscreen'; import styles from '../../styles/styles'; import withWindowDimensions, {windowDimensionsPropTypes} from '../withWindowDimensions'; -import {propTypes as anchorForCommentsOnlyPropTypes, defaultProps} from './anchorForCommentsOnlyPropTypes'; +import { + propTypes as anchorForCommentsOnlyPropTypes, + defaultProps as anchorForCommentsOnlyDefaultProps, +} from './anchorForCommentsOnlyPropTypes'; const propTypes = { + /** Press in handler for the link */ + onPressIn: PropTypes.func, + + /** Press out handler for the link */ + onPressOut: PropTypes.func, + ...anchorForCommentsOnlyPropTypes, ...windowDimensionsPropTypes, }; +const defaultProps = { + onPressIn: undefined, + onPressOut: undefined, + ...anchorForCommentsOnlyDefaultProps, +}; + /* * This is a default anchor component for regular links. */ @@ -45,6 +61,9 @@ const BaseAnchorForCommentsOnly = (props) => { ); } } + onPress={linkProps.onPress} + onPressIn={props.onPressIn} + onPressOut={props.onPressOut} > { rel: props.rel, target: props.target, }} - // eslint-disable-next-line react/jsx-props-no-spreading - {...linkProps} + href={linkProps.href} // eslint-disable-next-line react/jsx-props-no-spreading {...rest} > diff --git a/src/components/AnchorForCommentsOnly/index.js b/src/components/AnchorForCommentsOnly/index.js index 1526e78007fe..88010285a09d 100644 --- a/src/components/AnchorForCommentsOnly/index.js +++ b/src/components/AnchorForCommentsOnly/index.js @@ -1,11 +1,27 @@ import React from 'react'; -import * as anchorForCommentsOnlyPropTypes from './anchorForCommentsOnlyPropTypes'; +import _ from 'underscore'; +import {propTypes as anchorForCommentsOnlyPropTypes, defaultProps} from './anchorForCommentsOnlyPropTypes'; import BaseAnchorForCommentsOnly from './BaseAnchorForCommentsOnly'; +import canUseTouchScreen from '../../libs/canUseTouchscreen'; +import ControlSelection from '../../libs/ControlSelection'; +import withWindowDimensions, {windowDimensionsPropTypes} from '../withWindowDimensions'; -// eslint-disable-next-line react/jsx-props-no-spreading -const AnchorForCommentsOnly = props => ; -AnchorForCommentsOnly.propTypes = anchorForCommentsOnlyPropTypes.propTypes; -AnchorForCommentsOnly.defaultProps = anchorForCommentsOnlyPropTypes.defaultProps; +const propTypes = { + ...anchorForCommentsOnlyPropTypes, + ...windowDimensionsPropTypes, +}; + +const AnchorForCommentsOnly = props => ( + props.isSmallScreenWidth && canUseTouchScreen() && ControlSelection.block()} + onPressOut={() => ControlSelection.unblock()} + // eslint-disable-next-line react/jsx-props-no-spreading + {...(_.omit(props, ['onPressIn', 'onPressOut']))} + /> +); + +AnchorForCommentsOnly.propTypes = propTypes; +AnchorForCommentsOnly.defaultProps = defaultProps; AnchorForCommentsOnly.displayName = 'AnchorForCommentsOnly'; -export default AnchorForCommentsOnly; +export default withWindowDimensions(AnchorForCommentsOnly); diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.js b/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.js index f3e9009a72ca..cef91ba9a9e2 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.js +++ b/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.js @@ -6,6 +6,7 @@ import styles from '../../../styles/styles'; import ThumbnailImage from '../../ThumbnailImage'; import PressableWithoutFocus from '../../PressableWithoutFocus'; import CONST from '../../../CONST'; +import {ShowContextMenuContext, showContextMenuForReport} from '../../ShowContextMenuContext'; const ImageRenderer = (props) => { const htmlAttribs = props.tnode.attributes; @@ -57,27 +58,37 @@ const ImageRenderer = (props) => { imageHeight={imageHeight} /> ) : ( - - {({show}) => ( - + {({ + anchor, + reportID, + action, + checkIfContextMenuActive, + }) => ( + - - + {({show}) => ( + showContextMenuForReport(event, anchor, reportID, action, checkIfContextMenuActive)} + > + + + )} + )} - + ); }; diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer/BasePreRenderer.js b/src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer/BasePreRenderer.js index 5edafb4dc04d..25ea94e0ae6b 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer/BasePreRenderer.js +++ b/src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer/BasePreRenderer.js @@ -1,28 +1,59 @@ import React, {forwardRef} from 'react'; import {ScrollView} from 'react-native-gesture-handler'; -import {View} from 'react-native'; +import {Pressable} from 'react-native'; +import PropTypes from 'prop-types'; import _ from 'underscore'; import htmlRendererPropTypes from '../htmlRendererPropTypes'; import withLocalize from '../../../withLocalize'; +import {ShowContextMenuContext, showContextMenuForReport} from '../../../ShowContextMenuContext'; + +const propTypes = { + /** Press in handler for the code block */ + onPressIn: PropTypes.func, + + /** Press out handler for the code block */ + onPressOut: PropTypes.func, + + ...htmlRendererPropTypes, +}; + +const defaultProps = { + onPressIn: undefined, + onPressOut: undefined, +}; const BasePreRenderer = forwardRef((props, ref) => { const TDefaultRenderer = props.TDefaultRenderer; - const defaultRendererProps = _.omit(props, ['TDefaultRenderer']); + const defaultRendererProps = _.omit(props, ['TDefaultRenderer', 'onPressIn', 'onPressOut', 'onLongPress']); return ( - true}> - {/* eslint-disable-next-line react/jsx-props-no-spreading */} - - + + {({ + anchor, + reportID, + action, + checkIfContextMenuActive, + }) => ( + showContextMenuForReport(event, anchor, reportID, action, checkIfContextMenuActive)} + > + {/* eslint-disable-next-line react/jsx-props-no-spreading */} + + + )} + ); }); BasePreRenderer.displayName = 'BasePreRenderer'; -BasePreRenderer.propTypes = htmlRendererPropTypes; +BasePreRenderer.propTypes = propTypes; +BasePreRenderer.defaultProps = defaultProps; export default withLocalize(BasePreRenderer); diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer/index.js b/src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer/index.js index 59c05e73ed97..e8043491352e 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer/index.js +++ b/src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer/index.js @@ -3,6 +3,15 @@ import _ from 'underscore'; import withLocalize from '../../../withLocalize'; import htmlRendererPropTypes from '../htmlRendererPropTypes'; import BasePreRenderer from './BasePreRenderer'; +import compose from '../../../../libs/compose'; +import withWindowDimensions, {windowDimensionsPropTypes} from '../../../withWindowDimensions'; +import canUseTouchScreen from '../../../../libs/canUseTouchscreen'; +import ControlSelection from '../../../../libs/ControlSelection'; + +const propTypes = { + ...htmlRendererPropTypes, + ...windowDimensionsPropTypes, +}; class PreRenderer extends React.Component { constructor(props) { @@ -55,6 +64,8 @@ class PreRenderer extends React.Component { render() { return ( this.props.isSmallScreenWidth && canUseTouchScreen() && ControlSelection.block()} + onPressOut={() => ControlSelection.unblock()} // eslint-disable-next-line react/jsx-props-no-spreading {...this.props} ref={el => this.ref = el} @@ -63,6 +74,6 @@ class PreRenderer extends React.Component { } } -PreRenderer.propTypes = htmlRendererPropTypes; +PreRenderer.propTypes = propTypes; -export default withLocalize(PreRenderer); +export default compose(withLocalize, withWindowDimensions)(PreRenderer); diff --git a/src/components/PressableWithSecondaryInteraction/index.js b/src/components/PressableWithSecondaryInteraction/index.js index a6b21a59e1cb..78168a9f41a5 100644 --- a/src/components/PressableWithSecondaryInteraction/index.js +++ b/src/components/PressableWithSecondaryInteraction/index.js @@ -1,7 +1,6 @@ import _ from 'underscore'; import React, {Component} from 'react'; import {Pressable} from 'react-native'; -import {LongPressGestureHandler, State} from 'react-native-gesture-handler'; import * as pressableWithSecondaryInteractionPropTypes from './pressableWithSecondaryInteractionPropTypes'; import styles from '../../styles/styles'; import hasHoverSupport from '../../libs/hasHoverSupport'; @@ -12,7 +11,6 @@ import hasHoverSupport from '../../libs/hasHoverSupport'; class PressableWithSecondaryInteraction extends Component { constructor(props) { super(props); - this.callSecondaryInteractionWithMappedEvent = this.callSecondaryInteractionWithMappedEvent.bind(this); this.executeSecondaryInteractionOnContextMenu = this.executeSecondaryInteractionOnContextMenu.bind(this); } @@ -27,27 +25,6 @@ class PressableWithSecondaryInteraction extends Component { this.pressableRef.removeEventListener('contextmenu', this.executeSecondaryInteractionOnContextMenu); } - /** - * @param {Object} e - */ - callSecondaryInteractionWithMappedEvent(e) { - if ((e.nativeEvent.state !== State.ACTIVE) || hasHoverSupport()) { - return; - } - - // Map gesture event to normal Responder event - const { - absoluteX, absoluteY, locationX, locationY, - } = e.nativeEvent; - const mapEvent = { - ...e, - nativeEvent: { - ...e.nativeEvent, pageX: absoluteX, pageY: absoluteY, x: locationX, y: locationY, - }, - }; - this.props.onSecondaryInteraction(mapEvent); - } - /** * @param {contextmenu} e - A right-click MouseEvent. * https://developer.mozilla.org/en-US/docs/Web/API/Element/contextmenu_event @@ -65,19 +42,23 @@ class PressableWithSecondaryInteraction extends Component { // On Web, Text does not support LongPress events thus manage inline mode with styling instead of using Text. return ( - - this.pressableRef = el} - // eslint-disable-next-line react/jsx-props-no-spreading - {...defaultPressableProps} - > - {this.props.children} - - + { + if (hasHoverSupport()) { + return; + } + this.props.onSecondaryInteraction(e); + }} + onPressOut={this.props.onPressOut} + onPress={this.props.onPress} + ref={el => this.pressableRef = el} + // eslint-disable-next-line react/jsx-props-no-spreading + {...defaultPressableProps} + > + {this.props.children} + ); } } diff --git a/src/components/PressableWithSecondaryInteraction/index.native.js b/src/components/PressableWithSecondaryInteraction/index.native.js index efb68e52eb79..f186146b4134 100644 --- a/src/components/PressableWithSecondaryInteraction/index.native.js +++ b/src/components/PressableWithSecondaryInteraction/index.native.js @@ -1,7 +1,6 @@ import _ from 'underscore'; import React, {forwardRef} from 'react'; import {Pressable} from 'react-native'; -import {LongPressGestureHandler, State} from 'react-native-gesture-handler'; import * as pressableWithSecondaryInteractionPropTypes from './pressableWithSecondaryInteractionPropTypes'; import Text from '../Text'; import HapticFeedback from '../../libs/HapticFeedback'; @@ -16,28 +15,21 @@ const PressableWithSecondaryInteraction = (props) => { // Use Text node for inline mode to prevent content overflow. const Node = props.inline ? Text : Pressable; return ( - { - if (e.nativeEvent.state !== State.ACTIVE) { - return; - } + { e.preventDefault(); HapticFeedback.trigger(); props.onSecondaryInteraction(e); }} - > - - {props.children} - - - + {...(_.omit(props, 'onLongPress'))} + > + {props.children} + ); }; diff --git a/src/components/PressableWithoutFocus.js b/src/components/PressableWithoutFocus.js index 30668608496f..10ea16c71d06 100644 --- a/src/components/PressableWithoutFocus.js +++ b/src/components/PressableWithoutFocus.js @@ -12,6 +12,9 @@ const propTypes = { /** Callback for onPress event */ onPress: PropTypes.func.isRequired, + /** Callback for onLongPress event */ + onLongPress: PropTypes.func, + /** Styles that should be passed to touchable container */ // eslint-disable-next-line react/forbid-prop-types styles: PropTypes.arrayOf(PropTypes.object), @@ -19,6 +22,7 @@ const propTypes = { const defaultProps = { styles: [], + onLongPress: undefined, }; /** @@ -41,7 +45,12 @@ class PressableWithoutFocus extends React.Component { render() { return ( - this.pressableRef = el} style={this.props.styles}> + this.pressableRef = el} + style={this.props.styles} + > {this.props.children} ); diff --git a/src/components/ReportActionItem/IOUAction.js b/src/components/ReportActionItem/IOUAction.js index 015766612056..ee79914683dc 100644 --- a/src/components/ReportActionItem/IOUAction.js +++ b/src/components/ReportActionItem/IOUAction.js @@ -20,6 +20,12 @@ const propTypes = { /** Is this IOUACTION the most recent? */ isMostRecentIOUReportAction: PropTypes.bool.isRequired, + /** Popover context menu anchor, used for showing context menu */ + contextMenuAnchor: PropTypes.shape({current: PropTypes.elementType}), + + /** Callback for updating context menu active state, used for showing context menu */ + checkIfContextMenuActive: PropTypes.func, + /* Onyx Props */ /** chatReport associated with iouReport */ chatReport: PropTypes.shape({ @@ -29,6 +35,8 @@ const propTypes = { }; const defaultProps = { + contextMenuAnchor: undefined, + checkIfContextMenuActive: () => {}, chatReport: { participants: [], }, @@ -51,6 +59,9 @@ const IOUAction = (props) => { pendingAction={lodashGet(props.action, 'pendingAction', null)} iouReportID={props.action.originalMessage.IOUReportID.toString()} chatReportID={props.chatReportID} + action={props.action} + contextMenuAnchor={props.contextMenuAnchor} + checkIfContextMenuActive={props.checkIfContextMenuActive} onPayButtonPressed={launchDetailsModal} onPreviewPressed={launchDetailsModal} containerStyles={[styles.cursorPointer]} diff --git a/src/components/ReportActionItem/IOUPreview.js b/src/components/ReportActionItem/IOUPreview.js index 355c414e48aa..e4d69de3990d 100644 --- a/src/components/ReportActionItem/IOUPreview.js +++ b/src/components/ReportActionItem/IOUPreview.js @@ -24,6 +24,11 @@ import Text from '../Text'; import * as PaymentMethods from '../../libs/actions/PaymentMethods'; import OfflineWithFeedback from '../OfflineWithFeedback'; import walletTermsPropTypes from '../../pages/EnablePayments/walletTermsPropTypes'; +import ControlSelection from '../../libs/ControlSelection'; +import canUseTouchScreen from '../../libs/canUseTouchscreen'; +import withWindowDimensions, {windowDimensionsPropTypes} from '../withWindowDimensions'; +import reportActionPropTypes from '../../pages/home/report/reportActionPropTypes'; +import {showContextMenuForReport} from '../ShowContextMenuContext'; const propTypes = { /** Additional logic for displaying the pay button */ @@ -41,6 +46,15 @@ const propTypes = { /** Callback for the preview pressed */ onPreviewPressed: PropTypes.func, + /** All the data of the action, used for showing context menu */ + action: PropTypes.shape(reportActionPropTypes), + + /** Popover context menu anchor, used for showing context menu */ + contextMenuAnchor: PropTypes.shape({current: PropTypes.elementType}), + + /** Callback for updating context menu active state, used for showing context menu */ + checkIfContextMenuActive: PropTypes.func, + /** Extra styles to pass to View wrapper */ // eslint-disable-next-line react/forbid-prop-types containerStyles: PropTypes.arrayOf(PropTypes.object), @@ -85,6 +99,7 @@ const propTypes = { pendingAction: PropTypes.oneOf(_.values(CONST.RED_BRICK_ROAD_PENDING_ACTION)), ...withLocalizePropTypes, + ...windowDimensionsPropTypes, }; const defaultProps = { @@ -92,6 +107,9 @@ const defaultProps = { shouldHidePayButton: false, onPayButtonPressed: null, onPreviewPressed: () => {}, + action: undefined, + contextMenuAnchor: undefined, + checkIfContextMenuActive: () => {}, containerStyles: [], walletTerms: {}, pendingAction: null, @@ -129,8 +147,30 @@ const IOUPreview = (props) => { {style: 'currency', currency: props.iouReport.currency}, ) : ''; const avatarTooltip = [Str.removeSMSDomain(managerEmail), Str.removeSMSDomain(ownerEmail)]; + + const showContextMenu = (event) => { + // Use action and shouldHidePayButton props to check if we are in IOUDetailsModal, + // if it's true, do nothing when user long press, otherwise show context menu. + if (!props.action && props.shouldHidePayButton) { + return; + } + + showContextMenuForReport( + event, + props.contextMenuAnchor, + props.chatReportID, + props.action, + props.checkIfContextMenuActive, + ); + }; + return ( - + props.isSmallScreenWidth && canUseTouchScreen() && ControlSelection.block()} + onPressOut={() => ControlSelection.unblock()} + onLongPress={showContextMenu} + > {reportIsLoading ? @@ -185,6 +225,7 @@ const IOUPreview = (props) => { ); } else { - children = !this.props.draftMessage - ? ( - - ) : ( - this.textInput = el} - report={this.props.report} - shouldDisableEmojiPicker={ - (ReportUtils.chatIncludesConcierge(this.props.report) && User.isBlockedFromConcierge(this.props.blockedFromConcierge)) - || ReportUtils.isArchivedRoom(this.props.report) - } - /> - ); + children = ( + + {!this.props.draftMessage + ? ( + + ) : ( + this.textInput = el} + report={this.props.report} + shouldDisableEmojiPicker={ + (ReportUtils.chatIncludesConcierge(this.props.report) && User.isBlockedFromConcierge(this.props.blockedFromConcierge)) + || ReportUtils.isArchivedRoom(this.props.report) + } + /> + )} + + ); } return ( Date: Thu, 24 Nov 2022 18:41:25 +0800 Subject: [PATCH 002/189] fix no-trailing-spaces lint error --- src/components/ShowContextMenuContext.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ShowContextMenuContext.js b/src/components/ShowContextMenuContext.js index 88cec8a7dbec..1a5ca0d0d18e 100644 --- a/src/components/ShowContextMenuContext.js +++ b/src/components/ShowContextMenuContext.js @@ -7,7 +7,7 @@ ShowContextMenuContext.displayName = 'ShowContextMenuContext'; /** * Show the report action context menu. - * + * * @param {Object} [event] - A press event * @param {Element} anchor - Context menu anchor * @param {String} reportID - Active Report Id From b992707c4a31db963dc38bd91a25ba0045ee49b7 Mon Sep 17 00:00:00 2001 From: joelbettner Date: Tue, 29 Nov 2022 15:07:57 -0700 Subject: [PATCH 003/189] Add wallet details ONYX form --- src/ONYXKEYS.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ONYXKEYS.js b/src/ONYXKEYS.js index 60a686195dcd..34701dc3648f 100755 --- a/src/ONYXKEYS.js +++ b/src/ONYXKEYS.js @@ -172,6 +172,7 @@ export default { CLOSE_ACCOUNT_FORM: 'closeAccount', PROFILE_SETTINGS_FORM: 'profileSettingsForm', DISPLAY_NAME_FORM: 'displayNameForm', + WALLET_ADDITIONAL_DETAILS_FORM: 'walletAdditionalDetailsForm', }, // Whether we should show the compose input or not From 5d9643161dcf3b5f3e9f8aae870f87b31e41c858 Mon Sep 17 00:00:00 2001 From: joelbettner Date: Tue, 29 Nov 2022 16:23:46 -0700 Subject: [PATCH 004/189] Import Form --- src/pages/EnablePayments/AdditionalDetailsStep.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index 1a90a8a35189..6ff64db1618f 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -24,6 +24,7 @@ import * as ValidationUtils from '../../libs/ValidationUtils'; import * as LoginUtils from '../../libs/LoginUtils'; import AddressForm from '../ReimbursementAccount/AddressForm'; import DatePicker from '../../components/DatePicker'; +import Form from '../../components/Form'; import FormHelper from '../../libs/FormHelper'; import walletAdditionalDetailsDraftPropTypes from './walletAdditionalDetailsDraftPropTypes'; import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsPropTypes, withCurrentUserPersonalDetailsDefaultProps} from '../../components/withCurrentUserPersonalDetails'; From f29aa50334e4d9dd24e8aab9a134ead474097681 Mon Sep 17 00:00:00 2001 From: joelbettner Date: Tue, 29 Nov 2022 16:27:18 -0700 Subject: [PATCH 005/189] Add Form element --- .../EnablePayments/AdditionalDetailsStep.js | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index 6ff64db1618f..9442f6ae0147 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -293,6 +293,88 @@ class AdditionalDetailsStep extends React.Component { {this.props.translate('additionalDetailsStep.helpLink')} +
+ + + this.clearErrorAndSetValue('legalFirstName', val)} + defaultValue={this.getFirstName()} + errorText={this.getErrorText('legalFirstName')} + /> + this.clearErrorAndSetValue('legalLastName', val)} + defaultValue={this.getLastName()} + errorText={this.getErrorText('legalLastName')} + /> + { + const renamedFields = { + street: 'addressStreet', + state: 'addressState', + city: 'addressCity', + zipCode: 'addressZip', + }; + _.each(values, (value, inputKey) => { + const renamedInputKey = lodashGet(renamedFields, inputKey, inputKey); + this.clearErrorAndSetValue(renamedInputKey, value); + }); + }} + /> + + this.clearErrorAndSetValue('phoneNumber', val)} + value={this.props.walletAdditionalDetailsDraft.phoneNumber || ''} + placeholder={this.props.translate('common.phoneNumberPlaceholder')} + errorText={this.getErrorText('phoneNumber')} + /> + this.clearDateErrorsAndSetValue(val)} + defaultValue={this.props.walletAdditionalDetailsDraft.dob || ''} + placeholder={this.props.translate('common.dob')} + errorText={this.getErrorText('dob') || this.getErrorText('age')} + maximumDate={new Date()} + /> + this.clearSSNErrorAndSetValue(val)} + value={this.props.walletAdditionalDetailsDraft.ssn || ''} + errorText={this.getErrorText('ssnFull9') || this.getErrorText('ssn')} + maxLength={shouldAskForFullSSN ? 9 : 4} + keyboardType={CONST.KEYBOARD_TYPE.NUMBER_PAD} + /> + + + this.form = el}> From e86cddc93020face1211a22f611a478914974104 Mon Sep 17 00:00:00 2001 From: joelbettner Date: Tue, 29 Nov 2022 16:27:52 -0700 Subject: [PATCH 006/189] Delete FormScrollView element --- .../EnablePayments/AdditionalDetailsStep.js | 86 ------------------- 1 file changed, 86 deletions(-) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index 9442f6ae0147..2024b3693393 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -375,92 +375,6 @@ class AdditionalDetailsStep extends React.Component { - this.form = el}> - - - this.clearErrorAndSetValue('legalFirstName', val)} - value={this.getFirstName()} - errorText={this.getErrorText('legalFirstName')} - /> - this.clearErrorAndSetValue('legalLastName', val)} - value={this.getLastName()} - errorText={this.getErrorText('legalLastName')} - /> - { - const renamedFields = { - street: 'addressStreet', - state: 'addressState', - city: 'addressCity', - zipCode: 'addressZip', - }; - _.each(values, (value, inputKey) => { - const renamedInputKey = lodashGet(renamedFields, inputKey, inputKey); - this.clearErrorAndSetValue(renamedInputKey, value); - }); - }} - /> - - this.clearErrorAndSetValue('phoneNumber', val)} - value={this.props.walletAdditionalDetailsDraft.phoneNumber || ''} - placeholder={this.props.translate('common.phoneNumberPlaceholder')} - errorText={this.getErrorText('phoneNumber')} - /> - this.clearDateErrorsAndSetValue(val)} - defaultValue={this.props.walletAdditionalDetailsDraft.dob || ''} - placeholder={this.props.translate('common.dob')} - errorText={this.getErrorText('dob') || this.getErrorText('age')} - maximumDate={new Date()} - /> - this.clearSSNErrorAndSetValue(val)} - value={this.props.walletAdditionalDetailsDraft.ssn || ''} - errorText={this.getErrorText('ssnFull9') || this.getErrorText('ssn')} - maxLength={shouldAskForFullSSN ? 9 : 4} - keyboardType={CONST.KEYBOARD_TYPE.NUMBER_PAD} - /> - - { - this.form.scrollTo({y: 0, animated: true}); - }} - message={errorMessage} - isLoading={this.props.walletAdditionalDetails.isLoading} - buttonText={this.props.translate('common.saveAndContinue')} - /> - - ); From d73c7019ecaa1bb080df1245a03771a52da97c53 Mon Sep 17 00:00:00 2001 From: joelbettner Date: Wed, 30 Nov 2022 11:36:17 -0700 Subject: [PATCH 007/189] Remove onChangetText from legalFirstName and legalLastName text inputs --- src/pages/EnablePayments/AdditionalDetailsStep.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index 2024b3693393..0eccee1df6df 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -305,14 +305,12 @@ class AdditionalDetailsStep extends React.Component { this.clearErrorAndSetValue('legalFirstName', val)} defaultValue={this.getFirstName()} errorText={this.getErrorText('legalFirstName')} /> this.clearErrorAndSetValue('legalLastName', val)} defaultValue={this.getLastName()} errorText={this.getErrorText('legalLastName')} /> From 137a0bd2c293a6dc0c6c88f3a7a8382f084a9fd7 Mon Sep 17 00:00:00 2001 From: joelbettner Date: Wed, 30 Nov 2022 12:15:07 -0700 Subject: [PATCH 008/189] Getting rid of walletAdditionalDetailsDraft --- src/ONYXKEYS.js | 3 -- src/libs/actions/Wallet.js | 8 ----- .../EnablePayments/AdditionalDetailsStep.js | 29 ------------------- .../EnablePayments/EnablePaymentsPage.js | 3 -- 4 files changed, 43 deletions(-) diff --git a/src/ONYXKEYS.js b/src/ONYXKEYS.js index 34701dc3648f..007eae1f0d5f 100755 --- a/src/ONYXKEYS.js +++ b/src/ONYXKEYS.js @@ -112,9 +112,6 @@ export default { // Stores information about additional details form entry WALLET_ADDITIONAL_DETAILS: 'walletAdditionalDetails', - // Stores values put into the additional details step of the wallet KYC flow - WALLET_ADDITIONAL_DETAILS_DRAFT: 'walletAdditionalDetailsDraft', - // Object containing Wallet terms step state WALLET_TERMS: 'walletTerms', diff --git a/src/libs/actions/Wallet.js b/src/libs/actions/Wallet.js index 14db31e30bcd..539ccbd72265 100644 --- a/src/libs/actions/Wallet.js +++ b/src/libs/actions/Wallet.js @@ -524,13 +524,6 @@ function openEnablePaymentsPage() { API.read('OpenEnablePaymentsPage'); } -/** - * @param {Object} keyValuePair - */ -function updateAdditionalDetailsDraft(keyValuePair) { - Onyx.merge(ONYXKEYS.WALLET_ADDITIONAL_DETAILS_DRAFT, keyValuePair); -} - /** * @param {String} currentStep */ @@ -580,7 +573,6 @@ export { openInitialSettingsPage, openEnablePaymentsPage, setAdditionalDetailsErrors, - updateAdditionalDetailsDraft, setAdditionalDetailsErrorMessage, setAdditionalDetailsQuestions, buildIdologyError, diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index 0eccee1df6df..c0eb0a649956 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -226,35 +226,6 @@ class AdditionalDetailsStep extends React.Component { Wallet.updatePersonalDetails(personalDetails); } - /** - * Clear both errors associated with dob, and set the new value. - * - * @param {String} value - */ - clearDateErrorsAndSetValue(value) { - this.formHelper.clearErrors(this.props, ['dob', 'age']); - Wallet.updateAdditionalDetailsDraft({dob: moment(value).format(CONST.DATE.MOMENT_FORMAT_STRING)}); - } - - /** - * Clear ssn and ssnFull9 error and set the new value - * - * @param {String} value - */ - clearSSNErrorAndSetValue(value) { - this.formHelper.clearErrors(this.props, ['ssn', 'ssnFull9']); - Wallet.updateAdditionalDetailsDraft({ssn: value}); - } - - /** - * @param {String} fieldName - * @param {String} value - */ - clearErrorAndSetValue(fieldName, value) { - Wallet.updateAdditionalDetailsDraft({[fieldName]: value}); - this.clearError(fieldName); - } - render() { if (!_.isEmpty(this.props.walletAdditionalDetails.questions)) { return ( diff --git a/src/pages/EnablePayments/EnablePaymentsPage.js b/src/pages/EnablePayments/EnablePaymentsPage.js index 42aeea32622c..1559e3b0f030 100644 --- a/src/pages/EnablePayments/EnablePaymentsPage.js +++ b/src/pages/EnablePayments/EnablePaymentsPage.js @@ -104,9 +104,6 @@ export default compose( // stored values here. initWithStoredValues: false, }, - walletAdditionalDetailsDraft: { - key: ONYXKEYS.WALLET_ADDITIONAL_DETAILS_DRAFT, - }, }), withNetwork(), )(EnablePaymentsPage); From c62f5e6c42dc6e876352099af2b65dce94ced34e Mon Sep 17 00:00:00 2001 From: joelbettner Date: Wed, 30 Nov 2022 12:19:22 -0700 Subject: [PATCH 009/189] Remove onFieldChange and onTextChange props --- src/pages/EnablePayments/AdditionalDetailsStep.js | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index c0eb0a649956..0dfca545a138 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -300,25 +300,12 @@ class AdditionalDetailsStep extends React.Component { city: this.getErrors().addressCity, zipCode: this.getErrors().addressZip, }} - onFieldChange={(values) => { - const renamedFields = { - street: 'addressStreet', - state: 'addressState', - city: 'addressCity', - zipCode: 'addressZip', - }; - _.each(values, (value, inputKey) => { - const renamedInputKey = lodashGet(renamedFields, inputKey, inputKey); - this.clearErrorAndSetValue(renamedInputKey, value); - }); - }} /> this.clearErrorAndSetValue('phoneNumber', val)} value={this.props.walletAdditionalDetailsDraft.phoneNumber || ''} placeholder={this.props.translate('common.phoneNumberPlaceholder')} errorText={this.getErrorText('phoneNumber')} @@ -326,7 +313,6 @@ class AdditionalDetailsStep extends React.Component { this.clearDateErrorsAndSetValue(val)} defaultValue={this.props.walletAdditionalDetailsDraft.dob || ''} placeholder={this.props.translate('common.dob')} errorText={this.getErrorText('dob') || this.getErrorText('age')} @@ -335,7 +321,6 @@ class AdditionalDetailsStep extends React.Component { this.clearSSNErrorAndSetValue(val)} value={this.props.walletAdditionalDetailsDraft.ssn || ''} errorText={this.getErrorText('ssnFull9') || this.getErrorText('ssn')} maxLength={shouldAskForFullSSN ? 9 : 4} From 9291b907fc9c6ddb35045a3ea327dd88dcfdd61f Mon Sep 17 00:00:00 2001 From: joelbettner Date: Wed, 30 Nov 2022 15:57:51 -0700 Subject: [PATCH 010/189] Create INPUT_IDS const --- src/pages/EnablePayments/AdditionalDetailsStep.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index 0dfca545a138..da5fae805895 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -88,6 +88,8 @@ const defaultProps = { ...withCurrentUserPersonalDetailsDefaultProps, }; +const INPUT_IDS = {LEGAL_FIRST_NAME: 'legalFirstName'}; + class AdditionalDetailsStep extends React.Component { constructor(props) { super(props); @@ -274,10 +276,12 @@ class AdditionalDetailsStep extends React.Component { Date: Wed, 30 Nov 2022 15:58:11 -0700 Subject: [PATCH 011/189] Bind validate function to class --- src/pages/EnablePayments/AdditionalDetailsStep.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index da5fae805895..5abe48faa37a 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -120,6 +120,8 @@ class AdditionalDetailsStep extends React.Component { errorPath: 'walletAdditionalDetails.errorFields', setErrors: Wallet.setAdditionalDetailsErrors, }); + + this.validate = this.validate.bind(this); } getFirstName() { From 6d60f2a5d5974e3c1e3db1d8d1c2174320c14e17 Mon Sep 17 00:00:00 2001 From: joelbettner Date: Wed, 30 Nov 2022 15:58:31 -0700 Subject: [PATCH 012/189] Export the new ONYX key --- .../EnablePayments/AdditionalDetailsStep.js | 89 ++++++++++--------- 1 file changed, 45 insertions(+), 44 deletions(-) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index 5abe48faa37a..a440b2871778 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -170,51 +170,52 @@ class AdditionalDetailsStep extends React.Component { const errors = {}; if (!this.getFirstName()) { - errors.legalFirstName = true; + errors[INPUT_IDS.LEGAL_FIRST_NAME] = 'Invalid First Name'; } - if (!this.getLastName()) { - errors.legalLastName = true; - } - - if (!ValidationUtils.isValidPastDate(this.props.walletAdditionalDetailsDraft.dob)) { - errors.dob = true; - } - - if (!ValidationUtils.meetsAgeRequirements(this.props.walletAdditionalDetailsDraft.dob)) { - errors.age = true; - } - - if (!ValidationUtils.isValidAddress(this.props.walletAdditionalDetailsDraft.addressStreet)) { - errors.addressStreet = true; - } - - if (_.isEmpty(this.props.walletAdditionalDetailsDraft.addressCity)) { - errors.addressCity = true; - } - - if (_.isEmpty(this.props.walletAdditionalDetailsDraft.addressState)) { - errors.addressState = true; - } - - if (!ValidationUtils.isValidZipCode(this.props.walletAdditionalDetailsDraft.addressZip)) { - errors.addressZip = true; - } - - if (!ValidationUtils.isValidUSPhone(this.props.walletAdditionalDetailsDraft.phoneNumber, true)) { - errors.phoneNumber = true; - } - - if (this.props.walletAdditionalDetails.errorCode === CONST.WALLET.ERROR.SSN) { - if (!ValidationUtils.isValidSSNFullNine(this.props.walletAdditionalDetailsDraft.ssn)) { - errors.ssnFull9 = true; - } - } else if (!ValidationUtils.isValidSSNLastFour(this.props.walletAdditionalDetailsDraft.ssn)) { - errors.ssn = true; - } - - Wallet.setAdditionalDetailsErrors(errors); - return _.size(errors) === 0; + // if (!this.getLastName()) { + // errors.legalLastName = true; + // } + // + // if (!ValidationUtils.isValidPastDate(this.props.walletAdditionalDetailsDraft.dob)) { + // errors.dob = true; + // } + // + // if (!ValidationUtils.meetsAgeRequirements(this.props.walletAdditionalDetailsDraft.dob)) { + // errors.age = true; + // } + // + // if (!ValidationUtils.isValidAddress(this.props.walletAdditionalDetailsDraft.addressStreet)) { + // errors.addressStreet = true; + // } + // + // if (_.isEmpty(this.props.walletAdditionalDetailsDraft.addressCity)) { + // errors.addressCity = true; + // } + // + // if (_.isEmpty(this.props.walletAdditionalDetailsDraft.addressState)) { + // errors.addressState = true; + // } + // + // if (!ValidationUtils.isValidZipCode(this.props.walletAdditionalDetailsDraft.addressZip)) { + // errors.addressZip = true; + // } + // + // if (!ValidationUtils.isValidUSPhone(this.props.walletAdditionalDetailsDraft.phoneNumber, true)) { + // errors.phoneNumber = true; + // } + // + // if (this.props.walletAdditionalDetails.errorCode === CONST.WALLET.ERROR.SSN) { + // if (!ValidationUtils.isValidSSNFullNine(this.props.walletAdditionalDetailsDraft.ssn)) { + // errors.ssnFull9 = true; + // } + // } else if (!ValidationUtils.isValidSSNLastFour(this.props.walletAdditionalDetailsDraft.ssn)) { + // errors.ssn = true; + // } + // + // Wallet.setAdditionalDetailsErrors(errors); + // return _.size(errors) === 0; + return errors; } activateWallet() { @@ -348,7 +349,7 @@ export default compose( withCurrentUserPersonalDetails, withOnyx({ walletAdditionalDetails: { - key: ONYXKEYS.WALLET_ADDITIONAL_DETAILS, + key: ONYXKEYS.WALLET_ADDITIONAL_DETAILS_FORM, initWithStoredValues: false, }, }), From 1b3e04c2966c998e9562d9e92eecaaf5305094b1 Mon Sep 17 00:00:00 2001 From: joelbettner Date: Wed, 30 Nov 2022 17:54:17 -0700 Subject: [PATCH 013/189] Add other inputIDs --- src/pages/EnablePayments/AdditionalDetailsStep.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index a440b2871778..69f3865dfdff 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -88,7 +88,15 @@ const defaultProps = { ...withCurrentUserPersonalDetailsDefaultProps, }; -const INPUT_IDS = {LEGAL_FIRST_NAME: 'legalFirstName'}; +const INPUT_IDS = { + LEGAL_FIRST_NAME: 'legalFirstName', + LEGAL_LAST_NAME: 'legalLastName', + PHONE_NUMBER: 'phoneNumber', + DOB: 'dob', + AGE: 'age', + SSN: 'ssn', + SSN_FULL_9: 'ssnFull9', +}; class AdditionalDetailsStep extends React.Component { constructor(props) { From a53ba4bf96348800f318e11d78e6ce96262b3469 Mon Sep 17 00:00:00 2001 From: joelbettner Date: Wed, 30 Nov 2022 17:54:42 -0700 Subject: [PATCH 014/189] Save onyx draft to props --- src/pages/EnablePayments/AdditionalDetailsStep.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index 69f3865dfdff..fa29e0abbb9b 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -360,5 +360,8 @@ export default compose( key: ONYXKEYS.WALLET_ADDITIONAL_DETAILS_FORM, initWithStoredValues: false, }, + walletAdditionalDetailsDraft: { + key: 'walletAdditionalDetailsFormDraft', + }, }), )(AdditionalDetailsStep); From f00c9eed658deb33372b267bcd3be485a0148313 Mon Sep 17 00:00:00 2001 From: joelbettner Date: Wed, 30 Nov 2022 17:55:24 -0700 Subject: [PATCH 015/189] Use inputIDs in elements and save drafts of values --- src/pages/EnablePayments/AdditionalDetailsStep.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index fa29e0abbb9b..a373040dc7e6 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -295,10 +295,12 @@ class AdditionalDetailsStep extends React.Component { shouldSaveDraft /> From 9a2c97c92cdda0d4c2b7abe166d63c29a42904f7 Mon Sep 17 00:00:00 2001 From: joelbettner Date: Wed, 30 Nov 2022 17:55:59 -0700 Subject: [PATCH 016/189] Update some of the validation steps --- .../EnablePayments/AdditionalDetailsStep.js | 57 +++++++++---------- 1 file changed, 26 insertions(+), 31 deletions(-) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index a373040dc7e6..d10371f0363c 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -172,27 +172,24 @@ class AdditionalDetailsStep extends React.Component { * @returns {Boolean} */ validate() { - // Reset server error messages when resubmitting form - Wallet.setAdditionalDetailsErrorMessage(''); - const errors = {}; if (!this.getFirstName()) { - errors[INPUT_IDS.LEGAL_FIRST_NAME] = 'Invalid First Name'; + errors[INPUT_IDS.LEGAL_FIRST_NAME] = this.props.translate(this.errorTranslationKeys.legalFirstName); + } + + if (!this.getLastName()) { + errors[INPUT_IDS.LEGAL_LAST_NAME] = this.props.translate(this.errorTranslationKeys.legalLastName); + } + + if (!ValidationUtils.isValidPastDate(this.props.walletAdditionalDetailsDraft.dob)) { + errors[INPUT_IDS.DOB] = this.props.translate(this.errorTranslationKeys.dob); + } + + if (!ValidationUtils.meetsAgeRequirements(this.props.walletAdditionalDetailsDraft.dob)) { + errors[INPUT_IDS.AGE] = this.props.translate(this.errorTranslationKeys.age); } - // if (!this.getLastName()) { - // errors.legalLastName = true; - // } - // - // if (!ValidationUtils.isValidPastDate(this.props.walletAdditionalDetailsDraft.dob)) { - // errors.dob = true; - // } - // - // if (!ValidationUtils.meetsAgeRequirements(this.props.walletAdditionalDetailsDraft.dob)) { - // errors.age = true; - // } - // // if (!ValidationUtils.isValidAddress(this.props.walletAdditionalDetailsDraft.addressStreet)) { // errors.addressStreet = true; // } @@ -208,21 +205,19 @@ class AdditionalDetailsStep extends React.Component { // if (!ValidationUtils.isValidZipCode(this.props.walletAdditionalDetailsDraft.addressZip)) { // errors.addressZip = true; // } - // - // if (!ValidationUtils.isValidUSPhone(this.props.walletAdditionalDetailsDraft.phoneNumber, true)) { - // errors.phoneNumber = true; - // } - // - // if (this.props.walletAdditionalDetails.errorCode === CONST.WALLET.ERROR.SSN) { - // if (!ValidationUtils.isValidSSNFullNine(this.props.walletAdditionalDetailsDraft.ssn)) { - // errors.ssnFull9 = true; - // } - // } else if (!ValidationUtils.isValidSSNLastFour(this.props.walletAdditionalDetailsDraft.ssn)) { - // errors.ssn = true; - // } - // - // Wallet.setAdditionalDetailsErrors(errors); - // return _.size(errors) === 0; + + if (!ValidationUtils.isValidUSPhone(this.props.walletAdditionalDetailsDraft.phoneNumber, true)) { + errors[INPUT_IDS.PHONE_NUMBER] = this.props.translate(this.errorTranslationKeys.phoneNumber); + } + + if (this.props.walletAdditionalDetails.errorCode === CONST.WALLET.ERROR.SSN) { + if (!ValidationUtils.isValidSSNFullNine(this.props.walletAdditionalDetailsDraft.ssn)) { + errors[INPUT_IDS.SSN_FULL_9] = this.props.translate(this.errorTranslationKeys.ssnFull9); + } + } else if (!ValidationUtils.isValidSSNLastFour(this.props.walletAdditionalDetailsDraft.ssn)) { + errors[INPUT_IDS.SSN] = this.props.translate(this.errorTranslationKeys.ssn); + } + return errors; } From ab4691635224619b97efe725170a965004ae41f9 Mon Sep 17 00:00:00 2001 From: joelbettner Date: Wed, 30 Nov 2022 18:22:40 -0700 Subject: [PATCH 017/189] Use defaultValues for address --- src/pages/EnablePayments/AdditionalDetailsStep.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index d10371f0363c..5844ce261869 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -300,7 +300,7 @@ class AdditionalDetailsStep extends React.Component { Date: Wed, 30 Nov 2022 19:32:04 -0700 Subject: [PATCH 018/189] Add address inputIDs --- src/pages/EnablePayments/AdditionalDetailsStep.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index 5844ce261869..f2a3e30e18b2 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -96,6 +96,12 @@ const INPUT_IDS = { AGE: 'age', SSN: 'ssn', SSN_FULL_9: 'ssnFull9', + ADDRESS: { + street: 'addressStreet', + city: 'addressCity', + state: 'addressState', + zipCode: 'addressZip', + }, }; class AdditionalDetailsStep extends React.Component { From 325544a0d6cac8982abc43e2c1b76d86ca275366 Mon Sep 17 00:00:00 2001 From: joelbettner Date: Wed, 30 Nov 2022 19:32:34 -0700 Subject: [PATCH 019/189] Use better propType definition for addressForm errors --- src/pages/ReimbursementAccount/AddressForm.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pages/ReimbursementAccount/AddressForm.js b/src/pages/ReimbursementAccount/AddressForm.js index bccf706a16d9..a731952c9eed 100644 --- a/src/pages/ReimbursementAccount/AddressForm.js +++ b/src/pages/ReimbursementAccount/AddressForm.js @@ -46,7 +46,12 @@ const propTypes = { }), /** Any errors that can arise from form validation */ - errors: PropTypes.objectOf(PropTypes.bool), + errors: PropTypes.shape({ + street: PropTypes.bool, + city: PropTypes.bool, + state: PropTypes.bool, + zipCode: PropTypes.bool, + }), /** The map for inputID of the inputs */ inputKeys: PropTypes.shape({ From e16354576e3d29562a7783854889edc64ca3f455 Mon Sep 17 00:00:00 2001 From: joelbettner Date: Wed, 30 Nov 2022 19:33:02 -0700 Subject: [PATCH 020/189] Use passed values in validate --- .../EnablePayments/AdditionalDetailsStep.js | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index f2a3e30e18b2..913bb407a65b 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -177,10 +177,10 @@ class AdditionalDetailsStep extends React.Component { /** * @returns {Boolean} */ - validate() { + validate(values) { const errors = {}; - if (!this.getFirstName()) { + if (_.isEmpty(values[INPUT_IDS.LEGAL_FIRST_NAME])) { errors[INPUT_IDS.LEGAL_FIRST_NAME] = this.props.translate(this.errorTranslationKeys.legalFirstName); } @@ -188,39 +188,39 @@ class AdditionalDetailsStep extends React.Component { errors[INPUT_IDS.LEGAL_LAST_NAME] = this.props.translate(this.errorTranslationKeys.legalLastName); } - if (!ValidationUtils.isValidPastDate(this.props.walletAdditionalDetailsDraft.dob)) { + if (!ValidationUtils.isValidPastDate(values[INPUT_IDS.DOB])) { errors[INPUT_IDS.DOB] = this.props.translate(this.errorTranslationKeys.dob); } - if (!ValidationUtils.meetsAgeRequirements(this.props.walletAdditionalDetailsDraft.dob)) { + if (!ValidationUtils.meetsAgeRequirements(values[INPUT_IDS.DOB])) { errors[INPUT_IDS.AGE] = this.props.translate(this.errorTranslationKeys.age); } - // if (!ValidationUtils.isValidAddress(this.props.walletAdditionalDetailsDraft.addressStreet)) { - // errors.addressStreet = true; - // } - // - // if (_.isEmpty(this.props.walletAdditionalDetailsDraft.addressCity)) { - // errors.addressCity = true; - // } - // - // if (_.isEmpty(this.props.walletAdditionalDetailsDraft.addressState)) { - // errors.addressState = true; - // } - // - // if (!ValidationUtils.isValidZipCode(this.props.walletAdditionalDetailsDraft.addressZip)) { - // errors.addressZip = true; - // } - - if (!ValidationUtils.isValidUSPhone(this.props.walletAdditionalDetailsDraft.phoneNumber, true)) { + if (!ValidationUtils.isValidAddress(values[INPUT_IDS.ADDRESS.street])) { + errors[INPUT_IDS.ADDRESS.street] = this.props.translate('bankAccount.error.addressStreet'); + } + + if (_.isEmpty(values[INPUT_IDS.ADDRESS.city])) { + errors[INPUT_IDS.ADDRESS.city] = this.props.translate('bankAccount.error.addressCity'); + } + + if (_.isEmpty(values[INPUT_IDS.ADDRESS.state])) { + errors[INPUT_IDS.ADDRESS.state] = this.props.translate('bankAccount.error.addressState'); + } + + if (!ValidationUtils.isValidZipCode(values[INPUT_IDS.ADDRESS.addressZip])) { + errors[INPUT_IDS.ADDRESS.zipCode] = this.props.translate('bankAccount.error.zipCode'); + } + + if (!ValidationUtils.isValidUSPhone(values[INPUT_IDS.PHONE_NUMBER], true)) { errors[INPUT_IDS.PHONE_NUMBER] = this.props.translate(this.errorTranslationKeys.phoneNumber); } if (this.props.walletAdditionalDetails.errorCode === CONST.WALLET.ERROR.SSN) { - if (!ValidationUtils.isValidSSNFullNine(this.props.walletAdditionalDetailsDraft.ssn)) { + if (!ValidationUtils.isValidSSNFullNine(values[INPUT_IDS.SSN])) { errors[INPUT_IDS.SSN_FULL_9] = this.props.translate(this.errorTranslationKeys.ssnFull9); } - } else if (!ValidationUtils.isValidSSNLastFour(this.props.walletAdditionalDetailsDraft.ssn)) { + } else if (!ValidationUtils.isValidSSNLastFour(values[INPUT_IDS.SSN])) { errors[INPUT_IDS.SSN] = this.props.translate(this.errorTranslationKeys.ssn); } From d90272266af4d04ff14a68dfce3ce988ec201f8f Mon Sep 17 00:00:00 2001 From: joelbettner Date: Wed, 30 Nov 2022 19:33:23 -0700 Subject: [PATCH 021/189] Delete unused variables --- src/pages/EnablePayments/AdditionalDetailsStep.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index 913bb407a65b..b68a72016e96 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -257,9 +257,6 @@ class AdditionalDetailsStep extends React.Component { ); } - - const errorMessage = ErrorUtils.getLatestErrorMessage(this.props.walletAdditionalDetails) || ''; - const isErrorVisible = _.size(this.getErrors()) > 0 || Boolean(errorMessage); const shouldAskForFullSSN = this.props.walletAdditionalDetails.errorCode === CONST.WALLET.ERROR.SSN; return ( From f2521a7f6d2c7d77da3d446464d19601226f0f08 Mon Sep 17 00:00:00 2001 From: joelbettner Date: Wed, 30 Nov 2022 19:33:48 -0700 Subject: [PATCH 022/189] Do not save a draft of SSN number --- src/pages/EnablePayments/AdditionalDetailsStep.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index b68a72016e96..7174c807eeaa 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -345,7 +345,6 @@ class AdditionalDetailsStep extends React.Component { errorText={this.getErrorText('ssnFull9') || this.getErrorText('ssn')} maxLength={shouldAskForFullSSN ? 9 : 4} keyboardType={CONST.KEYBOARD_TYPE.NUMBER_PAD} - shouldSaveDraft // I thought we weren't supposed to save drafts of SSNs or passwords... /> From 8ee48dfb61fd11a7cadf9c79c80bd82946124a8f Mon Sep 17 00:00:00 2001 From: joelbettner Date: Wed, 30 Nov 2022 19:34:29 -0700 Subject: [PATCH 023/189] Do not save walletAdditionalDetailsFormDraft onyx object to walletAdditionalDetailsDraft prop --- src/pages/EnablePayments/AdditionalDetailsStep.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index 7174c807eeaa..faffb9e565d0 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -365,8 +365,5 @@ export default compose( key: ONYXKEYS.WALLET_ADDITIONAL_DETAILS_FORM, initWithStoredValues: false, }, - walletAdditionalDetailsDraft: { - key: 'walletAdditionalDetailsFormDraft', - }, }), )(AdditionalDetailsStep); From 7b1a7eb20a8890ac210ed1a8d08ca1cc0eff32f3 Mon Sep 17 00:00:00 2001 From: joelbettner Date: Wed, 30 Nov 2022 19:35:35 -0700 Subject: [PATCH 024/189] Set address for imputKeys, and let the errors populate correctly --- src/pages/EnablePayments/AdditionalDetailsStep.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index faffb9e565d0..e1d52626994e 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -301,6 +301,7 @@ class AdditionalDetailsStep extends React.Component { shouldSaveDraft /> Date: Wed, 30 Nov 2022 20:03:04 -0700 Subject: [PATCH 025/189] Update getFirstName, getLastName, and getPhoneNumber and get rid of default values that aren't necessary --- .../EnablePayments/AdditionalDetailsStep.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index e1d52626994e..8302a81ee939 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -139,13 +139,15 @@ class AdditionalDetailsStep extends React.Component { } getFirstName() { - const {firstName} = PersonalDetails.extractFirstAndLastNameFromAvailableDetails(this.props.currentUserPersonalDetails); - return this.props.walletAdditionalDetailsDraft.legalFirstName || firstName; + return PersonalDetails.extractFirstAndLastNameFromAvailableDetails(this.props.currentUserPersonalDetails).firstName; } getLastName() { - const {lastName} = PersonalDetails.extractFirstAndLastNameFromAvailableDetails(this.props.currentUserPersonalDetails); - return this.props.walletAdditionalDetailsDraft.legalLastName || lastName; + return PersonalDetails.extractFirstAndLastNameFromAvailableDetails(this.props.currentUserPersonalDetails).lastName; + } + + getPhoneNumber() { + return this.props.currentUserPersonalDetails.phoneNumber; } /** @@ -175,7 +177,8 @@ class AdditionalDetailsStep extends React.Component { } /** - * @returns {Boolean} + * @param {Object} values The values object is passed from Form.js and contains info for each form element that has an inputID + * @returns {Object} */ validate(values) { const errors = {}; @@ -318,7 +321,7 @@ class AdditionalDetailsStep extends React.Component { containerStyles={[styles.mt4]} keyboardType={CONST.KEYBOARD_TYPE.PHONE_PAD} label={this.props.translate(this.fieldNameTranslationKeys.phoneNumber)} - defaultValue={this.props.walletAdditionalDetailsDraft.phoneNumber || ''} + defaultValue={this.getPhoneNumber()} placeholder={this.props.translate('common.phoneNumberPlaceholder')} errorText={this.getErrorText('phoneNumber')} shouldSaveDraft @@ -327,7 +330,6 @@ class AdditionalDetailsStep extends React.Component { inputID={INPUT_IDS.DOB} containerStyles={[styles.mt4]} label={this.props.translate(this.fieldNameTranslationKeys.dob)} - defaultValue={this.props.walletAdditionalDetailsDraft.dob || ''} placeholder={this.props.translate('common.dob')} errorText={this.getErrorText('dob') || this.getErrorText('age')} maximumDate={new Date()} @@ -337,7 +339,6 @@ class AdditionalDetailsStep extends React.Component { inputID={INPUT_IDS.SSN} containerStyles={[styles.mt4]} label={this.props.translate(this.fieldNameTranslationKeys[shouldAskForFullSSN ? 'ssnFull9' : 'ssn'])} - defaultValue={this.props.walletAdditionalDetailsDraft.ssn || ''} errorText={this.getErrorText('ssnFull9') || this.getErrorText('ssn')} maxLength={shouldAskForFullSSN ? 9 : 4} keyboardType={CONST.KEYBOARD_TYPE.NUMBER_PAD} From 4aa4572539359cb65e18d38f220cc6ccae8d6eb6 Mon Sep 17 00:00:00 2001 From: joelbettner Date: Wed, 30 Nov 2022 20:04:51 -0700 Subject: [PATCH 026/189] Remove unnecessary default values for address --- src/pages/EnablePayments/AdditionalDetailsStep.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index 8302a81ee939..ab054d89a807 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -307,12 +307,6 @@ class AdditionalDetailsStep extends React.Component { inputKeys={INPUT_IDS.ADDRESS} translate={this.props.translate} streetTranslationKey={this.fieldNameTranslationKeys.addressStreet} - defaultValues={{ - street: this.props.walletAdditionalDetailsDraft.addressStreet, - state: this.props.walletAdditionalDetailsDraft.addressState, - city: this.props.walletAdditionalDetailsDraft.addressCity, - zipCode: this.props.walletAdditionalDetailsDraft.addressZip, - }} shouldSaveDraft /> From 2666df69b44a990ec529790dd18bfc45bab79274 Mon Sep 17 00:00:00 2001 From: joelbettner Date: Wed, 30 Nov 2022 20:08:35 -0700 Subject: [PATCH 027/189] Fix typo --- src/pages/EnablePayments/AdditionalDetailsStep.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index ab054d89a807..463c9ec0fb04 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -211,7 +211,7 @@ class AdditionalDetailsStep extends React.Component { errors[INPUT_IDS.ADDRESS.state] = this.props.translate('bankAccount.error.addressState'); } - if (!ValidationUtils.isValidZipCode(values[INPUT_IDS.ADDRESS.addressZip])) { + if (!ValidationUtils.isValidZipCode(values[INPUT_IDS.ADDRESS.zipCode])) { errors[INPUT_IDS.ADDRESS.zipCode] = this.props.translate('bankAccount.error.zipCode'); } From 400b672d6a4475ca57cd81a60342c0850a939c26 Mon Sep 17 00:00:00 2001 From: joelbettner Date: Wed, 30 Nov 2022 20:12:35 -0700 Subject: [PATCH 028/189] Validate last name correctly --- src/pages/EnablePayments/AdditionalDetailsStep.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index 463c9ec0fb04..3f900efd125f 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -187,7 +187,7 @@ class AdditionalDetailsStep extends React.Component { errors[INPUT_IDS.LEGAL_FIRST_NAME] = this.props.translate(this.errorTranslationKeys.legalFirstName); } - if (!this.getLastName()) { + if (_.isEmpty(values[INPUT_IDS.LEGAL_LAST_NAME])) { errors[INPUT_IDS.LEGAL_LAST_NAME] = this.props.translate(this.errorTranslationKeys.legalLastName); } From 9b10dcbe436a0a98cdbbfeb1714389577f724b8f Mon Sep 17 00:00:00 2001 From: joelbettner Date: Wed, 30 Nov 2022 20:14:37 -0700 Subject: [PATCH 029/189] Remove unnecessary getErrorText and errorText props --- .../EnablePayments/AdditionalDetailsStep.js | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index 3f900efd125f..ac91a60ec1ec 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -157,18 +157,6 @@ class AdditionalDetailsStep extends React.Component { return this.formHelper.getErrors(this.props); } - /** - * @param {String} fieldName - * @returns {String} - */ - getErrorText(fieldName) { - if (!this.getErrors()[fieldName]) { - return ''; - } - - return this.props.translate(this.errorTranslationKeys[fieldName]); - } - /** * @param {String} path */ @@ -292,7 +280,6 @@ class AdditionalDetailsStep extends React.Component { containerStyles={[styles.mt4]} label={this.props.translate(this.fieldNameTranslationKeys.legalFirstName)} defaultValue={this.getFirstName()} - errorText={this.getErrorText('legalFirstName')} shouldSaveDraft /> @@ -333,7 +317,6 @@ class AdditionalDetailsStep extends React.Component { inputID={INPUT_IDS.SSN} containerStyles={[styles.mt4]} label={this.props.translate(this.fieldNameTranslationKeys[shouldAskForFullSSN ? 'ssnFull9' : 'ssn'])} - errorText={this.getErrorText('ssnFull9') || this.getErrorText('ssn')} maxLength={shouldAskForFullSSN ? 9 : 4} keyboardType={CONST.KEYBOARD_TYPE.NUMBER_PAD} /> From b2ad981117b50c2cc7e0db375c2bf1a9568c47de Mon Sep 17 00:00:00 2001 From: joelbettner Date: Wed, 30 Nov 2022 20:15:07 -0700 Subject: [PATCH 030/189] Remove unused clearError --- src/pages/EnablePayments/AdditionalDetailsStep.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index ac91a60ec1ec..8ab041163f75 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -157,13 +157,6 @@ class AdditionalDetailsStep extends React.Component { return this.formHelper.getErrors(this.props); } - /** - * @param {String} path - */ - clearError(path) { - this.formHelper.clearError(this.props, path); - } - /** * @param {Object} values The values object is passed from Form.js and contains info for each form element that has an inputID * @returns {Object} From 3d5f02311913e5ae9ed963ffccb420fd8a3dd967 Mon Sep 17 00:00:00 2001 From: joelbettner Date: Wed, 30 Nov 2022 20:15:34 -0700 Subject: [PATCH 031/189] Remove unused getErrors --- src/pages/EnablePayments/AdditionalDetailsStep.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index 8ab041163f75..ad3fc46a1ef2 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -150,13 +150,6 @@ class AdditionalDetailsStep extends React.Component { return this.props.currentUserPersonalDetails.phoneNumber; } - /** - * @returns {Object} - */ - getErrors() { - return this.formHelper.getErrors(this.props); - } - /** * @param {Object} values The values object is passed from Form.js and contains info for each form element that has an inputID * @returns {Object} From c2b9d621a49438f71a3512eae108f99334e53d25 Mon Sep 17 00:00:00 2001 From: joelbettner Date: Wed, 30 Nov 2022 20:16:20 -0700 Subject: [PATCH 032/189] Remove unused formHelper --- src/pages/EnablePayments/AdditionalDetailsStep.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index ad3fc46a1ef2..78009aafeaa6 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -25,7 +25,6 @@ import * as LoginUtils from '../../libs/LoginUtils'; import AddressForm from '../ReimbursementAccount/AddressForm'; import DatePicker from '../../components/DatePicker'; import Form from '../../components/Form'; -import FormHelper from '../../libs/FormHelper'; import walletAdditionalDetailsDraftPropTypes from './walletAdditionalDetailsDraftPropTypes'; import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsPropTypes, withCurrentUserPersonalDetailsDefaultProps} from '../../components/withCurrentUserPersonalDetails'; import * as PersonalDetails from '../../libs/actions/PersonalDetails'; @@ -130,11 +129,6 @@ class AdditionalDetailsStep extends React.Component { ssnFull9: 'common.ssnFull9', }; - this.formHelper = new FormHelper({ - errorPath: 'walletAdditionalDetails.errorFields', - setErrors: Wallet.setAdditionalDetailsErrors, - }); - this.validate = this.validate.bind(this); } From f2914eb357d65f5df1c3cbfcc4059cdbf6509d44 Mon Sep 17 00:00:00 2001 From: joelbettner Date: Wed, 30 Nov 2022 20:18:56 -0700 Subject: [PATCH 033/189] Remove unused imports --- .../EnablePayments/AdditionalDetailsStep.js | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index 78009aafeaa6..0b4c41f7f0d0 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -1,10 +1,8 @@ -import lodashGet from 'lodash/get'; import _ from 'underscore'; import React from 'react'; import PropTypes from 'prop-types'; import {withOnyx} from 'react-native-onyx'; import {View} from 'react-native'; -import moment from 'moment'; import IdologyQuestions from './IdologyQuestions'; import ScreenWrapper from '../../components/ScreenWrapper'; import HeaderWithCloseButton from '../../components/HeaderWithCloseButton'; @@ -17,8 +15,6 @@ import compose from '../../libs/compose'; import ONYXKEYS from '../../ONYXKEYS'; import TextLink from '../../components/TextLink'; import TextInput from '../../components/TextInput'; -import FormScrollView from '../../components/FormScrollView'; -import FormAlertWithSubmitButton from '../../components/FormAlertWithSubmitButton'; import * as Wallet from '../../libs/actions/Wallet'; import * as ValidationUtils from '../../libs/ValidationUtils'; import * as LoginUtils from '../../libs/LoginUtils'; @@ -29,7 +25,6 @@ import walletAdditionalDetailsDraftPropTypes from './walletAdditionalDetailsDraf import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsPropTypes, withCurrentUserPersonalDetailsDefaultProps} from '../../components/withCurrentUserPersonalDetails'; import * as PersonalDetails from '../../libs/actions/PersonalDetails'; import OfflineIndicator from '../../components/OfflineIndicator'; -import * as ErrorUtils from '../../libs/ErrorUtils'; const propTypes = { ...withLocalizePropTypes, @@ -73,17 +68,6 @@ const defaultProps = { idNumber: '', errorCode: '', }, - walletAdditionalDetailsDraft: { - legalFirstName: '', - legalLastName: '', - addressStreet: '', - addressCity: '', - addressState: '', - addressZip: '', - phoneNumber: '', - dob: '', - ssn: '', - }, ...withCurrentUserPersonalDetailsDefaultProps, }; From 98e4354fc056c1b9877ba6200073fee1af04a527 Mon Sep 17 00:00:00 2001 From: joelbettner Date: Wed, 30 Nov 2022 20:33:07 -0700 Subject: [PATCH 034/189] Pass values to activateWallet correctly --- src/pages/EnablePayments/AdditionalDetailsStep.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index 0b4c41f7f0d0..a6ab8559e628 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -182,15 +182,20 @@ class AdditionalDetailsStep extends React.Component { return errors; } - activateWallet() { + activateWallet(values) { if (!this.validate()) { return; } const personalDetails = { - ...this.props.walletAdditionalDetailsDraft, - phoneNumber: LoginUtils.getPhoneNumberWithoutUSCountryCodeAndSpecialChars(this.props.walletAdditionalDetailsDraft.phoneNumber), - legalFirstName: this.getFirstName(), - legalLastName: this.getLastName(), + phoneNumber: LoginUtils.getPhoneNumberWithoutUSCountryCodeAndSpecialChars(values[INPUT_IDS.PHONE_NUMBER]), + legalFirstName: values[INPUT_IDS.LEGAL_FIRST_NAME], + legalLastName: values[INPUT_IDS.LEGAL_LAST_NAME], + addressStreet: values[INPUT_IDS.ADDRESS.street], + addressCity: values[INPUT_IDS.ADDRESS.city], + addressState: values[INPUT_IDS.ADDRESS.state], + addressZip: values[INPUT_IDS.ADDRESS.zipCode], + dob: values[INPUT_IDS.DOB], + ssn: values[INPUT_IDS.SSN], }; Wallet.updatePersonalDetails(personalDetails); } From d1a4e4d3be8afe8efb43d3edb223514d8ad012df Mon Sep 17 00:00:00 2001 From: joelbettner Date: Wed, 30 Nov 2022 20:33:59 -0700 Subject: [PATCH 035/189] Update documentation --- src/pages/EnablePayments/AdditionalDetailsStep.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index a6ab8559e628..06e1c43658f6 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -182,6 +182,9 @@ class AdditionalDetailsStep extends React.Component { return errors; } + /** + * @param {Object} values The values object is passed from Form.js and contains info for each form element that has an inputID + */ activateWallet(values) { if (!this.validate()) { return; From af7b892780d4b58832fd5102ef5e8ad0f2b0e656 Mon Sep 17 00:00:00 2001 From: joelbettner Date: Wed, 30 Nov 2022 20:38:20 -0700 Subject: [PATCH 036/189] Remove unused walletAdditionalDetailsDraft prop type definition --- src/pages/EnablePayments/AdditionalDetailsStep.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index 06e1c43658f6..b74940bfd7d1 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -21,7 +21,6 @@ import * as LoginUtils from '../../libs/LoginUtils'; import AddressForm from '../ReimbursementAccount/AddressForm'; import DatePicker from '../../components/DatePicker'; import Form from '../../components/Form'; -import walletAdditionalDetailsDraftPropTypes from './walletAdditionalDetailsDraftPropTypes'; import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsPropTypes, withCurrentUserPersonalDetailsDefaultProps} from '../../components/withCurrentUserPersonalDetails'; import * as PersonalDetails from '../../libs/actions/PersonalDetails'; import OfflineIndicator from '../../components/OfflineIndicator'; @@ -54,9 +53,6 @@ const propTypes = { /** Error code to determine additional behavior */ errorCode: PropTypes.string, }), - - /** Stores the personal details typed by the user */ - walletAdditionalDetailsDraft: walletAdditionalDetailsDraftPropTypes, }; const defaultProps = { From 6b15a96f892a2e85f25092fbfedb82c62b3e3089 Mon Sep 17 00:00:00 2001 From: joelbettner Date: Wed, 30 Nov 2022 20:53:06 -0700 Subject: [PATCH 037/189] Fixing age and 9 digit ssn errors --- src/pages/EnablePayments/AdditionalDetailsStep.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index b74940bfd7d1..ef677736f861 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -72,9 +72,7 @@ const INPUT_IDS = { LEGAL_LAST_NAME: 'legalLastName', PHONE_NUMBER: 'phoneNumber', DOB: 'dob', - AGE: 'age', SSN: 'ssn', - SSN_FULL_9: 'ssnFull9', ADDRESS: { street: 'addressStreet', city: 'addressCity', @@ -88,6 +86,7 @@ class AdditionalDetailsStep extends React.Component { super(props); this.activateWallet = this.activateWallet.bind(this); + this.validate = this.validate.bind(this); this.errorTranslationKeys = { legalFirstName: 'bankAccount.error.firstName', @@ -108,8 +107,6 @@ class AdditionalDetailsStep extends React.Component { ssn: 'common.ssnLast4', ssnFull9: 'common.ssnFull9', }; - - this.validate = this.validate.bind(this); } getFirstName() { @@ -144,7 +141,7 @@ class AdditionalDetailsStep extends React.Component { } if (!ValidationUtils.meetsAgeRequirements(values[INPUT_IDS.DOB])) { - errors[INPUT_IDS.AGE] = this.props.translate(this.errorTranslationKeys.age); + errors[INPUT_IDS.DOB] = this.props.translate(this.errorTranslationKeys.age); } if (!ValidationUtils.isValidAddress(values[INPUT_IDS.ADDRESS.street])) { @@ -169,7 +166,7 @@ class AdditionalDetailsStep extends React.Component { if (this.props.walletAdditionalDetails.errorCode === CONST.WALLET.ERROR.SSN) { if (!ValidationUtils.isValidSSNFullNine(values[INPUT_IDS.SSN])) { - errors[INPUT_IDS.SSN_FULL_9] = this.props.translate(this.errorTranslationKeys.ssnFull9); + errors[INPUT_IDS.SSN] = this.props.translate(this.errorTranslationKeys.ssnFull9); } } else if (!ValidationUtils.isValidSSNLastFour(values[INPUT_IDS.SSN])) { errors[INPUT_IDS.SSN] = this.props.translate(this.errorTranslationKeys.ssn); From 6023879d2f3cb3aa68aa8dcc175db7455438c4f6 Mon Sep 17 00:00:00 2001 From: b1tjoy <103875612+b1tjoy@users.noreply.github.com> Date: Thu, 1 Dec 2022 12:04:02 +0800 Subject: [PATCH 038/189] put onPressIn and onPressOut after props spreading --- src/components/AnchorForCommentsOnly/index.js | 5 ++--- .../HTMLEngineProvider/HTMLRenderers/PreRenderer/index.js | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/components/AnchorForCommentsOnly/index.js b/src/components/AnchorForCommentsOnly/index.js index 88010285a09d..c8c3b6a54321 100644 --- a/src/components/AnchorForCommentsOnly/index.js +++ b/src/components/AnchorForCommentsOnly/index.js @@ -1,5 +1,4 @@ import React from 'react'; -import _ from 'underscore'; import {propTypes as anchorForCommentsOnlyPropTypes, defaultProps} from './anchorForCommentsOnlyPropTypes'; import BaseAnchorForCommentsOnly from './BaseAnchorForCommentsOnly'; import canUseTouchScreen from '../../libs/canUseTouchscreen'; @@ -13,10 +12,10 @@ const propTypes = { const AnchorForCommentsOnly = props => ( props.isSmallScreenWidth && canUseTouchScreen() && ControlSelection.block()} onPressOut={() => ControlSelection.unblock()} - // eslint-disable-next-line react/jsx-props-no-spreading - {...(_.omit(props, ['onPressIn', 'onPressOut']))} /> ); diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer/index.js b/src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer/index.js index e8043491352e..3b2d50b0beda 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer/index.js +++ b/src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer/index.js @@ -64,11 +64,11 @@ class PreRenderer extends React.Component { render() { return ( this.props.isSmallScreenWidth && canUseTouchScreen() && ControlSelection.block()} - onPressOut={() => ControlSelection.unblock()} // eslint-disable-next-line react/jsx-props-no-spreading {...this.props} ref={el => this.ref = el} + onPressIn={() => this.props.isSmallScreenWidth && canUseTouchScreen() && ControlSelection.block()} + onPressOut={() => ControlSelection.unblock()} /> ); } From dac640e0447caec00211b722e9ab4be386a4853a Mon Sep 17 00:00:00 2001 From: joelbettner Date: Thu, 1 Dec 2022 09:27:42 -0700 Subject: [PATCH 039/189] Make sure values get sent to validate when activateWallet is called --- src/pages/EnablePayments/AdditionalDetailsStep.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index ef677736f861..de86d891f195 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -179,7 +179,7 @@ class AdditionalDetailsStep extends React.Component { * @param {Object} values The values object is passed from Form.js and contains info for each form element that has an inputID */ activateWallet(values) { - if (!this.validate()) { + if (!this.validate(values)) { return; } const personalDetails = { From 2ead055798a5ad4fb340310310fcd7112902171d Mon Sep 17 00:00:00 2001 From: joelbettner Date: Thu, 1 Dec 2022 10:54:07 -0700 Subject: [PATCH 040/189] Do not use FORM key for walletAdditionalDetails prop --- src/pages/EnablePayments/AdditionalDetailsStep.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index de86d891f195..157d684caf96 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -301,7 +301,7 @@ export default compose( withCurrentUserPersonalDetails, withOnyx({ walletAdditionalDetails: { - key: ONYXKEYS.WALLET_ADDITIONAL_DETAILS_FORM, + key: ONYXKEYS.WALLET_ADDITIONAL_DETAILS, initWithStoredValues: false, }, }), From d08cb591b114668a5214d56f71881dd3fcf0948d Mon Sep 17 00:00:00 2001 From: joelbettner Date: Thu, 1 Dec 2022 11:32:56 -0700 Subject: [PATCH 041/189] Do not pass unnecessary prop to AdditionalDetailsStep --- src/pages/EnablePayments/EnablePaymentsPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/EnablePayments/EnablePaymentsPage.js b/src/pages/EnablePayments/EnablePaymentsPage.js index 1559e3b0f030..b2d15b918e94 100644 --- a/src/pages/EnablePayments/EnablePaymentsPage.js +++ b/src/pages/EnablePayments/EnablePaymentsPage.js @@ -78,7 +78,7 @@ class EnablePaymentsPage extends React.Component { return ( <> {(currentStep === CONST.WALLET.STEP.ADDITIONAL_DETAILS || currentStep === CONST.WALLET.STEP.ADDITIONAL_DETAILS_KBA) - && } + && } {currentStep === CONST.WALLET.STEP.ONFIDO && this.props.walletAdditionalDetailsDraft && } {currentStep === CONST.WALLET.STEP.TERMS && } From a7e10777913a1f105fa85b0bc4685168ac7362a0 Mon Sep 17 00:00:00 2001 From: Jack Nam Date: Thu, 1 Dec 2022 12:37:07 -0800 Subject: [PATCH 042/189] kill sequence number --- src/libs/ReportUtils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index ba52c58a2772..6766f9658e4a 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -865,8 +865,9 @@ function buildOptimisticChatReport( * @returns {Object} */ function buildOptimisticCreatedReportAction(ownerEmail) { + const reportActionID = NumberUtils.rand64(); return { - 0: { + [reportActionID]: { actionName: CONST.REPORT.ACTIONS.TYPE.CREATED, pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, actorAccountID: currentUserAccountID, @@ -890,7 +891,6 @@ function buildOptimisticCreatedReportAction(ownerEmail) { }, ], automatic: false, - sequenceNumber: 0, avatar: lodashGet(allPersonalDetails, [currentUserEmail, 'avatar'], getDefaultAvatar(currentUserEmail)), created: DateUtils.getDBTime(), shouldShow: true, From 7fc0831f1d10f41f06bca37e10ba0b89de5e3151 Mon Sep 17 00:00:00 2001 From: joelbettner Date: Thu, 1 Dec 2022 14:32:08 -0700 Subject: [PATCH 043/189] Remove unnecessary validate from activateWallet --- src/pages/EnablePayments/AdditionalDetailsStep.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index 157d684caf96..69975823ff72 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -179,9 +179,6 @@ class AdditionalDetailsStep extends React.Component { * @param {Object} values The values object is passed from Form.js and contains info for each form element that has an inputID */ activateWallet(values) { - if (!this.validate(values)) { - return; - } const personalDetails = { phoneNumber: LoginUtils.getPhoneNumberWithoutUSCountryCodeAndSpecialChars(values[INPUT_IDS.PHONE_NUMBER]), legalFirstName: values[INPUT_IDS.LEGAL_FIRST_NAME], From a63dfce0c17fd1716b55fae3acb5a4cc15c7f4eb Mon Sep 17 00:00:00 2001 From: joelbettner Date: Thu, 1 Dec 2022 14:32:57 -0700 Subject: [PATCH 044/189] Validating inputs when component updates --- src/components/Form.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/components/Form.js b/src/components/Form.js index 34199bd4f443..135ff1fca687 100644 --- a/src/components/Form.js +++ b/src/components/Form.js @@ -85,6 +85,11 @@ class Form extends React.Component { this.submit = this.submit.bind(this); } + componentDidUpdate(prevProps) { + // Run the validate method when the component updates to display any possible server errors. + this.validate(this.state.inputValues); + } + /** * @param {String} inputID - The inputID of the input being touched */ From 40bc5fc77e1ae64be2cbb39b811d4b05a19ae005 Mon Sep 17 00:00:00 2001 From: joelbettner Date: Thu, 1 Dec 2022 16:07:17 -0700 Subject: [PATCH 045/189] Getting the error message to display when it is not recognized --- src/pages/EnablePayments/AdditionalDetailsStep.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index 69975823ff72..a4ede55e3517 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -167,6 +167,13 @@ class AdditionalDetailsStep extends React.Component { if (this.props.walletAdditionalDetails.errorCode === CONST.WALLET.ERROR.SSN) { if (!ValidationUtils.isValidSSNFullNine(values[INPUT_IDS.SSN])) { errors[INPUT_IDS.SSN] = this.props.translate(this.errorTranslationKeys.ssnFull9); + } else { + const errorsObject = this.props.walletAdditionalDetails.errors; + if (!_.isEmpty(errorsObject)) { + // Get the first element of the errors object. + const elementKey = _.keys(errorsObject)[0]; + errors[INPUT_IDS.SSN] = this.props.walletAdditionalDetails.errors[elementKey]; + } } } else if (!ValidationUtils.isValidSSNLastFour(values[INPUT_IDS.SSN])) { errors[INPUT_IDS.SSN] = this.props.translate(this.errorTranslationKeys.ssn); From c56716cbb28a15936a574811c73f43206d53a611 Mon Sep 17 00:00:00 2001 From: joelbettner Date: Thu, 1 Dec 2022 16:40:51 -0700 Subject: [PATCH 046/189] Make sure we default to the correct error message --- src/pages/EnablePayments/AdditionalDetailsStep.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index a4ede55e3517..f47bb7be8d42 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -164,15 +164,19 @@ class AdditionalDetailsStep extends React.Component { errors[INPUT_IDS.PHONE_NUMBER] = this.props.translate(this.errorTranslationKeys.phoneNumber); } + // this.props.walletAdditionalDetails stores errors returned by the server. If the server returns an SSN error + // then the user needs to provide the full 9 digit SSN. if (this.props.walletAdditionalDetails.errorCode === CONST.WALLET.ERROR.SSN) { if (!ValidationUtils.isValidSSNFullNine(values[INPUT_IDS.SSN])) { errors[INPUT_IDS.SSN] = this.props.translate(this.errorTranslationKeys.ssnFull9); } else { const errorsObject = this.props.walletAdditionalDetails.errors; if (!_.isEmpty(errorsObject)) { - // Get the first element of the errors object. const elementKey = _.keys(errorsObject)[0]; - errors[INPUT_IDS.SSN] = this.props.walletAdditionalDetails.errors[elementKey]; + if (this.props.walletAdditionalDetails.errors[elementKey] !== 'We\'re having trouble verifying your SSN. Please enter the full 9 digits of your SSN.') { + // Get the first element of the errors object. + errors[INPUT_IDS.SSN] = this.props.walletAdditionalDetails.errors[elementKey]; + } } } } else if (!ValidationUtils.isValidSSNLastFour(values[INPUT_IDS.SSN])) { From 1528554c23331fb7380260bd3a5ab3f6dd44424a Mon Sep 17 00:00:00 2001 From: joelbettner Date: Thu, 1 Dec 2022 16:41:16 -0700 Subject: [PATCH 047/189] Make sure we clear the server errors before making a call to the server again --- src/pages/EnablePayments/AdditionalDetailsStep.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index f47bb7be8d42..d2da6a9ec964 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -24,6 +24,7 @@ import Form from '../../components/Form'; import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsPropTypes, withCurrentUserPersonalDetailsDefaultProps} from '../../components/withCurrentUserPersonalDetails'; import * as PersonalDetails from '../../libs/actions/PersonalDetails'; import OfflineIndicator from '../../components/OfflineIndicator'; +import * as FormActions from '../../libs/actions/FormActions'; const propTypes = { ...withLocalizePropTypes, @@ -201,6 +202,12 @@ class AdditionalDetailsStep extends React.Component { dob: values[INPUT_IDS.DOB], ssn: values[INPUT_IDS.SSN], }; + + // Clear any errors that were sent by the server. + FormActions.setErrors(ONYXKEYS.WALLET_ADDITIONAL_DETAILS, null); + FormActions.setErrorFields(ONYXKEYS.WALLET_ADDITIONAL_DETAILS, null); + + // Attempt to set the personal details Wallet.updatePersonalDetails(personalDetails); } From 0642563d6a280fecb1393cde19d1babe60fc5ea0 Mon Sep 17 00:00:00 2001 From: joelbettner Date: Thu, 1 Dec 2022 16:46:55 -0700 Subject: [PATCH 048/189] Make sure we only display the error message if it is a string --- src/pages/EnablePayments/AdditionalDetailsStep.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index d2da6a9ec964..c3c4268e99a9 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -175,8 +175,12 @@ class AdditionalDetailsStep extends React.Component { if (!_.isEmpty(errorsObject)) { const elementKey = _.keys(errorsObject)[0]; if (this.props.walletAdditionalDetails.errors[elementKey] !== 'We\'re having trouble verifying your SSN. Please enter the full 9 digits of your SSN.') { - // Get the first element of the errors object. - errors[INPUT_IDS.SSN] = this.props.walletAdditionalDetails.errors[elementKey]; + if (typeof this.props.walletAdditionalDetails.errors[elementKey] === 'string') { + // Get the first element of the errors object. + errors[INPUT_IDS.SSN] = this.props.walletAdditionalDetails.errors[elementKey]; + } else { + errors[INPUT_IDS.SSN] = 'There was an error'; + } } } } From 4f5325980fc4cf60f44ad1b744417921f8941d2e Mon Sep 17 00:00:00 2001 From: joelbettner Date: Thu, 1 Dec 2022 17:01:16 -0700 Subject: [PATCH 049/189] Make sure the walletAdditionalDetailsDraft object gets set because it is used across multiple forms --- src/pages/EnablePayments/AdditionalDetailsStep.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index c3c4268e99a9..5487c2a89028 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -188,6 +188,10 @@ class AdditionalDetailsStep extends React.Component { errors[INPUT_IDS.SSN] = this.props.translate(this.errorTranslationKeys.ssn); } + // We need to make sure the draft values from the form are saved to the draft Wallet Additional Details Onyx + // object because the draft Wallet Additional Details Onyx object is populated by several forms in several steps. + FormActions.setDraftValues(ONYXKEYS.WALLET_ADDITIONAL_DETAILS, this.props.walletAdditionalDetailsDraft); + return errors; } @@ -323,5 +327,8 @@ export default compose( key: ONYXKEYS.WALLET_ADDITIONAL_DETAILS, initWithStoredValues: false, }, + walletAdditionalDetailsDraft: { + key: `${ONYXKEYS.FORMS.WALLET_ADDITIONAL_DETAILS_FORM}Draft`, + }, }), )(AdditionalDetailsStep); From 2b51063c9593314dcc478a88238eb642a336c5b3 Mon Sep 17 00:00:00 2001 From: Jack Nam Date: Thu, 1 Dec 2022 17:01:05 -0800 Subject: [PATCH 050/189] add details to pass in createdReportActionID --- src/libs/ReportUtils.js | 7 +++++++ src/libs/actions/Policy.js | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 6766f9658e4a..4b83622cac8f 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -893,6 +893,7 @@ function buildOptimisticCreatedReportAction(ownerEmail) { automatic: false, avatar: lodashGet(allPersonalDetails, [currentUserEmail, 'avatar'], getDefaultAvatar(currentUserEmail)), created: DateUtils.getDBTime(), + reportActionID: reportActionID, shouldShow: true, }, }; @@ -919,6 +920,7 @@ function buildOptimisticWorkspaceChats(policyID, policyName) { ); const announceChatReportID = announceChatData.reportID; const announceReportActionData = buildOptimisticCreatedReportAction(announceChatData.ownerEmail); + const announceCreatedReportActionID = announceReportActionData.reportActionID; const adminsChatData = buildOptimisticChatReport( [currentUserEmail], @@ -931,6 +933,7 @@ function buildOptimisticWorkspaceChats(policyID, policyName) { ); const adminsChatReportID = adminsChatData.reportID; const adminsReportActionData = buildOptimisticCreatedReportAction(adminsChatData.ownerEmail); + const adminsCreatedReportActionID = adminsReportActionData.reportActionID; const expenseChatData = buildOptimisticChatReport( [currentUserEmail], @@ -943,17 +946,21 @@ function buildOptimisticWorkspaceChats(policyID, policyName) { ); const expenseChatReportID = expenseChatData.reportID; const expenseReportActionData = buildOptimisticCreatedReportAction(expenseChatData.ownerEmail); + const expenseCreatedReportActionID = expenseReportActionData.reportActionID; return { announceChatReportID, announceChatData, announceReportActionData, + announceCreatedReportActionID, adminsChatReportID, adminsChatData, adminsReportActionData, + adminsCreatedReportActionID, expenseChatReportID, expenseChatData, expenseReportActionData, + expenseCreatedReportActionID, }; } diff --git a/src/libs/actions/Policy.js b/src/libs/actions/Policy.js index 9f3edbde34a8..19da64369487 100644 --- a/src/libs/actions/Policy.js +++ b/src/libs/actions/Policy.js @@ -707,12 +707,15 @@ function createWorkspace(ownerEmail = '', makeMeAdmin = false, policyName = '', announceChatReportID, announceChatData, announceReportActionData, + announceCreatedReportActionID, adminsChatReportID, adminsChatData, adminsReportActionData, + adminsCreatedReportActionID, expenseChatReportID, expenseChatData, expenseReportActionData, + expenseCreatedReportActionID, } = ReportUtils.buildOptimisticWorkspaceChats(policyID, workspaceName); API.write('CreateWorkspace', { @@ -724,6 +727,9 @@ function createWorkspace(ownerEmail = '', makeMeAdmin = false, policyName = '', makeMeAdmin, policyName: workspaceName, type: CONST.POLICY.TYPE.FREE, + announceCreatedReportActionID, + adminsCreatedReportActionID, + expenseCreatedReportActionID }, { optimisticData: [{ From e4f1471429fcec233ea203e56d50a7e51c5cf58d Mon Sep 17 00:00:00 2001 From: joelbettner Date: Thu, 1 Dec 2022 19:30:41 -0700 Subject: [PATCH 051/189] Use the original ONYX key --- src/ONYXKEYS.js | 4 +++- src/components/Form.js | 5 ----- src/pages/EnablePayments/AdditionalDetailsStep.js | 5 +---- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/ONYXKEYS.js b/src/ONYXKEYS.js index 007eae1f0d5f..60a686195dcd 100755 --- a/src/ONYXKEYS.js +++ b/src/ONYXKEYS.js @@ -112,6 +112,9 @@ export default { // Stores information about additional details form entry WALLET_ADDITIONAL_DETAILS: 'walletAdditionalDetails', + // Stores values put into the additional details step of the wallet KYC flow + WALLET_ADDITIONAL_DETAILS_DRAFT: 'walletAdditionalDetailsDraft', + // Object containing Wallet terms step state WALLET_TERMS: 'walletTerms', @@ -169,7 +172,6 @@ export default { CLOSE_ACCOUNT_FORM: 'closeAccount', PROFILE_SETTINGS_FORM: 'profileSettingsForm', DISPLAY_NAME_FORM: 'displayNameForm', - WALLET_ADDITIONAL_DETAILS_FORM: 'walletAdditionalDetailsForm', }, // Whether we should show the compose input or not diff --git a/src/components/Form.js b/src/components/Form.js index 135ff1fca687..34199bd4f443 100644 --- a/src/components/Form.js +++ b/src/components/Form.js @@ -85,11 +85,6 @@ class Form extends React.Component { this.submit = this.submit.bind(this); } - componentDidUpdate(prevProps) { - // Run the validate method when the component updates to display any possible server errors. - this.validate(this.state.inputValues); - } - /** * @param {String} inputID - The inputID of the input being touched */ diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index 5487c2a89028..09fff91d90e5 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -255,7 +255,7 @@ class AdditionalDetailsStep extends React.Component {
Date: Thu, 1 Dec 2022 20:29:01 -0700 Subject: [PATCH 052/189] Handle server errors with baked in form functionality --- .../EnablePayments/AdditionalDetailsStep.js | 21 ------------------- 1 file changed, 21 deletions(-) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index 09fff91d90e5..42036824fadd 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -170,28 +170,11 @@ class AdditionalDetailsStep extends React.Component { if (this.props.walletAdditionalDetails.errorCode === CONST.WALLET.ERROR.SSN) { if (!ValidationUtils.isValidSSNFullNine(values[INPUT_IDS.SSN])) { errors[INPUT_IDS.SSN] = this.props.translate(this.errorTranslationKeys.ssnFull9); - } else { - const errorsObject = this.props.walletAdditionalDetails.errors; - if (!_.isEmpty(errorsObject)) { - const elementKey = _.keys(errorsObject)[0]; - if (this.props.walletAdditionalDetails.errors[elementKey] !== 'We\'re having trouble verifying your SSN. Please enter the full 9 digits of your SSN.') { - if (typeof this.props.walletAdditionalDetails.errors[elementKey] === 'string') { - // Get the first element of the errors object. - errors[INPUT_IDS.SSN] = this.props.walletAdditionalDetails.errors[elementKey]; - } else { - errors[INPUT_IDS.SSN] = 'There was an error'; - } - } - } } } else if (!ValidationUtils.isValidSSNLastFour(values[INPUT_IDS.SSN])) { errors[INPUT_IDS.SSN] = this.props.translate(this.errorTranslationKeys.ssn); } - // We need to make sure the draft values from the form are saved to the draft Wallet Additional Details Onyx - // object because the draft Wallet Additional Details Onyx object is populated by several forms in several steps. - FormActions.setDraftValues(ONYXKEYS.WALLET_ADDITIONAL_DETAILS, this.props.walletAdditionalDetailsDraft); - return errors; } @@ -211,10 +194,6 @@ class AdditionalDetailsStep extends React.Component { ssn: values[INPUT_IDS.SSN], }; - // Clear any errors that were sent by the server. - FormActions.setErrors(ONYXKEYS.WALLET_ADDITIONAL_DETAILS, null); - FormActions.setErrorFields(ONYXKEYS.WALLET_ADDITIONAL_DETAILS, null); - // Attempt to set the personal details Wallet.updatePersonalDetails(personalDetails); } From 12875d1eb9931a75452aa71c71f27f3e7d7f7343 Mon Sep 17 00:00:00 2001 From: joelbettner Date: Thu, 1 Dec 2022 23:08:20 -0700 Subject: [PATCH 053/189] Load walletAdditionalDetails with stored values --- src/pages/EnablePayments/AdditionalDetailsStep.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index 42036824fadd..dc0e43e42111 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -304,7 +304,6 @@ export default compose( withOnyx({ walletAdditionalDetails: { key: ONYXKEYS.WALLET_ADDITIONAL_DETAILS, - initWithStoredValues: false, }, }), )(AdditionalDetailsStep); From a49a0726797336ad79340571a28212aa53f408d3 Mon Sep 17 00:00:00 2001 From: joelbettner Date: Fri, 2 Dec 2022 13:12:17 -0700 Subject: [PATCH 054/189] Linting error --- src/pages/EnablePayments/AdditionalDetailsStep.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index dc0e43e42111..013e6cc52838 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -24,7 +24,6 @@ import Form from '../../components/Form'; import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsPropTypes, withCurrentUserPersonalDetailsDefaultProps} from '../../components/withCurrentUserPersonalDetails'; import * as PersonalDetails from '../../libs/actions/PersonalDetails'; import OfflineIndicator from '../../components/OfflineIndicator'; -import * as FormActions from '../../libs/actions/FormActions'; const propTypes = { ...withLocalizePropTypes, From ea3984fef9a571e1b6f11604e98a12411a40b132 Mon Sep 17 00:00:00 2001 From: Florent De Neve Date: Mon, 5 Dec 2022 15:49:21 +0000 Subject: [PATCH 055/189] Pass createdReportActionID to OpenReport --- src/libs/actions/Report.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index e5e75e84a200..50b9ab3706ad 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -24,6 +24,7 @@ import * as Localize from '../Localize'; import DateUtils from '../DateUtils'; import * as ReportActionsUtils from '../ReportActionsUtils'; import * as OptionsListUtils from '../OptionsListUtils'; +import * as NumberUtils from "../NumberUtils"; let currentUserEmail; let currentUserAccountID; @@ -529,6 +530,7 @@ function openReport(reportID, participantList = [], newReportObject = {}) { }; // If we are creating a new report, we need to add the optimistic report data and a report action + let optimisticReportActionID = 0; if (!_.isEmpty(newReportObject)) { onyxData.optimisticData[0].value = { ...onyxData.optimisticData[0].value, @@ -544,16 +546,23 @@ function openReport(reportID, participantList = [], newReportObject = {}) { onyxData.optimisticData[0].onyxMethod = CONST.ONYX.METHOD.SET; // Also create a report action so that the page isn't endlessly loading + const optimisticReportAction = ReportUtils.buildOptimisticCreatedReportAction(newReportObject.ownerEmail); + optimisticReportActionID = NumberUtils.rand64(); + // optimisticReportAction[optimisticReportActionID] = optimisticReportAction[0]; + // delete optimisticReportAction[0]; + // console.log('sending optimisticReportActionID', optimisticReportActionID); + optimisticReportAction[0].reportActionID = optimisticReportActionID; onyxData.optimisticData[1] = { onyxMethod: CONST.ONYX.METHOD.SET, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, - value: ReportUtils.buildOptimisticCreatedReportAction(newReportObject.ownerEmail), + value: optimisticReportAction, }; } API.write('OpenReport', { reportID, emailList: participantList ? participantList.join(',') : '', + createdReportActionID: optimisticReportActionID, }, onyxData); } From 497d12e568683af0a54aa4d41ad5f80c07d30c53 Mon Sep 17 00:00:00 2001 From: Jack Nam Date: Mon, 5 Dec 2022 14:00:46 -0800 Subject: [PATCH 056/189] revert reportActionID --- src/libs/ReportUtils.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 4b83622cac8f..64f5d40e9894 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -867,7 +867,7 @@ function buildOptimisticChatReport( function buildOptimisticCreatedReportAction(ownerEmail) { const reportActionID = NumberUtils.rand64(); return { - [reportActionID]: { + 0: { actionName: CONST.REPORT.ACTIONS.TYPE.CREATED, pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, actorAccountID: currentUserAccountID, @@ -891,6 +891,7 @@ function buildOptimisticCreatedReportAction(ownerEmail) { }, ], automatic: false, + sequenceNumber: 0, avatar: lodashGet(allPersonalDetails, [currentUserEmail, 'avatar'], getDefaultAvatar(currentUserEmail)), created: DateUtils.getDBTime(), reportActionID: reportActionID, From 1771b1956abe5c3a86160d38e7c177f7633ca0d0 Mon Sep 17 00:00:00 2001 From: joelbettner Date: Mon, 5 Dec 2022 16:33:34 -0700 Subject: [PATCH 057/189] Pass the dob to the api in the correct format from all platforms --- src/pages/EnablePayments/AdditionalDetailsStep.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index 013e6cc52838..b617e4b44dea 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -24,6 +24,7 @@ import Form from '../../components/Form'; import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsPropTypes, withCurrentUserPersonalDetailsDefaultProps} from '../../components/withCurrentUserPersonalDetails'; import * as PersonalDetails from '../../libs/actions/PersonalDetails'; import OfflineIndicator from '../../components/OfflineIndicator'; +import moment from 'moment'; const propTypes = { ...withLocalizePropTypes, @@ -189,7 +190,7 @@ class AdditionalDetailsStep extends React.Component { addressCity: values[INPUT_IDS.ADDRESS.city], addressState: values[INPUT_IDS.ADDRESS.state], addressZip: values[INPUT_IDS.ADDRESS.zipCode], - dob: values[INPUT_IDS.DOB], + dob: moment(values[INPUT_IDS.DOB]).format(CONST.DATE.MOMENT_FORMAT_STRING), ssn: values[INPUT_IDS.SSN], }; From 52ffca27e8adaa7b9fc0403a520f7f9fcb289915 Mon Sep 17 00:00:00 2001 From: joelbettner Date: Tue, 6 Dec 2022 08:45:47 -0700 Subject: [PATCH 058/189] Linting --- src/pages/EnablePayments/AdditionalDetailsStep.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index b617e4b44dea..fe31982c6a2c 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -3,6 +3,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import {withOnyx} from 'react-native-onyx'; import {View} from 'react-native'; +import moment from 'moment'; import IdologyQuestions from './IdologyQuestions'; import ScreenWrapper from '../../components/ScreenWrapper'; import HeaderWithCloseButton from '../../components/HeaderWithCloseButton'; @@ -24,7 +25,6 @@ import Form from '../../components/Form'; import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsPropTypes, withCurrentUserPersonalDetailsDefaultProps} from '../../components/withCurrentUserPersonalDetails'; import * as PersonalDetails from '../../libs/actions/PersonalDetails'; import OfflineIndicator from '../../components/OfflineIndicator'; -import moment from 'moment'; const propTypes = { ...withLocalizePropTypes, From e4b7756572e40a5543f9ec6192130c3ba496a296 Mon Sep 17 00:00:00 2001 From: Florent De Neve Date: Wed, 7 Dec 2022 14:58:33 +0000 Subject: [PATCH 059/189] Fix isUnread --- src/libs/ReportUtils.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index c7eba83e0b2a..8ea68b74a344 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -966,7 +966,9 @@ function buildOptimisticWorkspaceChats(policyID, policyName) { function isUnread(report) { const lastReadSequenceNumber = report.lastReadSequenceNumber || 0; const maxSequenceNumber = report.maxSequenceNumber || 0; - return lastReadSequenceNumber < maxSequenceNumber; + + // maxSequenceNumber is actually reportActionsCount + return lastReadSequenceNumber + 1 < maxSequenceNumber; } /** From b97858343ff2d35e1a526f4e7acbc195f29f3e14 Mon Sep 17 00:00:00 2001 From: Florent De Neve Date: Wed, 7 Dec 2022 15:15:15 +0000 Subject: [PATCH 060/189] Cleanup code --- src/libs/ReportUtils.js | 2 ++ src/libs/actions/Report.js | 6 +----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 8ea68b74a344..d79d654f1fe7 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -867,6 +867,7 @@ function buildOptimisticChatReport( * @returns {Object} */ function buildOptimisticCreatedReportAction(ownerEmail) { + const optimisticReportActionID = NumberUtils.rand64(); return { 0: { actionName: CONST.REPORT.ACTIONS.TYPE.CREATED, @@ -893,6 +894,7 @@ function buildOptimisticCreatedReportAction(ownerEmail) { ], automatic: false, sequenceNumber: 0, + reportActionID: optimisticReportActionID, avatar: lodashGet(allPersonalDetails, [currentUserEmail, 'avatar'], getDefaultAvatar(currentUserEmail)), created: DateUtils.getDBTime(), shouldShow: true, diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 50b9ab3706ad..d43225442bf9 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -547,11 +547,7 @@ function openReport(reportID, participantList = [], newReportObject = {}) { // Also create a report action so that the page isn't endlessly loading const optimisticReportAction = ReportUtils.buildOptimisticCreatedReportAction(newReportObject.ownerEmail); - optimisticReportActionID = NumberUtils.rand64(); - // optimisticReportAction[optimisticReportActionID] = optimisticReportAction[0]; - // delete optimisticReportAction[0]; - // console.log('sending optimisticReportActionID', optimisticReportActionID); - optimisticReportAction[0].reportActionID = optimisticReportActionID; + optimisticReportActionID = optimisticReportAction.reportActionID; onyxData.optimisticData[1] = { onyxMethod: CONST.ONYX.METHOD.SET, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, From 6fd98ece7d3debfe58b1b5c2878cdb54a6254178 Mon Sep 17 00:00:00 2001 From: Jack Nam Date: Thu, 8 Dec 2022 16:25:53 -0800 Subject: [PATCH 061/189] fix missing trailing comma --- src/libs/actions/Policy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/Policy.js b/src/libs/actions/Policy.js index 19da64369487..d59a73dad54a 100644 --- a/src/libs/actions/Policy.js +++ b/src/libs/actions/Policy.js @@ -729,7 +729,7 @@ function createWorkspace(ownerEmail = '', makeMeAdmin = false, policyName = '', type: CONST.POLICY.TYPE.FREE, announceCreatedReportActionID, adminsCreatedReportActionID, - expenseCreatedReportActionID + expenseCreatedReportActionID, }, { optimisticData: [{ From adc194b9fb5ce4037ba323f910f54cf690170e7c Mon Sep 17 00:00:00 2001 From: Jack Nam Date: Thu, 8 Dec 2022 16:57:08 -0800 Subject: [PATCH 062/189] shorthand --- src/libs/ReportUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 64f5d40e9894..072c021ad51f 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -894,7 +894,7 @@ function buildOptimisticCreatedReportAction(ownerEmail) { sequenceNumber: 0, avatar: lodashGet(allPersonalDetails, [currentUserEmail, 'avatar'], getDefaultAvatar(currentUserEmail)), created: DateUtils.getDBTime(), - reportActionID: reportActionID, + reportActionID, shouldShow: true, }, }; From 030de8a3da44e3590450328ff05f5c623588da11 Mon Sep 17 00:00:00 2001 From: Florent De Neve Date: Fri, 9 Dec 2022 11:32:50 +0000 Subject: [PATCH 063/189] remove needless variable --- src/libs/ReportUtils.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index d79d654f1fe7..af681befe1c9 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -867,7 +867,6 @@ function buildOptimisticChatReport( * @returns {Object} */ function buildOptimisticCreatedReportAction(ownerEmail) { - const optimisticReportActionID = NumberUtils.rand64(); return { 0: { actionName: CONST.REPORT.ACTIONS.TYPE.CREATED, @@ -894,7 +893,7 @@ function buildOptimisticCreatedReportAction(ownerEmail) { ], automatic: false, sequenceNumber: 0, - reportActionID: optimisticReportActionID, + reportActionID: NumberUtils.rand64(), avatar: lodashGet(allPersonalDetails, [currentUserEmail, 'avatar'], getDefaultAvatar(currentUserEmail)), created: DateUtils.getDBTime(), shouldShow: true, From 37b8aebaa6801ae147c1bf13b126be39e60aae47 Mon Sep 17 00:00:00 2001 From: rory Date: Fri, 9 Dec 2022 13:51:36 -0800 Subject: [PATCH 064/189] Remove adjustment for incorrect maxSequenceNumber --- src/libs/ReportUtils.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index af681befe1c9..b8ba2eba2815 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -967,9 +967,7 @@ function buildOptimisticWorkspaceChats(policyID, policyName) { function isUnread(report) { const lastReadSequenceNumber = report.lastReadSequenceNumber || 0; const maxSequenceNumber = report.maxSequenceNumber || 0; - - // maxSequenceNumber is actually reportActionsCount - return lastReadSequenceNumber + 1 < maxSequenceNumber; + return lastReadSequenceNumber < maxSequenceNumber; } /** From 5f82d4b070344fbe204cf1be43bf9f480bf04ba6 Mon Sep 17 00:00:00 2001 From: rory Date: Fri, 9 Dec 2022 14:08:40 -0800 Subject: [PATCH 065/189] Dont pass createdReportActionID if its not used --- src/libs/actions/Report.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index d43225442bf9..609bac94c42e 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -24,7 +24,6 @@ import * as Localize from '../Localize'; import DateUtils from '../DateUtils'; import * as ReportActionsUtils from '../ReportActionsUtils'; import * as OptionsListUtils from '../OptionsListUtils'; -import * as NumberUtils from "../NumberUtils"; let currentUserEmail; let currentUserAccountID; @@ -529,8 +528,12 @@ function openReport(reportID, participantList = [], newReportObject = {}) { }], }; + const apiParams = { + reportID, + emailList: participantList ? participantList.join(',') : '', + }; + // If we are creating a new report, we need to add the optimistic report data and a report action - let optimisticReportActionID = 0; if (!_.isEmpty(newReportObject)) { onyxData.optimisticData[0].value = { ...onyxData.optimisticData[0].value, @@ -547,20 +550,17 @@ function openReport(reportID, participantList = [], newReportObject = {}) { // Also create a report action so that the page isn't endlessly loading const optimisticReportAction = ReportUtils.buildOptimisticCreatedReportAction(newReportObject.ownerEmail); - optimisticReportActionID = optimisticReportAction.reportActionID; onyxData.optimisticData[1] = { onyxMethod: CONST.ONYX.METHOD.SET, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, value: optimisticReportAction, }; + + // Add the createdReportActionID parameter to the API call + apiParams.createdReportActionID = optimisticReportAction.reportActionID; } - API.write('OpenReport', - { - reportID, - emailList: participantList ? participantList.join(',') : '', - createdReportActionID: optimisticReportActionID, - }, - onyxData); + + API.write('OpenReport', apiParams, onyxData); } /** From 0766f6a8bc1fd21b05ecdcb0b9e8265eec8530a3 Mon Sep 17 00:00:00 2001 From: rory Date: Fri, 9 Dec 2022 16:18:40 -0800 Subject: [PATCH 066/189] Update apiParams to just params for consistency --- src/libs/actions/Report.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 609bac94c42e..76f18c0ff0e4 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -528,7 +528,7 @@ function openReport(reportID, participantList = [], newReportObject = {}) { }], }; - const apiParams = { + const params = { reportID, emailList: participantList ? participantList.join(',') : '', }; @@ -557,10 +557,10 @@ function openReport(reportID, participantList = [], newReportObject = {}) { }; // Add the createdReportActionID parameter to the API call - apiParams.createdReportActionID = optimisticReportAction.reportActionID; + params.createdReportActionID = optimisticReportAction.reportActionID; } - API.write('OpenReport', apiParams, onyxData); + API.write('OpenReport', params, onyxData); } /** From 17fa2ba6eaa130d9ca936d95f855044515e5292e Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Thu, 15 Dec 2022 17:21:00 -0500 Subject: [PATCH 067/189] Align compose bar text with sent text --- src/styles/styles.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/styles/styles.js b/src/styles/styles.js index 4664aa9772a7..4c7f668a5b43 100644 --- a/src/styles/styles.js +++ b/src/styles/styles.js @@ -1499,9 +1499,7 @@ const styles = { borderRightWidth: 1, height: 32, width: 32, - marginBottom: 4, - marginTop: 4, - marginLeft: 4, + margin: 4, justifyContent: 'center', }, From 64b03da5677f74fd5f4860985e40af9bf048872e Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Thu, 15 Dec 2022 20:10:49 -0500 Subject: [PATCH 068/189] Add 1px to right margin --- src/styles/styles.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/styles/styles.js b/src/styles/styles.js index 4c7f668a5b43..187bb29da4be 100644 --- a/src/styles/styles.js +++ b/src/styles/styles.js @@ -1499,7 +1499,10 @@ const styles = { borderRightWidth: 1, height: 32, width: 32, - margin: 4, + marginBottom: 4, + marginTop: 4, + marginLeft: 4, + marginRight: 5, justifyContent: 'center', }, From 6fa4d92ee69f33f12d31448ed07b1a478a69be5f Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Thu, 15 Dec 2022 20:42:58 -0500 Subject: [PATCH 069/189] Align divider with edge of avatar, Text with username --- src/styles/styles.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/styles/styles.js b/src/styles/styles.js index 187bb29da4be..eedbb35a2e66 100644 --- a/src/styles/styles.js +++ b/src/styles/styles.js @@ -1501,8 +1501,7 @@ const styles = { width: 32, marginBottom: 4, marginTop: 4, - marginLeft: 4, - marginRight: 5, + marginLeft: 7, justifyContent: 'center', }, From 9a84771ea557677d7f2187649af05e43e935e18e Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Tue, 20 Dec 2022 19:29:30 -0800 Subject: [PATCH 070/189] Align plus/expand in compose bar, change compose height to 40px --- src/pages/home/report/ReportActionCompose.js | 32 +++++++++++--------- src/styles/styles.js | 17 +++++++---- src/styles/variables.js | 2 +- 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/src/pages/home/report/ReportActionCompose.js b/src/pages/home/report/ReportActionCompose.js index 7811d1c25ee1..10000537b06b 100644 --- a/src/pages/home/report/ReportActionCompose.js +++ b/src/pages/home/report/ReportActionCompose.js @@ -598,21 +598,23 @@ class ReportActionCompose extends React.Component { )} - this.actionButton = el} - onPress={(e) => { - e.preventDefault(); - - // Drop focus to avoid blue focus ring. - this.actionButton.blur(); - this.setMenuVisibility(true); - }} - style={styles.chatItemAttachButton} - underlayColor={themeColors.componentBG} - disabled={isBlockedFromConcierge} - > - - + + this.actionButton = el} + onPress={(e) => { + e.preventDefault(); + + // Drop focus to avoid blue focus ring. + this.actionButton.blur(); + this.setMenuVisibility(true); + }} + style={styles.chatItemAttachButton} + underlayColor={themeColors.componentBG} + disabled={isBlockedFromConcierge} + > + + + Date: Wed, 21 Dec 2022 10:41:56 -0700 Subject: [PATCH 071/189] Add style to form --- src/pages/EnablePayments/AdditionalDetailsStep.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index fe31982c6a2c..1daa61ab23e2 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -238,7 +238,7 @@ class AdditionalDetailsStep extends React.Component { validate={this.validate} onSubmit={this.activateWallet} submitButtonText={this.props.translate('common.saveAndContinue')} - style={[styles.flexGrow1]} + style={[styles.mh5, styles.flexGrow1]} > From a2c1fe1d7c4bfc3f115dbdac2018341c2313addd Mon Sep 17 00:00:00 2001 From: joelbettner Date: Wed, 21 Dec 2022 10:46:25 -0700 Subject: [PATCH 072/189] Use inline function calls instead of adding new methods --- .../EnablePayments/AdditionalDetailsStep.js | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index 1daa61ab23e2..88e30bc0171b 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -110,18 +110,6 @@ class AdditionalDetailsStep extends React.Component { }; } - getFirstName() { - return PersonalDetails.extractFirstAndLastNameFromAvailableDetails(this.props.currentUserPersonalDetails).firstName; - } - - getLastName() { - return PersonalDetails.extractFirstAndLastNameFromAvailableDetails(this.props.currentUserPersonalDetails).lastName; - } - - getPhoneNumber() { - return this.props.currentUserPersonalDetails.phoneNumber; - } - /** * @param {Object} values The values object is passed from Form.js and contains info for each form element that has an inputID * @returns {Object} @@ -246,14 +234,14 @@ class AdditionalDetailsStep extends React.Component { inputID={INPUT_IDS.LEGAL_FIRST_NAME} containerStyles={[styles.mt4]} label={this.props.translate(this.fieldNameTranslationKeys.legalFirstName)} - defaultValue={this.getFirstName()} + defaultValue={PersonalDetails.extractFirstAndLastNameFromAvailableDetails(this.props.currentUserPersonalDetails).firstName} shouldSaveDraft /> From a0e5df5605804b97d5d6c308c480b15a8a7923ba Mon Sep 17 00:00:00 2001 From: joelbettner Date: Wed, 21 Dec 2022 10:51:03 -0700 Subject: [PATCH 073/189] Capitalize constant names --- .../EnablePayments/AdditionalDetailsStep.js | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index 88e30bc0171b..dfe90d113958 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -75,10 +75,10 @@ const INPUT_IDS = { DOB: 'dob', SSN: 'ssn', ADDRESS: { - street: 'addressStreet', - city: 'addressCity', - state: 'addressState', - zipCode: 'addressZip', + STREET: 'addressStreet', + CITY: 'addressCity', + STATE: 'addressState', + ZIPCODE: 'addressZip', }, }; @@ -133,20 +133,20 @@ class AdditionalDetailsStep extends React.Component { errors[INPUT_IDS.DOB] = this.props.translate(this.errorTranslationKeys.age); } - if (!ValidationUtils.isValidAddress(values[INPUT_IDS.ADDRESS.street])) { - errors[INPUT_IDS.ADDRESS.street] = this.props.translate('bankAccount.error.addressStreet'); + if (!ValidationUtils.isValidAddress(values[INPUT_IDS.ADDRESS.STREET])) { + errors[INPUT_IDS.ADDRESS.STREET] = this.props.translate('bankAccount.error.addressStreet'); } - if (_.isEmpty(values[INPUT_IDS.ADDRESS.city])) { - errors[INPUT_IDS.ADDRESS.city] = this.props.translate('bankAccount.error.addressCity'); + if (_.isEmpty(values[INPUT_IDS.ADDRESS.CITY])) { + errors[INPUT_IDS.ADDRESS.CITY] = this.props.translate('bankAccount.error.addressCity'); } - if (_.isEmpty(values[INPUT_IDS.ADDRESS.state])) { - errors[INPUT_IDS.ADDRESS.state] = this.props.translate('bankAccount.error.addressState'); + if (_.isEmpty(values[INPUT_IDS.ADDRESS.STATE])) { + errors[INPUT_IDS.ADDRESS.STATE] = this.props.translate('bankAccount.error.addressState'); } - if (!ValidationUtils.isValidZipCode(values[INPUT_IDS.ADDRESS.zipCode])) { - errors[INPUT_IDS.ADDRESS.zipCode] = this.props.translate('bankAccount.error.zipCode'); + if (!ValidationUtils.isValidZipCode(values[INPUT_IDS.ADDRESS.ZIPCODE])) { + errors[INPUT_IDS.ADDRESS.ZIPCODE] = this.props.translate('bankAccount.error.zipCode'); } if (!ValidationUtils.isValidUSPhone(values[INPUT_IDS.PHONE_NUMBER], true)) { @@ -174,10 +174,10 @@ class AdditionalDetailsStep extends React.Component { phoneNumber: LoginUtils.getPhoneNumberWithoutUSCountryCodeAndSpecialChars(values[INPUT_IDS.PHONE_NUMBER]), legalFirstName: values[INPUT_IDS.LEGAL_FIRST_NAME], legalLastName: values[INPUT_IDS.LEGAL_LAST_NAME], - addressStreet: values[INPUT_IDS.ADDRESS.street], - addressCity: values[INPUT_IDS.ADDRESS.city], - addressState: values[INPUT_IDS.ADDRESS.state], - addressZip: values[INPUT_IDS.ADDRESS.zipCode], + addressStreet: values[INPUT_IDS.ADDRESS.STREET], + addressCity: values[INPUT_IDS.ADDRESS.CITY], + addressState: values[INPUT_IDS.ADDRESS.STATE], + addressZip: values[INPUT_IDS.ADDRESS.ZIPCODE], dob: moment(values[INPUT_IDS.DOB]).format(CONST.DATE.MOMENT_FORMAT_STRING), ssn: values[INPUT_IDS.SSN], }; From 7a237cf44325f38f52027e410a7d7de65aefa305 Mon Sep 17 00:00:00 2001 From: joelbettner Date: Wed, 21 Dec 2022 10:54:11 -0700 Subject: [PATCH 074/189] Remove maximumDate --- src/pages/EnablePayments/AdditionalDetailsStep.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index dfe90d113958..cfc5d6744f2e 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -265,7 +265,6 @@ class AdditionalDetailsStep extends React.Component { containerStyles={[styles.mt4]} label={this.props.translate(this.fieldNameTranslationKeys.dob)} placeholder={this.props.translate('common.dob')} - maximumDate={new Date()} shouldSaveDraft /> Date: Wed, 21 Dec 2022 11:56:33 -0800 Subject: [PATCH 075/189] Make composer total height 40px --- src/styles/styles.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/styles/styles.js b/src/styles/styles.js index 5023eec8c906..f9920b53a1ec 100644 --- a/src/styles/styles.js +++ b/src/styles/styles.js @@ -1414,7 +1414,7 @@ const styles = { backgroundColor: themeColors.transparent, height: 32, padding: 6, - margin: 4, + margin: 3, justifyContent: 'center', }, @@ -1479,7 +1479,7 @@ const styles = { alignSelf: 'flex-end', borderRadius: variables.buttonBorderRadius, height: 32, - marginVertical: 4, + marginVertical: 3, paddingHorizontal: 6, justifyContent: 'center', }, @@ -1506,7 +1506,9 @@ const styles = { chatItemAttachBorder: { borderRightColor: themeColors.border, borderRightWidth: 1, - marginBottom: 4, + marginBottom: 3, + marginTop: 3, + }, composerSizeButton: { From 0db661174eb60cb37268ee4e9b442894138e53d5 Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Thu, 22 Dec 2022 13:00:20 -0800 Subject: [PATCH 076/189] Close View component --- src/pages/home/report/ReportActionCompose.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/pages/home/report/ReportActionCompose.js b/src/pages/home/report/ReportActionCompose.js index f9049385b9a3..8466d9a982a6 100644 --- a/src/pages/home/report/ReportActionCompose.js +++ b/src/pages/home/report/ReportActionCompose.js @@ -604,15 +604,17 @@ class ReportActionCompose extends React.Component { onPress={(e) => { e.preventDefault(); - // Drop focus to avoid blue focus ring. - this.actionButton.blur(); - this.setMenuVisibility(true); - }} - style={styles.chatItemAttachButton} - disabled={isBlockedFromConcierge} - > - - + // Drop focus to avoid blue focus ring. + this.actionButton.blur(); + this.setMenuVisibility(true); + }} + style={styles.chatItemAttachButton} + underlayColor={themeColors.componentBG} + disabled={isBlockedFromConcierge} + > + + + Date: Tue, 27 Dec 2022 12:57:10 -0500 Subject: [PATCH 077/189] move session clean up logic to the logOut action fixes issues with push notifications getting unsubscribed when putting the app in the background using the back button on Android --- .../Navigation/AppNavigator/AuthScreens.js | 1 - src/libs/actions/Session/index.js | 21 +++++++------------ 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.js b/src/libs/Navigation/AppNavigator/AuthScreens.js index 09aec059ff1d..6a9139e29e0c 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.js +++ b/src/libs/Navigation/AppNavigator/AuthScreens.js @@ -132,7 +132,6 @@ class AuthScreens extends React.Component { if (this.unsubscribeGroupShortcut) { this.unsubscribeGroupShortcut(); } - Session.cleanupSession(); clearInterval(this.interval); this.interval = null; } diff --git a/src/libs/actions/Session/index.js b/src/libs/actions/Session/index.js index fd72ef0dac10..c78b0679e922 100644 --- a/src/libs/actions/Session/index.js +++ b/src/libs/actions/Session/index.js @@ -51,6 +51,13 @@ function signOut() { shouldRetry: false, }, {optimisticData}); + // We got signed out in this tab or another so clean up any subscriptions and timers + UnreadIndicatorUpdater.stopListeningForReportChanges(); + PushNotification.deregister(); + PushNotification.clearNotifications(); + Pusher.disconnect(); + Timers.clearAll(); + Welcome.resetReadyCheck(); Timing.clearData(); } @@ -306,19 +313,6 @@ function clearSignInData() { }); } -/** - * Put any logic that needs to run when we are signed out here. This can be triggered when the current tab or another tab signs out. - */ -function cleanupSession() { - // We got signed out in this tab or another so clean up any subscriptions and timers - UnreadIndicatorUpdater.stopListeningForReportChanges(); - PushNotification.deregister(); - PushNotification.clearNotifications(); - Pusher.disconnect(); - Timers.clearAll(); - Welcome.resetReadyCheck(); -} - function clearAccountMessages() { Onyx.merge(ONYXKEYS.ACCOUNT, { success: '', @@ -455,7 +449,6 @@ export { resetPassword, resendResetPassword, clearSignInData, - cleanupSession, clearAccountMessages, authenticatePusher, reauthenticatePusher, From d15772655949ba4dd0ece16e6ffcb93e8a784df3 Mon Sep 17 00:00:00 2001 From: Andrew Rosiclair Date: Tue, 27 Dec 2022 13:11:33 -0500 Subject: [PATCH 078/189] move push notification registration to auth screens --- src/Expensify.js | 7 ------- src/libs/Navigation/AppNavigator/AuthScreens.js | 3 ++- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/Expensify.js b/src/Expensify.js index 93224dfd9321..8359d02f1498 100644 --- a/src/Expensify.js +++ b/src/Expensify.js @@ -116,13 +116,6 @@ class Expensify extends PureComponent { } componentDidUpdate(prevProps) { - const previousAccountID = lodashGet(prevProps, 'session.accountID', null); - const currentAccountID = lodashGet(this.props, 'session.accountID', null); - - if (currentAccountID && (currentAccountID !== previousAccountID)) { - PushNotification.register(currentAccountID); - } - if (this.state.isNavigationReady && this.state.isSplashShown) { const shouldHideSplash = !this.isAuthenticated() || this.props.isSidebarLoaded; diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.js b/src/libs/Navigation/AppNavigator/AuthScreens.js index 6a9139e29e0c..19299a9f3a57 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.js +++ b/src/libs/Navigation/AppNavigator/AuthScreens.js @@ -29,7 +29,7 @@ import * as ModalStackNavigators from './ModalStackNavigators'; import SCREENS from '../../../SCREENS'; import defaultScreenOptions from './defaultScreenOptions'; import * as App from '../../actions/App'; -import * as Session from '../../actions/Session'; +import PushNotification from '../../Notification/PushNotification'; let currentUserEmail; Onyx.connect({ @@ -100,6 +100,7 @@ class AuthScreens extends React.Component { }).then(() => { User.subscribeToUserEvents(); }); + PushNotification.register(lodashGet(this.props, 'session.accountID', null)); // Listen for report changes and fetch some data we need on initialization UnreadIndicatorUpdater.listenForReportChanges(); From 1b6bee37a9651fe3a150da5ebf23948967035dd1 Mon Sep 17 00:00:00 2001 From: Andrew Rosiclair Date: Tue, 27 Dec 2022 13:13:25 -0500 Subject: [PATCH 079/189] use early return --- src/Expensify.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Expensify.js b/src/Expensify.js index 8359d02f1498..a590bf794368 100644 --- a/src/Expensify.js +++ b/src/Expensify.js @@ -115,16 +115,18 @@ class Expensify extends PureComponent { this.appStateChangeListener = AppState.addEventListener('change', this.initializeClient); } - componentDidUpdate(prevProps) { - if (this.state.isNavigationReady && this.state.isSplashShown) { - const shouldHideSplash = !this.isAuthenticated() || this.props.isSidebarLoaded; + componentDidUpdate() { + if (!(this.state.isNavigationReady || this.state.isSplashShown)) { + return; + } + + const shouldHideSplash = !this.isAuthenticated() || this.props.isSidebarLoaded; - if (shouldHideSplash) { - BootSplash.hide(); + if (shouldHideSplash) { + BootSplash.hide(); - // eslint-disable-next-line react/no-did-update-set-state - this.setState({isSplashShown: false}); - } + // eslint-disable-next-line react/no-did-update-set-state + this.setState({isSplashShown: false}); } } From d8025e065804ee3ac32aa303b90b0f69a16b8842 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Ch=C3=A1vez?= Date: Thu, 29 Dec 2022 12:56:51 -0600 Subject: [PATCH 080/189] ignore close action --- src/pages/home/report/ReportActionItem.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index 7158f15f37bb..f456070a97b6 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -170,6 +170,10 @@ class ReportActionItem extends Component { } render() { + // Ignore closed action here since we're already displaying a footer that explains why the report was closed + if (this.props.action.actionName === CONST.REPORT.ACTIONS.TYPE.CLOSED) { + return null; + } if (this.props.action.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED) { return ; } From 2cd870010a44f5520f2bb8d67d6644cf09a69b64 Mon Sep 17 00:00:00 2001 From: Andrew Rosiclair Date: Thu, 29 Dec 2022 15:05:04 -0500 Subject: [PATCH 081/189] fix check for navigation and splash state Co-authored-by: Marc Glasser --- src/Expensify.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Expensify.js b/src/Expensify.js index a590bf794368..1ae4750ca23e 100644 --- a/src/Expensify.js +++ b/src/Expensify.js @@ -116,7 +116,7 @@ class Expensify extends PureComponent { } componentDidUpdate() { - if (!(this.state.isNavigationReady || this.state.isSplashShown)) { + if (!this.state.isNavigationReady || !this.state.isSplashShown) { return; } From ed492393662530ae0a9181d2a855f7cb5920b578 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Ch=C3=A1vez?= Date: Thu, 29 Dec 2022 14:12:47 -0600 Subject: [PATCH 082/189] add text for link --- src/languages/en.js | 1 + src/languages/es.js | 1 + 2 files changed, 2 insertions(+) diff --git a/src/languages/en.js b/src/languages/en.js index d849ce04ee14..225d85751a2a 100755 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -376,6 +376,7 @@ export default { phrase3: 'and', phrase4: 'privacy policy', }, + help: 'Help', }, closeAccountPage: { closeAccount: 'Close account', diff --git a/src/languages/es.js b/src/languages/es.js index 889b0ab8c6bf..6aebf3da759e 100644 --- a/src/languages/es.js +++ b/src/languages/es.js @@ -376,6 +376,7 @@ export default { phrase3: 'y', phrase4: 'política de privacidad', }, + help: 'Ayuda', }, closeAccountPage: { closeAccount: 'Cerrar cuenta', From 3786f50275b99f9e5c9e52a33f98f8ab8678a1ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Ch=C3=A1vez?= Date: Thu, 29 Dec 2022 14:13:03 -0600 Subject: [PATCH 083/189] add new help url as const --- src/CONST.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CONST.js b/src/CONST.js index ef02585f6aed..125d618a59e5 100755 --- a/src/CONST.js +++ b/src/CONST.js @@ -243,6 +243,7 @@ const CONST = { FEES_URL: `${USE_EXPENSIFY_URL}/fees`, CFPB_PREPAID_URL: 'https://cfpb.gov/prepaid', STAGING_NEW_EXPENSIFY_URL: 'https://staging.new.expensify.com', + NEWHELP_URL: 'https://help.expensify.com', // Use Environment.getEnvironmentURL to get the complete URL with port number DEV_NEW_EXPENSIFY_URL: 'http://localhost:', From 582541dc35867c24316c1e15db81a7f9a456959c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Ch=C3=A1vez?= Date: Thu, 29 Dec 2022 14:13:32 -0600 Subject: [PATCH 084/189] add menu item to settings page --- src/pages/settings/InitialSettingsPage.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pages/settings/InitialSettingsPage.js b/src/pages/settings/InitialSettingsPage.js index c2bf6b384b87..ae6e56264a45 100755 --- a/src/pages/settings/InitialSettingsPage.js +++ b/src/pages/settings/InitialSettingsPage.js @@ -30,7 +30,7 @@ import * as Wallet from '../../libs/actions/Wallet'; import walletTermsPropTypes from '../EnablePayments/walletTermsPropTypes'; import * as PolicyUtils from '../../libs/PolicyUtils'; import ConfirmModal from '../../components/ConfirmModal'; - +import * as Link from '../../libs/actions/Link'; const propTypes = { /* Onyx Props */ @@ -171,6 +171,11 @@ class InitialSettingsPage extends React.Component { brickRoadIndicator: PaymentMethods.hasPaymentMethodError(this.props.bankAccountList, this.props.cardList) || !_.isEmpty(this.props.userWallet.errors) || !_.isEmpty(this.props.walletTerms.errors) ? 'error' : null, }, + { + translationKey: 'initialSettingsPage.help', + icon: Expensicons.QuestionMark, + action: () => { Link.openExternalLink(CONST.NEWHELP_URL); }, + }, { translationKey: 'initialSettingsPage.about', icon: Expensicons.Info, From 18988f34d528d7bff517cdd67210e32ab1822144 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Ch=C3=A1vez?= Date: Thu, 29 Dec 2022 18:13:07 -0600 Subject: [PATCH 085/189] add help link to Get assistance page --- src/pages/GetAssistancePage.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/pages/GetAssistancePage.js b/src/pages/GetAssistancePage.js index fbf7ab90bd3a..2168acd967f2 100644 --- a/src/pages/GetAssistancePage.js +++ b/src/pages/GetAssistancePage.js @@ -13,6 +13,8 @@ import * as Expensicons from '../components/Icon/Expensicons'; import * as Illustrations from '../components/Icon/Illustrations'; import * as Report from '../libs/actions/Report'; import ROUTES from '../ROUTES'; +import * as Link from '../libs/actions/Link'; +import CONST from '../CONST'; const propTypes = { /** Route object from navigation */ @@ -55,6 +57,14 @@ const GetAssistancePage = props => ( iconFill: themeColors.success, wrapperStyle: [styles.cardMenuItem], }, + { + title: props.translate('initialSettingsPage.help'), + onPress: () => Link.openExternalLink(CONST.NEWHELP_URL), + icon: Expensicons.QuestionMark, + shouldShowRightIcon: true, + iconFill: themeColors.success, + wrapperStyle: [styles.cardMenuItem], + }, ]} > From 58682316b5d43fc817b14ce01c17be224bc7767d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Ch=C3=A1vez?= Date: Thu, 29 Dec 2022 18:13:20 -0600 Subject: [PATCH 086/189] add space --- src/pages/settings/InitialSettingsPage.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/settings/InitialSettingsPage.js b/src/pages/settings/InitialSettingsPage.js index ae6e56264a45..7de6d84a2cb9 100755 --- a/src/pages/settings/InitialSettingsPage.js +++ b/src/pages/settings/InitialSettingsPage.js @@ -31,6 +31,7 @@ import walletTermsPropTypes from '../EnablePayments/walletTermsPropTypes'; import * as PolicyUtils from '../../libs/PolicyUtils'; import ConfirmModal from '../../components/ConfirmModal'; import * as Link from '../../libs/actions/Link'; + const propTypes = { /* Onyx Props */ From ca1b3118390a9f1974e4c24545917e7e739069c5 Mon Sep 17 00:00:00 2001 From: b1tjoy <103875612+b1tjoy@users.noreply.github.com> Date: Fri, 30 Dec 2022 11:16:22 +0800 Subject: [PATCH 087/189] provide default property values for context consumer --- src/components/ShowContextMenuContext.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/ShowContextMenuContext.js b/src/components/ShowContextMenuContext.js index 1a5ca0d0d18e..d063d8ff1eb7 100644 --- a/src/components/ShowContextMenuContext.js +++ b/src/components/ShowContextMenuContext.js @@ -2,15 +2,21 @@ import React from 'react'; import * as ReportActionContextMenu from '../pages/home/report/ContextMenu/ReportActionContextMenu'; import * as ContextMenuActions from '../pages/home/report/ContextMenu/ContextMenuActions'; -const ShowContextMenuContext = React.createContext(null); +const ShowContextMenuContext = React.createContext({ + anchor: null, + reportID: null, + action: undefined, + checkIfContextMenuActive: () => {}, +}); + ShowContextMenuContext.displayName = 'ShowContextMenuContext'; /** * Show the report action context menu. * - * @param {Object} [event] - A press event + * @param {Object} event - Press event object * @param {Element} anchor - Context menu anchor - * @param {String} reportID - Active Report Id + * @param {String} reportID - Active Report ID * @param {Object} action - ReportAction for ContextMenu * @param {Function} checkIfContextMenuActive Callback to update context menu active state */ From 12e1013b38b49b71da05e0acc5ee9bd6f89f97f9 Mon Sep 17 00:00:00 2001 From: b1tjoy <103875612+b1tjoy@users.noreply.github.com> Date: Fri, 30 Dec 2022 11:31:43 +0800 Subject: [PATCH 088/189] avoid 3D-Touch menu when long press on iPad --- src/components/AnchorForCommentsOnly/index.js | 16 +++++----------- .../HTMLRenderers/PreRenderer/index.js | 13 +++---------- src/components/ReportActionItem/IOUPreview.js | 5 +---- 3 files changed, 9 insertions(+), 25 deletions(-) diff --git a/src/components/AnchorForCommentsOnly/index.js b/src/components/AnchorForCommentsOnly/index.js index c8c3b6a54321..5e93ef00b3bc 100644 --- a/src/components/AnchorForCommentsOnly/index.js +++ b/src/components/AnchorForCommentsOnly/index.js @@ -1,26 +1,20 @@ import React from 'react'; -import {propTypes as anchorForCommentsOnlyPropTypes, defaultProps} from './anchorForCommentsOnlyPropTypes'; +import * as anchorForCommentsOnlyPropTypes from './anchorForCommentsOnlyPropTypes'; import BaseAnchorForCommentsOnly from './BaseAnchorForCommentsOnly'; import canUseTouchScreen from '../../libs/canUseTouchscreen'; import ControlSelection from '../../libs/ControlSelection'; -import withWindowDimensions, {windowDimensionsPropTypes} from '../withWindowDimensions'; - -const propTypes = { - ...anchorForCommentsOnlyPropTypes, - ...windowDimensionsPropTypes, -}; const AnchorForCommentsOnly = props => ( props.isSmallScreenWidth && canUseTouchScreen() && ControlSelection.block()} + onPressIn={() => canUseTouchScreen() && ControlSelection.block()} onPressOut={() => ControlSelection.unblock()} /> ); -AnchorForCommentsOnly.propTypes = propTypes; -AnchorForCommentsOnly.defaultProps = defaultProps; +AnchorForCommentsOnly.propTypes = anchorForCommentsOnlyPropTypes.propTypes; +AnchorForCommentsOnly.defaultProps = anchorForCommentsOnlyPropTypes.defaultProps; AnchorForCommentsOnly.displayName = 'AnchorForCommentsOnly'; -export default withWindowDimensions(AnchorForCommentsOnly); +export default AnchorForCommentsOnly; diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer/index.js b/src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer/index.js index 3b2d50b0beda..b964b25cc574 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer/index.js +++ b/src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer/index.js @@ -3,16 +3,9 @@ import _ from 'underscore'; import withLocalize from '../../../withLocalize'; import htmlRendererPropTypes from '../htmlRendererPropTypes'; import BasePreRenderer from './BasePreRenderer'; -import compose from '../../../../libs/compose'; -import withWindowDimensions, {windowDimensionsPropTypes} from '../../../withWindowDimensions'; import canUseTouchScreen from '../../../../libs/canUseTouchscreen'; import ControlSelection from '../../../../libs/ControlSelection'; -const propTypes = { - ...htmlRendererPropTypes, - ...windowDimensionsPropTypes, -}; - class PreRenderer extends React.Component { constructor(props) { super(props); @@ -67,13 +60,13 @@ class PreRenderer extends React.Component { // eslint-disable-next-line react/jsx-props-no-spreading {...this.props} ref={el => this.ref = el} - onPressIn={() => this.props.isSmallScreenWidth && canUseTouchScreen() && ControlSelection.block()} + onPressIn={() => canUseTouchScreen() && ControlSelection.block()} onPressOut={() => ControlSelection.unblock()} /> ); } } -PreRenderer.propTypes = propTypes; +PreRenderer.propTypes = htmlRendererPropTypes; -export default compose(withLocalize, withWindowDimensions)(PreRenderer); +export default withLocalize(PreRenderer); diff --git a/src/components/ReportActionItem/IOUPreview.js b/src/components/ReportActionItem/IOUPreview.js index bbf81151b744..5ab0e0a2a586 100644 --- a/src/components/ReportActionItem/IOUPreview.js +++ b/src/components/ReportActionItem/IOUPreview.js @@ -24,7 +24,6 @@ import OfflineWithFeedback from '../OfflineWithFeedback'; import walletTermsPropTypes from '../../pages/EnablePayments/walletTermsPropTypes'; import ControlSelection from '../../libs/ControlSelection'; import canUseTouchScreen from '../../libs/canUseTouchscreen'; -import withWindowDimensions, {windowDimensionsPropTypes} from '../withWindowDimensions'; import reportActionPropTypes from '../../pages/home/report/reportActionPropTypes'; import {showContextMenuForReport} from '../ShowContextMenuContext'; import * as ReportUtils from '../../libs/ReportUtils'; @@ -103,7 +102,6 @@ const propTypes = { pendingAction: PropTypes.oneOf(_.values(CONST.RED_BRICK_ROAD_PENDING_ACTION)), ...withLocalizePropTypes, - ...windowDimensionsPropTypes, }; const defaultProps = { @@ -167,7 +165,7 @@ const IOUPreview = (props) => { return ( props.isSmallScreenWidth && canUseTouchScreen() && ControlSelection.block()} + onPressIn={() => canUseTouchScreen() && ControlSelection.block()} onPressOut={() => ControlSelection.unblock()} onLongPress={showContextMenu} > @@ -245,7 +243,6 @@ IOUPreview.defaultProps = defaultProps; IOUPreview.displayName = 'IOUPreview'; export default compose( - withWindowDimensions, withLocalize, withOnyx({ personalDetails: { From 44be76dea43df879018ae44a27289eff0ea45189 Mon Sep 17 00:00:00 2001 From: b1tjoy <103875612+b1tjoy@users.noreply.github.com> Date: Fri, 30 Dec 2022 15:34:49 +0800 Subject: [PATCH 089/189] fix long press on IOU quote message shows IOU details modal issue --- src/components/ReportActionItem/IOUAction.js | 3 +++ src/components/ReportActionItem/IOUQuote.js | 23 ++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/components/ReportActionItem/IOUAction.js b/src/components/ReportActionItem/IOUAction.js index 9291739b6886..d74052fff0e9 100644 --- a/src/components/ReportActionItem/IOUAction.js +++ b/src/components/ReportActionItem/IOUAction.js @@ -64,8 +64,11 @@ const IOUAction = (props) => { <> {shouldShowIOUPreview && ( {}, + checkIfContextMenuActive: () => {}, }; const IOUQuote = props => ( @@ -37,6 +51,15 @@ const IOUQuote = props => ( onPress={props.shouldAllowViewDetails ? props.onViewDetailsPressed : () => {}} + onPressIn={() => canUseTouchScreen() && ControlSelection.block()} + onPressOut={() => ControlSelection.unblock()} + onLongPress={event => showContextMenuForReport( + event, + props.contextMenuAnchor, + props.chatReportID, + props.action, + props.checkIfContextMenuActive, + )} style={[styles.flexRow, styles.justifyContentBetween, props.shouldAllowViewDetails ? undefined From 658adf7919a36f5f9ea6e235ce24febe3dc415bd Mon Sep 17 00:00:00 2001 From: b1tjoy <103875612+b1tjoy@users.noreply.github.com> Date: Fri, 30 Dec 2022 15:38:14 +0800 Subject: [PATCH 090/189] avoid 3D-Touch menu when long press on IOU pay button on iOS Safari --- src/components/ReportActionItem/IOUPreview.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/ReportActionItem/IOUPreview.js b/src/components/ReportActionItem/IOUPreview.js index 5ab0e0a2a586..ad6c9191d10e 100644 --- a/src/components/ReportActionItem/IOUPreview.js +++ b/src/components/ReportActionItem/IOUPreview.js @@ -225,6 +225,8 @@ const IOUPreview = (props) => {