diff --git a/package-lock.json b/package-lock.json index e7f4383b3874..7a3e95de0d4d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21989,9 +21989,9 @@ } }, "eslint-config-expensify": { - "version": "2.0.18", - "resolved": "https://registry.npmjs.org/eslint-config-expensify/-/eslint-config-expensify-2.0.18.tgz", - "integrity": "sha512-jEBAcXWm89NptiprvlBrRoDsK8zJbbkt8yVZOgzo/Vadp86gL0oc7blgyLfJHA2cjecs1kgfPYGByXb6V8v8cw==", + "version": "2.0.19", + "resolved": "https://registry.npmjs.org/eslint-config-expensify/-/eslint-config-expensify-2.0.19.tgz", + "integrity": "sha512-y9Rl9+/J3DCIjK4vwM05IDApT0vTKc540f9VFztt1bwMrc8PUeBcGnYqOmRRCA1gqil5Ug58TjRaju24SRa6Qw==", "dev": true, "requires": { "@lwc/eslint-plugin-lwc": "^0.11.0", @@ -22720,9 +22720,9 @@ } }, "eslint-plugin-import": { - "version": "2.25.2", - "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.25.2.tgz", - "integrity": "sha512-qCwQr9TYfoBHOFcVGKY9C9unq05uOxxdklmBXLVvcwo68y5Hta6/GzCZEMx2zQiu0woKNEER0LE7ZgaOfBU14g==", + "version": "2.25.3", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.25.3.tgz", + "integrity": "sha512-RzAVbby+72IB3iOEL8clzPLzL3wpDrlwjsTBAQXgyp5SeTqqY+0bFubwuo+y/HLhNZcXV4XqTBO4LGsfyHIDXg==", "dev": true, "requires": { "array-includes": "^3.1.4", @@ -22730,9 +22730,9 @@ "debug": "^2.6.9", "doctrine": "^2.1.0", "eslint-import-resolver-node": "^0.3.6", - "eslint-module-utils": "^2.7.0", + "eslint-module-utils": "^2.7.1", "has": "^1.0.3", - "is-core-module": "^2.7.0", + "is-core-module": "^2.8.0", "is-glob": "^4.0.3", "minimatch": "^3.0.4", "object.values": "^1.1.5", @@ -23114,9 +23114,9 @@ "dev": true }, "eslint-plugin-rulesdir": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-rulesdir/-/eslint-plugin-rulesdir-0.2.0.tgz", - "integrity": "sha512-PPQPCsPkzF3upl1862swPA1bmDAAHKHmJJ4JTHJ11JCVCU4sycB0K5LLA/Rwr6r4VbnpScvUvHV4hqfdjvFmhQ==", + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-rulesdir/-/eslint-plugin-rulesdir-0.2.1.tgz", + "integrity": "sha512-t7rQvEyfE4JZJu6dPl4/uVr6Fr0fxopBhzVbtq3isfOHMKdlIe9xW/5CtIaWZI0E1U+wzAk0lEnZC8laCD5YLA==", "dev": true }, "eslint-scope": { @@ -41170,9 +41170,9 @@ "integrity": "sha1-Trw8d04WkUjLx2inNCUz8ILHpuU=" }, "tsconfig-paths": { - "version": "3.11.0", - "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.11.0.tgz", - "integrity": "sha512-7ecdYDnIdmv639mmDwslG6KQg1Z9STTz1j7Gcz0xa+nshh/gKDAHcPxRbWOsA3SPp0tXP2leTcY9Kw+NAkfZzA==", + "version": "3.12.0", + "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.12.0.tgz", + "integrity": "sha512-e5adrnOYT6zqVnWqZu7i/BQ3BnhzvGbjEjejFXO20lKIKpwTaupkCPgEfv4GZK1IBciJUEhYs3J3p75FdaTFVg==", "dev": true, "requires": { "@types/json5": "^0.0.29", diff --git a/package.json b/package.json index bb6d15976c1d..7a4f71fd751b 100644 --- a/package.json +++ b/package.json @@ -146,7 +146,7 @@ "electron-notarize": "^1.0.0", "electron-reloader": "^1.2.0", "eslint": "^7.6.0", - "eslint-config-expensify": "^2.0.18", + "eslint-config-expensify": "2.0.19", "eslint-loader": "^4.0.2", "eslint-plugin-detox": "^1.0.0", "eslint-plugin-jest": "^24.1.0", diff --git a/src/CONFIG.js b/src/CONFIG.js index fcad4bf55193..70e169425dee 100644 --- a/src/CONFIG.js +++ b/src/CONFIG.js @@ -2,16 +2,16 @@ import lodashGet from 'lodash/get'; import {Platform} from 'react-native'; import Config from 'react-native-config'; import getPlatform from './libs/getPlatform/index'; -import {addTrailingForwardSlash} from './libs/Url'; +import * as Url from './libs/Url'; import CONST from './CONST'; // Set default values to contributor friendly values to make development work out of the box without an .env file const ENVIRONMENT = lodashGet(Config, 'ENVIRONMENT', CONST.ENVIRONMENT.DEV); -const expensifyCashURL = addTrailingForwardSlash(lodashGet(Config, 'EXPENSIFY_URL_CASH', 'https://new.expensify.com/')); -const expensifyURL = addTrailingForwardSlash(lodashGet(Config, 'EXPENSIFY_URL_COM', 'https://www.expensify.com/')); -const ngrokURL = addTrailingForwardSlash(lodashGet(Config, 'NGROK_URL', '')); -const secureNgrokURL = addTrailingForwardSlash(lodashGet(Config, 'SECURE_NGROK_URL', '')); -const expensifyURLSecure = addTrailingForwardSlash(lodashGet( +const expensifyCashURL = Url.addTrailingForwardSlash(lodashGet(Config, 'EXPENSIFY_URL_CASH', 'https://new.expensify.com/')); +const expensifyURL = Url.addTrailingForwardSlash(lodashGet(Config, 'EXPENSIFY_URL_COM', 'https://www.expensify.com/')); +const ngrokURL = Url.addTrailingForwardSlash(lodashGet(Config, 'NGROK_URL', '')); +const secureNgrokURL = Url.addTrailingForwardSlash(lodashGet(Config, 'SECURE_NGROK_URL', '')); +const expensifyURLSecure = Url.addTrailingForwardSlash(lodashGet( Config, 'EXPENSIFY_URL_SECURE', 'https://secure.expensify.com/', )); const useNgrok = lodashGet(Config, 'USE_NGROK', 'false') === 'true'; diff --git a/src/CONST.js b/src/CONST.js index eb07a1820c5b..199c13733afd 100755 --- a/src/CONST.js +++ b/src/CONST.js @@ -509,27 +509,25 @@ const CONST = { PREFIX: '__predefined_', SELF_SELECT: '__predefined_selfSelect', }, + get EXPENSIFY_EMAILS() { + return [ + this.EMAIL.CONCIERGE, + this.EMAIL.HELP, + this.EMAIL.RECEIPTS, + this.EMAIL.CHRONOS, + this.EMAIL.QA, + this.EMAIL.CONTRIBUTORS, + this.EMAIL.FIRST_RESPONDER, + this.EMAIL.QA_TRAVIS, + this.EMAIL.BILLS, + this.EMAIL.STUDENT_AMBASSADOR, + this.EMAIL.ACCOUNTING, + this.EMAIL.PAYROLL, + this.EMAIL.SVFG, + this.EMAIL.INTEGRATION_TESTING_CREDS, + this.EMAIL.ADMIN, + ]; + }, }; -const EXPENSIFY_EMAILS = [ - CONST.EMAIL.CONCIERGE, - CONST.EMAIL.HELP, - CONST.EMAIL.RECEIPTS, - CONST.EMAIL.CHRONOS, - CONST.EMAIL.QA, - CONST.EMAIL.CONTRIBUTORS, - CONST.EMAIL.FIRST_RESPONDER, - CONST.EMAIL.QA_TRAVIS, - CONST.EMAIL.BILLS, - CONST.EMAIL.STUDENT_AMBASSADOR, - CONST.EMAIL.ACCOUNTING, - CONST.EMAIL.PAYROLL, - CONST.EMAIL.SVFG, - CONST.EMAIL.INTEGRATION_TESTING_CREDS, - CONST.EMAIL.ADMIN, -]; - -export { - EXPENSIFY_EMAILS, -}; export default CONST; diff --git a/src/Expensify.js b/src/Expensify.js index 78ae766f4be9..66350a2ad2bb 100644 --- a/src/Expensify.js +++ b/src/Expensify.js @@ -14,7 +14,7 @@ import PushNotification from './libs/Notification/PushNotification'; import UpdateAppModal from './components/UpdateAppModal'; import Visibility from './libs/Visibility'; import GrowlNotification from './components/GrowlNotification'; -import {growlRef} from './libs/Growl'; +import * as Growl from './libs/Growl'; import StartupTimer from './libs/StartupTimer'; import Log from './libs/Log'; @@ -144,7 +144,7 @@ class Expensify extends PureComponent { } return ( <> - + {/* We include the modal for showing a new update at the top level so the option is always present. */} {this.props.updateAvailable ? : null} diff --git a/src/ROUTES.js b/src/ROUTES.js index 9facdbd64a1b..ca7d80b93881 100644 --- a/src/ROUTES.js +++ b/src/ROUTES.js @@ -1,5 +1,5 @@ import lodashGet from 'lodash/get'; -import {addTrailingForwardSlash} from './libs/Url'; +import * as Url from './libs/Url'; /** * This is a file containing constants for all of the routes we want to be able to go to @@ -102,7 +102,7 @@ export default { * @returns {Object} */ parseReportRouteParams: (route) => { - if (!route.startsWith(addTrailingForwardSlash(REPORT))) { + if (!route.startsWith(Url.addTrailingForwardSlash(REPORT))) { return {}; } diff --git a/src/components/AddPlaidBankAccount.js b/src/components/AddPlaidBankAccount.js index 8ce5a6cc4a1d..af3f95c3b458 100644 --- a/src/components/AddPlaidBankAccount.js +++ b/src/components/AddPlaidBankAccount.js @@ -9,13 +9,7 @@ import lodashGet from 'lodash/get'; import {withOnyx} from 'react-native-onyx'; import Log from '../libs/Log'; import PlaidLink from './PlaidLink'; -import { - clearPlaidBankAccountsAndToken, - fetchPlaidLinkToken, - getPlaidBankAccounts, - setBankAccountFormValidationErrors, - showBankAccountErrorModal, -} from '../libs/actions/BankAccounts'; +import * as BankAccounts from '../libs/actions/BankAccounts'; import ONYXKEYS from '../ONYXKEYS'; import styles from '../styles/styles'; import themeColors from '../styles/themes/default'; @@ -106,8 +100,8 @@ class AddPlaidBankAccount extends React.Component { } componentDidMount() { - clearPlaidBankAccountsAndToken(); - fetchPlaidLinkToken(); + BankAccounts.clearPlaidBankAccountsAndToken(); + BankAccounts.fetchPlaidLinkToken(); } /** @@ -127,13 +121,13 @@ class AddPlaidBankAccount extends React.Component { if (_.isUndefined(this.state.selectedIndex)) { errors.selectedBank = true; } - setBankAccountFormValidationErrors(errors); + BankAccounts.setBankAccountFormValidationErrors(errors); return _.size(errors) === 0; } selectAccount() { if (!this.validate()) { - showBankAccountErrorModal(); + BankAccounts.showBankAccountErrorModal(); return; } @@ -165,7 +159,7 @@ class AddPlaidBankAccount extends React.Component { token={this.props.plaidLinkToken} onSuccess={({publicToken, metadata}) => { Log.info('[PlaidLink] Success!'); - getPlaidBankAccounts(publicToken, metadata.institution.name); + BankAccounts.getPlaidBankAccounts(publicToken, metadata.institution.name); this.setState({institution: metadata.institution}); }} onError={(error) => { diff --git a/src/components/AddressSearch.js b/src/components/AddressSearch.js index 158e3829779b..855f7f7fe4d2 100644 --- a/src/components/AddressSearch.js +++ b/src/components/AddressSearch.js @@ -8,7 +8,7 @@ import withLocalize, {withLocalizePropTypes} from './withLocalize'; import styles from '../styles/styles'; import ExpensiTextInput from './ExpensiTextInput'; import Log from '../libs/Log'; -import {getAddressComponent, isAddressValidForVBA} from '../libs/GooglePlacesUtils'; +import * as GooglePlacesUtils from '../libs/GooglePlacesUtils'; // The error that's being thrown below will be ignored until we fork the // react-native-google-places-autocomplete repo and replace the @@ -51,17 +51,17 @@ const AddressSearch = (props) => { const saveLocationDetails = (details) => { const addressComponents = details.address_components; - if (isAddressValidForVBA(addressComponents)) { + if (GooglePlacesUtils.isAddressValidForVBA(addressComponents)) { // Gather the values from the Google details - const streetNumber = getAddressComponent(addressComponents, 'street_number', 'long_name'); - const streetName = getAddressComponent(addressComponents, 'route', 'long_name'); - let city = getAddressComponent(addressComponents, 'locality', 'long_name'); + const streetNumber = GooglePlacesUtils.getAddressComponent(addressComponents, 'street_number', 'long_name'); + const streetName = GooglePlacesUtils.getAddressComponent(addressComponents, 'route', 'long_name'); + let city = GooglePlacesUtils.getAddressComponent(addressComponents, 'locality', 'long_name'); if (!city) { - city = getAddressComponent(addressComponents, 'sublocality', 'long_name'); + city = GooglePlacesUtils.getAddressComponent(addressComponents, 'sublocality', 'long_name'); Log.hmmm('[AddressSearch] Replacing missing locality with sublocality: ', {address: details.formatted_address, sublocality: city}); } - const state = getAddressComponent(addressComponents, 'administrative_area_level_1', 'short_name'); - const zipCode = getAddressComponent(addressComponents, 'postal_code', 'long_name'); + const state = GooglePlacesUtils.getAddressComponent(addressComponents, 'administrative_area_level_1', 'short_name'); + const zipCode = GooglePlacesUtils.getAddressComponent(addressComponents, 'postal_code', 'long_name'); // Trigger text change events for each of the individual fields being saved on the server props.onChangeText('addressStreet', `${streetNumber} ${streetName}`); diff --git a/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.js b/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.js index 295c6a6541c8..7e95d407eb21 100644 --- a/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.js +++ b/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.js @@ -5,8 +5,8 @@ import lodashGet from 'lodash/get'; import Text from '../../Text'; import {propTypes, defaultProps} from '../anchorForCommentsOnlyPropTypes'; import PressableWithSecondaryInteraction from '../../PressableWithSecondaryInteraction'; -import {showContextMenu} from '../../../pages/home/report/ContextMenu/ReportActionContextMenu'; -import {CONTEXT_MENU_TYPES} from '../../../pages/home/report/ContextMenu/ContextMenuActions'; +import * as ReportActionContextMenu from '../../../pages/home/report/ContextMenu/ReportActionContextMenu'; +import * as ContextMenuActions from '../../../pages/home/report/ContextMenu/ContextMenuActions'; import AttachmentView from '../../AttachmentView'; import fileDownload from '../../../libs/fileDownload'; @@ -34,8 +34,8 @@ const BaseAnchorForCommentsOnly = (props) => { { - showContextMenu( - CONTEXT_MENU_TYPES.LINK, + ReportActionContextMenu.showContextMenu( + ContextMenuActions.CONTEXT_MENU_TYPES.LINK, event, props.href, lodashGet(linkRef, 'current'), diff --git a/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.native.js b/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.native.js index 49a3b581e27b..2cac487788bc 100644 --- a/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.native.js +++ b/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.native.js @@ -6,8 +6,8 @@ import {propTypes, defaultProps} from '../anchorForCommentsOnlyPropTypes'; import fileDownload from '../../../libs/fileDownload'; import Text from '../../Text'; import PressableWithSecondaryInteraction from '../../PressableWithSecondaryInteraction'; -import {showContextMenu} from '../../../pages/home/report/ContextMenu/ReportActionContextMenu'; -import {CONTEXT_MENU_TYPES} from '../../../pages/home/report/ContextMenu/ContextMenuActions'; +import * as ReportActionContextMenu from '../../../pages/home/report/ContextMenu/ReportActionContextMenu'; +import * as ContextMenuActions from '../../../pages/home/report/ContextMenu/ContextMenuActions'; import AttachmentView from '../../AttachmentView'; import styles from '../../../styles/styles'; @@ -37,8 +37,8 @@ const BaseAnchorForCommentsOnly = (props) => { { - showContextMenu( - CONTEXT_MENU_TYPES.LINK, + ReportActionContextMenu.showContextMenu( + ContextMenuActions.CONTEXT_MENU_TYPES.LINK, event, props.href, lodashGet(linkRef, 'current'), diff --git a/src/components/AttachmentPicker/index.js b/src/components/AttachmentPicker/index.js index c1d666d1d244..25191883f709 100644 --- a/src/components/AttachmentPicker/index.js +++ b/src/components/AttachmentPicker/index.js @@ -1,6 +1,6 @@ import React from 'react'; import CONST from '../../CONST'; -import * as attachmentPickerPropTypes from './attachmentPickerPropTypes'; +import {propTypes, defaultProps} from './attachmentPickerPropTypes'; /** * Returns acceptable FileTypes based on ATTACHMENT_PICKER_TYPE @@ -54,6 +54,6 @@ class AttachmentPicker extends React.Component { } } -AttachmentPicker.propTypes = attachmentPickerPropTypes.propTypes; -AttachmentPicker.defaultProps = attachmentPickerPropTypes.defaultProps; +AttachmentPicker.propTypes = propTypes; +AttachmentPicker.defaultProps = defaultProps; export default AttachmentPicker; diff --git a/src/components/AttachmentPicker/index.native.js b/src/components/AttachmentPicker/index.native.js index 20996c420a54..494d33bf76f2 100644 --- a/src/components/AttachmentPicker/index.native.js +++ b/src/components/AttachmentPicker/index.native.js @@ -10,7 +10,7 @@ import {propTypes as basePropTypes, defaultProps} from './attachmentPickerPropTy import styles from '../../styles/styles'; import Popover from '../Popover'; import MenuItem from '../MenuItem'; -import {Camera, Gallery, Paperclip} from '../Icon/Expensicons'; +import * as Expensicons from '../Icon/Expensicons'; import withWindowDimensions, {windowDimensionsPropTypes} from '../withWindowDimensions'; import withLocalize, {withLocalizePropTypes} from '../withLocalize'; import compose from '../../libs/compose'; @@ -86,12 +86,12 @@ class AttachmentPicker extends Component { this.menuItemData = [ { - icon: Camera, + icon: Expensicons.Camera, textTranslationKey: 'attachmentPicker.takePhoto', pickAttachment: () => this.showImagePicker(launchCamera), }, { - icon: Gallery, + icon: Expensicons.Gallery, textTranslationKey: 'attachmentPicker.chooseFromGallery', pickAttachment: () => this.showImagePicker(launchImageLibrary), }, @@ -102,7 +102,7 @@ class AttachmentPicker extends Component { if (this.props.type !== CONST.ATTACHMENT_PICKER_TYPE.IMAGE) { this.menuItemData.push( { - icon: Paperclip, + icon: Expensicons.Paperclip, textTranslationKey: 'attachmentPicker.chooseDocument', pickAttachment: () => this.showDocumentPicker(), }, diff --git a/src/components/AttachmentView.js b/src/components/AttachmentView.js index 1e6eab70fc93..ac0ba78936b9 100755 --- a/src/components/AttachmentView.js +++ b/src/components/AttachmentView.js @@ -6,7 +6,7 @@ import styles from '../styles/styles'; import PDFView from './PDFView'; import ImageView from './ImageView'; import Icon from './Icon'; -import {Paperclip, Download} from './Icon/Expensicons'; +import * as Expensicons from './Icon/Expensicons'; import withLocalize, {withLocalizePropTypes} from './withLocalize'; import compose from '../libs/compose'; import Text from './Text'; @@ -60,13 +60,13 @@ const AttachmentView = (props) => { style={styles.defaultAttachmentView} > - + {props.file && props.file.name} {props.shouldShowDownloadIcon && ( - + )} diff --git a/src/components/AvatarWithImagePicker.js b/src/components/AvatarWithImagePicker.js index 1dacf4b88c68..7ac5303b02b8 100644 --- a/src/components/AvatarWithImagePicker.js +++ b/src/components/AvatarWithImagePicker.js @@ -8,9 +8,7 @@ import lodashGet from 'lodash/get'; import Avatar from './Avatar'; import Icon from './Icon'; import PopoverMenu from './PopoverMenu'; -import { - Upload, Trashcan, Camera, Sync, -} from './Icon/Expensicons'; +import * as Expensicons from './Icon/Expensicons'; import styles from '../styles/styles'; import themeColors from '../styles/themes/default'; import AttachmentPicker from './AttachmentPicker'; @@ -127,7 +125,7 @@ class AvatarWithImagePicker extends React.Component { createMenuItems(openPicker) { const menuItems = [ { - icon: Upload, + icon: Expensicons.Upload, text: this.props.translate('avatarWithImagePicker.uploadPhoto'), onSelected: () => { openPicker({ @@ -146,7 +144,7 @@ class AvatarWithImagePicker extends React.Component { // If current avatar isn't a default avatar, allow Remove Photo option if (!this.props.isUsingDefaultAvatar) { menuItems.push({ - icon: Trashcan, + icon: Expensicons.Trashcan, text: this.props.translate('avatarWithImagePicker.removePhoto'), onSelected: () => { this.props.onImageRemoved(); @@ -197,7 +195,7 @@ class AvatarWithImagePicker extends React.Component { {this.props.isSyncing && ( { const wrapperStyles = ({pressed}) => ([ styles.badge, styles.ml2, - getBadgeColorStyle(props.success, props.error, pressed), + StyleUtils.getBadgeColorStyle(props.success, props.error, pressed), ...props.badgeStyles, ]); diff --git a/src/components/ButtonWithDropdown.js b/src/components/ButtonWithDropdown.js index bc3c94d66be7..f2193629b5b0 100644 --- a/src/components/ButtonWithDropdown.js +++ b/src/components/ButtonWithDropdown.js @@ -4,7 +4,7 @@ import {View} from 'react-native'; import styles from '../styles/styles'; import Button from './Button'; import Icon from './Icon'; -import {DownArrow} from './Icon/Expensicons'; +import * as Expensicons from './Icon/Expensicons'; import themeColors from '../styles/themes/default'; const propTypes = { @@ -43,7 +43,7 @@ const ButtonWithDropdown = props => ( onPress={props.onDropdownPress} shouldRemoveLeftBorderRadius ContentComponent={() => ( - + )} /> diff --git a/src/components/Checkbox.js b/src/components/Checkbox.js index 970363b193ee..81412da8d7c3 100644 --- a/src/components/Checkbox.js +++ b/src/components/Checkbox.js @@ -3,7 +3,7 @@ import {View, Pressable} from 'react-native'; import PropTypes from 'prop-types'; import styles from '../styles/styles'; import Icon from './Icon'; -import {Checkmark} from './Icon/Expensicons'; +import * as Expensicons from './Icon/Expensicons'; const propTypes = { /** Whether checkbox is checked */ @@ -37,7 +37,7 @@ const Checkbox = props => ( props.disabled && styles.cursorDisabled, ]} > - + ); diff --git a/src/components/CollapsibleSection/index.js b/src/components/CollapsibleSection/index.js index b30cb5b0122a..2a423e568930 100644 --- a/src/components/CollapsibleSection/index.js +++ b/src/components/CollapsibleSection/index.js @@ -5,7 +5,7 @@ import Collapsible from './Collapsible'; import Text from '../Text'; import styles from '../../styles/styles'; import Icon from '../Icon'; -import {DownArrow, UpArrow} from '../Icon/Expensicons'; +import * as Expensicons from '../Icon/Expensicons'; const propTypes = { /** Title of the Collapsible section */ @@ -34,7 +34,7 @@ class CollapsibleSection extends React.Component { } render() { - const src = this.state.isExpanded ? UpArrow : DownArrow; + const src = this.state.isExpanded ? Expensicons.UpArrow : Expensicons.DownArrow; return ( diff --git a/src/components/CommunicationsLink.js b/src/components/CommunicationsLink.js index e2b156daea46..e8f2de75259d 100644 --- a/src/components/CommunicationsLink.js +++ b/src/components/CommunicationsLink.js @@ -3,7 +3,7 @@ import {View, Pressable, Linking} from 'react-native'; import PropTypes from 'prop-types'; import styles from '../styles/styles'; import compose from '../libs/compose'; -import {Checkmark, Clipboard as ClipboardIcon} from './Icon/Expensicons'; +import * as Expensicons from './Icon/Expensicons'; import Clipboard from '../libs/Clipboard'; import ContextMenuItem from './ContextMenuItem'; import withLocalize, {withLocalizePropTypes} from './withLocalize'; @@ -55,9 +55,9 @@ const CommunicationsLink = props => ( ) : props.children} [ styles.reportActionContextMenuMiniButton, - getButtonBackgroundColorStyle(getButtonState(hovered, pressed, this.state.success)), + StyleUtils.getButtonBackgroundColorStyle(getButtonState(hovered, pressed, this.state.success)), ] } > {({hovered, pressed}) => ( )} diff --git a/src/components/CopyTextToClipboard.js b/src/components/CopyTextToClipboard.js index ef721eaac69a..a9f2ab8d508d 100644 --- a/src/components/CopyTextToClipboard.js +++ b/src/components/CopyTextToClipboard.js @@ -1,7 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import Text from './Text'; -import {Checkmark, Clipboard as ClipboardIcon} from './Icon/Expensicons'; +import * as Expensicons from './Icon/Expensicons'; import Clipboard from '../libs/Clipboard'; import Icon from './Icon'; import styles from '../styles/styles'; @@ -52,8 +52,8 @@ class CopyTextToClipboard extends React.Component { > {this.props.text} {this.state.showCheckmark - ? - : } + ? + : } ); } diff --git a/src/components/FAB/FAB.js b/src/components/FAB/FAB.js index ad9e72325de4..8cbb277659fb 100644 --- a/src/components/FAB/FAB.js +++ b/src/components/FAB/FAB.js @@ -3,8 +3,9 @@ import { Pressable, Animated, Easing, } from 'react-native'; import Icon from '../Icon'; -import {Plus} from '../Icon/Expensicons'; -import styles, {getAnimatedFABStyle} from '../../styles/styles'; +import * as Expensicons from '../Icon/Expensicons'; +import styles from '../../styles/styles'; +import * as StyleUtils from '../../styles/StyleUtils'; import themeColors from '../../styles/themes/default'; import fabPropTypes from './fabPropTypes'; import Tooltip from '../Tooltip'; @@ -69,10 +70,10 @@ class FAB extends PureComponent { onPress={this.props.onPress} style={[ styles.floatingActionButton, - getAnimatedFABStyle(rotate, backgroundColor), + StyleUtils.getAnimatedFABStyle(rotate, backgroundColor), ]} > - + ); diff --git a/src/components/FormAlertWithSubmitButton.js b/src/components/FormAlertWithSubmitButton.js index d7db46120845..9c90472b016c 100644 --- a/src/components/FormAlertWithSubmitButton.js +++ b/src/components/FormAlertWithSubmitButton.js @@ -4,7 +4,7 @@ import {View} from 'react-native'; import PropTypes from 'prop-types'; import styles from '../styles/styles'; import Icon from './Icon'; -import {Exclamation} from './Icon/Expensicons'; +import * as Expensicons from './Icon/Expensicons'; import colors from '../styles/colors'; import Button from './Button'; import withLocalize, {withLocalizePropTypes} from './withLocalize'; @@ -98,7 +98,7 @@ const FormAlertWithSubmitButton = (props) => { {props.isAlertVisible && ( - + {getAlertPrompt()} )} diff --git a/src/components/GrowlNotification/GrowlNotificationContainer/index.native.js b/src/components/GrowlNotification/GrowlNotificationContainer/index.native.js index c90aa162b5a1..2eb32a511bce 100644 --- a/src/components/GrowlNotification/GrowlNotificationContainer/index.native.js +++ b/src/components/GrowlNotification/GrowlNotificationContainer/index.native.js @@ -1,7 +1,8 @@ import React from 'react'; import {Animated} from 'react-native'; import {SafeAreaInsetsContext} from 'react-native-safe-area-context'; -import styles, {getSafeAreaPadding} from '../../../styles/styles'; +import styles from '../../../styles/styles'; +import * as StyleUtils from '../../../styles/StyleUtils'; import growlNotificationContainerPropTypes from './growlNotificationContainerPropTypes'; const propTypes = { @@ -14,7 +15,7 @@ const GrowlNotificationContainer = props => ( diff --git a/src/components/GrowlNotification/index.js b/src/components/GrowlNotification/index.js index 0c83024f1a35..d5d8659d307b 100644 --- a/src/components/GrowlNotification/index.js +++ b/src/components/GrowlNotification/index.js @@ -8,22 +8,22 @@ import { import colors from '../../styles/colors'; import Text from '../Text'; import Icon from '../Icon'; -import {Checkmark, Exclamation} from '../Icon/Expensicons'; +import * as Expensicons from '../Icon/Expensicons'; import styles from '../../styles/styles'; import GrowlNotificationContainer from './GrowlNotificationContainer'; import CONST from '../../CONST'; const types = { [CONST.GROWL.SUCCESS]: { - icon: Checkmark, + icon: Expensicons.Checkmark, iconColor: colors.green, }, [CONST.GROWL.ERROR]: { - icon: Exclamation, + icon: Expensicons.Exclamation, iconColor: colors.red, }, [CONST.GROWL.WARNING]: { - icon: Exclamation, + icon: Expensicons.Exclamation, iconColor: colors.yellow, }, }; diff --git a/src/components/HTMLEngineProvider/BaseHTMLEngineProvider.js b/src/components/HTMLEngineProvider/BaseHTMLEngineProvider.js index d68954d4fff8..a97b8a70e18d 100755 --- a/src/components/HTMLEngineProvider/BaseHTMLEngineProvider.js +++ b/src/components/HTMLEngineProvider/BaseHTMLEngineProvider.js @@ -12,7 +12,8 @@ import { import PropTypes from 'prop-types'; import lodashGet from 'lodash/get'; import Config from '../../CONFIG'; -import styles, {webViewStyles, getFontFamilyMonospace} from '../../styles/styles'; +import styles from '../../styles/styles'; +import * as StyleUtils from '../../styles/StyleUtils'; import fontFamily from '../../styles/fontFamily'; import AnchorForCommentsOnly from '../AnchorForCommentsOnly'; import InlineCodeBlock from '../InlineCodeBlock'; @@ -150,7 +151,7 @@ function CodeRenderer(props) { const {boxModelStyle, otherStyle: textStyle} = splitBoxModelStyle(props.style); // Get the correct fontFamily variant based in the fontStyle and fontWeight - const font = getFontFamilyMonospace({ + const font = StyleUtils.getFontFamilyMonospace({ fontStyle: textStyle.fontStyle, fontWeight: textStyle.fontWeight, }); @@ -243,7 +244,7 @@ function ImgRenderer(props) { > @@ -297,8 +298,8 @@ const BaseHTMLEngineProvider = (props) => { return ( ( onPress={props.onBackButtonPress} style={[styles.touchableButtonImage]} > - + )} @@ -99,7 +99,7 @@ const HeaderWithCloseButton = props => ( onPress={props.onDownloadButtonPress} style={[styles.touchableButtonImage]} > - + ) @@ -114,7 +114,7 @@ const HeaderWithCloseButton = props => ( accessibilityRole="button" accessibilityLabel={props.translate('common.close')} > - + diff --git a/src/components/IOUConfirmationList.js b/src/components/IOUConfirmationList.js index 988a67abae6d..391ed1cc986b 100755 --- a/src/components/IOUConfirmationList.js +++ b/src/components/IOUConfirmationList.js @@ -7,11 +7,7 @@ import _ from 'underscore'; import styles from '../styles/styles'; import Text from './Text'; import themeColors from '../styles/themes/default'; -import { - addSMSDomainIfPhoneNumber, - getIOUConfirmationOptionsFromMyPersonalDetail, - getIOUConfirmationOptionsFromParticipants, -} from '../libs/OptionsListUtils'; +import * as OptionsListUtils from '../libs/OptionsListUtils'; import OptionsList from './OptionsList'; import ONYXKEYS from '../ONYXKEYS'; import withLocalize, {withLocalizePropTypes} from './withLocalize'; @@ -21,12 +17,10 @@ import FixedFooter from './FixedFooter'; import ExpensiTextInput from './ExpensiTextInput'; import CONST from '../CONST'; import ButtonWithMenu from './ButtonWithMenu'; -import { - Cash, Wallet, Venmo, PayPal, -} from './Icon/Expensicons'; +import * as Expensicons from './Icon/Expensicons'; import Permissions from '../libs/Permissions'; import isAppInstalled from '../libs/isAppInstalled'; -import {isValidUSPhone} from '../libs/ValidationUtils'; +import * as ValidationUtils from '../libs/ValidationUtils'; import makeCancellablePromise from '../libs/MakeCancellablePromise'; const propTypes = { @@ -141,14 +135,14 @@ class IOUConfirmationList extends Component { if (this.props.iouType === CONST.IOU.IOU_TYPE.SEND && this.props.participants.length === 1 && Permissions.canUseIOUSend(this.props.betas)) { // Add the Expensify Wallet option if available and make it the first option if (this.props.localCurrencyCode === CONST.CURRENCY.USD && Permissions.canUsePayWithExpensify(this.props.betas) && Permissions.canUseWallet(this.props.betas)) { - confirmationButtonOptions.push({text: this.props.translate('iou.settleExpensify'), icon: Wallet}); + confirmationButtonOptions.push({text: this.props.translate('iou.settleExpensify'), icon: Expensicons.Wallet}); } // Add PayPal option if (this.props.participants[0].payPalMeAddress) { - confirmationButtonOptions.push({text: this.props.translate('iou.settlePaypalMe'), icon: PayPal}); + confirmationButtonOptions.push({text: this.props.translate('iou.settlePaypalMe'), icon: Expensicons.PayPal}); } - defaultButtonOption = {text: this.props.translate('iou.settleElsewhere'), icon: Cash}; + defaultButtonOption = {text: this.props.translate('iou.settleElsewhere'), icon: Expensicons.Cash}; } confirmationButtonOptions.push(defaultButtonOption); @@ -218,7 +212,7 @@ class IOUConfirmationList extends Component { * @returns {Array} */ getParticipantsWithAmount(participants) { - return getIOUConfirmationOptionsFromParticipants( + return OptionsListUtils.getIOUConfirmationOptionsFromParticipants( participants, this.props.numberFormat(this.calculateAmount(participants) / 100, { style: 'currency', @@ -250,7 +244,7 @@ class IOUConfirmationList extends Component { const formattedSelectedParticipants = this.getParticipantsWithAmount(selectedParticipants); const formattedUnselectedParticipants = this.getParticipantsWithoutAmount(unselectedParticipants); - const formattedMyPersonalDetails = getIOUConfirmationOptionsFromMyPersonalDetail( + const formattedMyPersonalDetails = OptionsListUtils.getIOUConfirmationOptionsFromMyPersonalDetail( this.props.myPersonalDetails, this.props.numberFormat(this.calculateAmount(selectedParticipants, true) / 100, { style: 'currency', @@ -275,7 +269,7 @@ class IOUConfirmationList extends Component { indexOffset: 0, }); } else { - const formattedParticipants = getIOUConfirmationOptionsFromParticipants(this.props.participants, + const formattedParticipants = OptionsListUtils.getIOUConfirmationOptionsFromParticipants(this.props.participants, this.props.numberFormat(this.props.iouAmount, { style: 'currency', currency: this.props.iou.selectedCurrencyCode, @@ -303,7 +297,7 @@ class IOUConfirmationList extends Component { } const selectedParticipants = this.getSelectedParticipants(); const splits = _.map(selectedParticipants, participant => ({ - email: addSMSDomainIfPhoneNumber(participant.login), + email: OptionsListUtils.addSMSDomainIfPhoneNumber(participant.login), // We should send in cents to API // Cents is temporary and there must be support for other currencies in the future @@ -311,7 +305,7 @@ class IOUConfirmationList extends Component { })); splits.push({ - email: addSMSDomainIfPhoneNumber(this.props.myPersonalDetails.login), + email: OptionsListUtils.addSMSDomainIfPhoneNumber(this.props.myPersonalDetails.login), // The user is default and we should send in cents to API // USD is temporary and there must be support for other currencies in the future @@ -331,7 +325,7 @@ class IOUConfirmationList extends Component { const selectedParticipants = this.getSelectedParticipants(); return [ ...selectedParticipants, - getIOUConfirmationOptionsFromMyPersonalDetail(this.props.myPersonalDetails), + OptionsListUtils.getIOUConfirmationOptionsFromMyPersonalDetail(this.props.myPersonalDetails), ]; } @@ -339,7 +333,7 @@ class IOUConfirmationList extends Component { * Adds Venmo, if available, as the second option in the menu of payment options */ addVenmoPaymentOptionToMenu() { - if (this.props.localCurrencyCode !== CONST.CURRENCY.USD || !this.state.participants[0].phoneNumber || !isValidUSPhone(this.state.participants[0].phoneNumber)) { + if (this.props.localCurrencyCode !== CONST.CURRENCY.USD || !this.state.participants[0].phoneNumber || !ValidationUtils.isValidUSPhone(this.state.participants[0].phoneNumber)) { return; } @@ -353,7 +347,7 @@ class IOUConfirmationList extends Component { this.setState(prevState => ({ confirmationButtonOptions: [...prevState.confirmationButtonOptions.slice(0, 1), - {text: this.props.translate('iou.settleVenmo'), icon: Venmo}, + {text: this.props.translate('iou.settleVenmo'), icon: Expensicons.Venmo}, ...prevState.confirmationButtonOptions.slice(1), ], })); diff --git a/src/components/Icon/BankIcons.js b/src/components/Icon/BankIcons.js index 8e5f48ceedce..ff7c1fb95271 100644 --- a/src/components/Icon/BankIcons.js +++ b/src/components/Icon/BankIcons.js @@ -1,5 +1,5 @@ import _ from 'underscore'; -import {CreditCard} from './Expensicons'; +import * as Expensicons from './Expensicons'; import AmericanExpress from '../../../assets/images/bankicons/american-express.svg'; import BankOfAmerica from '../../../assets/images/bankicons/bank-of-america.svg'; import BB_T from '../../../assets/images/bankicons/bb-t.svg'; @@ -101,7 +101,7 @@ function getAssetIcon(bankName, isCard) { return USAA; } - return isCard ? CreditCard : GenericBank; + return isCard ? Expensicons.CreditCard : GenericBank; } /** @@ -113,7 +113,7 @@ function getAssetIcon(bankName, isCard) { export default function getBankIcon(bankName, isCard) { const bankIcon = { - icon: isCard ? CreditCard : GenericBank, + icon: isCard ? Expensicons.CreditCard : GenericBank, }; if (bankName) { @@ -121,7 +121,7 @@ export default function getBankIcon(bankName, isCard) { } // For default Credit Card icon the icon size should not be set. - if (!_.contains([CreditCard], bankIcon.icon)) { + if (!_.contains([Expensicons.CreditCard], bankIcon.icon)) { bankIcon.iconSize = variables.iconSizeExtraLarge; } diff --git a/src/components/ImageView/index.js b/src/components/ImageView/index.js index a2115383619d..878adc18c239 100644 --- a/src/components/ImageView/index.js +++ b/src/components/ImageView/index.js @@ -3,7 +3,8 @@ import PropTypes from 'prop-types'; import { View, Image, Pressable, } from 'react-native'; -import styles, {getZoomCursorStyle, getZoomSizingStyle} from '../../styles/styles'; +import styles from '../../styles/styles'; +import * as StyleUtils from '../../styles/StyleUtils'; import canUseTouchScreen from '../../libs/canUseTouchscreen'; import withWindowDimensions, {windowDimensionsPropTypes} from '../withWindowDimensions'; @@ -180,8 +181,8 @@ class ImageView extends PureComponent { > { let imageWidth = width; diff --git a/src/components/InboxCallButton.js b/src/components/InboxCallButton.js index c8d4c240db0a..770a73c4d2eb 100644 --- a/src/components/InboxCallButton.js +++ b/src/components/InboxCallButton.js @@ -6,7 +6,7 @@ import Navigation from '../libs/Navigation/Navigation'; import ROUTES from '../ROUTES'; import Tooltip from './Tooltip'; import Button from './Button'; -import {Phone} from './Icon/Expensicons'; +import * as Expensicons from './Icon/Expensicons'; const propTypes = { ...withLocalizePropTypes, @@ -30,7 +30,7 @@ const InboxCallButton = props => ( }} text={props.translate('requestCallPage.callButton')} small - icon={Phone} + icon={Expensicons.Phone} /> ); diff --git a/src/components/InvertedFlatList/BaseInvertedFlatList.js b/src/components/InvertedFlatList/BaseInvertedFlatList.js index e768d078caf0..0ecf5234501a 100644 --- a/src/components/InvertedFlatList/BaseInvertedFlatList.js +++ b/src/components/InvertedFlatList/BaseInvertedFlatList.js @@ -3,7 +3,7 @@ import _ from 'underscore'; import React, {forwardRef, Component} from 'react'; import PropTypes from 'prop-types'; import {FlatList, View} from 'react-native'; -import {lastItem} from '../../libs/CollectionUtils'; +import * as CollectionUtils from '../../libs/CollectionUtils'; const propTypes = { /** Same as FlatList can be any array of anything */ @@ -71,7 +71,7 @@ class BaseInvertedFlatList extends Component { // If we don't have a size yet means we haven't measured this // item yet. However, we can still calculate the offset by looking // at the last size we have recorded (if any) - const lastMeasuredItem = lastItem(this.sizeMap); + const lastMeasuredItem = CollectionUtils.lastItem(this.sizeMap); return { // We haven't measured this so we must return the minimum row height diff --git a/src/components/LocalePicker.js b/src/components/LocalePicker.js index 06bdf60ef2c2..63e4f54793c6 100644 --- a/src/components/LocalePicker.js +++ b/src/components/LocalePicker.js @@ -3,12 +3,12 @@ import React from 'react'; import {withOnyx} from 'react-native-onyx'; import PropTypes from 'prop-types'; import compose from '../libs/compose'; -import {setLocale} from '../libs/actions/App'; +import * as App from '../libs/actions/App'; import withLocalize, {withLocalizePropTypes} from './withLocalize'; import ONYXKEYS from '../ONYXKEYS'; import CONST from '../CONST'; import Permissions from '../libs/Permissions'; -import {translate} from '../libs/translate'; +import * as Localize from '../libs/Localize'; import ExpensiPicker from './ExpensiPicker'; const propTypes = { @@ -33,11 +33,11 @@ const defaultProps = { const localesToLanguages = { default: { value: 'en', - label: translate('en', 'preferencesPage.languages.english'), + label: Localize.translate('en', 'preferencesPage.languages.english'), }, es: { value: 'es', - label: translate('es', 'preferencesPage.languages.spanish'), + label: Localize.translate('es', 'preferencesPage.languages.spanish'), }, }; @@ -54,7 +54,7 @@ const LocalePicker = (props) => { return; } - setLocale(locale); + App.setLocale(locale); }} items={_.values(localesToLanguages)} size={props.size} diff --git a/src/components/MenuItem.js b/src/components/MenuItem.js index 0e4d23b38b4f..2f9e261d82e3 100644 --- a/src/components/MenuItem.js +++ b/src/components/MenuItem.js @@ -4,9 +4,10 @@ import { View, Pressable, } from 'react-native'; import Text from './Text'; -import styles, {getButtonBackgroundColorStyle, getIconFillColor} from '../styles/styles'; +import styles from '../styles/styles'; +import * as StyleUtils from '../styles/StyleUtils'; import Icon from './Icon'; -import {ArrowRight} from './Icon/Expensicons'; +import * as Expensicons from './Icon/Expensicons'; import getButtonState from '../libs/getButtonState'; import Avatar from './Avatar'; import Badge from './Badge'; @@ -26,7 +27,7 @@ const defaultProps = { iconWidth: undefined, iconHeight: undefined, description: undefined, - iconRight: ArrowRight, + iconRight: Expensicons.ArrowRight, iconStyles: [], iconFill: undefined, focused: false, @@ -48,7 +49,7 @@ const MenuItem = props => ( }} style={({hovered, pressed}) => ([ styles.popoverMenuItem, - getButtonBackgroundColorStyle(getButtonState(props.focused || hovered, pressed, props.success, props.disabled, props.interactive)), + StyleUtils.getButtonBackgroundColorStyle(getButtonState(props.focused || hovered, pressed, props.success, props.disabled, props.interactive)), ..._.isArray(props.wrapperStyle) ? props.wrapperStyle : [props.wrapperStyle], ])} disabled={props.disabled} @@ -67,7 +68,7 @@ const MenuItem = props => ( src={props.icon} width={props.iconWidth} height={props.iconHeight} - fill={props.iconFill || getIconFillColor( + fill={props.iconFill || StyleUtils.getIconFillColor( getButtonState(props.focused || hovered, pressed, props.success, props.disabled, props.interactive), )} /> @@ -119,7 +120,7 @@ const MenuItem = props => ( )} diff --git a/src/components/Modal/BaseModal.js b/src/components/Modal/BaseModal.js index 8b6416e6fe7d..d6f0a7cbc424 100644 --- a/src/components/Modal/BaseModal.js +++ b/src/components/Modal/BaseModal.js @@ -3,11 +3,12 @@ import {View} from 'react-native'; import PropTypes from 'prop-types'; import ReactNativeModal from 'react-native-modal'; import {SafeAreaInsetsContext} from 'react-native-safe-area-context'; -import styles, {getModalPaddingStyles, getSafeAreaPadding} from '../../styles/styles'; +import styles from '../../styles/styles'; +import * as StyleUtils from '../../styles/StyleUtils'; import themeColors from '../../styles/themes/default'; import {propTypes as modalPropTypes, defaultProps as modalDefaultProps} from './modalPropTypes'; import getModalStyles from '../../styles/getModalStyles'; -import {setModalVisibility, willAlertModalBecomeVisible} from '../../libs/actions/Modal'; +import * as Modal from '../../libs/actions/Modal'; const propTypes = { ...modalPropTypes, @@ -33,7 +34,7 @@ class BaseModal extends PureComponent { return; } - willAlertModalBecomeVisible(this.props.isVisible); + Modal.willAlertModalBecomeVisible(this.props.isVisible); } componentWillUnmount() { @@ -47,7 +48,7 @@ class BaseModal extends PureComponent { */ hideModal(callHideCallback = true) { if (this.props.shouldSetModalVisibility) { - setModalVisibility(false); + Modal.setModalVisibility(false); } if (callHideCallback) { this.props.onModalHide(); @@ -88,7 +89,7 @@ class BaseModal extends PureComponent { onBackButtonPress={this.props.onClose} onModalShow={() => { if (this.props.shouldSetModalVisibility) { - setModalVisibility(true); + Modal.setModalVisibility(true); } this.props.onModalShow(); }} @@ -119,9 +120,9 @@ class BaseModal extends PureComponent { paddingBottom: safeAreaPaddingBottom, paddingLeft: safeAreaPaddingLeft, paddingRight: safeAreaPaddingRight, - } = getSafeAreaPadding(insets); + } = StyleUtils.getSafeAreaPadding(insets); - const modalPaddingStyles = getModalPaddingStyles({ + const modalPaddingStyles = StyleUtils.getModalPaddingStyles({ safeAreaPaddingTop, safeAreaPaddingBottom, safeAreaPaddingLeft, diff --git a/src/components/PDFView/index.native.js b/src/components/PDFView/index.native.js index 89e74ee5ca49..be24d7a35f48 100644 --- a/src/components/PDFView/index.native.js +++ b/src/components/PDFView/index.native.js @@ -2,7 +2,8 @@ import React from 'react'; import PropTypes from 'prop-types'; import {TouchableWithoutFeedback} from 'react-native'; import PDF from 'react-native-pdf'; -import styles, {getWidthAndHeightStyle} from '../../styles/styles'; +import styles from '../../styles/styles'; +import * as StyleUtils from '../../styles/StyleUtils'; import withWindowDimensions, {windowDimensionsPropTypes} from '../withWindowDimensions'; import FullScreenLoadingIndicator from '../FullscreenLoadingIndicator'; @@ -36,7 +37,7 @@ const PDFView = props => ( source={{uri: props.sourceURL}} style={[ styles.imageModalPDF, - getWidthAndHeightStyle(props.windowWidth, props.windowHeight), + StyleUtils.getWidthAndHeightStyle(props.windowWidth, props.windowHeight), ]} /> diff --git a/src/components/Picker/pickerPropTypes.js b/src/components/Picker/pickerPropTypes.js index 1e25bff6d347..ef8c0589a64a 100644 --- a/src/components/Picker/pickerPropTypes.js +++ b/src/components/Picker/pickerPropTypes.js @@ -2,7 +2,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import Icon from '../Icon'; import styles from '../../styles/styles'; -import {DownArrow} from '../Icon/Expensicons'; +import * as Expensicons from '../Icon/Expensicons'; const propTypes = { /** A callback method that is called when the value changes and it received the selected value as an argument */ @@ -53,12 +53,12 @@ const defaultProps = { ) : ( )} diff --git a/src/components/ReportActionItem/IOUPreview.js b/src/components/ReportActionItem/IOUPreview.js index 92ec8b48d3a0..c76d1ce450d7 100644 --- a/src/components/ReportActionItem/IOUPreview.js +++ b/src/components/ReportActionItem/IOUPreview.js @@ -15,11 +15,11 @@ import styles from '../../styles/styles'; import ONYXKEYS from '../../ONYXKEYS'; import MultipleAvatars from '../MultipleAvatars'; import withLocalize, {withLocalizePropTypes} from '../withLocalize'; -import {fetchIOUReportByID} from '../../libs/actions/Report'; +import * as Report from '../../libs/actions/Report'; import themeColors from '../../styles/themes/default'; import Icon from '../Icon'; import CONST from '../../CONST'; -import {Checkmark} from '../Icon/Expensicons'; +import * as Expensicons from '../Icon/Expensicons'; import Text from '../Text'; const propTypes = { @@ -92,7 +92,7 @@ const IOUPreview = (props) => { const reportIsLoading = _.isEmpty(props.iouReport); if (reportIsLoading) { - fetchIOUReportByID(props.iouReportID, props.chatReportID); + Report.fetchIOUReportByID(props.iouReportID, props.chatReportID); } const managerName = lodashGet(props.personalDetails, [managerEmail, 'firstName'], '') @@ -116,7 +116,7 @@ const IOUPreview = (props) => { {!props.iouReport.hasOutstandingIOU && ( - + )} diff --git a/src/components/ReportTransaction.js b/src/components/ReportTransaction.js index a81812a6e536..599fa482c4b0 100644 --- a/src/components/ReportTransaction.js +++ b/src/components/ReportTransaction.js @@ -9,7 +9,7 @@ import _ from 'underscore'; import ONYXKEYS from '../ONYXKEYS'; import styles from '../styles/styles'; import themeColors from '../styles/themes/default'; -import {rejectTransaction} from '../libs/actions/IOU'; +import * as IOU from '../libs/actions/IOU'; import reportActionPropTypes from '../pages/home/report/reportActionPropTypes'; import ReportActionItemSingle from '../pages/home/report/ReportActionItemSingle'; import Text from './Text'; @@ -54,7 +54,7 @@ class ReportTransaction extends Component { } rejectTransaction() { - rejectTransaction({ + IOU.rejectTransaction({ reportID: this.props.iouReportID, chatReportID: this.props.chatReportID, transactionID: this.props.action.originalMessage.IOUTransactionID, diff --git a/src/components/ReportWelcomeText.js b/src/components/ReportWelcomeText.js index 9624cee94e72..480b65336e06 100644 --- a/src/components/ReportWelcomeText.js +++ b/src/components/ReportWelcomeText.js @@ -8,7 +8,7 @@ import styles from '../styles/styles'; import Text from './Text'; import withLocalize, {withLocalizePropTypes} from './withLocalize'; import compose from '../libs/compose'; -import {getPersonalDetailsForLogins} from '../libs/OptionsListUtils'; +import * as OptionsListUtils from '../libs/OptionsListUtils'; import ONYXKEYS from '../ONYXKEYS'; import CONST from '../CONST'; @@ -47,7 +47,7 @@ const ReportWelcomeText = (props) => { const participants = lodashGet(props.report, 'participants', []); const isMultipleParticipant = participants.length > 1; const displayNamesWithTooltips = _.map( - getPersonalDetailsForLogins(participants, props.personalDetails), + OptionsListUtils.getPersonalDetailsForLogins(participants, props.personalDetails), ({ displayName, firstName, login, pronouns, }) => { diff --git a/src/components/SVGImage/index.js b/src/components/SVGImage/index.js index be19eb3d0841..aaddf8e853a0 100644 --- a/src/components/SVGImage/index.js +++ b/src/components/SVGImage/index.js @@ -1,11 +1,11 @@ import React from 'react'; import {Image} from 'react-native'; -import {getWidthAndHeightStyle} from '../../styles/styles'; +import * as StyleUtils from '../../styles/StyleUtils'; import propTypes from './propTypes'; const SVGImage = props => ( ); diff --git a/src/components/ScreenWrapper.js b/src/components/ScreenWrapper.js index 34185c95d8ed..833b2e090b73 100644 --- a/src/components/ScreenWrapper.js +++ b/src/components/ScreenWrapper.js @@ -5,7 +5,8 @@ import {View} from 'react-native'; import {withNavigation} from '@react-navigation/compat'; import {SafeAreaInsetsContext} from 'react-native-safe-area-context'; import {withOnyx} from 'react-native-onyx'; -import styles, {getSafeAreaPadding} from '../styles/styles'; +import styles from '../styles/styles'; +import * as StyleUtils from '../styles/StyleUtils'; import HeaderGap from './HeaderGap'; import KeyboardShortcutsModal from './KeyboardShortcutsModal'; import KeyboardShortcut from '../libs/KeyboardShortcut'; @@ -97,7 +98,7 @@ class ScreenWrapper extends React.Component { return ( {(insets) => { - const {paddingTop, paddingBottom} = getSafeAreaPadding(insets); + const {paddingTop, paddingBottom} = StyleUtils.getSafeAreaPadding(insets); const paddingStyle = {}; if (this.props.includePaddingTop) { diff --git a/src/components/TextInputAutoWidth.js b/src/components/TextInputAutoWidth.js index 18a04bb9e335..a43eed308f4c 100644 --- a/src/components/TextInputAutoWidth.js +++ b/src/components/TextInputAutoWidth.js @@ -2,7 +2,8 @@ import React from 'react'; import {View} from 'react-native'; import PropTypes from 'prop-types'; import _ from 'underscore'; -import styles, {getAutoGrowTextInputStyle} from '../styles/styles'; +import styles from '../styles/styles'; +import * as StyleUtils from '../styles/StyleUtils'; import Text from './Text'; import TextInputFocusable from './TextInputFocusable'; @@ -45,7 +46,7 @@ class TextInputAutoWidth extends React.Component { <> { this.setState({environment}); }); diff --git a/src/components/withLocalize.js b/src/components/withLocalize.js index 0a6797ff027c..6f885ef36f40 100755 --- a/src/components/withLocalize.js +++ b/src/components/withLocalize.js @@ -3,9 +3,9 @@ import PropTypes from 'prop-types'; import {withOnyx} from 'react-native-onyx'; import getComponentDisplayName from '../libs/getComponentDisplayName'; import ONYXKEYS from '../ONYXKEYS'; -import {translate} from '../libs/translate'; +import * as Localize from '../libs/Localize'; import DateUtils from '../libs/DateUtils'; -import {toLocalPhone, fromLocalPhone} from '../libs/LocalePhoneNumber'; +import * as LocalePhoneNumber from '../libs/LocalePhoneNumber'; import numberFormat from '../libs/numberFormat'; import CONST from '../CONST'; @@ -66,7 +66,7 @@ class LocaleContextProvider extends React.Component { * @returns {String} */ translate(phrase, variables) { - return translate(this.props.preferredLocale, phrase, variables); + return Localize.translate(this.props.preferredLocale, phrase, variables); } /** @@ -104,7 +104,7 @@ class LocaleContextProvider extends React.Component { * @returns {String} */ toLocalPhone(number) { - return toLocalPhone(this.props.preferredLocale, number); + return LocalePhoneNumber.toLocalPhone(this.props.preferredLocale, number); } /** @@ -112,7 +112,7 @@ class LocaleContextProvider extends React.Component { * @returns {String} */ fromLocalPhone(number) { - return fromLocalPhone(this.props.preferredLocale, number); + return LocalePhoneNumber.fromLocalPhone(this.props.preferredLocale, number); } render() { diff --git a/src/libs/DateUtils.js b/src/libs/DateUtils.js index 0ee479a6d3bc..0d67cc369d93 100644 --- a/src/libs/DateUtils.js +++ b/src/libs/DateUtils.js @@ -8,7 +8,7 @@ import _ from 'underscore'; import Onyx from 'react-native-onyx'; import ONYXKEYS from '../ONYXKEYS'; import CONST from '../CONST'; -import {translate} from './translate'; +import * as Localize from './Localize'; import * as PersonalDetails from './actions/PersonalDetails'; import * as CurrentDate from './actions/CurrentDate'; @@ -54,10 +54,10 @@ function timestampToDateTime(locale, timestamp, includeTimeZone = false) { const date = getLocalMomentFromTimestamp(locale, timestamp); const tz = includeTimeZone ? ' [UTC]Z' : ''; - const todayAt = translate(locale, 'common.todayAt'); - const tomorrowAt = translate(locale, 'common.tomorrowAt'); - const yesterdayAt = translate(locale, 'common.yesterdayAt'); - const at = translate(locale, 'common.conjunctionAt'); + const todayAt = Localize.translate(locale, 'common.todayAt'); + const tomorrowAt = Localize.translate(locale, 'common.tomorrowAt'); + const yesterdayAt = Localize.translate(locale, 'common.yesterdayAt'); + const at = Localize.translate(locale, 'common.conjunctionAt'); return moment(date).calendar({ sameDay: `[${todayAt}] LT${tz}`, diff --git a/src/libs/Firebase/index.native.js b/src/libs/Firebase/index.native.js index af627091a0ae..adebd4c80ca0 100644 --- a/src/libs/Firebase/index.native.js +++ b/src/libs/Firebase/index.native.js @@ -1,6 +1,6 @@ /* eslint-disable no-unused-vars */ import perf from '@react-native-firebase/perf'; -import {isDevelopment} from '../Environment/Environment'; +import * as Environment from '../Environment/Environment'; import Log from '../Log'; const traceMap = {}; @@ -10,7 +10,7 @@ const traceMap = {}; */ function startTrace(customEventName) { const start = global.performance.now(); - if (isDevelopment()) { + if (Environment.isDevelopment()) { return; } @@ -33,7 +33,7 @@ function startTrace(customEventName) { function stopTrace(customEventName) { const stop = global.performance.now(); - if (isDevelopment()) { + if (Environment.isDevelopment()) { return; } diff --git a/src/libs/translate.js b/src/libs/Localize.js similarity index 100% rename from src/libs/translate.js rename to src/libs/Localize.js diff --git a/src/libs/canCaptureMetrics/index.js b/src/libs/Metrics/index.js similarity index 100% rename from src/libs/canCaptureMetrics/index.js rename to src/libs/Metrics/index.js diff --git a/src/libs/canCaptureMetrics/index.native.js b/src/libs/Metrics/index.native.js similarity index 100% rename from src/libs/canCaptureMetrics/index.native.js rename to src/libs/Metrics/index.native.js diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.js b/src/libs/Navigation/AppNavigator/AuthScreens.js index a6c0131eafbf..ad051bc2e46e 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.js +++ b/src/libs/Navigation/AppNavigator/AuthScreens.js @@ -6,14 +6,11 @@ import Str from 'expensify-common/lib/str'; import moment from 'moment'; import _ from 'underscore'; import lodashGet from 'lodash/get'; -import {getNavigationModalCardStyle} from '../../../styles/styles'; +import * as StyleUtils from '../../../styles/StyleUtils'; import withWindowDimensions, {windowDimensionsPropTypes} from '../../../components/withWindowDimensions'; import CONST from '../../../CONST'; import compose from '../../compose'; -import { - subscribeToUserEvents, - fetchAllReports, -} from '../../actions/Report'; +import * as Report from '../../actions/Report'; import * as PersonalDetails from '../../actions/PersonalDetails'; import * as Pusher from '../../Pusher/pusher'; import PusherConnectionManager from '../../PusherConnectionManager'; @@ -23,44 +20,29 @@ import ONYXKEYS from '../../../ONYXKEYS'; import Timing from '../../actions/Timing'; import NetworkConnection from '../../NetworkConnection'; import CONFIG from '../../../CONFIG'; -import {fetchCountryCodeByRequestIP} from '../../actions/GeoLocation'; +import * as GeoLocation from '../../actions/GeoLocation'; import KeyboardShortcut from '../../KeyboardShortcut'; import Navigation from '../Navigation'; import * as User from '../../actions/User'; -import {setModalVisibility} from '../../actions/Modal'; +import * as Modal from '../../actions/Modal'; import NameValuePair from '../../actions/NameValuePair'; import * as Policy from '../../actions/Policy'; import modalCardStyleInterpolator from './modalCardStyleInterpolator'; import createCustomModalStackNavigator from './createCustomModalStackNavigator'; -import {fetchFreePlanVerifiedBankAccount, fetchUserWallet} from '../../actions/BankAccounts'; +import * as BankAccounts from '../../actions/BankAccounts'; // Main drawer navigator import MainDrawerNavigator from './MainDrawerNavigator'; // Modal Stack Navigators -import { - IOUBillStackNavigator, - IOURequestModalStackNavigator, - IOUSendModalStackNavigator, - IOUDetailsModalStackNavigator, - DetailsModalStackNavigator, - ReportParticipantsModalStackNavigator, - SearchModalStackNavigator, - NewGroupModalStackNavigator, - NewChatModalStackNavigator, - SettingsModalStackNavigator, - EnablePaymentsStackNavigator, - AddPersonalBankAccountModalStackNavigator, - RequestCallModalStackNavigator, - ReportDetailsModalStackNavigator, -} from './ModalStackNavigators'; +import * as ModalStackNavigators from './ModalStackNavigators'; import SCREENS from '../../../SCREENS'; import Timers from '../../Timers'; import LogInWithShortLivedTokenPage from '../../../pages/LogInWithShortLivedTokenPage'; import ValidateLoginPage from '../../../pages/ValidateLoginPage'; import defaultScreenOptions from './defaultScreenOptions'; import * as App from '../../actions/App'; -import {cleanupSession} from '../../actions/Session'; +import * as Session from '../../actions/Session'; Onyx.connect({ key: ONYXKEYS.MY_PERSONAL_DETAILS, @@ -89,10 +71,10 @@ const RootStack = createCustomModalStackNavigator(); // https://reactnavigation.org/docs/navigation-events/ const modalScreenListeners = { focus: () => { - setModalVisibility(true); + Modal.setModalVisibility(true); }, beforeRemove: () => { - setModalVisibility(false); + Modal.setModalVisibility(false); }, }; @@ -126,7 +108,7 @@ class AuthScreens extends React.Component { cluster: CONFIG.PUSHER.CLUSTER, authEndpoint: `${CONFIG.EXPENSIFY.URL_API_ROOT}api?command=Push_Authenticate`, }).then(() => { - subscribeToUserEvents(); + Report.subscribeToUserEvents(); User.subscribeToUserEvents(); }); @@ -139,11 +121,11 @@ class AuthScreens extends React.Component { User.getBetas(); User.getDomainInfo(); PersonalDetails.fetchLocalCurrency(); - fetchAllReports(true, true); - fetchCountryCodeByRequestIP(); + Report.fetchAllReports(true, true); + GeoLocation.fetchCountryCodeByRequestIP(); UnreadIndicatorUpdater.listenForReportChanges(); - fetchFreePlanVerifiedBankAccount(); - fetchUserWallet(); + BankAccounts.fetchFreePlanVerifiedBankAccount(); + BankAccounts.fetchUserWallet(); // Load policies, maybe creating a new policy first. Linking.getInitialURL() @@ -198,7 +180,7 @@ class AuthScreens extends React.Component { if (this.unsubscribeGroupShortcut) { this.unsubscribeGroupShortcut(); } - cleanupSession(); + Session.cleanupSession(); clearInterval(this.interval); this.interval = null; } @@ -230,7 +212,7 @@ class AuthScreens extends React.Component { }; const modalScreenOptions = { ...commonModalScreenOptions, - cardStyle: getNavigationModalCardStyle(this.props.isSmallScreenWidth), + cardStyle: StyleUtils.getNavigationModalCardStyle(this.props.isSmallScreenWidth), cardStyleInterpolator: props => modalCardStyleInterpolator(this.props.isSmallScreenWidth, false, props), cardOverlayEnabled: true, @@ -286,83 +268,83 @@ class AuthScreens extends React.Component { diff --git a/src/libs/Navigation/AppNavigator/BaseDrawerNavigator.js b/src/libs/Navigation/AppNavigator/BaseDrawerNavigator.js index 2db411eb15f8..dec53e122ef5 100644 --- a/src/libs/Navigation/AppNavigator/BaseDrawerNavigator.js +++ b/src/libs/Navigation/AppNavigator/BaseDrawerNavigator.js @@ -4,7 +4,9 @@ import PropTypes from 'prop-types'; import {createDrawerNavigator} from '@react-navigation/drawer'; import {View} from 'react-native'; import withWindowDimensions, {windowDimensionsPropTypes} from '../../../components/withWindowDimensions'; -import styles, {getNavigationDrawerStyle, getNavigationDrawerType} from '../../../styles/styles'; +import styles from '../../../styles/styles'; +import * as StyleUtils from '../../../styles/StyleUtils'; + import Navigation from '../Navigation'; const propTypes = { @@ -43,8 +45,8 @@ const BaseDrawerNavigator = (props) => { screenOptions={{ cardStyle: styles.navigationScreenCardStyle, headerShown: false, - drawerType: getNavigationDrawerType(props.isSmallScreenWidth), - drawerStyle: getNavigationDrawerStyle( + drawerType: StyleUtils.getNavigationDrawerType(props.isSmallScreenWidth), + drawerStyle: StyleUtils.getNavigationDrawerStyle( props.isSmallScreenWidth, ), swipeEdgeWidth: 500, diff --git a/src/libs/Navigation/AppNavigator/MainDrawerNavigator.js b/src/libs/Navigation/AppNavigator/MainDrawerNavigator.js index 7671baa96809..c326ece31769 100644 --- a/src/libs/Navigation/AppNavigator/MainDrawerNavigator.js +++ b/src/libs/Navigation/AppNavigator/MainDrawerNavigator.js @@ -12,7 +12,7 @@ import Permissions from '../../Permissions'; import ReportScreen from '../../../pages/home/ReportScreen'; import SidebarScreen from '../../../pages/home/sidebar/SidebarScreen'; import BaseDrawerNavigator from './BaseDrawerNavigator'; -import {findLastAccessedReport} from '../../reportUtils'; +import * as ReportUtils from '../../reportUtils'; const propTypes = { /** Available reports that would be displayed in this navigator */ @@ -37,7 +37,7 @@ const defaultProps = { * @returns {Object} */ const getInitialReportScreenParams = (reports, ignoreDefaultRooms) => { - const last = findLastAccessedReport(reports, ignoreDefaultRooms); + const last = ReportUtils.findLastAccessedReport(reports, ignoreDefaultRooms); // Fallback to empty if for some reason reportID cannot be derived - prevents the app from crashing const reportID = lodashGet(last, 'reportID', ''); diff --git a/src/libs/Navigation/NavigationRoot.js b/src/libs/Navigation/NavigationRoot.js index fb8134d55f72..3fb272a0c167 100644 --- a/src/libs/Navigation/NavigationRoot.js +++ b/src/libs/Navigation/NavigationRoot.js @@ -1,10 +1,10 @@ import React, {Component} from 'react'; import PropTypes from 'prop-types'; import {getPathFromState, NavigationContainer} from '@react-navigation/native'; -import {navigationRef} from './Navigation'; +import * as Navigation from './Navigation'; import linkingConfig from './linkingConfig'; import AppNavigator from './AppNavigator'; -import {setCurrentURL} from '../actions/App'; +import * as App from '../actions/App'; import FullScreenLoadingIndicator from '../../components/FullscreenLoadingIndicator'; import Log from '../Log'; @@ -37,7 +37,7 @@ class NavigationRoot extends Component { } else { Log.info('Navigating to route', false, {path}); } - setCurrentURL(path); + App.setCurrentURL(path); } render() { @@ -45,7 +45,7 @@ class NavigationRoot extends Component { } onStateChange={this.parseAndStoreRoute} - ref={navigationRef} + ref={Navigation.navigationRef} linking={linkingConfig} documentTitle={{ enabled: false, diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index ca482b84c7cf..395ec13b54c0 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -6,10 +6,8 @@ import lodashOrderBy from 'lodash/orderBy'; import Str from 'expensify-common/lib/str'; import ONYXKEYS from '../ONYXKEYS'; import CONST from '../CONST'; -import { - getReportParticipantsTitle, isDefaultRoom, getDefaultRoomSubtitle, isArchivedRoom, -} from './reportUtils'; -import {translate} from './translate'; +import * as ReportUtils from './reportUtils'; +import * as Localize from './Localize'; import Permissions from './Permissions'; import md5 from './md5'; @@ -183,7 +181,7 @@ function getSearchText(report, personalDetailList, isDefaultChatRoom) { searchTerms.push(..._.map(report.reportName.split(','), name => name.trim())); if (isDefaultChatRoom) { - const defaultRoomSubtitle = getDefaultRoomSubtitle(report, policies); + const defaultRoomSubtitle = ReportUtils.getDefaultRoomSubtitle(report, policies); searchTerms.push(...defaultRoomSubtitle); searchTerms.push(..._.map(defaultRoomSubtitle.split(','), name => name.trim())); } else { @@ -218,7 +216,7 @@ function hasReportDraftComment(report) { function createOption(personalDetailList, report, { showChatPreviewLine = false, forcePolicyNamePreview = false, }) { - const isDefaultChatRoom = isDefaultRoom(report); + const isDefaultChatRoom = ReportUtils.isDefaultRoom(report); const hasMultipleParticipants = personalDetailList.length > 1 || isDefaultChatRoom; const personalDetail = personalDetailList[0]; const hasDraftComment = hasReportDraftComment(report); @@ -235,7 +233,7 @@ function createOption(personalDetailList, report, { + Str.htmlDecode(report.lastMessageText) : ''; - const tooltipText = getReportParticipantsTitle(lodashGet(report, ['participants'], [])); + const tooltipText = ReportUtils.getReportParticipantsTitle(lodashGet(report, ['participants'], [])); let text; let alternateText; @@ -243,7 +241,7 @@ function createOption(personalDetailList, report, { text = lodashGet(report, ['reportName'], ''); alternateText = (showChatPreviewLine && !forcePolicyNamePreview && lastMessageText) ? lastMessageText - : getDefaultRoomSubtitle(report, policies); + : ReportUtils.getDefaultRoomSubtitle(report, policies); } else { text = hasMultipleParticipants ? _.map(personalDetailList, ({firstName, login}) => firstName || Str.removeSMSDomain(login)) @@ -276,7 +274,7 @@ function createOption(personalDetailList, report, { isIOUReportOwner: lodashGet(iouReport, 'ownerEmail', '') === currentUserLogin, iouReportAmount: lodashGet(iouReport, 'total', 0), isDefaultChatRoom, - isArchivedRoom: isArchivedRoom(report), + isArchivedRoom: ReportUtils.isArchivedRoom(report), }; } @@ -408,7 +406,7 @@ function getOptions(reports, personalDetails, activeReportID, { return; } - if (isDefaultRoom(report) && (!Permissions.canUseDefaultRooms(betas) || excludeDefaultRooms)) { + if (ReportUtils.isDefaultRoom(report) && (!Permissions.canUseDefaultRooms(betas) || excludeDefaultRooms)) { return; } @@ -703,21 +701,21 @@ function getSidebarOptions( */ function getHeaderMessage(hasSelectableOptions, hasUserToInvite, searchValue, maxParticipantsReached = false) { if (maxParticipantsReached) { - return translate(preferredLocale, 'messages.maxParticipantsReached'); + return Localize.translate(preferredLocale, 'messages.maxParticipantsReached'); } if (searchValue && CONST.REGEX.DIGITS_AND_PLUS.test(searchValue) && !Str.isValidPhone(searchValue)) { - return translate(preferredLocale, 'messages.errorMessageInvalidPhone'); + return Localize.translate(preferredLocale, 'messages.errorMessageInvalidPhone'); } // Without a search value, it would be very confusing to see a search validation message. // Therefore, this skips the validation when there is no search value. if (searchValue && !hasSelectableOptions && !hasUserToInvite) { if (/^\d+$/.test(searchValue)) { - return translate(preferredLocale, 'messages.errorMessageInvalidPhone'); + return Localize.translate(preferredLocale, 'messages.errorMessageInvalidPhone'); } - return translate(preferredLocale, 'common.noResultsFound'); + return Localize.translate(preferredLocale, 'common.noResultsFound'); } return ''; @@ -749,7 +747,7 @@ function getCurrencyListForSections(currencyOptions, searchValue) { */ function getReportIcons(report, personalDetails) { // Default rooms have a specific avatar so we can return any non-empty array - if (isDefaultRoom(report)) { + if (ReportUtils.isDefaultRoom(report)) { return ['']; } const sortedParticipants = _.map(report.participants, dmParticipant => ({ diff --git a/src/libs/Performance.js b/src/libs/Performance.js index 87ce1aeb4dcd..2ef4f938bc66 100644 --- a/src/libs/Performance.js +++ b/src/libs/Performance.js @@ -3,7 +3,7 @@ import lodashTransform from 'lodash/transform'; import React, {Profiler, forwardRef} from 'react'; import {Alert} from 'react-native'; -import {canCapturePerformanceMetrics} from './canCaptureMetrics'; +import * as Metrics from './Metrics'; import getComponentDisplayName from './getComponentDisplayName'; import CONST from '../CONST'; @@ -45,7 +45,7 @@ const Performance = { withRenderTrace: () => Component => Component, }; -if (canCapturePerformanceMetrics()) { +if (Metrics.canCapturePerformanceMetrics()) { /** * Sets up an observer to capture events recorded in the native layer before the app fully initializes. */ diff --git a/src/libs/Permissions.js b/src/libs/Permissions.js index 1eede852be35..492431550c21 100644 --- a/src/libs/Permissions.js +++ b/src/libs/Permissions.js @@ -1,5 +1,5 @@ import _ from 'underscore'; -import {isDevelopment} from './Environment/Environment'; +import * as Environment from './Environment/Environment'; import CONST from '../CONST'; /** @@ -8,7 +8,7 @@ import CONST from '../CONST'; * @returns {Boolean} */ function canUseAllBetas(betas) { - return isDevelopment() || _.contains(betas, CONST.BETAS.ALL); + return Environment.isDevelopment() || _.contains(betas, CONST.BETAS.ALL); } /** diff --git a/src/libs/ReimbursementAccountUtils.js b/src/libs/ReimbursementAccountUtils.js index e655da493637..5de61144092b 100644 --- a/src/libs/ReimbursementAccountUtils.js +++ b/src/libs/ReimbursementAccountUtils.js @@ -1,7 +1,7 @@ import lodashGet from 'lodash/get'; import lodashUnset from 'lodash/unset'; import lodashCloneDeep from 'lodash/cloneDeep'; -import {setBankAccountFormValidationErrors} from './actions/BankAccounts'; +import * as BankAccounts from './actions/BankAccounts'; /** * Get the default state for input fields in the VBA flow @@ -39,7 +39,7 @@ function clearError(props, path) { // Clear the existing errors const newErrors = lodashCloneDeep(errors); lodashUnset(newErrors, path); - setBankAccountFormValidationErrors(newErrors); + BankAccounts.setBankAccountFormValidationErrors(newErrors); } /** diff --git a/src/libs/ValidationUtils.js b/src/libs/ValidationUtils.js index e7fd33d3cf63..df8fa3b53382 100644 --- a/src/libs/ValidationUtils.js +++ b/src/libs/ValidationUtils.js @@ -1,7 +1,7 @@ import moment from 'moment'; import _ from 'underscore'; import CONST from '../CONST'; -import {getMonthFromExpirationDateString, getYearFromExpirationDateString} from './CardUtils'; +import * as CardUtils from './CardUtils'; import LoginUtil from './LoginUtil'; /** @@ -109,7 +109,7 @@ function isValidExpirationDate(string) { } // Use the last of the month to check if the expiration date is in the future or not - const expirationDate = `${getYearFromExpirationDateString(string)}-${getMonthFromExpirationDateString(string)}-01`; + const expirationDate = `${CardUtils.getYearFromExpirationDateString(string)}-${CardUtils.getMonthFromExpirationDateString(string)}-01`; return moment(expirationDate).endOf('month').isAfter(moment()); } diff --git a/src/libs/actions/BankAccounts.js b/src/libs/actions/BankAccounts.js index 69b452cbab42..2c681f1650f3 100644 --- a/src/libs/actions/BankAccounts.js +++ b/src/libs/actions/BankAccounts.js @@ -8,7 +8,7 @@ import ONYXKEYS from '../../ONYXKEYS'; import * as API from '../API'; import BankAccount from '../models/BankAccount'; import Growl from '../Growl'; -import {translateLocal} from '../translate'; +import * as Localize from '../Localize'; /** * List of bank accounts. This data should not be stored in Onyx since it contains unmasked PANs. @@ -109,7 +109,7 @@ function getPlaidBankAccounts(publicToken, bank) { plaidBankAccounts = _.filter(response.accounts, account => !account.alreadyExists); if (plaidBankAccounts.length === 0) { - Growl.error(translateLocal('bankAccount.error.noBankAccountAvailable')); + Growl.error(Localize.translateLocal('bankAccount.error.noBankAccountAvailable')); } Onyx.merge(ONYXKEYS.PLAID_BANK_ACCOUNTS, { @@ -606,7 +606,7 @@ function validateBankAccount(bankAccountID, validateCode) { // If the validation amounts entered were incorrect, show specific error if (response.message === CONST.BANK_ACCOUNT.ERROR.INCORRECT_VALIDATION_AMOUNTS) { - showBankAccountErrorModal(translateLocal('bankAccount.error.validationAmounts')); + showBankAccountErrorModal(Localize.translateLocal('bankAccount.error.validationAmounts')); Onyx.merge(ONYXKEYS.REIMBURSEMENT_ACCOUNT, {loading: false}); return; } @@ -784,9 +784,9 @@ function setupWithdrawalAccount(data) { errors.routingNumber = true; achData.subStep = CONST.BANK_ACCOUNT.SETUP_TYPE.MANUAL; } else if (response.message === CONST.BANK_ACCOUNT.ERROR.MISSING_INCORPORATION_STATE) { - error = translateLocal('bankAccount.error.incorporationState'); + error = Localize.translateLocal('bankAccount.error.incorporationState'); } else if (response.message === CONST.BANK_ACCOUNT.ERROR.MISSING_INCORPORATION_TYPE) { - error = translateLocal('bankAccount.error.companyType'); + error = Localize.translateLocal('bankAccount.error.companyType'); } else { console.error(response.message); } @@ -809,7 +809,7 @@ function setupWithdrawalAccount(data) { .catch((response) => { Onyx.merge(ONYXKEYS.REIMBURSEMENT_ACCOUNT, {loading: false, achData: {...newACHData}}); console.error(response.stack); - showBankAccountErrorModal(translateLocal('common.genericErrorMessage')); + showBankAccountErrorModal(Localize.translateLocal('common.genericErrorMessage')); }); } diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index 3c17bad4f492..80bfdfa8ab11 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -4,10 +4,10 @@ import CONST from '../../CONST'; import ONYXKEYS from '../../ONYXKEYS'; import ROUTES from '../../ROUTES'; import * as API from '../API'; -import {getSimplifiedIOUReport, syncChatAndIOUReports} from './Report'; +import * as Report from './Report'; import Navigation from '../Navigation/Navigation'; import Growl from '../Growl'; -import {translateLocal} from '../translate'; +import * as Localize from '../Localize'; import asyncOpenURL from '../asyncOpenURL'; /** @@ -43,7 +43,7 @@ function getIOUReportsForNewTransaction(requestParams) { // Second, the IOU report needs updated with the new IOU details too const iouReportKey = `${ONYXKEYS.COLLECTION.REPORT_IOUS}${reportData.reportID}`; - iouReportsToUpdate[iouReportKey] = getSimplifiedIOUReport(reportData, chatReportID); + iouReportsToUpdate[iouReportKey] = Report.getSimplifiedIOUReport(reportData, chatReportID); } }); @@ -63,12 +63,12 @@ function getIOUReportsForNewTransaction(requestParams) { function getIOUErrorMessage(error) { if (error && error.jsonCode) { if (error.jsonCode === 405) { - return translateLocal('common.error.invalidAmount'); + return Localize.translateLocal('common.error.invalidAmount'); } if (error.jsonCode === 404) { - return translateLocal('iou.error.invalidSplit'); + return Localize.translateLocal('iou.error.invalidSplit'); } } - return translateLocal('iou.error.other'); + return Localize.translateLocal('iou.error.other'); } /** @@ -193,7 +193,7 @@ function rejectTransaction({ const chatReport = response.reports[chatReportID]; const iouReport = response.reports[reportID]; - syncChatAndIOUReports(chatReport, iouReport); + Report.syncChatAndIOUReports(chatReport, iouReport); }) .catch(error => console.error(`Error rejecting transaction: ${error}`)) .finally(() => { @@ -275,16 +275,16 @@ function payIOUReport({ const chatReportStuff = response.reports[chatReportID]; const iouReportStuff = response.reports[reportID]; - syncChatAndIOUReports(chatReportStuff, iouReportStuff); + Report.syncChatAndIOUReports(chatReportStuff, iouReportStuff); }) .catch((error) => { switch (error.message) { // eslint-disable-next-line max-len case 'You cannot pay via Expensify Wallet until you have either a verified deposit bank account or debit card.': - Growl.error(translateLocal('bankAccount.error.noDefaultDepositAccountOrDebitCardAvailable'), 5000); + Growl.error(Localize.translateLocal('bankAccount.error.noDefaultDepositAccountOrDebitCardAvailable'), 5000); break; case 'This report doesn\'t have reimbursable expenses.': - Growl.error(translateLocal('iou.noReimbursableExpenses'), 5000); + Growl.error(Localize.translateLocal('iou.noReimbursableExpenses'), 5000); break; default: Growl.error(error.message, 5000); diff --git a/src/libs/actions/Inbox.js b/src/libs/actions/Inbox.js index 3fb1e3b1f712..44992493d5d4 100644 --- a/src/libs/actions/Inbox.js +++ b/src/libs/actions/Inbox.js @@ -1,9 +1,9 @@ import Onyx from 'react-native-onyx'; import CONST from '../../CONST'; import ONYXKEYS from '../../ONYXKEYS'; -import {Inbox_CallUser} from '../API'; +import * as API from '../API'; import Growl from '../Growl'; -import {translateLocal} from '../translate'; +import * as Localize from '../Localize'; import * as Report from './Report'; /** @@ -19,7 +19,7 @@ function requestInboxCall({ taskID, policyID, firstName, lastName, phoneNumber, email, }) { Onyx.merge(ONYXKEYS.REQUEST_CALL_FORM, {loading: true}); - Inbox_CallUser({ + API.Inbox_CallUser({ policyID, firstName, lastName, @@ -28,7 +28,7 @@ function requestInboxCall({ }) .then((result) => { if (result.jsonCode === 200) { - Growl.success(translateLocal('requestCallPage.growlMessageOnSave')); + Growl.success(Localize.translateLocal('requestCallPage.growlMessageOnSave')); Report.fetchOrCreateChatReport([email, CONST.EMAIL.CONCIERGE], true); return; } diff --git a/src/libs/actions/Link.js b/src/libs/actions/Link.js index 8623ca0f1573..091edba49a9b 100644 --- a/src/libs/actions/Link.js +++ b/src/libs/actions/Link.js @@ -3,7 +3,7 @@ import lodashGet from 'lodash/get'; import {Linking} from 'react-native'; import ONYXKEYS from '../../ONYXKEYS'; import Growl from '../Growl'; -import {translateLocal} from '../translate'; +import * as Localize from '../Localize'; import CONST from '../../CONST'; import * as API from '../API'; import CONFIG from '../../CONFIG'; @@ -26,7 +26,7 @@ Onyx.connect({ */ function showGrowlIfOffline() { if (isNetworkOffline) { - Growl.show(translateLocal('session.offlineMessageRetry'), CONST.GROWL.WARNING); + Growl.show(Localize.translateLocal('session.offlineMessageRetry'), CONST.GROWL.WARNING); } return isNetworkOffline; } diff --git a/src/libs/actions/PaymentMethods.js b/src/libs/actions/PaymentMethods.js index f8b6cacedf4f..1d982f178700 100644 --- a/src/libs/actions/PaymentMethods.js +++ b/src/libs/actions/PaymentMethods.js @@ -5,9 +5,9 @@ import * as API from '../API'; import CONST from '../../CONST'; import ROUTES from '../../ROUTES'; import Growl from '../Growl'; -import {translateLocal} from '../translate'; +import * as Localize from '../Localize'; import Navigation from '../Navigation/Navigation'; -import {maskCardNumber, getMonthFromExpirationDateString, getYearFromExpirationDateString} from '../CardUtils'; +import * as CardUtils from '../CardUtils'; /** * Calls the API to get the user's bankAccountList, cardList, wallet, and payPalMe @@ -41,8 +41,8 @@ function getPaymentMethods() { * @param {Object} params */ function addBillingCard(params) { - const cardMonth = getMonthFromExpirationDateString(params.expirationDate); - const cardYear = getYearFromExpirationDateString(params.expirationDate); + const cardMonth = CardUtils.getMonthFromExpirationDateString(params.expirationDate); + const cardYear = CardUtils.getYearFromExpirationDateString(params.expirationDate); Onyx.merge(ONYXKEYS.ADD_DEBIT_CARD_FORM, {submitting: true}); API.AddBillingCard({ @@ -66,16 +66,16 @@ function addBillingCard(params) { addressStreet: params.addressStreet, addressZip: params.addressZipCode, cardMonth, - cardNumber: maskCardNumber(params.cardNumber), + cardNumber: CardUtils.maskCardNumber(params.cardNumber), cardYear, currency: 'USD', fundID: lodashGet(response, 'fundID', ''), }; Onyx.merge(ONYXKEYS.CARD_LIST, [cardObject]); - Growl.show(translateLocal('addDebitCardPage.growlMessageOnSave'), CONST.GROWL.SUCCESS, 3000); + Growl.show(Localize.translateLocal('addDebitCardPage.growlMessageOnSave'), CONST.GROWL.SUCCESS, 3000); Navigation.navigate(ROUTES.SETTINGS_PAYMENTS); } else { - errorMessage = response.message ? response.message : translateLocal('addDebitCardPage.error.genericFailureMessage'); + errorMessage = response.message ? response.message : Localize.translateLocal('addDebitCardPage.error.genericFailureMessage'); } Onyx.merge(ONYXKEYS.ADD_DEBIT_CARD_FORM, { diff --git a/src/libs/actions/PersonalDetails.js b/src/libs/actions/PersonalDetails.js index f5fc4dbd3df4..0397e1491813 100644 --- a/src/libs/actions/PersonalDetails.js +++ b/src/libs/actions/PersonalDetails.js @@ -8,11 +8,11 @@ import CONST from '../../CONST'; import NetworkConnection from '../NetworkConnection'; import * as API from '../API'; import NameValuePair from './NameValuePair'; -import {isDefaultRoom} from '../reportUtils'; -import {getReportIcons, getDefaultAvatar} from '../OptionsListUtils'; +import * as ReportUtils from '../reportUtils'; +import * as OptionsListUtils from '../OptionsListUtils'; import Growl from '../Growl'; -import {translateLocal} from '../translate'; -import {isValidLengthForFirstOrLastName} from '../ValidationUtils'; +import * as Localize from '../Localize'; +import * as ValidationUtils from '../ValidationUtils'; let currentUserEmail = ''; Onyx.connect({ @@ -38,7 +38,7 @@ function getAvatar(personalDetail, login) { return personalDetail.avatarThumbnail; } - return getDefaultAvatar(login); + return OptionsListUtils.getDefaultAvatar(login); } /** @@ -75,8 +75,8 @@ function getDisplayName(login, personalDetail) { */ function getFirstAndLastNameErrors(firstName, lastName) { return { - firstNameError: isValidLengthForFirstOrLastName(firstName) ? '' : translateLocal('personalDetails.error.firstNameLength'), - lastNameError: isValidLengthForFirstOrLastName(lastName) ? '' : translateLocal('personalDetails.error.lastNameLength'), + firstNameError: ValidationUtils.isValidLengthForFirstOrLastName(firstName) ? '' : Localize.translateLocal('personalDetails.error.firstNameLength'), + lastNameError: ValidationUtils.isValidLengthForFirstOrLastName(lastName) ? '' : Localize.translateLocal('personalDetails.error.lastNameLength'), }; } @@ -184,12 +184,12 @@ function getFromReportParticipants(reports) { // skip over default rooms which aren't named by participants. const reportsToUpdate = {}; _.each(reports, (report) => { - if (report.participants.length <= 0 && !isDefaultRoom(report)) { + if (report.participants.length <= 0 && !ReportUtils.isDefaultRoom(report)) { return; } - const avatars = getReportIcons(report, details); - const reportName = isDefaultRoom(report) + const avatars = OptionsListUtils.getReportIcons(report, details); + const reportName = ReportUtils.isDefaultRoom(report) ? report.reportName : _.chain(report.participants) .filter(participant => participant !== currentUserEmail) @@ -246,12 +246,12 @@ function setPersonalDetails(details, shouldGrowl) { mergeLocalPersonalDetails(details); if (shouldGrowl) { - Growl.show(translateLocal('profilePage.growlMessageOnSave'), CONST.GROWL.SUCCESS, 3000); + Growl.show(Localize.translateLocal('profilePage.growlMessageOnSave'), CONST.GROWL.SUCCESS, 3000); } } else if (response.jsonCode === 400) { - Growl.error(translateLocal('personalDetails.error.firstNameLength'), 3000); + Growl.error(Localize.translateLocal('personalDetails.error.firstNameLength'), 3000); } else if (response.jsonCode === 401) { - Growl.error(translateLocal('personalDetails.error.lastNameLength'), 3000); + Growl.error(Localize.translateLocal('personalDetails.error.lastNameLength'), 3000); } }).catch((error) => { console.debug('Error while setting personal details', error); @@ -317,9 +317,9 @@ function setAvatar(file) { .catch((error) => { setPersonalDetails({avatarUploading: false}); if (error.jsonCode === 405 || error.jsonCode === 502) { - Growl.show(translateLocal('profilePage.invalidFileMessage'), CONST.GROWL.ERROR, 3000); + Growl.show(Localize.translateLocal('profilePage.invalidFileMessage'), CONST.GROWL.ERROR, 3000); } else { - Growl.show(translateLocal('profilePage.avatarUploadFailureMessage'), CONST.GROWL.ERROR, 3000); + Growl.show(Localize.translateLocal('profilePage.avatarUploadFailureMessage'), CONST.GROWL.ERROR, 3000); } }); } @@ -333,8 +333,8 @@ function deleteAvatar(login) { // We don't want to save the default avatar URL in the backend since we don't want to allow // users the option of removing the default avatar, instead we'll save an empty string API.PersonalDetails_Update({details: JSON.stringify({avatar: ''})}); - mergeLocalPersonalDetails({avatar: getDefaultAvatar(login)}); - Growl.show(translateLocal('profilePage.growlMessageOnSave'), CONST.GROWL.SUCCESS, 3000); + mergeLocalPersonalDetails({avatar: OptionsListUtils.getDefaultAvatar(login)}); + Growl.show(Localize.translateLocal('profilePage.growlMessageOnSave'), CONST.GROWL.SUCCESS, 3000); } // When the app reconnects from being offline, fetch all of the personal details @@ -345,7 +345,6 @@ export { formatPersonalDetails, getFromReportParticipants, getDisplayName, - getDefaultAvatar, getFirstAndLastNameErrors, setPersonalDetails, setAvatar, diff --git a/src/libs/actions/Policy.js b/src/libs/actions/Policy.js index e08b5edee9fe..80c09f1f6205 100644 --- a/src/libs/actions/Policy.js +++ b/src/libs/actions/Policy.js @@ -3,13 +3,13 @@ import Onyx from 'react-native-onyx'; import lodashGet from 'lodash/get'; import * as API from '../API'; import ONYXKEYS from '../../ONYXKEYS'; -import {formatPersonalDetails} from './PersonalDetails'; +import * as PersonalDetails from './PersonalDetails'; import Growl from '../Growl'; import CONST from '../../CONST'; -import {translateLocal} from '../translate'; +import * as Localize from '../Localize'; import Navigation from '../Navigation/Navigation'; import ROUTES from '../../ROUTES'; -import {addSMSDomainIfPhoneNumber} from '../OptionsListUtils'; +import * as OptionsListUtils from '../OptionsListUtils'; const allPolicies = {}; Onyx.connect({ @@ -101,7 +101,7 @@ function create(name = '') { Onyx.set(ONYXKEYS.IS_CREATING_WORKSPACE, false); if (response.jsonCode !== 200) { // Show the user feedback - const errorMessage = translateLocal('workspace.new.genericFailureMessage'); + const errorMessage = Localize.translateLocal('workspace.new.genericFailureMessage'); Growl.error(errorMessage, 5000); return; } @@ -243,7 +243,7 @@ function removeMembers(members, policyID) { // Show the user feedback that the removal failed console.error(data.message); - Growl.show(translateLocal('workspace.people.genericFailureMessage'), CONST.GROWL.ERROR, 5000); + Growl.show(Localize.translateLocal('workspace.people.genericFailureMessage'), CONST.GROWL.ERROR, 5000); }); } @@ -256,7 +256,7 @@ function removeMembers(members, policyID) { */ function invite(logins, welcomeNote, policyID) { const key = `${ONYXKEYS.COLLECTION.POLICY}${policyID}`; - const newEmployeeList = _.map(logins, login => addSMSDomainIfPhoneNumber(login)); + const newEmployeeList = _.map(logins, login => OptionsListUtils.addSMSDomainIfPhoneNumber(login)); // Make a shallow copy to preserve original data, and concat the login const policy = _.clone(allPolicies[key]); @@ -275,7 +275,7 @@ function invite(logins, welcomeNote, policyID) { .then((data) => { // Save the personalDetails for the invited user in Onyx if (data.jsonCode === 200) { - Onyx.merge(ONYXKEYS.PERSONAL_DETAILS, formatPersonalDetails(data.personalDetails)); + Onyx.merge(ONYXKEYS.PERSONAL_DETAILS, PersonalDetails.formatPersonalDetails(data.personalDetails)); Navigation.goBack(); return; } @@ -285,9 +285,9 @@ function invite(logins, welcomeNote, policyID) { policyDataWithoutLogin.employeeList = _.without(allPolicies[key].employeeList, ...newEmployeeList); // Show the user feedback that the addition failed - policyDataWithoutLogin.alertMessage = translateLocal('workspace.invite.genericFailureMessage'); + policyDataWithoutLogin.alertMessage = Localize.translateLocal('workspace.invite.genericFailureMessage'); if (data.jsonCode === 402) { - policyDataWithoutLogin.alertMessage += ` ${translateLocal('workspace.invite.pleaseEnterValidLogin')}`; + policyDataWithoutLogin.alertMessage += ` ${Localize.translateLocal('workspace.invite.pleaseEnterValidLogin')}`; } Onyx.set(key, policyDataWithoutLogin); @@ -320,13 +320,13 @@ function update(policyID, values, shouldGrowl = false) { updateLocalPolicyValues(policyID, {...values, isPolicyUpdating: false}); if (shouldGrowl) { - Growl.show(translateLocal('workspace.common.growlMessageOnSave'), CONST.GROWL.SUCCESS, 3000); + Growl.show(Localize.translateLocal('workspace.common.growlMessageOnSave'), CONST.GROWL.SUCCESS, 3000); } }).catch(() => { updateLocalPolicyValues(policyID, {isPolicyUpdating: false}); // Show the user feedback - const errorMessage = translateLocal('workspace.editor.genericFailureMessage'); + const errorMessage = Localize.translateLocal('workspace.editor.genericFailureMessage'); Growl.error(errorMessage, 5000); }); } @@ -349,7 +349,7 @@ function uploadAvatar(policyID, file) { } Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, {isAvatarUploading: false}); - const errorMessage = translateLocal('workspace.editor.avatarUploadFailureMessage'); + const errorMessage = Localize.translateLocal('workspace.editor.avatarUploadFailureMessage'); Growl.error(errorMessage, 5000); }); } diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 128623b1aa99..f8b51506a25b 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -19,13 +19,11 @@ import Timing from './Timing'; import * as API from '../API'; import CONST from '../../CONST'; import Log from '../Log'; -import { - isConciergeChatReport, isDefaultRoom, isReportMessageAttachment, sortReportsByLastVisited, isArchivedRoom, -} from '../reportUtils'; +import * as ReportUtils from '../reportUtils'; import Timers from '../Timers'; import * as ReportActions from './ReportActions'; import Growl from '../Growl'; -import {translateLocal} from '../translate'; +import * as Localize from '../Localize'; let currentUserEmail; let currentUserAccountID; @@ -134,13 +132,13 @@ function getParticipantEmailsFromReport({sharedReportList}) { * @return {String} */ function getChatReportName(fullReport, chatType) { - if (isDefaultRoom({chatType})) { - return `#${fullReport.reportName}${(isArchivedRoom({ + if (ReportUtils.isDefaultRoom({chatType})) { + return `#${fullReport.reportName}${(ReportUtils.isArchivedRoom({ chatType, stateNum: fullReport.state, statusNum: fullReport.status, }) - ? ` (${translateLocal('common.deleted')})` + ? ` (${Localize.translateLocal('common.deleted')})` : '')}`; } @@ -177,13 +175,14 @@ function getSimplifiedReportObject(report) { // We convert the line-breaks in html to space ' ' before striping the tags lastMessageText = lastActionMessage .replace(/((]*>)+)/gi, ' ') - .replace(/(<([^>]+)>)/gi, '') || `[${translateLocal('common.deletedCommentMessage')}]`; + .replace(/(<([^>]+)>)/gi, '') || `[${Localize.translateLocal('common.deletedCommentMessage')}]`; } + const reportName = lodashGet(report, ['reportNameValuePairs', 'type']) === 'chat' ? getChatReportName(report, chatType) : report.reportName; const lastActorEmail = lodashGet(report, 'lastActionActorEmail', ''); - const notificationPreference = isDefaultRoom({chatType}) + const notificationPreference = ReportUtils.isDefaultRoom({chatType}) ? lodashGet(report, ['reportNameValuePairs', 'notificationPreferences', currentUserAccountID], 'daily') : ''; @@ -469,7 +468,7 @@ function fetchIOUReportByID(iouReportID, chatReportID, shouldRedirectIfEmpty = f return fetchIOUReport(iouReportID, chatReportID) .then((iouReportObject) => { if (!iouReportObject && shouldRedirectIfEmpty) { - Growl.error(translateLocal('notFound.iouReportNotFound')); + Growl.error(Localize.translateLocal('notFound.iouReportNotFound')); Navigation.navigate(ROUTES.REPORT); return; } @@ -539,7 +538,7 @@ function updateReportActionMessage(reportID, sequenceNumber, message) { // If this is the most recent message, update the lastMessageText in the report object as well if (sequenceNumber === reportMaxSequenceNumbers[reportID]) { Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, { - lastMessageText: message.text || `[${translateLocal('common.deletedCommentMessage')}]`, + lastMessageText: message.text || `[${Localize.translateLocal('common.deletedCommentMessage')}]`, }); } } @@ -601,7 +600,7 @@ function updateReportWithNewAction( // Add the action into Onyx reportActionsToMerge[reportAction.sequenceNumber] = { ...reportAction, - isAttachment: isReportMessageAttachment(messageText), + isAttachment: ReportUtils.isReportMessageAttachment(messageText), loading: false, }; @@ -972,7 +971,7 @@ function fetchAllReports( // If at this point the user still doesn't have a Concierge report, create it for them. // This means they were a participant in reports before their account was created (e.g. default rooms) - const hasConciergeChat = _.some(returnedReports, report => isConciergeChatReport(report)); + const hasConciergeChat = _.some(returnedReports, report => ReportUtils.isConciergeChatReport(report)); if (!hasConciergeChat) { fetchOrCreateChatReport([currentUserEmail, CONST.EMAIL.CONCIERGE], false); } @@ -997,7 +996,7 @@ function fetchAllReports( // Once we have the reports that are missing actions we will find the intersection between the most // recently accessed reports and reports missing actions. Then we'll fetch the history for a small // set to avoid making too many network requests at once. - const reportIDsToFetchActions = _.chain(sortReportsByLastVisited(allReports)) + const reportIDsToFetchActions = _.chain(ReportUtils.sortReportsByLastVisited(allReports)) .map(report => report.reportID) .reverse() .intersection(reportIDsWithMissingActions) @@ -1119,7 +1118,7 @@ function addAction(reportID, text, file) { }) .then((response) => { if (response.jsonCode === 408) { - Growl.error(translateLocal('reportActionCompose.fileUploadFailed')); + Growl.error(Localize.translateLocal('reportActionCompose.fileUploadFailed')); Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, { [optimisticReportActionID]: null, }); @@ -1294,7 +1293,7 @@ function handleReportChanged(report) { if (report && report.reportID) { allReports[report.reportID] = report; - if (isConciergeChatReport(report)) { + if (ReportUtils.isConciergeChatReport(report)) { conciergeChatReportID = report.reportID; } } @@ -1447,7 +1446,7 @@ function navigateToConciergeChat() { * Handle the navigation when report is inaccessible */ function handleInaccessibleReport() { - Growl.error(translateLocal('notFound.chatYouLookingForCannotBeFound')); + Growl.error(Localize.translateLocal('notFound.chatYouLookingForCannotBeFound')); navigateToConciergeChat(); } diff --git a/src/libs/actions/Session/index.js b/src/libs/actions/Session/index.js index 0c16afb3b74a..afdf7e66f9e9 100644 --- a/src/libs/actions/Session/index.js +++ b/src/libs/actions/Session/index.js @@ -12,14 +12,14 @@ import Timing from '../Timing'; import CONST from '../../../CONST'; import Navigation from '../../Navigation/Navigation'; import ROUTES from '../../../ROUTES'; -import {translateLocal} from '../../translate'; +import * as Localize from '../../Localize'; import * as Network from '../../Network'; import UnreadIndicatorUpdater from '../../UnreadIndicatorUpdater'; import Timers from '../../Timers'; import * as Pusher from '../../Pusher/pusher'; import NetworkConnection from '../../NetworkConnection'; -import {getUserDetails} from '../User'; -import {isNumericWithSpecialChars} from '../../ValidationUtils'; +import * as User from '../User'; +import * as ValidationUtils from '../../ValidationUtils'; let credentials = {}; Onyx.connect({ @@ -145,16 +145,16 @@ function fetchAccountDetails(login) { } } else if (response.jsonCode === 402) { Onyx.merge(ONYXKEYS.ACCOUNT, { - error: isNumericWithSpecialChars(login) - ? translateLocal('messages.errorMessageInvalidPhone') - : translateLocal('loginForm.error.invalidFormatEmailLogin'), + error: ValidationUtils.isNumericWithSpecialChars(login) + ? Localize.translateLocal('messages.errorMessageInvalidPhone') + : Localize.translateLocal('loginForm.error.invalidFormatEmailLogin'), }); } else { Onyx.merge(ONYXKEYS.ACCOUNT, {error: response.message}); } }) .catch(() => { - Onyx.merge(ONYXKEYS.ACCOUNT, {error: translateLocal('session.offlineMessageRetry')}); + Onyx.merge(ONYXKEYS.ACCOUNT, {error: Localize.translateLocal('session.offlineMessageRetry')}); }) .finally(() => { Onyx.merge(ONYXKEYS.ACCOUNT, {loading: false}); @@ -243,7 +243,7 @@ function signIn(password, twoFactorAuthCode) { createTemporaryLogin(authToken, email); }) .catch((error) => { - Onyx.merge(ONYXKEYS.ACCOUNT, {error: translateLocal(error.message), loading: false}); + Onyx.merge(ONYXKEYS.ACCOUNT, {error: Localize.translateLocal(error.message), loading: false}); }); } @@ -263,7 +263,7 @@ function signInWithShortLivedToken(accountID, email, shortLivedToken) { email, }); if (response.jsonCode === 200) { - getUserDetails(); + User.getUserDetails(); Onyx.merge(ONYXKEYS.ACCOUNT, {success: true}); } else { const error = lodashGet(response, 'message', 'Unable to login.'); @@ -316,7 +316,7 @@ function setPassword(password, validateCode, accountID) { return; } - Onyx.merge(ONYXKEYS.ACCOUNT, {error: translateLocal('setPasswordPage.accountNotValidated')}); + Onyx.merge(ONYXKEYS.ACCOUNT, {error: Localize.translateLocal('setPasswordPage.accountNotValidated')}); }) .finally(() => { Onyx.merge(ONYXKEYS.ACCOUNT, {loading: false}); diff --git a/src/libs/actions/Timing.js b/src/libs/actions/Timing.js index a3a4567f2dfa..fbcb287cd959 100644 --- a/src/libs/actions/Timing.js +++ b/src/libs/actions/Timing.js @@ -1,6 +1,6 @@ import getPlatform from '../getPlatform'; -import {Graphite_Timer} from '../API'; -import {isDevelopment} from '../Environment/Environment'; +import * as API from '../API'; +import * as Environment from '../Environment/Environment'; import Firebase from '../Firebase'; let timestampData = {}; @@ -46,12 +46,12 @@ function end(eventName, secondaryName = '') { console.debug(`Timing:${grafanaEventName}`, eventTime); delete timestampData[eventName]; - if (isDevelopment()) { + if (Environment.isDevelopment()) { // Don't create traces on dev as this will mess up the accuracy of data in release builds of the app return; } - Graphite_Timer({ + API.Graphite_Timer({ name: grafanaEventName, value: eventTime, platform: `${getPlatform()}`, diff --git a/src/libs/migrations/AddEncryptedAuthToken.js b/src/libs/migrations/AddEncryptedAuthToken.js index e8277ff12877..540b3c9f3e10 100644 --- a/src/libs/migrations/AddEncryptedAuthToken.js +++ b/src/libs/migrations/AddEncryptedAuthToken.js @@ -2,7 +2,7 @@ import _ from 'underscore'; import Onyx from 'react-native-onyx'; import Log from '../Log'; import ONYXKEYS from '../../ONYXKEYS'; -import {reauthenticate} from '../API'; +import * as reauthenticate from '../API'; /** * This migration adds an encryptedAuthToken to the SESSION key, if it is not present. diff --git a/src/libs/reportUtils.js b/src/libs/reportUtils.js index cf51e03a770b..d6a4f1d56717 100644 --- a/src/libs/reportUtils.js +++ b/src/libs/reportUtils.js @@ -4,7 +4,7 @@ import lodashGet from 'lodash/get'; import Onyx from 'react-native-onyx'; import moment from 'moment'; import ONYXKEYS from '../ONYXKEYS'; -import CONST, {EXPENSIFY_EMAILS} from '../CONST'; +import CONST from '../CONST'; let sessionEmail; Onyx.connect({ @@ -165,7 +165,7 @@ function isConciergeChatReport(report) { * @returns {Boolean} */ function hasExpensifyEmails(emails) { - return _.intersection(emails, EXPENSIFY_EMAILS).length > 0; + return _.intersection(emails, CONST.EXPENSIFY_EMAILS).length > 0; } /** @@ -175,7 +175,7 @@ function hasExpensifyEmails(emails) { * @param {Object} report * @return {Boolean} */ -function shouldShowReportRecipientLocalTime(personalDetails, myPersonalDetails, report) { +function canShowReportRecipientLocalTime(personalDetails, myPersonalDetails, report) { const reportParticipants = lodashGet(report, 'participants', []); const hasMultipleParticipants = reportParticipants.length > 1; const reportRecipient = personalDetails[reportParticipants[0]]; @@ -202,5 +202,5 @@ export { isArchivedRoom, isConciergeChatReport, hasExpensifyEmails, - shouldShowReportRecipientLocalTime, + canShowReportRecipientLocalTime, }; diff --git a/src/pages/AddPersonalBankAccountPage.js b/src/pages/AddPersonalBankAccountPage.js index 6ce8651c3306..1b66d9c09106 100644 --- a/src/pages/AddPersonalBankAccountPage.js +++ b/src/pages/AddPersonalBankAccountPage.js @@ -2,9 +2,7 @@ import React from 'react'; import HeaderWithCloseButton from '../components/HeaderWithCloseButton'; import ScreenWrapper from '../components/ScreenWrapper'; import Navigation from '../libs/Navigation/Navigation'; -import { - addPersonalBankAccount, -} from '../libs/actions/BankAccounts'; +import * as BankAccounts from '../libs/actions/BankAccounts'; import withLocalize, {withLocalizePropTypes} from '../components/withLocalize'; import AddPlaidBankAccount from '../components/AddPlaidBankAccount'; @@ -20,7 +18,7 @@ const AddPersonalBankAccountPage = props => ( /> { - addPersonalBankAccount(account, password, plaidLinkToken); + BankAccounts.addPersonalBankAccount(account, password, plaidLinkToken); }} onExitPlaid={Navigation.dismissModal} /> diff --git a/src/pages/DetailsPage.js b/src/pages/DetailsPage.js index 544ba789016c..a6e51ebaf6f0 100755 --- a/src/pages/DetailsPage.js +++ b/src/pages/DetailsPage.js @@ -17,7 +17,7 @@ import compose from '../libs/compose'; import CommunicationsLink from '../components/CommunicationsLink'; import Tooltip from '../components/Tooltip'; import CONST from '../CONST'; -import {hasExpensifyEmails} from '../libs/reportUtils'; +import * as ReportUtils from '../libs/reportUtils'; const matchType = PropTypes.shape({ params: PropTypes.shape({ @@ -69,7 +69,7 @@ const DetailsPage = (props) => { const timezone = moment().tz(details.timezone.selected); const GMTTime = `${timezone.toString().split(/[+-]/)[0].slice(-3)} ${timezone.zoneAbbr()}`; const currentTime = Number.isNaN(Number(timezone.zoneAbbr())) ? timezone.zoneAbbr() : GMTTime; - const shouldShowLocalTime = !hasExpensifyEmails([details.login]); + const shouldShowLocalTime = !ReportUtils.hasExpensifyEmails([details.login]); let pronouns = details.pronouns; diff --git a/src/pages/EnablePayments/AdditionalDetailsStep.js b/src/pages/EnablePayments/AdditionalDetailsStep.js index fee1d2fdd86e..3d80857894a0 100644 --- a/src/pages/EnablePayments/AdditionalDetailsStep.js +++ b/src/pages/EnablePayments/AdditionalDetailsStep.js @@ -12,7 +12,7 @@ import Navigation from '../../libs/Navigation/Navigation'; import styles from '../../styles/styles'; import Button from '../../components/Button'; import Text from '../../components/Text'; -import {activateWallet} from '../../libs/actions/BankAccounts'; +import * as BankAccounts from '../../libs/actions/BankAccounts'; import CONST from '../../CONST'; import compose from '../../libs/compose'; import ONYXKEYS from '../../ONYXKEYS'; @@ -155,7 +155,7 @@ class AdditionalDetailsStep extends React.Component { text={this.props.translate('common.saveAndContinue')} isLoading={this.props.walletAdditionalDetails.loading} onPress={() => { - activateWallet(CONST.WALLET.STEP.ADDITIONAL_DETAILS, { + BankAccounts.activateWallet(CONST.WALLET.STEP.ADDITIONAL_DETAILS, { personalDetails: this.state, }); }} diff --git a/src/pages/EnablePayments/OnfidoStep.js b/src/pages/EnablePayments/OnfidoStep.js index 2a75c3f6d273..e39dad6a1ff1 100644 --- a/src/pages/EnablePayments/OnfidoStep.js +++ b/src/pages/EnablePayments/OnfidoStep.js @@ -5,7 +5,7 @@ import PropTypes from 'prop-types'; import Onfido from '../../components/Onfido'; import FullscreenLoadingIndicator from '../../components/FullscreenLoadingIndicator'; import ONYXKEYS from '../../ONYXKEYS'; -import {activateWallet, fetchOnfidoToken} from '../../libs/actions/BankAccounts'; +import * as BankAccounts from '../../libs/actions/BankAccounts'; import Navigation from '../../libs/Navigation/Navigation'; import CONST from '../../CONST'; import Button from '../../components/Button'; @@ -78,7 +78,7 @@ class OnfidoStep extends React.Component { Navigation.goBack(); }} onSuccess={(data) => { - activateWallet(CONST.WALLET.STEP.ONFIDO, { + BankAccounts.activateWallet(CONST.WALLET.STEP.ONFIDO, { onfidoData: JSON.stringify({ ...data, applicantID: this.props.walletOnfidoData.applicantID, @@ -118,7 +118,7 @@ class OnfidoStep extends React.Component { text={this.props.translate('common.continue')} isLoading={this.props.walletOnfidoData.loading} onPress={() => { - fetchOnfidoToken(); + BankAccounts.fetchOnfidoToken(); }} /> @@ -135,7 +135,7 @@ class OnfidoStep extends React.Component { text={this.props.translate('onfidoStep.tryAgain')} onPress={() => { // Restart the flow so the user can try again. - fetchOnfidoToken(); + BankAccounts.fetchOnfidoToken(); }} /> diff --git a/src/pages/EnablePayments/TermsPage/LongTermsForm.js b/src/pages/EnablePayments/TermsPage/LongTermsForm.js index e1c67581a973..9ecfe78c690e 100644 --- a/src/pages/EnablePayments/TermsPage/LongTermsForm.js +++ b/src/pages/EnablePayments/TermsPage/LongTermsForm.js @@ -4,57 +4,57 @@ import {View} from 'react-native'; import styles from '../../../styles/styles'; import Text from '../../../components/Text'; import CollapsibleSection from '../../../components/CollapsibleSection'; -import {translateLocal} from '../../../libs/translate'; +import * as Localize from '../../../libs/Localize'; import CONST from '../../../CONST'; import Icon from '../../../components/Icon'; -import {Printer} from '../../../components/Icon/Expensicons'; -import {openExternalLink} from '../../../libs/actions/Link'; +import * as Expensicons from '../../../components/Icon/Expensicons'; +import * as Link from '../../../libs/actions/Link'; const termsData = [ { - title: translateLocal('termsStep.longTermsForm.openingAccountTitle'), - rightText: translateLocal('termsStep.feeAmountZero'), - details: translateLocal('termsStep.longTermsForm.openingAccountDetails'), + title: Localize.translateLocal('termsStep.longTermsForm.openingAccountTitle'), + rightText: Localize.translateLocal('termsStep.feeAmountZero'), + details: Localize.translateLocal('termsStep.longTermsForm.openingAccountDetails'), }, { - title: translateLocal('termsStep.monthlyFee'), - rightText: translateLocal('termsStep.feeAmountZero'), - details: translateLocal('termsStep.longTermsForm.monthlyFeeDetails'), + title: Localize.translateLocal('termsStep.monthlyFee'), + rightText: Localize.translateLocal('termsStep.feeAmountZero'), + details: Localize.translateLocal('termsStep.longTermsForm.monthlyFeeDetails'), }, { - title: translateLocal('termsStep.longTermsForm.customerServiceTitle'), - subTitle: translateLocal('termsStep.longTermsForm.automated'), - rightText: translateLocal('termsStep.feeAmountZero'), - details: translateLocal('termsStep.longTermsForm.customerServiceDetails'), + title: Localize.translateLocal('termsStep.longTermsForm.customerServiceTitle'), + subTitle: Localize.translateLocal('termsStep.longTermsForm.automated'), + rightText: Localize.translateLocal('termsStep.feeAmountZero'), + details: Localize.translateLocal('termsStep.longTermsForm.customerServiceDetails'), }, { - title: translateLocal('termsStep.longTermsForm.customerServiceTitle'), - subTitle: translateLocal('termsStep.longTermsForm.liveAgent'), - rightText: translateLocal('termsStep.feeAmountZero'), - details: translateLocal('termsStep.longTermsForm.customerServiceDetails'), + title: Localize.translateLocal('termsStep.longTermsForm.customerServiceTitle'), + subTitle: Localize.translateLocal('termsStep.longTermsForm.liveAgent'), + rightText: Localize.translateLocal('termsStep.feeAmountZero'), + details: Localize.translateLocal('termsStep.longTermsForm.customerServiceDetails'), }, { - title: translateLocal('termsStep.inactivity'), - rightText: translateLocal('termsStep.feeAmountZero'), - details: translateLocal('termsStep.longTermsForm.inactivityDetails'), + title: Localize.translateLocal('termsStep.inactivity'), + rightText: Localize.translateLocal('termsStep.feeAmountZero'), + details: Localize.translateLocal('termsStep.longTermsForm.inactivityDetails'), }, { - title: translateLocal('termsStep.longTermsForm.sendingFundsTitle'), - rightText: translateLocal('termsStep.feeAmountZero'), - details: translateLocal('termsStep.longTermsForm.sendingFundsDetails'), + title: Localize.translateLocal('termsStep.longTermsForm.sendingFundsTitle'), + rightText: Localize.translateLocal('termsStep.feeAmountZero'), + details: Localize.translateLocal('termsStep.longTermsForm.sendingFundsDetails'), }, { - title: translateLocal('termsStep.electronicFundsWithdrawal'), - subTitle: translateLocal('termsStep.standard'), - rightText: translateLocal('termsStep.feeAmountZero'), - details: translateLocal('termsStep.longTermsForm.electronicFundsStandardDetails'), + title: Localize.translateLocal('termsStep.electronicFundsWithdrawal'), + subTitle: Localize.translateLocal('termsStep.standard'), + rightText: Localize.translateLocal('termsStep.feeAmountZero'), + details: Localize.translateLocal('termsStep.longTermsForm.electronicFundsStandardDetails'), }, { - title: translateLocal('termsStep.electronicFundsWithdrawal'), - subTitle: translateLocal('termsStep.instant'), - rightText: translateLocal('termsStep.electronicFundsInstantFee'), - subRightText: translateLocal('termsStep.electronicFundsInstantFeeMin'), - details: translateLocal('termsStep.longTermsForm.electronicFundsStandardDetails'), + title: Localize.translateLocal('termsStep.electronicFundsWithdrawal'), + subTitle: Localize.translateLocal('termsStep.instant'), + rightText: Localize.translateLocal('termsStep.electronicFundsInstantFee'), + subRightText: Localize.translateLocal('termsStep.electronicFundsInstantFeeMin'), + details: Localize.translateLocal('termsStep.longTermsForm.electronicFundsStandardDetails'), }, ]; @@ -95,48 +95,48 @@ const getLongTermsSections = () => _.map(termsData, (section, index) => ( const LongTermsForm = () => ( <> - + {getLongTermsSections()} - {translateLocal('termsStep.longTermsForm.fdicInsuranceBancorp')} + {Localize.translateLocal('termsStep.longTermsForm.fdicInsuranceBancorp')} {' '} {CONST.TERMS.FDIC_PREPAID} {' '} - {translateLocal('termsStep.longTermsForm.fdicInsuranceBancorp2')} + {Localize.translateLocal('termsStep.longTermsForm.fdicInsuranceBancorp2')} - {translateLocal('termsStep.noOverdraftOrCredit')} + {Localize.translateLocal('termsStep.noOverdraftOrCredit')} - {translateLocal('termsStep.longTermsForm.contactExpensifyPayments')} + {Localize.translateLocal('termsStep.longTermsForm.contactExpensifyPayments')} {' '} {CONST.EMAIL.CONCIERGE} {' '} - {translateLocal('termsStep.longTermsForm.contactExpensifyPayments2')} + {Localize.translateLocal('termsStep.longTermsForm.contactExpensifyPayments2')} {' '} {CONST.NEWDOT} . - {translateLocal('termsStep.longTermsForm.generalInformation')} + {Localize.translateLocal('termsStep.longTermsForm.generalInformation')} {' '} {CONST.TERMS.CFPB_PREPAID} {'. '} - {translateLocal('termsStep.longTermsForm.generalInformation2')} + {Localize.translateLocal('termsStep.longTermsForm.generalInformation2')} {' '} {CONST.TERMS.CFPB_COMPLAINT} . - + openExternalLink(CONST.FEES_URL)} + onPress={() => Link.openExternalLink(CONST.FEES_URL)} > - {translateLocal('termsStep.longTermsForm.printerFriendlyView')} + {Localize.translateLocal('termsStep.longTermsForm.printerFriendlyView')} diff --git a/src/pages/EnablePayments/TermsPage/ShortTermsForm.js b/src/pages/EnablePayments/TermsPage/ShortTermsForm.js index 15808fd332a2..de3b6d6b3829 100644 --- a/src/pages/EnablePayments/TermsPage/ShortTermsForm.js +++ b/src/pages/EnablePayments/TermsPage/ShortTermsForm.js @@ -3,42 +3,42 @@ import React from 'react'; import {View} from 'react-native'; import styles from '../../../styles/styles'; import Text from '../../../components/Text'; -import {translateLocal} from '../../../libs/translate'; +import * as Localize from '../../../libs/Localize'; import CONST from '../../../CONST'; -import {openExternalLink} from '../../../libs/actions/Link'; +import * as Link from '../../../libs/actions/Link'; const termsData = [ { - title: translateLocal('termsStep.monthlyFee'), - rightText: translateLocal('termsStep.feeAmountZero'), + title: Localize.translateLocal('termsStep.monthlyFee'), + rightText: Localize.translateLocal('termsStep.feeAmountZero'), }, { - title: translateLocal('termsStep.shortTermsForm.perPurchase'), - rightText: translateLocal('termsStep.feeAmountZero'), + title: Localize.translateLocal('termsStep.shortTermsForm.perPurchase'), + rightText: Localize.translateLocal('termsStep.feeAmountZero'), }, { - title: translateLocal('termsStep.shortTermsForm.atmWithdrawal'), - subTitle: translateLocal('termsStep.shortTermsForm.inOrOutOfNetwork'), - rightText: translateLocal('common.na'), + title: Localize.translateLocal('termsStep.shortTermsForm.atmWithdrawal'), + subTitle: Localize.translateLocal('termsStep.shortTermsForm.inOrOutOfNetwork'), + rightText: Localize.translateLocal('common.na'), }, { - title: translateLocal('termsStep.shortTermsForm.cashReload'), - rightText: translateLocal('common.na'), + title: Localize.translateLocal('termsStep.shortTermsForm.cashReload'), + rightText: Localize.translateLocal('common.na'), }, { - title: translateLocal('termsStep.shortTermsForm.atmBalanceInquiry'), - subTitle: translateLocal('termsStep.shortTermsForm.inOrOutOfNetwork'), - rightText: translateLocal('common.na'), + title: Localize.translateLocal('termsStep.shortTermsForm.atmBalanceInquiry'), + subTitle: Localize.translateLocal('termsStep.shortTermsForm.inOrOutOfNetwork'), + rightText: Localize.translateLocal('common.na'), }, { - title: translateLocal('termsStep.shortTermsForm.customerService'), - subTitle: translateLocal('termsStep.shortTermsForm.automatedOrLive'), - rightText: translateLocal('termsStep.feeAmountZero'), + title: Localize.translateLocal('termsStep.shortTermsForm.customerService'), + subTitle: Localize.translateLocal('termsStep.shortTermsForm.automatedOrLive'), + rightText: Localize.translateLocal('termsStep.feeAmountZero'), }, { - title: translateLocal('termsStep.inactivity'), - subTitle: translateLocal('termsStep.shortTermsForm.afterTwelveMonths'), - rightText: translateLocal('termsStep.feeAmountZero'), + title: Localize.translateLocal('termsStep.inactivity'), + subTitle: Localize.translateLocal('termsStep.shortTermsForm.afterTwelveMonths'), + rightText: Localize.translateLocal('termsStep.feeAmountZero'), }, ]; @@ -66,61 +66,61 @@ const getShortTermsSections = () => _.map(termsData, section => ( const ShortTermsForm = () => ( <> - {translateLocal('termsStep.shortTermsForm.expensifyPaymentsAccount')} + {Localize.translateLocal('termsStep.shortTermsForm.expensifyPaymentsAccount')} {getShortTermsSections()} - {translateLocal('termsStep.shortTermsForm.weChargeOneFee')} + {Localize.translateLocal('termsStep.shortTermsForm.weChargeOneFee')} - {translateLocal('termsStep.electronicFundsWithdrawal')} + {Localize.translateLocal('termsStep.electronicFundsWithdrawal')} - {translateLocal('termsStep.instant')} + {Localize.translateLocal('termsStep.instant')} - {translateLocal('termsStep.electronicFundsInstantFee')} + {Localize.translateLocal('termsStep.electronicFundsInstantFee')} - {translateLocal('termsStep.electronicFundsInstantFeeMin')} + {Localize.translateLocal('termsStep.electronicFundsInstantFeeMin')} - {translateLocal('termsStep.noOverdraftOrCredit')} + {Localize.translateLocal('termsStep.noOverdraftOrCredit')} - {translateLocal('termsStep.shortTermsForm.fdicInsurance')} + {Localize.translateLocal('termsStep.shortTermsForm.fdicInsurance')} - {translateLocal('termsStep.shortTermsForm.generalInfo')} + {Localize.translateLocal('termsStep.shortTermsForm.generalInfo')} {' '} openExternalLink(CONST.CFPB_PREPAID_URL)} + onPress={() => Link.openExternalLink(CONST.CFPB_PREPAID_URL)} > {CONST.TERMS.CFPB_PREPAID} . - {translateLocal('termsStep.shortTermsForm.conditionsDetails')} + {Localize.translateLocal('termsStep.shortTermsForm.conditionsDetails')} {' '} openExternalLink(CONST.FEES_URL)} + onPress={() => Link.openExternalLink(CONST.FEES_URL)} > {CONST.TERMS.USE_EXPENSIFY_FEES} {' '} - {translateLocal('termsStep.shortTermsForm.conditionsPhone')} + {Localize.translateLocal('termsStep.shortTermsForm.conditionsPhone')} diff --git a/src/pages/EnablePayments/TermsStep.js b/src/pages/EnablePayments/TermsStep.js index f1cdc76f3afa..0c7c541fa052 100644 --- a/src/pages/EnablePayments/TermsStep.js +++ b/src/pages/EnablePayments/TermsStep.js @@ -7,7 +7,7 @@ import Navigation from '../../libs/Navigation/Navigation'; import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize'; import styles from '../../styles/styles'; import Button from '../../components/Button'; -import {activateWallet} from '../../libs/actions/BankAccounts'; +import * as BankAccounts from '../../libs/actions/BankAccounts'; import CONST from '../../CONST'; import TextLink from '../../components/TextLink'; import compose from '../../libs/compose'; @@ -121,7 +121,7 @@ class TermsStep extends React.Component { } this.setState({error: false}); - activateWallet(CONST.WALLET.STEP.TERMS, { + BankAccounts.activateWallet(CONST.WALLET.STEP.TERMS, { hasAcceptedTerms: this.state.hasAcceptedDisclosure && this.state.hasAcceptedPrivacyPolicyAndWalletAgreement, }); diff --git a/src/pages/EnablePayments/index.js b/src/pages/EnablePayments/index.js index 8012df050e5c..36f645a9221f 100644 --- a/src/pages/EnablePayments/index.js +++ b/src/pages/EnablePayments/index.js @@ -2,7 +2,7 @@ import _ from 'underscore'; import React from 'react'; import {withOnyx} from 'react-native-onyx'; import ScreenWrapper from '../../components/ScreenWrapper'; -import {fetchUserWallet} from '../../libs/actions/BankAccounts'; +import * as BankAccounts from '../../libs/actions/BankAccounts'; import ONYXKEYS from '../../ONYXKEYS'; import FullScreenLoadingIndicator from '../../components/FullscreenLoadingIndicator'; import CONST from '../../CONST'; @@ -24,7 +24,7 @@ const defaultProps = { class EnablePaymentsPage extends React.Component { componentDidMount() { - fetchUserWallet(); + BankAccounts.fetchUserWallet(); } render() { diff --git a/src/pages/LogInWithShortLivedTokenPage.js b/src/pages/LogInWithShortLivedTokenPage.js index e1bc522e7a8f..b13f8b0a40f0 100644 --- a/src/pages/LogInWithShortLivedTokenPage.js +++ b/src/pages/LogInWithShortLivedTokenPage.js @@ -4,7 +4,7 @@ import PropTypes from 'prop-types'; import {withOnyx} from 'react-native-onyx'; import ROUTES from '../ROUTES'; import ONYXKEYS from '../ONYXKEYS'; -import {signInWithShortLivedToken} from '../libs/actions/Session'; +import * as Session from '../libs/actions/Session'; import FullScreenLoadingIndicator from '../components/FullscreenLoadingIndicator'; import Navigation from '../libs/Navigation/Navigation'; @@ -62,7 +62,7 @@ class LogInWithShortLivedTokenPage extends Component { return; } - signInWithShortLivedToken(accountID, email, shortLivedToken); + Session.signInWithShortLivedToken(accountID, email, shortLivedToken); } componentDidUpdate() { diff --git a/src/pages/NewChatPage.js b/src/pages/NewChatPage.js index fd6df170d6a9..3771931f3237 100755 --- a/src/pages/NewChatPage.js +++ b/src/pages/NewChatPage.js @@ -5,11 +5,11 @@ import {View} from 'react-native'; import PropTypes from 'prop-types'; import {withOnyx} from 'react-native-onyx'; import OptionsSelector from '../components/OptionsSelector'; -import {getNewChatOptions, getHeaderMessage} from '../libs/OptionsListUtils'; +import * as OptionsListUtils from '../libs/OptionsListUtils'; import ONYXKEYS from '../ONYXKEYS'; import styles from '../styles/styles'; -import {fetchOrCreateChatReport} from '../libs/actions/Report'; -import CONST, {EXPENSIFY_EMAILS} from '../CONST'; +import * as Report from '../libs/actions/Report'; +import CONST from '../CONST'; import withWindowDimensions, {windowDimensionsPropTypes} from '../components/withWindowDimensions'; import HeaderWithCloseButton from '../components/HeaderWithCloseButton'; import Navigation from '../libs/Navigation/Navigation'; @@ -60,7 +60,7 @@ class NewChatPage extends Component { this.createGroup = this.createGroup.bind(this); this.toggleGroupOptionOrCreateChat = this.toggleGroupOptionOrCreateChat.bind(this); this.createNewChat = this.createNewChat.bind(this); - this.excludedGroupEmails = _.without(EXPENSIFY_EMAILS, [ + this.excludedGroupEmails = _.without(CONST.EXPENSIFY_EMAILS, [ CONST.EMAIL.CONCIERGE, CONST.EMAIL.RECEIPTS, CONST.EMAIL.INTEGRATION_TESTING_CREDS, @@ -70,7 +70,7 @@ class NewChatPage extends Component { recentReports, personalDetails, userToInvite, - } = getNewChatOptions( + } = OptionsListUtils.getNewChatOptions( props.reports, props.personalDetails, props.betas, @@ -143,7 +143,8 @@ class NewChatPage extends Component { if (userLogins.length < 1) { return; } - fetchOrCreateChatReport([this.props.session.email, ...userLogins]); + + Report.fetchOrCreateChatReport([this.props.session.email, ...userLogins]); } /** @@ -170,7 +171,7 @@ class NewChatPage extends Component { recentReports, personalDetails, userToInvite, - } = getNewChatOptions( + } = OptionsListUtils.getNewChatOptions( this.props.reports, this.props.personalDetails, this.props.betas, @@ -194,7 +195,7 @@ class NewChatPage extends Component { * @param {Object} option */ createNewChat(option) { - fetchOrCreateChatReport([ + Report.fetchOrCreateChatReport([ this.props.session.email, option.login, ]); @@ -211,7 +212,7 @@ class NewChatPage extends Component { render() { const maxParticipantsReached = this.state.selectedOptions.length === CONST.REPORT.MAXIMUM_PARTICIPANTS; const sections = this.getSections(maxParticipantsReached); - const headerMessage = getHeaderMessage( + const headerMessage = OptionsListUtils.getHeaderMessage( (this.state.personalDetails.length + this.state.recentReports.length) !== 0, Boolean(this.state.userToInvite), this.state.searchValue, @@ -242,7 +243,7 @@ class NewChatPage extends Component { recentReports, personalDetails, userToInvite, - } = getNewChatOptions( + } = OptionsListUtils.getNewChatOptions( this.props.reports, this.props.personalDetails, this.props.betas, diff --git a/src/pages/ReimbursementAccount/BankAccountStep.js b/src/pages/ReimbursementAccount/BankAccountStep.js index 01acd421f9d3..cf19831681ae 100644 --- a/src/pages/ReimbursementAccount/BankAccountStep.js +++ b/src/pages/ReimbursementAccount/BankAccountStep.js @@ -4,9 +4,7 @@ import {View, Image} from 'react-native'; import {withOnyx} from 'react-native-onyx'; import HeaderWithCloseButton from '../../components/HeaderWithCloseButton'; import MenuItem from '../../components/MenuItem'; -import { - Paycheck, Bank, Lock, Exclamation, -} from '../../components/Icon/Expensicons'; +import * as Expensicons from '../../components/Icon/Expensicons'; import styles from '../../styles/styles'; import TextLink from '../../components/TextLink'; import Icon from '../../components/Icon'; @@ -19,21 +17,14 @@ import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize import exampleCheckImage from './exampleCheckImage'; import Text from '../../components/Text'; import ExpensiTextInput from '../../components/ExpensiTextInput'; -import { - setBankAccountFormValidationErrors, - setBankAccountSubStep, - setupWithdrawalAccount, - showBankAccountErrorModal, - updateReimbursementAccountDraft, - validateRoutingNumber, -} from '../../libs/actions/BankAccounts'; +import * as BankAccounts from '../../libs/actions/BankAccounts'; import ONYXKEYS from '../../ONYXKEYS'; import compose from '../../libs/compose'; import * as ReimbursementAccountUtils from '../../libs/ReimbursementAccountUtils'; import ReimbursementAccountForm from './ReimbursementAccountForm'; import reimbursementAccountPropTypes from './reimbursementAccountPropTypes'; import WorkspaceSection from '../workspace/WorkspaceSection'; -import {BankMouseGreen} from '../../components/Icon/Illustrations'; +import * as Illustrations from '../../components/Icon/Illustrations'; const propTypes = { /** Bank account currently in setup */ @@ -71,7 +62,7 @@ class BankAccountStep extends React.Component { toggleTerms() { this.setState((prevState) => { const hasAcceptedTerms = !prevState.hasAcceptedTerms; - updateReimbursementAccountDraft({acceptTerms: hasAcceptedTerms}); + BankAccounts.updateReimbursementAccountDraft({acceptTerms: hasAcceptedTerms}); return {hasAcceptedTerms}; }); this.clearError('hasAcceptedTerms'); @@ -87,14 +78,14 @@ class BankAccountStep extends React.Component { if (!CONST.BANK_ACCOUNT.REGEX.IBAN.test(this.state.accountNumber.trim())) { errors.accountNumber = true; } - if (!CONST.BANK_ACCOUNT.REGEX.SWIFT_BIC.test(this.state.routingNumber.trim()) || !validateRoutingNumber(this.state.routingNumber.trim())) { + if (!CONST.BANK_ACCOUNT.REGEX.SWIFT_BIC.test(this.state.routingNumber.trim()) || !BankAccounts.validateRoutingNumber(this.state.routingNumber.trim())) { errors.routingNumber = true; } if (!this.state.hasAcceptedTerms) { errors.hasAcceptedTerms = true; } - setBankAccountFormValidationErrors(errors); + BankAccounts.setBankAccountFormValidationErrors(errors); return _.size(errors) === 0; } @@ -107,16 +98,17 @@ class BankAccountStep extends React.Component { clearErrorAndSetValue(inputKey, value) { const newState = {[inputKey]: value}; this.setState(newState); - updateReimbursementAccountDraft(newState); + BankAccounts.updateReimbursementAccountDraft(newState); this.clearError(inputKey); } addManualAccount() { if (!this.validate()) { - showBankAccountErrorModal(); + BankAccounts.showBankAccountErrorModal(); return; } - setupWithdrawalAccount({ + + BankAccounts.setupWithdrawalAccount({ acceptTerms: this.state.hasAcceptedTerms, accountNumber: this.state.accountNumber, routingNumber: this.state.routingNumber, @@ -141,7 +133,7 @@ class BankAccountStep extends React.Component { * @param {String} params.account.plaidAccountID */ addPlaidAccount(params) { - setupWithdrawalAccount({ + BankAccounts.setupWithdrawalAccount({ acceptTerms: true, setupType: CONST.BANK_ACCOUNT.SETUP_TYPE.PLAID, @@ -176,7 +168,7 @@ class BankAccountStep extends React.Component { onBackButtonPress={() => { // If we have a subStep then we will remove otherwise we will go back if (subStep) { - setBankAccountSubStep(null); + BankAccounts.setBankAccountSubStep(null); return; } Navigation.goBack(); @@ -187,16 +179,16 @@ class BankAccountStep extends React.Component { <> {this.props.translate('bankAccount.toGetStarted')} setBankAccountSubStep(CONST.BANK_ACCOUNT.SETUP_TYPE.PLAID)} + onPress={() => BankAccounts.setBankAccountSubStep(CONST.BANK_ACCOUNT.SETUP_TYPE.PLAID)} disabled={this.props.isPlaidDisabled || !this.props.user.validated} shouldShowRightIcon /> @@ -206,16 +198,16 @@ class BankAccountStep extends React.Component { )} setBankAccountSubStep(CONST.BANK_ACCOUNT.SETUP_TYPE.MANUAL)} + onPress={() => BankAccounts.setBankAccountSubStep(CONST.BANK_ACCOUNT.SETUP_TYPE.MANUAL)} shouldShowRightIcon /> {!this.props.user.validated && ( - + {this.props.translate('bankAccount.validateAccountError')} @@ -234,7 +226,7 @@ class BankAccountStep extends React.Component { {this.props.translate('bankAccount.yourDataIsSecure')} - + @@ -245,7 +237,7 @@ class BankAccountStep extends React.Component { setBankAccountSubStep(null)} + onExitPlaid={() => BankAccounts.setBankAccountSubStep(null)} /> )} diff --git a/src/pages/ReimbursementAccount/BeneficialOwnersStep.js b/src/pages/ReimbursementAccount/BeneficialOwnersStep.js index 3319f92d1717..a8c282d00b41 100644 --- a/src/pages/ReimbursementAccount/BeneficialOwnersStep.js +++ b/src/pages/ReimbursementAccount/BeneficialOwnersStep.js @@ -11,22 +11,13 @@ import CheckboxWithLabel from '../../components/CheckboxWithLabel'; import TextLink from '../../components/TextLink'; import IdentityForm from './IdentityForm'; import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize'; -import { - goToWithdrawalAccountSetupStep, - setBankAccountFormValidationErrors, - setupWithdrawalAccount, - updateReimbursementAccountDraft, -} from '../../libs/actions/BankAccounts'; +import * as BankAccounts from '../../libs/actions/BankAccounts'; import Navigation from '../../libs/Navigation/Navigation'; import CONST from '../../CONST'; -import {validateIdentity, isRequiredFulfilled} from '../../libs/ValidationUtils'; +import * as ValidationUtils from '../../libs/ValidationUtils'; import ONYXKEYS from '../../ONYXKEYS'; import compose from '../../libs/compose'; -import { - getDefaultStateForField, - clearError, - getErrorText, -} from '../../libs/ReimbursementAccountUtils'; +import * as ReimbursementAccountUtils from '../../libs/ReimbursementAccountUtils'; import reimbursementAccountPropTypes from './reimbursementAccountPropTypes'; import ReimbursementAccountForm from './ReimbursementAccountForm'; @@ -49,11 +40,11 @@ class BeneficialOwnersStep extends React.Component { this.submit = this.submit.bind(this); this.state = { - ownsMoreThan25Percent: getDefaultStateForField(props, 'ownsMoreThan25Percent', false), - hasOtherBeneficialOwners: getDefaultStateForField(props, 'hasOtherBeneficialOwners', false), - acceptTermsAndConditions: getDefaultStateForField(props, 'acceptTermsAndConditions', false), - certifyTrueInformation: getDefaultStateForField(props, 'certifyTrueInformation', false), - beneficialOwners: getDefaultStateForField(props, 'beneficialOwners', []), + ownsMoreThan25Percent: ReimbursementAccountUtils.getDefaultStateForField(props, 'ownsMoreThan25Percent', false), + hasOtherBeneficialOwners: ReimbursementAccountUtils.getDefaultStateForField(props, 'hasOtherBeneficialOwners', false), + acceptTermsAndConditions: ReimbursementAccountUtils.getDefaultStateForField(props, 'acceptTermsAndConditions', false), + certifyTrueInformation: ReimbursementAccountUtils.getDefaultStateForField(props, 'certifyTrueInformation', false), + beneficialOwners: ReimbursementAccountUtils.getDefaultStateForField(props, 'beneficialOwners', []), }; // These fields need to be filled out in order to submit the form (doesn't include IdentityForm fields) @@ -68,8 +59,8 @@ class BeneficialOwnersStep extends React.Component { certifyTrueInformation: 'beneficialOwnersStep.error.certify', }; - this.clearError = inputKey => clearError(this.props, inputKey); - this.getErrorText = inputKey => getErrorText(this.props, this.errorTranslationKeys, inputKey); + this.clearError = inputKey => ReimbursementAccountUtils.clearError(this.props, inputKey); + this.getErrorText = inputKey => ReimbursementAccountUtils.getErrorText(this.props, this.errorTranslationKeys, inputKey); } /** @@ -85,18 +76,18 @@ class BeneficialOwnersStep extends React.Component { validate() { let beneficialOwnersErrors = []; if (this.state.hasOtherBeneficialOwners) { - beneficialOwnersErrors = _.map(this.state.beneficialOwners, validateIdentity); + beneficialOwnersErrors = _.map(this.state.beneficialOwners, ValidationUtils.validateIdentity); } const errors = {}; _.each(this.requiredFields, (inputKey) => { - if (isRequiredFulfilled(this.state[inputKey])) { + if (ValidationUtils.isRequiredFulfilled(this.state[inputKey])) { return; } errors[inputKey] = true; }); - setBankAccountFormValidationErrors({...errors, beneficialOwnersErrors}); + BankAccounts.setBankAccountFormValidationErrors({...errors, beneficialOwnersErrors}); return _.every(beneficialOwnersErrors, _.isEmpty) && _.isEmpty(errors); } @@ -106,11 +97,11 @@ class BeneficialOwnersStep extends React.Component { // We set 'beneficialOwners' to null first because we don't have a way yet to replace a specific property without merging it. // We don't use the debounced function because we want to make both function calls. - updateReimbursementAccountDraft({beneficialOwners: null}); - updateReimbursementAccountDraft({beneficialOwners}); + BankAccounts.updateReimbursementAccountDraft({beneficialOwners: null}); + BankAccounts.updateReimbursementAccountDraft({beneficialOwners}); // Clear errors - setBankAccountFormValidationErrors({}); + BankAccounts.setBankAccountFormValidationErrors({}); return {beneficialOwners}; }); } @@ -145,7 +136,7 @@ class BeneficialOwnersStep extends React.Component { const renamedInputKey = lodashGet(renamedFields, inputKey, inputKey); const beneficialOwners = [...prevState.beneficialOwners]; beneficialOwners[ownerIndex] = {...beneficialOwners[ownerIndex], [renamedInputKey]: value}; - updateReimbursementAccountDraft({beneficialOwners}); + BankAccounts.updateReimbursementAccountDraft({beneficialOwners}); return {beneficialOwners}; }); @@ -168,7 +159,7 @@ class BeneficialOwnersStep extends React.Component { this.setState(prevState => ({ beneficialOwners: !prevState.hasOtherBeneficialOwners ? [] : prevState.beneficialOwners, }), - () => setupWithdrawalAccount({...this.state})); + () => BankAccounts.setupWithdrawalAccount({...this.state})); } /** @@ -177,7 +168,7 @@ class BeneficialOwnersStep extends React.Component { toggleCheckbox(fieldName) { this.setState((prevState) => { const newState = {[fieldName]: !prevState[fieldName]}; - updateReimbursementAccountDraft(newState); + BankAccounts.updateReimbursementAccountDraft(newState); return newState; }); this.clearError(fieldName); @@ -190,7 +181,7 @@ class BeneficialOwnersStep extends React.Component { title={this.props.translate('beneficialOwnersStep.additionalInformation')} stepCounter={{step: 4, total: 5}} onCloseButtonPress={Navigation.dismissModal} - onBackButtonPress={() => goToWithdrawalAccountSetupStep(CONST.BANK_ACCOUNT.STEP.REQUESTOR)} + onBackButtonPress={() => BankAccounts.goToWithdrawalAccountSetupStep(CONST.BANK_ACCOUNT.STEP.REQUESTOR)} shouldShowBackButton /> { - if (isRequiredFulfilled(this.state[inputKey])) { + if (ValidationUtils.isRequiredFulfilled(this.state[inputKey])) { return; } errors[inputKey] = true; }); - setBankAccountFormValidationErrors(errors); + BankAccounts.setBankAccountFormValidationErrors(errors); return _.size(errors) === 0; } submit() { if (!this.validate()) { - showBankAccountErrorModal(); + BankAccounts.showBankAccountErrorModal(); return; } const incorporationDate = moment(this.state.incorporationDate).format(CONST.DATE.MOMENT_FORMAT_STRING); - setupWithdrawalAccount({...this.state, incorporationDate}); + BankAccounts.setupWithdrawalAccount({...this.state, incorporationDate}); } render() { @@ -219,7 +211,7 @@ class CompanyStep extends React.Component { title={this.props.translate('companyStep.headerTitle')} stepCounter={{step: 2, total: 5}} shouldShowBackButton - onBackButtonPress={() => goToWithdrawalAccountSetupStep(CONST.BANK_ACCOUNT.STEP.BANK_ACCOUNT)} + onBackButtonPress={() => BankAccounts.goToWithdrawalAccountSetupStep(CONST.BANK_ACCOUNT.STEP.BANK_ACCOUNT)} onCloseButtonPress={Navigation.dismissModal} /> { this.setState((prevState) => { const newState = {hasNoConnectionToCannabis: !prevState.hasNoConnectionToCannabis}; - updateReimbursementAccountDraft(newState); + BankAccounts.updateReimbursementAccountDraft(newState); return newState; }); this.clearError('hasNoConnectionToCannabis'); diff --git a/src/pages/ReimbursementAccount/EnableStep.js b/src/pages/ReimbursementAccount/EnableStep.js index a2dbefbae0df..ee78c8fed403 100644 --- a/src/pages/ReimbursementAccount/EnableStep.js +++ b/src/pages/ReimbursementAccount/EnableStep.js @@ -10,19 +10,19 @@ import Navigation from '../../libs/Navigation/Navigation'; import Text from '../../components/Text'; import compose from '../../libs/compose'; import ONYXKEYS from '../../ONYXKEYS'; -import {Mail, Close} from '../../components/Icon/Expensicons'; +import * as Expensicons from '../../components/Icon/Expensicons'; import MenuItem from '../../components/MenuItem'; import getBankIcon from '../../components/Icon/BankIcons'; -import {getPaymentMethods} from '../../libs/actions/PaymentMethods'; +import * as PaymentMethods from '../../libs/actions/PaymentMethods'; import FullScreenLoadingIndicator from '../../components/FullscreenLoadingIndicator'; import bankAccountPropTypes from '../../components/bankAccountPropTypes'; import confettiPop from '../../../assets/images/confetti-pop.gif'; import Icon from '../../components/Icon'; import WorkspaceSection from '../workspace/WorkspaceSection'; -import {ConciergeBlue} from '../../components/Icon/Illustrations'; -import {requestResetFreePlanBankAccount} from '../../libs/actions/BankAccounts'; -import {openOldDotLink} from '../../libs/actions/Link'; -import {subscribeToExpensifyCardUpdates} from '../../libs/actions/User'; +import * as Illustrations from '../../components/Icon/Illustrations'; +import * as BankAccounts from '../../libs/actions/BankAccounts'; +import * as Link from '../../libs/actions/Link'; +import * as User from '../../libs/actions/User'; const propTypes = { /** Are we loading payment methods? */ @@ -41,7 +41,7 @@ const defaultProps = { class EnableStep extends React.Component { componentDidMount() { - getPaymentMethods(); + PaymentMethods.getPaymentMethods(); } render() { @@ -68,16 +68,16 @@ class EnableStep extends React.Component { const bankName = account.addressName; const menuItems = [{ title: this.props.translate('workspace.bankAccount.disconnectBankAccount'), - icon: Close, - onPress: requestResetFreePlanBankAccount, + icon: Expensicons.Close, + onPress: BankAccounts.requestResetFreePlanBankAccount, }]; if (!isUsingExpensifyCard) { menuItems.unshift({ title: this.props.translate('workspace.bankAccount.addWorkEmail'), - icon: Mail, + icon: Expensicons.Mail, onPress: () => { - openOldDotLink('settings?param={"section":"account","openModal":"secondaryLogin"}'); - subscribeToExpensifyCardUpdates(); + Link.openOldDotLink('settings?param={"section":"account","openModal":"secondaryLogin"}'); + User.subscribeToExpensifyCardUpdates(); }, shouldShowRightIcon: true, }); @@ -94,7 +94,8 @@ class EnableStep extends React.Component { (!isUsingExpensifyCard ? : )} + // eslint-disable-next-line max-len + IconComponent={() => (!isUsingExpensifyCard ? : )} menuItems={menuItems} > clearError(this.props, inputKey); - this.getErrors = () => getErrors(this.props); + this.clearError = inputKey => ReimbursementAccountUtils.clearError(this.props, inputKey); + this.getErrors = () => ReimbursementAccountUtils.getErrors(this.props); } /** @@ -102,7 +92,7 @@ class RequestorStep extends React.Component { const renamedInputKey = lodashGet(renamedFields, inputKey, inputKey); const newState = {[renamedInputKey]: value}; this.setState(newState); - updateReimbursementAccountDraft(newState); + BankAccounts.updateReimbursementAccountDraft(newState); // dob field has multiple validations/errors, we are handling it temporarily like this. if (inputKey === 'dob') { @@ -116,7 +106,7 @@ class RequestorStep extends React.Component { * @returns {Boolean} */ validate() { - const errors = validateIdentity({ + const errors = ValidationUtils.validateIdentity({ firstName: this.state.firstName, lastName: this.state.lastName, street: this.state.requestorAddressStreet, @@ -128,15 +118,15 @@ class RequestorStep extends React.Component { }); _.each(this.requiredFields, (inputKey) => { - if (isRequiredFulfilled(this.state[inputKey])) { + if (ValidationUtils.isRequiredFulfilled(this.state[inputKey])) { return; } errors[inputKey] = true; }); if (_.size(errors)) { - setBankAccountFormValidationErrors(errors); - showBankAccountErrorModal(); + BankAccounts.setBankAccountFormValidationErrors(errors); + BankAccounts.showBankAccountErrorModal(); return false; } return true; @@ -152,7 +142,7 @@ class RequestorStep extends React.Component { dob: moment(this.state.dob).format(CONST.DATE.MOMENT_FORMAT_STRING), }; - setupWithdrawalAccount(payload); + BankAccounts.setupWithdrawalAccount(payload); } render() { @@ -162,7 +152,7 @@ class RequestorStep extends React.Component { title={this.props.translate('requestorStep.headerTitle')} stepCounter={{step: 3, total: 5}} shouldShowBackButton - onBackButtonPress={() => goToWithdrawalAccountSetupStep(CONST.BANK_ACCOUNT.STEP.COMPANY)} + onBackButtonPress={() => BankAccounts.goToWithdrawalAccountSetupStep(CONST.BANK_ACCOUNT.STEP.COMPANY)} onCloseButtonPress={Navigation.dismissModal} /> {this.props.achData.useOnfido && this.props.achData.sdkToken && !this.state.isOnfidoSetupComplete ? ( @@ -170,13 +160,13 @@ class RequestorStep extends React.Component { sdkToken={this.props.achData.sdkToken} onUserExit={() => { // We're taking the user back to the company step. They will need to come back to the requestor step to make the Onfido flow appear again. - goToWithdrawalAccountSetupStep(CONST.BANK_ACCOUNT.STEP.COMPANY); + BankAccounts.goToWithdrawalAccountSetupStep(CONST.BANK_ACCOUNT.STEP.COMPANY); }} onError={(error) => { // In case of any unexpected error we log it to the server, show a growl, and return the user back to the company step so they can try again. Log.hmmm('Onfido error in RequestorStep', {error}); Growl.error(this.props.translate('onfidoStep.genericError'), 10000); - goToWithdrawalAccountSetupStep(CONST.BANK_ACCOUNT.STEP.COMPANY); + BankAccounts.goToWithdrawalAccountSetupStep(CONST.BANK_ACCOUNT.STEP.COMPANY); }} onSuccess={(onfidoData) => { this.setState({ @@ -227,7 +217,7 @@ class RequestorStep extends React.Component { onPress={() => { this.setState((prevState) => { const newState = {isControllingOfficer: !prevState.isControllingOfficer}; - updateReimbursementAccountDraft(newState); + BankAccounts.updateReimbursementAccountDraft(newState); return newState; }); this.clearError('isControllingOfficer'); @@ -246,7 +236,7 @@ class RequestorStep extends React.Component { {this.props.translate('requestorStep.onFidoConditions')} openExternalLink('https://onfido.com/facial-scan-policy-and-release/')} + onPress={() => Link.openExternalLink('https://onfido.com/facial-scan-policy-and-release/')} style={[styles.textMicro, styles.link]} accessibilityRole="link" > @@ -254,7 +244,7 @@ class RequestorStep extends React.Component { {', '} openExternalLink('https://onfido.com/privacy/')} + onPress={() => Link.openExternalLink('https://onfido.com/privacy/')} style={[styles.textMicro, styles.link]} accessibilityRole="link" > @@ -262,7 +252,7 @@ class RequestorStep extends React.Component { {` ${this.props.translate('common.and')} `} openExternalLink('https://onfido.com/terms-of-service/')} + onPress={() => Link.openExternalLink('https://onfido.com/terms-of-service/')} style={[styles.textMicro, styles.link]} accessibilityRole="link" > diff --git a/src/pages/ReimbursementAccount/ValidationStep.js b/src/pages/ReimbursementAccount/ValidationStep.js index a5546b19a039..e141658d514c 100644 --- a/src/pages/ReimbursementAccount/ValidationStep.js +++ b/src/pages/ReimbursementAccount/ValidationStep.js @@ -6,10 +6,8 @@ import Str from 'expensify-common/lib/str'; import _ from 'underscore'; import styles from '../../styles/styles'; import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize'; -import { - validateBankAccount, updateReimbursementAccountDraft, setBankAccountFormValidationErrors, showBankAccountErrorModal, requestResetFreePlanBankAccount, -} from '../../libs/actions/BankAccounts'; -import {navigateToConciergeChat} from '../../libs/actions/Report'; +import * as BankAccounts from '../../libs/actions/BankAccounts'; +import * as Report from '../../libs/actions/Report'; import HeaderWithCloseButton from '../../components/HeaderWithCloseButton'; import Navigation from '../../libs/Navigation/Navigation'; import ExpensiTextInput from '../../components/ExpensiTextInput'; @@ -19,12 +17,12 @@ import TextLink from '../../components/TextLink'; import ONYXKEYS from '../../ONYXKEYS'; import compose from '../../libs/compose'; import * as ReimbursementAccountUtils from '../../libs/ReimbursementAccountUtils'; -import {isRequiredFulfilled} from '../../libs/ValidationUtils'; +import * as ValidationUtils from '../../libs/ValidationUtils'; import EnableStep from './EnableStep'; import reimbursementAccountPropTypes from './reimbursementAccountPropTypes'; import ReimbursementAccountForm from './ReimbursementAccountForm'; -import {ChatBubble, RotateLeft} from '../../components/Icon/Expensicons'; -import {ConciergeBlue} from '../../components/Icon/Illustrations'; +import * as Expensicons from '../../components/Icon/Expensicons'; +import * as Illustrations from '../../components/Icon/Illustrations'; import WorkspaceSection from '../workspace/WorkspaceSection'; const propTypes = { @@ -74,7 +72,7 @@ class ValidationStep extends React.Component { * @param {Object} value */ setValue(value) { - updateReimbursementAccountDraft(value); + BankAccounts.updateReimbursementAccountDraft(value); this.setState(value); } @@ -101,19 +99,19 @@ class ValidationStep extends React.Component { }; _.each(this.requiredFields, (inputKey) => { - if (isRequiredFulfilled(values[inputKey])) { + if (ValidationUtils.isRequiredFulfilled(values[inputKey])) { return; } errors[inputKey] = true; }); - setBankAccountFormValidationErrors(errors); + BankAccounts.setBankAccountFormValidationErrors(errors); return _.size(errors) === 0; } submit() { if (!this.validate()) { - showBankAccountErrorModal(); + BankAccounts.showBankAccountErrorModal(); return; } @@ -125,7 +123,7 @@ class ValidationStep extends React.Component { // Send valid amounts to BankAccountAPI::validateBankAccount in Web-Expensify const bankaccountID = lodashGet(this.props.reimbursementAccount, 'achData.bankAccountID'); - validateBankAccount(bankaccountID, validateCode); + BankAccounts.validateBankAccount(bankaccountID, validateCode); } /** @@ -179,7 +177,7 @@ class ValidationStep extends React.Component { {' '} {this.props.translate('common.please')} {' '} - + {this.props.translate('common.contactUs')} . @@ -230,19 +228,19 @@ class ValidationStep extends React.Component { diff --git a/src/pages/ReportDetailsPage.js b/src/pages/ReportDetailsPage.js index 2695f097dfec..8f05a855b218 100644 --- a/src/pages/ReportDetailsPage.js +++ b/src/pages/ReportDetailsPage.js @@ -15,11 +15,11 @@ import Navigation from '../libs/Navigation/Navigation'; import HeaderWithCloseButton from '../components/HeaderWithCloseButton'; import styles from '../styles/styles'; import DisplayNames from '../components/DisplayNames'; -import {getPersonalDetailsForLogins} from '../libs/OptionsListUtils'; -import {getDefaultRoomSubtitle, isDefaultRoom, isArchivedRoom} from '../libs/reportUtils'; +import * as OptionsListUtils from '../libs/OptionsListUtils'; +import * as ReportUtils from '../libs/reportUtils'; import {participantPropTypes} from './home/sidebar/optionPropTypes'; -import {updateNotificationPreference} from '../libs/actions/Report'; -import {Users} from '../components/Icon/Expensicons'; +import * as Report from '../libs/actions/Report'; +import * as Expensicons from '../components/Icon/Expensicons'; import ROUTES from '../ROUTES'; import MenuItem from '../components/MenuItem'; import Text from '../components/Text'; @@ -89,11 +89,11 @@ class ReportDetailsPage extends Component { }, }; - this.menuItems = isArchivedRoom(this.props.report) ? [] + this.menuItems = ReportUtils.isArchivedRoom(this.props.report) ? [] : [ { translationKey: 'common.members', - icon: Users, + icon: Expensicons.Users, subtitle: props.report.participants.length, action: () => { Navigation.navigate(ROUTES.getReportParticipantsRoute(props.report.reportID)); }, }, @@ -101,11 +101,11 @@ class ReportDetailsPage extends Component { } render() { - const defaultRoomSubtitle = getDefaultRoomSubtitle(this.props.report, this.props.policies); + const defaultRoomSubtitle = ReportUtils.getDefaultRoomSubtitle(this.props.report, this.props.policies); const participants = lodashGet(this.props.report, 'participants', []); const isMultipleParticipant = participants.length > 1; const displayNamesWithTooltips = _.map( - getPersonalDetailsForLogins(participants, this.props.personalDetails), + OptionsListUtils.getPersonalDetailsForLogins(participants, this.props.personalDetails), ({displayName, firstName, login}) => { const displayNameTrimmed = Str.isSMSLogin(login) ? this.props.toLocalPhone(displayName) : displayName; @@ -129,8 +129,8 @@ class ReportDetailsPage extends Component { style={styles.reportDetailsTitleContainer} > - {!isArchivedRoom(this.props.report) && ( + {!ReportUtils.isArchivedRoom(this.props.report) && ( @@ -170,7 +170,7 @@ class ReportDetailsPage extends Component { // eslint-disable-next-line max-len label={this.props.translate('reportDetailsPage.notificationPreferencesDescription')} onChange={(notificationPreference) => { - updateNotificationPreference( + Report.updateNotificationPreference( this.props.report.reportID, notificationPreference, ); diff --git a/src/pages/ReportParticipantsPage.js b/src/pages/ReportParticipantsPage.js index ad97e6a150f9..6e56fbd62cc1 100755 --- a/src/pages/ReportParticipantsPage.js +++ b/src/pages/ReportParticipantsPage.js @@ -16,7 +16,7 @@ import ROUTES from '../ROUTES'; import personalDetailsPropType from './personalDetailsPropType'; import withLocalize, {withLocalizePropTypes} from '../components/withLocalize'; import compose from '../libs/compose'; -import {isDefaultRoom} from '../libs/reportUtils'; +import * as ReportUtils from '../libs/reportUtils'; const propTypes = { /* Onyx Props */ @@ -80,10 +80,10 @@ const ReportParticipantsPage = (props) => { return ( fetchOrCreateChatReport([ + onBackButtonPress={() => Report.fetchOrCreateChatReport([ this.props.session.email, CONST.EMAIL.CONCIERGE, ], true)} diff --git a/src/pages/SearchPage.js b/src/pages/SearchPage.js index ce473549a0e2..664af9ad0415 100755 --- a/src/pages/SearchPage.js +++ b/src/pages/SearchPage.js @@ -4,14 +4,14 @@ import {View} from 'react-native'; import PropTypes from 'prop-types'; import {withOnyx} from 'react-native-onyx'; import OptionsSelector from '../components/OptionsSelector'; -import {getSearchOptions, getHeaderMessage} from '../libs/OptionsListUtils'; +import * as OptionsListUtils from '../libs/OptionsListUtils'; import ONYXKEYS from '../ONYXKEYS'; import styles from '../styles/styles'; import KeyboardSpacer from '../components/KeyboardSpacer'; import Navigation from '../libs/Navigation/Navigation'; import ROUTES from '../ROUTES'; import withWindowDimensions, {windowDimensionsPropTypes} from '../components/withWindowDimensions'; -import {fetchOrCreateChatReport} from '../libs/actions/Report'; +import * as Report from '../libs/actions/Report'; import HeaderWithCloseButton from '../components/HeaderWithCloseButton'; import ScreenWrapper from '../components/ScreenWrapper'; import Timing from '../libs/actions/Timing'; @@ -61,7 +61,7 @@ class SearchPage extends Component { recentReports, personalDetails, userToInvite, - } = getSearchOptions( + } = OptionsListUtils.getSearchOptions( props.reports, props.personalDetails, '', @@ -114,7 +114,7 @@ class SearchPage extends Component { recentReports, personalDetails, userToInvite, - } = getSearchOptions( + } = OptionsListUtils.getSearchOptions( this.props.reports, this.props.personalDetails, this.state.searchValue.trim(), @@ -144,7 +144,7 @@ class SearchPage extends Component { Navigation.navigate(ROUTES.getReportRoute(option.reportID)); }); } else { - fetchOrCreateChatReport([ + Report.fetchOrCreateChatReport([ this.props.session.email, option.login, ]); @@ -153,7 +153,7 @@ class SearchPage extends Component { render() { const sections = this.getSections(); - const headerMessage = getHeaderMessage( + const headerMessage = OptionsListUtils.getHeaderMessage( (this.state.recentReports.length + this.state.personalDetails.length) !== 0, Boolean(this.state.userToInvite), this.state.searchValue, diff --git a/src/pages/ValidateLoginPage.js b/src/pages/ValidateLoginPage.js index 979fdd0546c4..ffa1d295225b 100644 --- a/src/pages/ValidateLoginPage.js +++ b/src/pages/ValidateLoginPage.js @@ -4,7 +4,7 @@ import { propTypes as validateLinkPropTypes, defaultProps as validateLinkDefaultProps, } from './validateLinkPropTypes'; -import {validateLogin} from '../libs/actions/User'; +import * as User from '../libs/actions/User'; import FullScreenLoadingIndicator from '../components/FullscreenLoadingIndicator'; const propTypes = { @@ -20,7 +20,7 @@ class ValidateLoginPage extends Component { const accountID = lodashGet(this.props.route.params, 'accountID', ''); const validateCode = lodashGet(this.props.route.params, 'validateCode', ''); - validateLogin(accountID, validateCode); + User.validateLogin(accountID, validateCode); } render() { diff --git a/src/pages/home/HeaderView.js b/src/pages/home/HeaderView.js index 04f5f3fa6bd1..a370c8885c8c 100644 --- a/src/pages/home/HeaderView.js +++ b/src/pages/home/HeaderView.js @@ -9,23 +9,21 @@ import styles from '../../styles/styles'; import ONYXKEYS from '../../ONYXKEYS'; import themeColors from '../../styles/themes/default'; import Icon from '../../components/Icon'; -import {BackArrow, Pin} from '../../components/Icon/Expensicons'; +import * as Expensicons from '../../components/Icon/Expensicons'; import compose from '../../libs/compose'; -import {togglePinnedState} from '../../libs/actions/Report'; +import * as Report from '../../libs/actions/Report'; import withWindowDimensions, {windowDimensionsPropTypes} from '../../components/withWindowDimensions'; import MultipleAvatars from '../../components/MultipleAvatars'; import Navigation from '../../libs/Navigation/Navigation'; import ROUTES from '../../ROUTES'; import DisplayNames from '../../components/DisplayNames'; -import {getPersonalDetailsForLogins} from '../../libs/OptionsListUtils'; +import * as OptionsListUtils from '../../libs/OptionsListUtils'; import {participantPropTypes} from './sidebar/optionPropTypes'; import VideoChatButtonAndMenu from '../../components/VideoChatButtonAndMenu'; import IOUBadge from '../../components/IOUBadge'; import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize'; import CONST from '../../CONST'; -import { - getDefaultRoomSubtitle, isDefaultRoom, isArchivedRoom, hasExpensifyEmails, -} from '../../libs/reportUtils'; +import * as ReportUtils from '../../libs/reportUtils'; import Text from '../../components/Text'; import Tooltip from '../../components/Tooltip'; @@ -77,7 +75,7 @@ const HeaderView = (props) => { const participants = lodashGet(props.report, 'participants', []); const isMultipleParticipant = participants.length > 1; const displayNamesWithTooltips = _.map( - getPersonalDetailsForLogins(participants, props.personalDetails), + OptionsListUtils.getPersonalDetailsForLogins(participants, props.personalDetails), ({displayName, firstName, login}) => { const displayNameTrimmed = Str.isSMSLogin(login) ? props.toLocalPhone(displayName) : displayName; @@ -87,14 +85,14 @@ const HeaderView = (props) => { }; }, ); - const isDefaultChatRoom = isDefaultRoom(props.report); + const isDefaultChatRoom = ReportUtils.isDefaultRoom(props.report); const title = isDefaultChatRoom ? props.report.reportName : _.map(displayNamesWithTooltips, ({displayName}) => displayName).join(', '); - const subtitle = getDefaultRoomSubtitle(props.report, props.policies); + const subtitle = ReportUtils.getDefaultRoomSubtitle(props.report, props.policies); const isConcierge = participants.length === 1 && _.contains(participants, CONST.EMAIL.CONCIERGE); - const isAutomatedExpensifyAccount = (participants.length === 1 && hasExpensifyEmails(participants)); + const isAutomatedExpensifyAccount = (participants.length === 1 && ReportUtils.hasExpensifyEmails(participants)); // We hide the button when we are chatting with an automated Expensify account since it's not possible to contact // these users via alternative means. It is possible to request a call with Concierge so we leave the option for them. @@ -109,7 +107,7 @@ const HeaderView = (props) => { onPress={props.onNavigationMenuButtonClicked} style={[styles.LHNToggle]} > - + )} @@ -124,7 +122,7 @@ const HeaderView = (props) => { > { - if (isDefaultRoom(props.report)) { + if (ReportUtils.isDefaultRoom(props.report)) { return Navigation.navigate(ROUTES.getReportDetailsRoute(props.report.reportID)); } if (participants.length === 1) { @@ -138,7 +136,7 @@ const HeaderView = (props) => { avatarImageURLs={props.report.icons} secondAvatarStyle={[styles.secondAvatarHovered]} isDefaultChatRoom={isDefaultChatRoom} - isArchivedRoom={isArchivedRoom(props.report)} + isArchivedRoom={ReportUtils.isArchivedRoom(props.report)} /> { {shouldShowCallButton && } togglePinnedState(props.report)} + onPress={() => Report.togglePinnedState(props.report)} style={[styles.touchableButtonImage, styles.mr0]} > - + diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index a3d808e6e890..ec655e1d5d13 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -9,10 +9,10 @@ import ScreenWrapper from '../../components/ScreenWrapper'; import HeaderView from './HeaderView'; import Navigation from '../../libs/Navigation/Navigation'; import ROUTES from '../../ROUTES'; -import {handleInaccessibleReport, updateCurrentlyViewedReportID, addAction} from '../../libs/actions/Report'; +import * as Report from '../../libs/actions/Report'; import ONYXKEYS from '../../ONYXKEYS'; import Permissions from '../../libs/Permissions'; -import {isDefaultRoom} from '../../libs/reportUtils'; +import * as ReportUtils from '../../libs/reportUtils'; import ReportActionsView from './report/ReportActionsView'; import ReportActionCompose from './report/ReportActionCompose'; import KeyboardSpacer from '../../components/KeyboardSpacer'; @@ -121,7 +121,7 @@ class ReportScreen extends React.Component { * @param {String} text */ onSubmitComment(text) { - addAction(getReportID(this.props.route), text); + Report.addAction(getReportID(this.props.route), text); } /** @@ -148,10 +148,10 @@ class ReportScreen extends React.Component { storeCurrentlyViewedReport() { const reportID = getReportID(this.props.route); if (_.isNaN(reportID) || !lodashGet(this.props.report, 'reportID', '')) { - handleInaccessibleReport(); + Report.handleInaccessibleReport(); return; } - updateCurrentlyViewedReportID(reportID); + Report.updateCurrentlyViewedReportID(reportID); } render() { @@ -159,7 +159,7 @@ class ReportScreen extends React.Component { return null; } - if (!Permissions.canUseDefaultRooms(this.props.betas) && isDefaultRoom(this.props.report)) { + if (!Permissions.canUseDefaultRooms(this.props.betas) && ReportUtils.isDefaultRoom(this.props.report)) { return null; } diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.js b/src/pages/home/report/ContextMenu/ContextMenuActions.js index 688d27725f9d..b1359504180d 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.js +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.js @@ -1,14 +1,10 @@ import _ from 'underscore'; import lodashGet from 'lodash/get'; import Str from 'expensify-common/lib/str'; -import { - Clipboard as ClipboardIcon, LinkCopy, Mail, Pencil, Trashcan, Checkmark, -} from '../../../../components/Icon/Expensicons'; -import { - setNewMarkerPosition, updateLastReadActionID, saveReportActionDraft, -} from '../../../../libs/actions/Report'; +import * as Expensicons from '../../../../components/Icon/Expensicons'; +import * as Report from '../../../../libs/actions/Report'; import Clipboard from '../../../../libs/Clipboard'; -import {isReportMessageAttachment, canEditReportAction, canDeleteReportAction} from '../../../../libs/reportUtils'; +import * as ReportUtils from '../../../../libs/reportUtils'; import ReportActionComposeFocusManager from '../../../../libs/ReportActionComposeFocusManager'; import {hideContextMenu, showDeleteModal} from './ReportActionContextMenu'; @@ -31,9 +27,9 @@ const CONTEXT_MENU_TYPES = { export default [ { textTranslateKey: 'reportActionContextMenu.copyURLToClipboard', - icon: ClipboardIcon, + icon: Expensicons.Clipboard, successTextTranslateKey: 'reportActionContextMenu.copied', - successIcon: Checkmark, + successIcon: Expensicons.Checkmark, shouldShow: type => type === CONTEXT_MENU_TYPES.LINK, onPress: (closePopover, {selection}) => { Clipboard.setString(selection); @@ -42,9 +38,9 @@ export default [ }, { textTranslateKey: 'reportActionContextMenu.copyToClipboard', - icon: ClipboardIcon, + icon: Expensicons.Clipboard, successTextTranslateKey: 'reportActionContextMenu.copied', - successIcon: Checkmark, + successIcon: Expensicons.Checkmark, shouldShow: type => type === CONTEXT_MENU_TYPES.REPORT_ACTION, // If return value is true, we switch the `text` and `icon` on @@ -56,7 +52,7 @@ export default [ const text = Str.htmlDecode(selection || lodashGet(message, 'text', '')); const isAttachment = _.has(reportAction, 'isAttachment') ? reportAction.isAttachment - : isReportMessageAttachment(text); + : ReportUtils.isReportMessageAttachment(text); if (!isAttachment) { Clipboard.setString(text); } else { @@ -70,19 +66,19 @@ export default [ { textTranslateKey: 'reportActionContextMenu.copyLink', - icon: LinkCopy, + icon: Expensicons.LinkCopy, shouldShow: () => false, onPress: () => {}, }, { textTranslateKey: 'reportActionContextMenu.markAsUnread', - icon: Mail, - successIcon: Checkmark, + icon: Expensicons.Mail, + successIcon: Expensicons.Checkmark, shouldShow: type => type === CONTEXT_MENU_TYPES.REPORT_ACTION, onPress: (closePopover, {reportAction, reportID}) => { - updateLastReadActionID(reportID, reportAction.sequenceNumber); - setNewMarkerPosition(reportID, reportAction.sequenceNumber); + Report.updateLastReadActionID(reportID, reportAction.sequenceNumber); + Report.setNewMarkerPosition(reportID, reportAction.sequenceNumber); if (closePopover) { hideContextMenu(true, ReportActionComposeFocusManager.focus); } @@ -91,12 +87,12 @@ export default [ { textTranslateKey: 'reportActionContextMenu.editComment', - icon: Pencil, + icon: Expensicons.Pencil, shouldShow: (type, reportAction) => ( - type === CONTEXT_MENU_TYPES.REPORT_ACTION && canEditReportAction(reportAction) + type === CONTEXT_MENU_TYPES.REPORT_ACTION && ReportUtils.canEditReportAction(reportAction) ), onPress: (closePopover, {reportID, reportAction, draftMessage}) => { - const editAction = () => saveReportActionDraft( + const editAction = () => Report.saveReportActionDraft( reportID, reportAction.reportActionID, _.isEmpty(draftMessage) ? getActionText(reportAction) : '', @@ -114,9 +110,9 @@ export default [ }, { textTranslateKey: 'reportActionContextMenu.deleteComment', - icon: Trashcan, + icon: Expensicons.Trashcan, shouldShow: (type, reportAction) => type === CONTEXT_MENU_TYPES.REPORT_ACTION - && canDeleteReportAction(reportAction), + && ReportUtils.canDeleteReportAction(reportAction), onPress: (closePopover, {reportID, reportAction}) => { if (closePopover) { // Hide popover, then call showDeleteConfirmModal diff --git a/src/pages/home/report/ContextMenu/MiniReportActionContextMenu/index.js b/src/pages/home/report/ContextMenu/MiniReportActionContextMenu/index.js index 3fd99d7d7d39..d90b47d71b79 100644 --- a/src/pages/home/report/ContextMenu/MiniReportActionContextMenu/index.js +++ b/src/pages/home/report/ContextMenu/MiniReportActionContextMenu/index.js @@ -6,7 +6,7 @@ import { propTypes as genericReportActionContextMenuPropTypes, defaultProps as GenericReportActionContextMenuDefaultProps, } from '../genericReportActionContextMenuPropTypes'; -import {getMiniReportActionContextMenuWrapperStyle} from '../../../../../styles/getReportActionItemStyles'; +import * as StyleUtils from '../../../../../styles/StyleUtils'; import BaseReportActionContextMenu from '../BaseReportActionContextMenu'; const propTypes = { @@ -23,7 +23,7 @@ const defaultProps = { }; const MiniReportActionContextMenu = props => ( - + {/* eslint-disable-next-line react/jsx-props-no-spreading */} diff --git a/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js b/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js index 77239361d603..6ad0e45f09ad 100644 --- a/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js +++ b/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js @@ -3,9 +3,7 @@ import { Dimensions, } from 'react-native'; import _ from 'underscore'; -import { - deleteReportComment, -} from '../../../../libs/actions/Report'; +import * as Report from '../../../../libs/actions/Report'; import withLocalize, {withLocalizePropTypes} from '../../../../components/withLocalize'; import PopoverWithMeasuredContent from '../../../../components/PopoverWithMeasuredContent'; import BaseReportActionContextMenu from './BaseReportActionContextMenu'; @@ -227,7 +225,7 @@ class PopoverReportActionContextMenu extends React.Component { } confirmDeleteAndHideModal() { - deleteReportComment(this.state.reportID, this.state.reportAction); + Report.deleteReportComment(this.state.reportID, this.state.reportAction); this.setState({isDeleteCommentConfirmModalVisible: false}); } diff --git a/src/pages/home/report/EmojiPickerMenu/getSkinToneEmojiFromIndex.js b/src/pages/home/report/EmojiPickerMenu/getSkinToneEmojiFromIndex.js index 070d94f630a6..abd173b073bd 100644 --- a/src/pages/home/report/EmojiPickerMenu/getSkinToneEmojiFromIndex.js +++ b/src/pages/home/report/EmojiPickerMenu/getSkinToneEmojiFromIndex.js @@ -1,5 +1,5 @@ import _ from 'underscore'; -import {skinTones} from '../../../../../assets/emojis'; +import * as Emojis from '../../../../../assets/emojis'; /** * Fetch the emoji code of selected skinTone @@ -7,7 +7,7 @@ import {skinTones} from '../../../../../assets/emojis'; * @returns {String} */ function getSkinToneEmojiFromIndex(skinToneIndex) { - return _.find(skinTones, emoji => emoji.skinTone === skinToneIndex) || skinTones[0]; + return _.find(Emojis.skinTones, emoji => emoji.skinTone === skinToneIndex) || Emojis.skinTones[0]; } export default getSkinToneEmojiFromIndex; diff --git a/src/pages/home/report/EmojiPickerMenu/index.js b/src/pages/home/report/EmojiPickerMenu/index.js index 1c3bd85eabd7..046e27b08c6e 100755 --- a/src/pages/home/report/EmojiPickerMenu/index.js +++ b/src/pages/home/report/EmojiPickerMenu/index.js @@ -3,7 +3,8 @@ import {View, FlatList} from 'react-native'; import PropTypes from 'prop-types'; import _ from 'underscore'; import CONST from '../../../../CONST'; -import styles, {getEmojiPickerStyle} from '../../../../styles/styles'; +import styles from '../../../../styles/styles'; +import * as StyleUtils from '../../../../styles/StyleUtils'; import themeColors from '../../../../styles/themes/default'; import emojis from '../../../../../assets/emojis'; import EmojiPickerMenuItem from '../EmojiPickerMenuItem'; @@ -356,7 +357,7 @@ class EmojiPickerMenu extends Component { render() { return ( {!this.props.isSmallScreenWidth && ( diff --git a/src/pages/home/report/EmojiPickerMenuItem.js b/src/pages/home/report/EmojiPickerMenuItem.js index 1e24aac47ea9..d2bb719943db 100644 --- a/src/pages/home/report/EmojiPickerMenuItem.js +++ b/src/pages/home/report/EmojiPickerMenuItem.js @@ -1,7 +1,8 @@ import React from 'react'; import PropTypes from 'prop-types'; import {Pressable} from 'react-native'; -import styles, {getButtonBackgroundColorStyle} from '../../../styles/styles'; +import styles from '../../../styles/styles'; +import * as StyleUtils from '../../../styles/StyleUtils'; import getButtonState from '../../../libs/getButtonState'; import Hoverable from '../../../components/Hoverable'; import Text from '../../../components/Text'; @@ -27,7 +28,7 @@ const EmojiPickerMenuItem = props => ( pressed, }) => ([ styles.pv1, - getButtonBackgroundColorStyle(getButtonState(false, pressed)), + StyleUtils.getButtonBackgroundColorStyle(getButtonState(false, pressed)), props.isHighlighted ? styles.emojiItemHighlighted : {}, styles.emojiItem, ])} diff --git a/src/pages/home/report/EmojiSkinToneList.js b/src/pages/home/report/EmojiSkinToneList.js index b9a584b44817..c04d3c49c622 100644 --- a/src/pages/home/report/EmojiSkinToneList.js +++ b/src/pages/home/report/EmojiSkinToneList.js @@ -3,7 +3,7 @@ import React, {Component} from 'react'; import {View, Pressable} from 'react-native'; import PropTypes from 'prop-types'; import styles from '../../../styles/styles'; -import {skinTones} from '../../../../assets/emojis'; +import * as Emojis from '../../../../assets/emojis'; import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize'; import Text from '../../../components/Text'; import getSkinToneEmojiFromIndex from './EmojiPickerMenu/getSkinToneEmojiFromIndex'; @@ -82,7 +82,7 @@ class EmojiSkinToneList extends Component { { - _.map(skinTones, skinToneEmoji => ( + _.map(Emojis.skinTones, skinToneEmoji => ( this.updateSelectedSkinTone(skinToneEmoji)} onHover={() => this.setState({highlightedIndex: skinToneEmoji.skinTone})} diff --git a/src/pages/home/report/MarkerBadge/index.js b/src/pages/home/report/MarkerBadge/index.js index d076a38d8a43..07eb5179751e 100644 --- a/src/pages/home/report/MarkerBadge/index.js +++ b/src/pages/home/report/MarkerBadge/index.js @@ -4,7 +4,7 @@ import PropTypes from 'prop-types'; import styles from '../../../../styles/styles'; import Button from '../../../../components/Button'; import Icon from '../../../../components/Icon'; -import {Close, DownArrow} from '../../../../components/Icon/Expensicons'; +import * as Expensicons from '../../../../components/Icon/Expensicons'; import themeColors from '../../../../styles/themes/default'; import withLocalize, {withLocalizePropTypes} from '../../../../components/withLocalize'; import MarkerBadgeContainer from './MarkerBadgeContainer'; @@ -83,7 +83,7 @@ class MarkerBadge extends PureComponent { onPress={this.props.onClick} ContentComponent={() => ( - + ( - + )} /> diff --git a/src/pages/home/report/ReportActionCompose.js b/src/pages/home/report/ReportActionCompose.js index d5f21d4b0774..2a2359615d85 100755 --- a/src/pages/home/report/ReportActionCompose.js +++ b/src/pages/home/report/ReportActionCompose.js @@ -12,28 +12,15 @@ import _ from 'underscore'; import lodashGet from 'lodash/get'; import {withOnyx} from 'react-native-onyx'; import lodashIntersection from 'lodash/intersection'; -import styles, {getButtonBackgroundColorStyle, getIconFillColor} from '../../../styles/styles'; +import styles from '../../../styles/styles'; +import * as StyleUtils from '../../../styles/StyleUtils'; import themeColors from '../../../styles/themes/default'; import TextInputFocusable from '../../../components/TextInputFocusable'; import ONYXKEYS from '../../../ONYXKEYS'; import Icon from '../../../components/Icon'; -import { - Plus, - Send, - Emoji, - Paperclip, - Offline, - MoneyCircle, - Receipt, -} from '../../../components/Icon/Expensicons'; +import * as Expensicons from '../../../components/Icon/Expensicons'; import AttachmentPicker from '../../../components/AttachmentPicker'; -import { - addAction, - saveReportComment, - saveReportActionDraft, - broadcastUserIsTyping, - setReportWithDraft, -} from '../../../libs/actions/Report'; +import * as Report from '../../../libs/actions/Report'; import ReportTypingIndicator from './ReportTypingIndicator'; import AttachmentModal from '../../../components/AttachmentModal'; import compose from '../../../libs/compose'; @@ -43,7 +30,7 @@ import EmojiPickerMenu from './EmojiPickerMenu'; import withWindowDimensions, {windowDimensionsPropTypes} from '../../../components/withWindowDimensions'; import withDrawerState from '../../../components/withDrawerState'; import getButtonState from '../../../libs/getButtonState'; -import CONST, {EXPENSIFY_EMAILS} from '../../../CONST'; +import CONST from '../../../CONST'; import canFocusInputOnScreenFocus from '../../../libs/canFocusInputOnScreenFocus'; import variables from '../../../styles/variables'; import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize'; @@ -52,7 +39,7 @@ import Navigation from '../../../libs/Navigation/Navigation'; import ROUTES from '../../../ROUTES'; import * as User from '../../../libs/actions/User'; import reportActionPropTypes from './reportActionPropTypes'; -import {canEditReportAction, isArchivedRoom, shouldShowReportRecipientLocalTime as canShowReportRecipientLocalTime} from '../../../libs/reportUtils'; +import * as ReportUtils from '../../../libs/reportUtils'; import ReportActionComposeFocusManager from '../../../libs/ReportActionComposeFocusManager'; import Text from '../../../components/Text'; import {participantPropTypes} from '../sidebar/optionPropTypes'; @@ -270,7 +257,7 @@ class ReportActionCompose extends React.Component { * @return {String} */ getInputPlaceholder() { - if (isArchivedRoom(this.props.report)) { + if (ReportUtils.isArchivedRoom(this.props.report)) { return this.props.translate('reportActionCompose.roomIsArchived'); } @@ -320,7 +307,7 @@ class ReportActionCompose extends React.Component { * @param {String} comment */ debouncedSaveReportComment(comment) { - saveReportComment(this.props.reportID, comment || ''); + Report.saveReportComment(this.props.reportID, comment || ''); } /** @@ -328,7 +315,7 @@ class ReportActionCompose extends React.Component { * client events. */ debouncedBroadcastUserIsTyping() { - broadcastUserIsTyping(this.props.reportID); + Report.broadcastUserIsTyping(this.props.reportID); } /** @@ -344,12 +331,12 @@ class ReportActionCompose extends React.Component { // Indicate that draft has been created. if (this.comment.length === 0 && newComment.length !== 0) { - setReportWithDraft(this.props.reportID.toString(), true); + Report.setReportWithDraft(this.props.reportID.toString(), true); } // The draft has been deleted. if (newComment.length === 0) { - setReportWithDraft(this.props.reportID.toString(), false); + Report.setReportWithDraft(this.props.reportID.toString(), false); } this.comment = newComment; @@ -381,12 +368,12 @@ class ReportActionCompose extends React.Component { const reportActionKey = _.find( _.keys(this.props.reportActions).reverse(), - key => canEditReportAction(this.props.reportActions[key]), + key => ReportUtils.canEditReportAction(this.props.reportActions[key]), ); if (reportActionKey !== -1 && this.props.reportActions[reportActionKey]) { const {reportActionID, message} = this.props.reportActions[reportActionKey]; - saveReportActionDraft(this.props.reportID, reportActionID, _.last(message).html); + Report.saveReportActionDraft(this.props.reportID, reportActionID, _.last(message).html); } } } @@ -485,10 +472,10 @@ class ReportActionCompose extends React.Component { const reportParticipants = lodashGet(this.props.report, 'participants', []); const hasMultipleParticipants = reportParticipants.length > 1; - const hasExcludedIOUEmails = lodashIntersection(reportParticipants, EXPENSIFY_EMAILS).length > 0; + const hasExcludedIOUEmails = lodashIntersection(reportParticipants, CONST.EXPENSIFY_EMAILS).length > 0; const reportRecipient = this.props.personalDetails[reportParticipants[0]]; const currentUserTimezone = lodashGet(this.props.myPersonalDetails, 'timezone', CONST.DEFAULT_TIME_ZONE); - const shouldShowReportRecipientLocalTime = canShowReportRecipientLocalTime(this.props.personalDetails, this.props.myPersonalDetails, this.props.report); + const shouldShowReportRecipientLocalTime = ReportUtils.canShowReportRecipientLocalTime(this.props.personalDetails, this.props.myPersonalDetails, this.props.report); // Prevents focusing and showing the keyboard while the drawer is covering the chat. const isComposeDisabled = this.props.isDrawerOpen && this.props.isSmallScreenWidth; @@ -499,7 +486,7 @@ class ReportActionCompose extends React.Component { isBlockedFromConcierge = User.isBlockedFromConcierge(this.props.blockedFromConcierge.expiresAt); } const inputPlaceholder = this.getInputPlaceholder(); - const isArchivedChatRoom = isArchivedRoom(this.props.report); + const isArchivedChatRoom = ReportUtils.isArchivedRoom(this.props.report); return ( { this.submitForm(); - addAction(this.props.reportID, '', file); + Report.addAction(this.props.reportID, '', file); this.setTextInputShouldClear(false); }} > @@ -541,7 +528,7 @@ class ReportActionCompose extends React.Component { underlayColor={themeColors.componentBG} disabled={isBlockedFromConcierge || isArchivedChatRoom} > - + @@ -557,7 +544,7 @@ class ReportActionCompose extends React.Component { && Permissions.canUseIOU(this.props.betas) ? [ hasMultipleParticipants ? { - icon: Receipt, + icon: Expensicons.Receipt, text: this.props.translate('iou.splitBill'), onSelected: () => { Navigation.navigate( @@ -568,7 +555,7 @@ class ReportActionCompose extends React.Component { }, } : { - icon: MoneyCircle, + icon: Expensicons.MoneyCircle, text: this.props.translate('iou.requestMoney'), onSelected: () => { Navigation.navigate( @@ -581,7 +568,7 @@ class ReportActionCompose extends React.Component { ] : []), ...(!hasExcludedIOUEmails && Permissions.canUseIOUSend(this.props.betas) && !hasMultipleParticipants ? [ { - icon: Send, + icon: Expensicons.Send, text: this.props.translate('iou.sendMoney'), onSelected: () => { Navigation.navigate( @@ -593,7 +580,7 @@ class ReportActionCompose extends React.Component { }, ] : []), { - icon: Paperclip, + icon: Expensicons.Paperclip, text: this.props.translate('reportActionCompose.addAttachment'), onSelected: () => { openPicker({ @@ -687,7 +674,7 @@ class ReportActionCompose extends React.Component { ([ styles.chatItemEmojiButton, - getButtonBackgroundColorStyle(getButtonState(hovered, pressed)), + StyleUtils.getButtonBackgroundColorStyle(getButtonState(hovered, pressed)), ])} ref={el => this.emojiPopoverAnchor = el} onLayout={this.measureEmojiPopoverAnchorPosition} @@ -697,8 +684,8 @@ class ReportActionCompose extends React.Component { {({hovered, pressed}) => ( )} @@ -713,7 +700,7 @@ class ReportActionCompose extends React.Component { underlayColor={themeColors.componentBG} disabled={this.state.isCommentEmpty || isBlockedFromConcierge || isArchivedChatRoom} > - + @@ -726,7 +713,7 @@ class ReportActionCompose extends React.Component { styles.alignItemsCenter]} > diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index 92dd9d1564a0..c26b3d2e38d0 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -6,9 +6,7 @@ import PropTypes from 'prop-types'; import CONST from '../../../CONST'; import ONYXKEYS from '../../../ONYXKEYS'; import reportActionPropTypes from './reportActionPropTypes'; -import { - getReportActionItemStyle, -} from '../../../styles/getReportActionItemStyles'; +import * as StyleUtils from '../../../styles/StyleUtils'; import PressableWithSecondaryInteraction from '../../../components/PressableWithSecondaryInteraction'; import Hoverable from '../../../components/Hoverable'; import ReportActionItemSingle from './ReportActionItemSingle'; @@ -22,8 +20,8 @@ import withWindowDimensions, {windowDimensionsPropTypes} from '../../../componen import ControlSelection from '../../../libs/ControlSelection'; import canUseTouchScreen from '../../../libs/canUseTouchscreen'; import MiniReportActionContextMenu from './ContextMenu/MiniReportActionContextMenu'; -import {isActiveReportAction, showContextMenu} from './ContextMenu/ReportActionContextMenu'; -import {CONTEXT_MENU_TYPES} from './ContextMenu/ContextMenuActions'; +import * as ReportActionContextMenu from './ContextMenu/ReportActionContextMenu'; +import * as ContextMenuActions from './ContextMenu/ContextMenuActions'; import {withReportActionsDrafts} from '../../../components/OnyxProvider'; const propTypes = { @@ -64,7 +62,7 @@ class ReportActionItem extends Component { super(props); this.popoverAnchor = undefined; this.state = { - isContextMenuActive: isActiveReportAction(props.action.reportActionID), + isContextMenuActive: ReportActionContextMenu.isActiveReportAction(props.action.reportActionID), }; this.checkIfContextMenuActive = this.checkIfContextMenuActive.bind(this); this.showPopover = this.showPopover.bind(this); @@ -100,8 +98,8 @@ class ReportActionItem extends Component { if (this.props.draftMessage) { return; } - showContextMenu( - CONTEXT_MENU_TYPES.REPORT_ACTION, + ReportActionContextMenu.showContextMenu( + ContextMenuActions.CONTEXT_MENU_TYPES.REPORT_ACTION, event, selection, this.popoverAnchor, @@ -114,7 +112,7 @@ class ReportActionItem extends Component { } checkIfContextMenuActive() { - this.setState({isContextMenuActive: isActiveReportAction(this.props.action.reportActionID)}); + this.setState({isContextMenuActive: ReportActionContextMenu.isActiveReportAction(this.props.action.reportActionID)}); } render() { @@ -156,7 +154,7 @@ class ReportActionItem extends Component { )} {Str.htmlDecode(this.props.fragment.text)} {this.props.fragment.isEdited && ( diff --git a/src/pages/home/report/ReportActionItemMessageEdit.js b/src/pages/home/report/ReportActionItemMessageEdit.js index f942de1ac28d..df9679bba1c0 100644 --- a/src/pages/home/report/ReportActionItemMessageEdit.js +++ b/src/pages/home/report/ReportActionItemMessageEdit.js @@ -6,8 +6,8 @@ import ExpensiMark from 'expensify-common/lib/ExpensiMark'; import reportActionPropTypes from './reportActionPropTypes'; import styles from '../../../styles/styles'; import TextInputFocusable from '../../../components/TextInputFocusable'; -import {editReportComment, saveReportActionDraft} from '../../../libs/actions/Report'; -import {scrollToIndex} from '../../../libs/ReportScrollManager'; +import * as Report from '../../../libs/actions/Report'; +import * as ReportScrollManager from '../../../libs/ReportScrollManager'; import toggleReportActionComposeView from '../../../libs/toggleReportActionComposeView'; import withWindowDimensions, {windowDimensionsPropTypes} from '../../../components/withWindowDimensions'; import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize'; @@ -88,7 +88,7 @@ class ReportActionItemMessageEdit extends React.Component { * Delete the draft of the comment being edited. This will take the comment out of "edit mode" with the old content. */ deleteDraft() { - saveReportActionDraft(this.props.reportID, this.props.action.reportActionID, ''); + Report.saveReportActionDraft(this.props.reportID, this.props.action.reportActionID, ''); toggleReportActionComposeView(true, this.props.isSmallScreenWidth); ReportActionComposeFocusManager.focus(); } @@ -98,7 +98,7 @@ class ReportActionItemMessageEdit extends React.Component { * allows one to navigate somewhere else and come back to the comment and still have it in edit mode. */ debouncedSaveDraft() { - saveReportActionDraft(this.props.reportID, this.props.action.reportActionID, this.state.draft); + Report.saveReportActionDraft(this.props.reportID, this.props.action.reportActionID, this.state.draft); } /** @@ -107,7 +107,7 @@ class ReportActionItemMessageEdit extends React.Component { */ publishDraft() { const trimmedNewDraft = this.state.draft.trim(); - editReportComment(this.props.reportID, this.props.action, trimmedNewDraft); + Report.editReportComment(this.props.reportID, this.props.action, trimmedNewDraft); this.deleteDraft(); } @@ -142,7 +142,7 @@ class ReportActionItemMessageEdit extends React.Component { maxLines={16} // This is the same that slack has style={[styles.textInputCompose, styles.flex4]} onFocus={() => { - scrollToIndex({animated: true, index: this.props.index}, true); + ReportScrollManager.scrollToIndex({animated: true, index: this.props.index}, true); toggleReportActionComposeView(false); }} selection={this.state.selection} diff --git a/src/pages/home/report/ReportActionsView.js b/src/pages/home/report/ReportActionsView.js index 2c96f44c4659..12279a878501 100755 --- a/src/pages/home/report/ReportActionsView.js +++ b/src/pages/home/report/ReportActionsView.js @@ -14,7 +14,7 @@ import ReportActionItem from './ReportActionItem'; import styles from '../../../styles/styles'; import reportActionPropTypes from './reportActionPropTypes'; import InvertedFlatList from '../../../components/InvertedFlatList'; -import {lastItem} from '../../../libs/CollectionUtils'; +import * as CollectionUtils from '../../../libs/CollectionUtils'; import Visibility from '../../../libs/Visibility'; import Timing from '../../../libs/actions/Timing'; import CONST from '../../../CONST'; @@ -22,10 +22,10 @@ import themeColors from '../../../styles/themes/default'; import compose from '../../../libs/compose'; import withWindowDimensions, {windowDimensionsPropTypes} from '../../../components/withWindowDimensions'; import withDrawerState, {withDrawerPropTypes} from '../../../components/withDrawerState'; -import {flatListRef, scrollToBottom} from '../../../libs/ReportScrollManager'; +import * as ReportScrollManager from '../../../libs/ReportScrollManager'; import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize'; import ReportActionComposeFocusManager from '../../../libs/ReportActionComposeFocusManager'; -import {contextMenuRef} from './ContextMenu/ReportActionContextMenu'; +import * as ReportActionContextMenu from './ContextMenu/ReportActionContextMenu'; import PopoverReportActionContextMenu from './ContextMenu/PopoverReportActionContextMenu'; import variables from '../../../styles/variables'; import MarkerBadge from './MarkerBadge'; @@ -37,8 +37,6 @@ import ONYXKEYS from '../../../ONYXKEYS'; import {withPersonalDetails} from '../../../components/OnyxProvider'; import currentUserPersonalDetailsPropsTypes from '../../settings/Profile/currentUserPersonalDetailsPropsTypes'; import {participantPropTypes} from '../sidebar/optionPropTypes'; -import {shouldShowReportRecipientLocalTime as canShowReportRecipientLocalTime} from '../../../libs/reportUtils'; - const propTypes = { /** The ID of the report actions will be created for */ @@ -196,8 +194,8 @@ class ReportActionsView extends React.Component { componentDidUpdate(prevProps) { // The last sequenceNumber of the same report has changed. - const previousLastSequenceNumber = lodashGet(lastItem(prevProps.reportActions), 'sequenceNumber'); - const currentLastSequenceNumber = lodashGet(lastItem(this.props.reportActions), 'sequenceNumber'); + const previousLastSequenceNumber = lodashGet(CollectionUtils.lastItem(prevProps.reportActions), 'sequenceNumber'); + const currentLastSequenceNumber = lodashGet(CollectionUtils.lastItem(this.props.reportActions), 'sequenceNumber'); // Record the max action when window is visible except when Drawer is open on small screen const shouldRecordMaxAction = Visibility.isVisible() @@ -206,7 +204,7 @@ class ReportActionsView extends React.Component { if (previousLastSequenceNumber !== currentLastSequenceNumber) { // If a new comment is added and it's from the current user scroll to the bottom otherwise // leave the user positioned where they are now in the list. - const lastAction = lastItem(this.props.reportActions); + const lastAction = CollectionUtils.lastItem(this.props.reportActions); if (lastAction && (lastAction.actorEmail === this.props.session.email)) { this.scrollToListBottom(); } @@ -376,7 +374,7 @@ class ReportActionsView extends React.Component { * scroll the list to the end. As a report can contain non-message actions, we should confirm that list data exists. */ scrollToListBottom() { - scrollToBottom(); + ReportScrollManager.scrollToBottom(); Report.updateLastReadActionID(this.props.reportID); } @@ -545,7 +543,7 @@ class ReportActionsView extends React.Component { // Native mobile does not render updates flatlist the changes even though component did update called. // To notify there something changes we can use extraData prop to flatlist const extraData = (!this.props.isDrawerOpen && this.props.isSmallScreenWidth) ? this.props.report.newMarkerSequenceNumber : undefined; - const shouldShowReportRecipientLocalTime = canShowReportRecipientLocalTime(this.props.personalDetails, this.props.myPersonalDetails, this.props.report); + const shouldShowReportRecipientLocalTime = ReportUtils.canShowReportRecipientLocalTime(this.props.personalDetails, this.props.myPersonalDetails, this.props.report); return ( <> @@ -556,7 +554,7 @@ class ReportActionsView extends React.Component { onClose={this.hideMarker} /> - + ); } diff --git a/src/pages/home/report/ReportTypingIndicator.js b/src/pages/home/report/ReportTypingIndicator.js index 825a005089ad..371b069994f5 100755 --- a/src/pages/home/report/ReportTypingIndicator.js +++ b/src/pages/home/report/ReportTypingIndicator.js @@ -6,7 +6,7 @@ import {withOnyx} from 'react-native-onyx'; import compose from '../../../libs/compose'; import ONYXKEYS from '../../../ONYXKEYS'; import styles from '../../../styles/styles'; -import {getDisplayName} from '../../../libs/actions/PersonalDetails'; +import * as PersonalDetails from '../../../libs/actions/PersonalDetails'; import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize'; import Text from '../../../components/Text'; @@ -58,7 +58,7 @@ class ReportTypingIndicator extends React.Component { style={[styles.chatItemComposeSecondaryRowSubText]} numberOfLines={1} > - {getDisplayName(this.state.usersTyping[0])} + {PersonalDetails.getDisplayName(this.state.usersTyping[0])} diff --git a/src/pages/home/sidebar/OptionRow.js b/src/pages/home/sidebar/OptionRow.js index ecd68cbc3ddd..0041cf6a019b 100644 --- a/src/pages/home/sidebar/OptionRow.js +++ b/src/pages/home/sidebar/OptionRow.js @@ -8,10 +8,11 @@ import { StyleSheet, } from 'react-native'; import Str from 'expensify-common/lib/str'; -import styles, {getBackgroundAndBorderStyle, getBackgroundColorStyle} from '../../../styles/styles'; +import styles from '../../../styles/styles'; +import * as StyleUtils from '../../../styles/StyleUtils'; import {optionPropTypes} from './optionPropTypes'; import Icon from '../../../components/Icon'; -import {Pencil, Pin, Checkmark} from '../../../components/Icon/Expensicons'; +import * as Expensicons from '../../../components/Icon/Expensicons'; import MultipleAvatars from '../../../components/MultipleAvatars'; import themeColors from '../../../styles/themes/default'; import Hoverable from '../../../components/Hoverable'; @@ -140,7 +141,7 @@ const OptionRow = (props) => { styles.justifyContentBetween, styles.sidebarLink, styles.sidebarLinkInner, - getBackgroundColorStyle(props.backgroundColor), + StyleUtils.getBackgroundColorStyle(props.backgroundColor), props.optionIsFocused ? styles.sidebarLinkActive : null, hovered && !props.optionIsFocused ? props.hoverStyle : null, props.isDisabled && styles.cursorDisabled, @@ -160,12 +161,12 @@ const OptionRow = (props) => { avatarImageURLs={props.option.icons} size={props.mode === 'compact' ? 'small' : 'default'} secondAvatarStyle={[ - getBackgroundAndBorderStyle(props.backgroundColor), + StyleUtils.getBackgroundAndBorderStyle(props.backgroundColor), props.optionIsFocused - ? getBackgroundAndBorderStyle(focusedBackgroundColor) + ? StyleUtils.getBackgroundAndBorderStyle(focusedBackgroundColor) : undefined, hovered && !props.optionIsFocused - ? getBackgroundAndBorderStyle(hoveredBackgroundColor) + ? StyleUtils.getBackgroundAndBorderStyle(hoveredBackgroundColor) : undefined, ]} isDefaultChatRoom={props.option.isDefaultChatRoom} @@ -201,7 +202,7 @@ const OptionRow = (props) => { {props.showSelectedState && ( {props.isSelected && ( - + )} )} @@ -211,7 +212,7 @@ const OptionRow = (props) => { {props.option.hasDraftComment && ( - + )} {props.option.hasOutstandingIOU && ( @@ -219,7 +220,7 @@ const OptionRow = (props) => { )} {props.option.isPinned && ( - + )} diff --git a/src/pages/home/sidebar/SidebarLinks.js b/src/pages/home/sidebar/SidebarLinks.js index e54a0fcceadf..f084e1c9caec 100644 --- a/src/pages/home/sidebar/SidebarLinks.js +++ b/src/pages/home/sidebar/SidebarLinks.js @@ -4,7 +4,8 @@ import _ from 'underscore'; import PropTypes from 'prop-types'; import {withOnyx} from 'react-native-onyx'; import lodashGet from 'lodash/get'; -import styles, {getSafeAreaMargins} from '../../../styles/styles'; +import styles from '../../../styles/styles'; +import * as StyleUtils from '../../../styles/StyleUtils'; import ONYXKEYS from '../../../ONYXKEYS'; import safeAreaInsetPropTypes from '../../safeAreaInsetPropTypes'; import compose from '../../../libs/compose'; @@ -13,9 +14,9 @@ import ROUTES from '../../../ROUTES'; import Icon from '../../../components/Icon'; import Header from '../../../components/Header'; import OptionsList from '../../../components/OptionsList'; -import {MagnifyingGlass} from '../../../components/Icon/Expensicons'; +import * as Expensicons from '../../../components/Icon/Expensicons'; import AvatarWithIndicator from '../../../components/AvatarWithIndicator'; -import {getSidebarOptions, getDefaultAvatar} from '../../../libs/OptionsListUtils'; +import * as OptionsListUtils from '../../../libs/OptionsListUtils'; import KeyboardSpacer from '../../../components/KeyboardSpacer'; import Tooltip from '../../../components/Tooltip'; import CONST from '../../../CONST'; @@ -82,7 +83,7 @@ const defaultProps = { reports: {}, personalDetails: {}, myPersonalDetails: { - avatar: getDefaultAvatar(), + avatar: OptionsListUtils.getDefaultAvatar(), }, network: null, currentlyViewedReportID: '', @@ -94,7 +95,7 @@ const defaultProps = { class SidebarLinks extends React.Component { static getRecentReports(props) { const activeReportID = parseInt(props.currentlyViewedReportID, 10); - const sidebarOptions = getSidebarOptions( + const sidebarOptions = OptionsListUtils.getSidebarOptions( props.reports, props.personalDetails, activeReportID, @@ -223,7 +224,7 @@ class SidebarLinks extends React.Component { style={[styles.flexRow, styles.ph5]} onPress={this.showSearchPage} > - + Navigation.navigate(ROUTES.NEW_CHAT), }, { - icon: Users, + icon: Expensicons.Users, text: this.props.translate('sidebarScreen.newGroup'), onSelected: () => Navigation.navigate(ROUTES.NEW_GROUP), }, ...(Permissions.canUseIOUSend(this.props.betas) ? [ { - icon: Send, + icon: Expensicons.Send, text: this.props.translate('iou.sendMoney'), onSelected: () => Navigation.navigate(ROUTES.IOU_SEND), }, ] : []), ...(Permissions.canUseIOU(this.props.betas) ? [ { - icon: MoneyCircle, + icon: Expensicons.MoneyCircle, text: this.props.translate('iou.requestMoney'), onSelected: () => Navigation.navigate(ROUTES.IOU_REQUEST), }, ] : []), ...(Permissions.canUseIOU(this.props.betas) ? [ { - icon: Receipt, + icon: Expensicons.Receipt, text: this.props.translate('iou.splitBill'), onSelected: () => Navigation.navigate(ROUTES.IOU_BILL), }, ] : []), ...(!this.props.isCreatingWorkspace && Permissions.canUseFreePlan(this.props.betas) && !Policy.isAdminOfFreePolicy(this.props.allPolicies) ? [ { - icon: NewWorkspace, + icon: Expensicons.NewWorkspace, iconWidth: 46, iconHeight: 40, text: this.props.translate('workspace.new.newWorkspace'), diff --git a/src/pages/iou/IOUCurrencySelection.js b/src/pages/iou/IOUCurrencySelection.js index a0a3c2ae0e91..3adfeba4a99d 100644 --- a/src/pages/iou/IOUCurrencySelection.js +++ b/src/pages/iou/IOUCurrencySelection.js @@ -4,9 +4,9 @@ import PropTypes from 'prop-types'; import {withOnyx} from 'react-native-onyx'; import _ from 'underscore'; import styles from '../../styles/styles'; -import {getCurrencyList} from '../../libs/actions/PersonalDetails'; +import * as PersonalDetails from '../../libs/actions/PersonalDetails'; import ONYXKEYS from '../../ONYXKEYS'; -import {getCurrencyListForSections} from '../../libs/OptionsListUtils'; +import * as OptionsListUtils from '../../libs/OptionsListUtils'; import Text from '../../components/Text'; import OptionRow from '../home/sidebar/OptionRow'; import themeColors from '../../styles/themes/default'; @@ -20,7 +20,7 @@ import CONST from '../../CONST'; import KeyboardAvoidingView from '../../components/KeyboardAvoidingView'; import Button from '../../components/Button'; import FixedFooter from '../../components/FixedFooter'; -import {setIOUSelectedCurrency} from '../../libs/actions/IOU'; +import * as IOU from '../../libs/actions/IOU'; /** * IOU Currency selection for selecting currency @@ -69,7 +69,7 @@ class IOUCurrencySelection extends Component { constructor(props) { super(props); - const {currencyOptions} = getCurrencyListForSections(this.getCurrencyOptions(this.props.currencyList), + const {currencyOptions} = OptionsListUtils.getCurrencyListForSections(this.getCurrencyOptions(this.props.currencyList), ''); this.state = { @@ -85,7 +85,7 @@ class IOUCurrencySelection extends Component { } componentDidMount() { - getCurrencyList(); + PersonalDetails.getCurrencyList(); } /** @@ -137,7 +137,7 @@ class IOUCurrencySelection extends Component { * @return {void} */ changeSearchValue(searchValue) { - const {currencyOptions} = getCurrencyListForSections( + const {currencyOptions} = OptionsListUtils.getCurrencyListForSections( this.getCurrencyOptions(this.props.currencyList), searchValue, ); @@ -152,7 +152,7 @@ class IOUCurrencySelection extends Component { * @return {void} */ confirmCurrencySelection() { - setIOUSelectedCurrency(this.state.toggledCurrencyCode); + IOU.setIOUSelectedCurrency(this.state.toggledCurrencyCode); Navigation.goBack(); } diff --git a/src/pages/iou/IOUDetailsModal.js b/src/pages/iou/IOUDetailsModal.js index 4ef5ffb171cd..5c8206e3eb95 100644 --- a/src/pages/iou/IOUDetailsModal.js +++ b/src/pages/iou/IOUDetailsModal.js @@ -11,8 +11,8 @@ import HeaderWithCloseButton from '../../components/HeaderWithCloseButton'; import Navigation from '../../libs/Navigation/Navigation'; import ButtonWithDropdown from '../../components/ButtonWithDropdown'; import ScreenWrapper from '../../components/ScreenWrapper'; -import {payIOUReport} from '../../libs/actions/IOU'; -import {fetchIOUReportByID} from '../../libs/actions/Report'; +import * as IOU from '../../libs/actions/IOU'; +import * as Report from '../../libs/actions/Report'; import IOUPreview from '../../components/ReportActionItem/IOUPreview'; import IOUTransactions from './IOUTransactions'; import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize'; @@ -22,10 +22,8 @@ import PopoverMenu from '../../components/PopoverMenu'; import isAppInstalled from '../../libs/isAppInstalled'; import Button from '../../components/Button'; import Permissions from '../../libs/Permissions'; -import { - Cash, PayPal, Venmo, Wallet, -} from '../../components/Icon/Expensicons'; -import {isValidUSPhone} from '../../libs/ValidationUtils'; +import * as Expensicons from '../../components/Icon/Expensicons'; +import * as ValidationUtils from '../../libs/ValidationUtils'; const propTypes = { /** URL Route params */ @@ -108,7 +106,7 @@ class IOUDetailsModal extends Component { componentDidMount() { this.isComponentMounted = true; - fetchIOUReportByID(this.props.route.params.iouReportID, this.props.route.params.chatReportID, true); + Report.fetchIOUReportByID(this.props.route.params.iouReportID, this.props.route.params.chatReportID, true); this.addVenmoPaymentOptionIfAvailable(); this.addExpensifyPaymentOptionIfAvailable(); } @@ -122,7 +120,7 @@ class IOUDetailsModal extends Component { } performIOUPayment() { - payIOUReport({ + IOU.payIOUReport({ chatReportID: this.props.route.params.chatReportID, reportID: this.props.route.params.iouReportID, paymentMethodType: this.state.paymentType, @@ -151,7 +149,7 @@ class IOUDetailsModal extends Component { return; } - this.submitterPhoneNumber = _.find(submitterPhoneNumbers, isValidUSPhone); + this.submitterPhoneNumber = _.find(submitterPhoneNumbers, ValidationUtils.isValidUSPhone); if (!this.submitterPhoneNumber) { return; } @@ -193,19 +191,19 @@ class IOUDetailsModal extends Component { const paymentTypeOptions = { [CONST.IOU.PAYMENT_TYPE.EXPENSIFY]: { text: this.props.translate('iou.settleExpensify'), - icon: Wallet, + icon: Expensicons.Wallet, }, [CONST.IOU.PAYMENT_TYPE.VENMO]: { text: this.props.translate('iou.settleVenmo'), - icon: Venmo, + icon: Expensicons.Venmo, }, [CONST.IOU.PAYMENT_TYPE.PAYPAL_ME]: { text: this.props.translate('iou.settlePaypalMe'), - icon: PayPal, + icon: Expensicons.PayPal, }, [CONST.IOU.PAYMENT_TYPE.ELSEWHERE]: { text: this.props.translate('iou.settleElsewhere'), - icon: Cash, + icon: Expensicons.Cash, }, }; const selectedPaymentType = paymentTypeOptions[this.state.paymentType].text; diff --git a/src/pages/iou/IOUModal.js b/src/pages/iou/IOUModal.js index 43872a4d1d5c..5c1eb004a4fd 100755 --- a/src/pages/iou/IOUModal.js +++ b/src/pages/iou/IOUModal.js @@ -11,15 +11,13 @@ import IOUConfirmPage from './steps/IOUConfirmPage'; import Header from '../../components/Header'; import styles from '../../styles/styles'; import Icon from '../../components/Icon'; -import { - createIOUSplit, createIOUTransaction, createIOUSplitGroup, setIOUSelectedCurrency, -} from '../../libs/actions/IOU'; -import {Close, BackArrow} from '../../components/Icon/Expensicons'; +import * as IOU from '../../libs/actions/IOU'; +import * as Expensicons from '../../components/Icon/Expensicons'; import Navigation from '../../libs/Navigation/Navigation'; import ONYXKEYS from '../../ONYXKEYS'; import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize'; import compose from '../../libs/compose'; -import {addSMSDomainIfPhoneNumber, getPersonalDetailsForLogins} from '../../libs/OptionsListUtils'; +import * as OptionsListUtils from '../../libs/OptionsListUtils'; import FullScreenLoadingIndicator from '../../components/FullscreenLoadingIndicator'; import AnimatedStep from '../../components/AnimatedStep'; import ScreenWrapper from '../../components/ScreenWrapper'; @@ -114,7 +112,7 @@ class IOUModal extends Component { this.createTransaction = this.createTransaction.bind(this); this.updateComment = this.updateComment.bind(this); const participants = lodashGet(props, 'report.participants', []); - const participantsWithDetails = _.map(getPersonalDetailsForLogins(participants, props.personalDetails), personalDetails => ({ + const participantsWithDetails = _.map(OptionsListUtils.getPersonalDetailsForLogins(participants, props.personalDetails), personalDetails => ({ login: personalDetails.login, text: personalDetails.displayName, alternateText: Str.isSMSLogin(personalDetails.login) ? Str.removeSMSDomain(personalDetails.login) : personalDetails.login, @@ -147,7 +145,7 @@ class IOUModal extends Component { componentDidMount() { PersonalDetails.fetchLocalCurrency(); - setIOUSelectedCurrency(this.props.myPersonalDetails.localCurrencyCode); + IOU.setIOUSelectedCurrency(this.props.myPersonalDetails.localCurrencyCode); } componentDidUpdate(prevProps) { @@ -165,7 +163,7 @@ class IOUModal extends Component { if (prevProps.iou.selectedCurrencyCode !== this.props.iou.selectedCurrencyCode) { - setIOUSelectedCurrency(this.props.iou.selectedCurrencyCode); + IOU.setIOUSelectedCurrency(this.props.iou.selectedCurrencyCode); } } @@ -281,7 +279,7 @@ class IOUModal extends Component { // Only splits from a group DM has a reportID // Check if reportID is a number if (splits && CONST.REGEX.NUMBER.test(reportID)) { - createIOUSplitGroup({ + IOU.createIOUSplitGroup({ comment: this.state.comment, // should send in cents to API @@ -293,7 +291,7 @@ class IOUModal extends Component { return; } if (splits) { - createIOUSplit({ + IOU.createIOUSplit({ comment: this.state.comment, // should send in cents to API @@ -304,13 +302,13 @@ class IOUModal extends Component { return; } - createIOUTransaction({ + IOU.createIOUTransaction({ comment: this.state.comment, // should send in cents to API amount: Math.round(this.state.amount * 100), currency: this.props.iou.selectedCurrencyCode, - debtorEmail: addSMSDomainIfPhoneNumber(this.state.participants[0].login), + debtorEmail: OptionsListUtils.addSMSDomainIfPhoneNumber(this.state.participants[0].login), }); } @@ -338,7 +336,7 @@ class IOUModal extends Component { onPress={this.navigateToPreviousStep} style={[styles.touchableButtonImage]} > - + )} @@ -351,7 +349,7 @@ class IOUModal extends Component { accessibilityRole="button" accessibilityLabel={this.props.translate('common.close')} > - + diff --git a/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsRequest.js b/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsRequest.js index 1cb939352ade..247a873c12d3 100755 --- a/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsRequest.js +++ b/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsRequest.js @@ -2,12 +2,12 @@ import React, {Component} from 'react'; import PropTypes from 'prop-types'; import {withOnyx} from 'react-native-onyx'; import _ from 'underscore'; -import {getHeaderMessage, getNewChatOptions, isCurrentUser} from '../../../../libs/OptionsListUtils'; +import * as OptionsListUtils from '../../../../libs/OptionsListUtils'; import OptionsSelector from '../../../../components/OptionsSelector'; import ONYXKEYS from '../../../../ONYXKEYS'; import withLocalize, {withLocalizePropTypes} from '../../../../components/withLocalize'; import compose from '../../../../libs/compose'; -import {EXPENSIFY_EMAILS} from '../../../../CONST'; +import CONST from '../../../../CONST'; import personalDetailsPropType from '../../../personalDetailsPropType'; const propTypes = { @@ -42,13 +42,13 @@ class IOUParticipantsRequest extends Component { recentReports, personalDetails, userToInvite, - } = getNewChatOptions( + } = OptionsListUtils.getNewChatOptions( props.reports, props.personalDetails, props.betas, '', [], - EXPENSIFY_EMAILS, + CONST.EXPENSIFY_EMAILS, ); this.state = { @@ -81,7 +81,7 @@ class IOUParticipantsRequest extends Component { indexOffset: 0, }); - if (this.state.userToInvite && !isCurrentUser(this.state.userToInvite)) { + if (this.state.userToInvite && !OptionsListUtils.isCurrentUser(this.state.userToInvite)) { sections.push({ undefined, data: [this.state.userToInvite], @@ -105,7 +105,7 @@ class IOUParticipantsRequest extends Component { render() { const sections = this.getSections(); - const headerMessage = getHeaderMessage( + const headerMessage = OptionsListUtils.getHeaderMessage( this.state.personalDetails.length + this.state.recentReports.length !== 0, Boolean(this.state.userToInvite), this.state.searchValue, @@ -120,13 +120,13 @@ class IOUParticipantsRequest extends Component { recentReports, personalDetails, userToInvite, - } = getNewChatOptions( + } = OptionsListUtils.getNewChatOptions( this.props.reports, this.props.personalDetails, this.props.betas, searchValue, [], - EXPENSIFY_EMAILS, + CONST.EXPENSIFY_EMAILS, ); this.setState({ searchValue, diff --git a/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsSplit.js b/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsSplit.js index 53594380cc54..46c048e819a6 100755 --- a/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsSplit.js +++ b/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsSplit.js @@ -7,8 +7,8 @@ import {withOnyx} from 'react-native-onyx'; import ONYXKEYS from '../../../../ONYXKEYS'; import styles from '../../../../styles/styles'; import OptionsSelector from '../../../../components/OptionsSelector'; -import {getHeaderMessage, getNewChatOptions, isCurrentUser} from '../../../../libs/OptionsListUtils'; -import CONST, {EXPENSIFY_EMAILS} from '../../../../CONST'; +import * as OptionsListUtils from '../../../../libs/OptionsListUtils'; +import CONST from '../../../../CONST'; import withLocalize, {withLocalizePropTypes} from '../../../../components/withLocalize'; import compose from '../../../../libs/compose'; import Button from '../../../../components/Button'; @@ -67,13 +67,13 @@ class IOUParticipantsSplit extends Component { recentReports, personalDetails, userToInvite, - } = getNewChatOptions( + } = OptionsListUtils.getNewChatOptions( props.reports, props.personalDetails, props.betas, '', props.participants, - EXPENSIFY_EMAILS, + CONST.EXPENSIFY_EMAILS, ); this.state = { @@ -123,7 +123,7 @@ class IOUParticipantsSplit extends Component { indexOffset: _.reduce(sections, (prev, {data}) => prev + data.length, 0), }); - if (this.state.userToInvite && !isCurrentUser(this.state.userToInvite)) { + if (this.state.userToInvite && !OptionsListUtils.isCurrentUser(this.state.userToInvite)) { sections.push(({ undefined, data: [this.state.userToInvite], @@ -168,13 +168,13 @@ class IOUParticipantsSplit extends Component { recentReports, personalDetails, userToInvite, - } = getNewChatOptions( + } = OptionsListUtils.getNewChatOptions( this.props.reports, this.props.personalDetails, this.props.betas, isOptionInList ? prevState.searchValue : '', newSelectedOptions, - EXPENSIFY_EMAILS, + CONST.EXPENSIFY_EMAILS, ); return { recentReports, @@ -188,7 +188,7 @@ class IOUParticipantsSplit extends Component { render() { const maxParticipantsReached = this.props.participants.length === CONST.REPORT.MAXIMUM_PARTICIPANTS; const sections = this.getSections(maxParticipantsReached); - const headerMessage = !maxParticipantsReached ? getHeaderMessage( + const headerMessage = !maxParticipantsReached ? OptionsListUtils.getHeaderMessage( this.state.personalDetails.length + this.state.recentReports.length !== 0, Boolean(this.state.userToInvite), this.state.searchValue, @@ -210,13 +210,13 @@ class IOUParticipantsSplit extends Component { recentReports, personalDetails, userToInvite, - } = getNewChatOptions( + } = OptionsListUtils.getNewChatOptions( this.props.reports, this.props.personalDetails, this.props.betas, searchValue, [], - EXPENSIFY_EMAILS, + CONST.EXPENSIFY_EMAILS, ); this.setState({ searchValue, diff --git a/src/pages/settings/AboutPage.js b/src/pages/settings/AboutPage.js index 3d2d7207e547..5917e0782f76 100644 --- a/src/pages/settings/AboutPage.js +++ b/src/pages/settings/AboutPage.js @@ -7,20 +7,14 @@ import ROUTES from '../../ROUTES'; import styles from '../../styles/styles'; import Text from '../../components/Text'; import CONST from '../../CONST'; -import { - Link, - Eye, - MoneyBag, - Bug, - NewWindow, -} from '../../components/Icon/Expensicons'; +import * as Expensicons from '../../components/Icon/Expensicons'; import ScreenWrapper from '../../components/ScreenWrapper'; import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize'; import MenuItem from '../../components/MenuItem'; import Logo from '../../../assets/images/new-expensify.svg'; import {version} from '../../../package.json'; -import {navigateToConciergeChat} from '../../libs/actions/Report'; -import {openExternalLink} from '../../libs/actions/Link'; +import * as Report from '../../libs/actions/Report'; +import * as Link from '../../libs/actions/Link'; const propTypes = { ...withLocalizePropTypes, @@ -30,31 +24,31 @@ const AboutPage = (props) => { const menuItems = [ { translationKey: 'initialSettingsPage.aboutPage.appDownloadLinks', - icon: Link, + icon: Expensicons.Link, action: () => { Navigation.navigate(ROUTES.SETTINGS_APP_DOWNLOAD_LINKS); }, }, { translationKey: 'initialSettingsPage.aboutPage.viewTheCode', - icon: Eye, - iconRight: NewWindow, + icon: Expensicons.Eye, + iconRight: Expensicons.NewWindow, action: () => { - openExternalLink(CONST.GITHUB_URL); + Link.openExternalLink(CONST.GITHUB_URL); }, }, { translationKey: 'initialSettingsPage.aboutPage.viewOpenJobs', - icon: MoneyBag, - iconRight: NewWindow, + icon: Expensicons.MoneyBag, + iconRight: Expensicons.NewWindow, action: () => { - openExternalLink(CONST.UPWORK_URL); + Link.openExternalLink(CONST.UPWORK_URL); }, }, { translationKey: 'initialSettingsPage.aboutPage.reportABug', - icon: Bug, - action: navigateToConciergeChat, + icon: Expensicons.Bug, + action: Report.navigateToConciergeChat, }, ]; @@ -116,7 +110,7 @@ const AboutPage = (props) => { {' '} openExternalLink(CONST.TERMS_URL)} + onPress={() => Link.openExternalLink(CONST.TERMS_URL)} > {props.translate( 'initialSettingsPage.readTheTermsAndPrivacyPolicy.phrase2', @@ -129,7 +123,7 @@ const AboutPage = (props) => { {' '} openExternalLink(CONST.PRIVACY_URL)} + onPress={() => Link.openExternalLink(CONST.PRIVACY_URL)} > {props.translate( 'initialSettingsPage.readTheTermsAndPrivacyPolicy.phrase4', diff --git a/src/pages/settings/AppDownloadLinks.js b/src/pages/settings/AppDownloadLinks.js index ee85fc33635a..d395d375f304 100644 --- a/src/pages/settings/AppDownloadLinks.js +++ b/src/pages/settings/AppDownloadLinks.js @@ -4,14 +4,12 @@ import {ScrollView} from 'react-native'; import HeaderWithCloseButton from '../../components/HeaderWithCloseButton'; import Navigation from '../../libs/Navigation/Navigation'; import CONST from '../../CONST'; -import { - Android, Apple, NewWindow, Monitor, -} from '../../components/Icon/Expensicons'; +import * as Expensicons from '../../components/Icon/Expensicons'; import ScreenWrapper from '../../components/ScreenWrapper'; import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize'; import MenuItem from '../../components/MenuItem'; import styles from '../../styles/styles'; -import {openExternalLink} from '../../libs/actions/Link'; +import * as Link from '../../libs/actions/Link'; const propTypes = { ...withLocalizePropTypes, @@ -21,21 +19,27 @@ const AppDownloadLinksPage = (props) => { const menuItems = [ { translationKey: 'initialSettingsPage.appDownloadLinks.android.label', - icon: Android, - iconRight: NewWindow, - action: () => { openExternalLink(CONST.APP_DOWNLOAD_LINKS.ANDROID); }, + icon: Expensicons.Android, + iconRight: Expensicons.NewWindow, + action: () => { + Link.openExternalLink(CONST.APP_DOWNLOAD_LINKS.ANDROID); + }, }, { translationKey: 'initialSettingsPage.appDownloadLinks.ios.label', - icon: Apple, - iconRight: NewWindow, - action: () => { openExternalLink(CONST.APP_DOWNLOAD_LINKS.IOS); }, + icon: Expensicons.Apple, + iconRight: Expensicons.NewWindow, + action: () => { + Link.openExternalLink(CONST.APP_DOWNLOAD_LINKS.IOS); + }, }, { translationKey: 'initialSettingsPage.appDownloadLinks.desktop.label', - icon: Monitor, - iconRight: NewWindow, - action: () => { openExternalLink(CONST.APP_DOWNLOAD_LINKS.DESKTOP); }, + icon: Expensicons.Monitor, + iconRight: Expensicons.NewWindow, + action: () => { + Link.openExternalLink(CONST.APP_DOWNLOAD_LINKS.DESKTOP); + }, }, ]; diff --git a/src/pages/settings/InitialSettingsPage.js b/src/pages/settings/InitialSettingsPage.js index 1ca415cc7e17..23a80a3400a7 100755 --- a/src/pages/settings/InitialSettingsPage.js +++ b/src/pages/settings/InitialSettingsPage.js @@ -7,20 +7,12 @@ import Str from 'expensify-common/lib/str'; import styles from '../../styles/styles'; import themeColors from '../../styles/themes/default'; import Text from '../../components/Text'; -import {signOut} from '../../libs/actions/Session'; +import * as Session from '../../libs/actions/Session'; import ONYXKEYS from '../../ONYXKEYS'; import AvatarWithIndicator from '../../components/AvatarWithIndicator'; import HeaderWithCloseButton from '../../components/HeaderWithCloseButton'; import Navigation from '../../libs/Navigation/Navigation'; -import { - Building, - Gear, - Info, - Lock, - Profile, - SignOut, - Wallet, -} from '../../components/Icon/Expensicons'; +import * as Expensicons from '../../components/Icon/Expensicons'; import ScreenWrapper from '../../components/ScreenWrapper'; import MenuItem from '../../components/MenuItem'; import ROUTES from '../../ROUTES'; @@ -95,7 +87,7 @@ const defaultProps = { const defaultMenuItems = [ { translationKey: 'common.profile', - icon: Profile, + icon: Expensicons.Profile, action: () => { DateUtils.updateTimezone(); Navigation.navigate(ROUTES.SETTINGS_PROFILE); @@ -103,28 +95,28 @@ const defaultMenuItems = [ }, { translationKey: 'common.preferences', - icon: Gear, + icon: Expensicons.Gear, action: () => { Navigation.navigate(ROUTES.SETTINGS_PREFERENCES); }, }, { translationKey: 'initialSettingsPage.changePassword', - icon: Lock, + icon: Expensicons.Lock, action: () => { Navigation.navigate(ROUTES.SETTINGS_PASSWORD); }, }, { translationKey: 'common.payments', - icon: Wallet, + icon: Expensicons.Wallet, action: () => { Navigation.navigate(ROUTES.SETTINGS_PAYMENTS); }, }, { translationKey: 'initialSettingsPage.about', - icon: Info, + icon: Expensicons.Info, action: () => { Navigation.navigate(ROUTES.SETTINGS_ABOUT); }, }, { translationKey: 'initialSettingsPage.signOut', - icon: SignOut, - action: signOut, + icon: Expensicons.SignOut, + action: Session.signOut, }, ]; @@ -146,7 +138,7 @@ const InitialSettingsPage = (props) => { .filter(policy => policy && policy.type === CONST.POLICY.TYPE.FREE && policy.role === CONST.POLICY.ROLE.ADMIN) .map(policy => ({ title: policy.name, - icon: policy.avatarURL ? policy.avatarURL : Building, + icon: policy.avatarURL ? policy.avatarURL : Expensicons.Building, iconType: policy.avatarURL ? CONST.ICON_TYPE_AVATAR : CONST.ICON_TYPE_ICON, action: () => Navigation.navigate(ROUTES.getWorkspaceInitialRoute(policy.id)), iconStyles: [styles.popoverMenuIconEmphasized], diff --git a/src/pages/settings/PasswordPage.js b/src/pages/settings/PasswordPage.js index 461a73986dd9..743a50563429 100755 --- a/src/pages/settings/PasswordPage.js +++ b/src/pages/settings/PasswordPage.js @@ -12,14 +12,14 @@ import Text from '../../components/Text'; import styles from '../../styles/styles'; import ONYXKEYS from '../../ONYXKEYS'; import Button from '../../components/Button'; -import {isValidPassword} from '../../libs/ValidationUtils'; +import * as ValidationUtils from '../../libs/ValidationUtils'; import * as User from '../../libs/actions/User'; import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize'; import compose from '../../libs/compose'; import KeyboardAvoidingView from '../../components/KeyboardAvoidingView'; import FixedFooter from '../../components/FixedFooter'; import ExpensiTextInput from '../../components/ExpensiTextInput'; -import {clearAccountMessages} from '../../libs/actions/Session'; +import * as Session from '../../libs/actions/Session'; const propTypes = { /* Onyx Props */ @@ -75,7 +75,7 @@ class PasswordPage extends Component { } componentWillUnmount() { - clearAccountMessages(); + Session.clearAccountMessages(); } /** @@ -121,7 +121,7 @@ class PasswordPage extends Component { errors.currentPassword = true; } - if (!this.state.newPassword || !isValidPassword(this.state.newPassword)) { + if (!this.state.newPassword || !ValidationUtils.isValidPassword(this.state.newPassword)) { errors.newPassword = true; } @@ -133,7 +133,7 @@ class PasswordPage extends Component { errors.newPasswordSameAsOld = true; } - if (isValidPassword(this.state.newPassword) && this.state.confirmNewPassword && !_.isEqual(this.state.newPassword, this.state.confirmNewPassword)) { + if (ValidationUtils.isValidPassword(this.state.newPassword) && this.state.confirmNewPassword && !_.isEqual(this.state.newPassword, this.state.confirmNewPassword)) { errors.confirmPasswordMatch = true; } diff --git a/src/pages/settings/Payments/AddDebitCardPage.js b/src/pages/settings/Payments/AddDebitCardPage.js index 476d609b1d05..8fc8de1b160e 100644 --- a/src/pages/settings/Payments/AddDebitCardPage.js +++ b/src/pages/settings/Payments/AddDebitCardPage.js @@ -14,11 +14,9 @@ import styles from '../../../styles/styles'; import Text from '../../../components/Text'; import TextLink from '../../../components/TextLink'; import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize'; -import {addBillingCard, clearDebitCardFormErrorAndSubmit} from '../../../libs/actions/PaymentMethods'; +import * as PaymentMethods from '../../../libs/actions/PaymentMethods'; import KeyboardAvoidingView from '../../../components/KeyboardAvoidingView'; -import { - isValidAddress, isValidExpirationDate, isValidZipCode, isValidDebitCard, isValidSecurityCode, -} from '../../../libs/ValidationUtils'; +import * as ValidationUtils from '../../../libs/ValidationUtils'; import CheckboxWithLabel from '../../../components/CheckboxWithLabel'; import ExpensiTextInput from '../../../components/ExpensiTextInput'; import CONST from '../../../CONST'; @@ -96,7 +94,7 @@ class DebitCardPage extends Component { * Make sure we reset the onyx values so old errors don't show if this form is displayed later */ componentWillUnmount() { - clearDebitCardFormErrorAndSubmit(); + PaymentMethods.clearDebitCardFormErrorAndSubmit(); } /** @@ -120,21 +118,21 @@ class DebitCardPage extends Component { errors.nameOnCard = true; } - if (!isValidDebitCard(this.state.cardNumber.replace(/ /g, ''))) { + if (!ValidationUtils.isValidDebitCard(this.state.cardNumber.replace(/ /g, ''))) { errors.cardNumber = true; } - if (!isValidExpirationDate(this.state.expirationDate)) { + if (!ValidationUtils.isValidExpirationDate(this.state.expirationDate)) { errors.expirationDate = true; } - if (!isValidSecurityCode(this.state.securityCode)) { + if (!ValidationUtils.isValidSecurityCode(this.state.securityCode)) { errors.securityCode = true; } - if (!isValidAddress(this.state.addressStreet) + if (!ValidationUtils.isValidAddress(this.state.addressStreet) || !this.state.addressState - || !isValidZipCode(this.state.addressZipCode)) { + || !ValidationUtils.isValidZipCode(this.state.addressZipCode)) { errors.addressStreet = true; } @@ -154,7 +152,7 @@ class DebitCardPage extends Component { if (!this.validate()) { return; } - addBillingCard(this.state); + PaymentMethods.addBillingCard(this.state); } /** diff --git a/src/pages/settings/Payments/AddPayPalMePage.js b/src/pages/settings/Payments/AddPayPalMePage.js index 2b81dc96ab81..647200c4c322 100644 --- a/src/pages/settings/Payments/AddPayPalMePage.js +++ b/src/pages/settings/Payments/AddPayPalMePage.js @@ -9,7 +9,7 @@ import HeaderWithCloseButton from '../../../components/HeaderWithCloseButton'; import Text from '../../../components/Text'; import ScreenWrapper from '../../../components/ScreenWrapper'; import NameValuePair from '../../../libs/actions/NameValuePair'; -import {getPaymentMethods} from '../../../libs/actions/PaymentMethods'; +import * as PaymentMethods from '../../../libs/actions/PaymentMethods'; import Navigation from '../../../libs/Navigation/Navigation'; import styles from '../../../styles/styles'; import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize'; @@ -19,7 +19,7 @@ import KeyboardAvoidingView from '../../../components/KeyboardAvoidingView'; import FixedFooter from '../../../components/FixedFooter'; import Growl from '../../../libs/Growl'; import ExpensiTextInput from '../../../components/ExpensiTextInput'; -import {isValidPaypalUsername} from '../../../libs/ValidationUtils'; +import * as ValidationUtils from '../../../libs/ValidationUtils'; const propTypes = { /** Username for PayPal.Me */ @@ -44,7 +44,7 @@ class AddPayPalMePage extends React.Component { } componentDidMount() { - getPaymentMethods(); + PaymentMethods.getPaymentMethods(); } componentDidUpdate(prevProps) { @@ -60,7 +60,7 @@ class AddPayPalMePage extends React.Component { * Sets the payPalMeUsername for the current user */ setPayPalMeUsername() { - const isValid = isValidPaypalUsername(this.state.payPalMeUsername); + const isValid = ValidationUtils.isValidPaypalUsername(this.state.payPalMeUsername); if (!isValid) { this.setState({payPalMeUsernameError: true}); return; diff --git a/src/pages/settings/Payments/PaymentMethodList.js b/src/pages/settings/Payments/PaymentMethodList.js index 738f1a893e35..7e8595eda6e9 100644 --- a/src/pages/settings/Payments/PaymentMethodList.js +++ b/src/pages/settings/Payments/PaymentMethodList.js @@ -4,16 +4,14 @@ import PropTypes from 'prop-types'; import {FlatList, Text} from 'react-native'; import {withOnyx} from 'react-native-onyx'; import lodashGet from 'lodash/get'; -import styles, {getButtonBackgroundColorStyle, getIconFillColor} from '../../../styles/styles'; +import styles from '../../../styles/styles'; +import * as StyleUtils from '../../../styles/StyleUtils'; import MenuItem from '../../../components/MenuItem'; import compose from '../../../libs/compose'; import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize'; import ONYXKEYS from '../../../ONYXKEYS'; import CONST from '../../../CONST'; -import { - PayPal, - Plus, -} from '../../../components/Icon/Expensicons'; +import * as Expensicons from '../../../components/Icon/Expensicons'; import getBankIcon from '../../../components/Icon/BankIcons'; import bankAccountPropTypes from '../../../components/bankAccountPropTypes'; @@ -120,7 +118,7 @@ class PaymentMethodList extends Component { type: MENU_ITEM, title: 'PayPal.me', description: this.props.payPalMeUsername, - icon: PayPal, + icon: Expensicons.PayPal, onPress: e => this.props.onPress(e, 'payPalMe'), key: 'payPalMePaymentMethod', }); @@ -136,12 +134,12 @@ class PaymentMethodList extends Component { combinedPaymentMethods.push({ type: MENU_ITEM, title: this.props.translate('paymentMethodList.addPaymentMethod'), - icon: Plus, + icon: Expensicons.Plus, onPress: e => this.props.onPress(e), key: 'addPaymentMethodButton', disabled: this.props.isLoadingPayments, - iconFill: this.props.isAddPaymentMenuActive ? getIconFillColor(CONST.BUTTON_STATES.PRESSED) : null, - wrapperStyle: this.props.isAddPaymentMenuActive ? [getButtonBackgroundColorStyle(CONST.BUTTON_STATES.PRESSED)] : [], + iconFill: this.props.isAddPaymentMenuActive ? StyleUtils.getIconFillColor(CONST.BUTTON_STATES.PRESSED) : null, + wrapperStyle: this.props.isAddPaymentMenuActive ? [StyleUtils.getButtonBackgroundColorStyle(CONST.BUTTON_STATES.PRESSED)] : [], }); return combinedPaymentMethods; diff --git a/src/pages/settings/Payments/PaymentsPage.js b/src/pages/settings/Payments/PaymentsPage.js index 7a9cb9a14c47..25fd9feaf97b 100644 --- a/src/pages/settings/Payments/PaymentsPage.js +++ b/src/pages/settings/Payments/PaymentsPage.js @@ -12,9 +12,9 @@ import withLocalize, {withLocalizePropTypes} from '../../../components/withLocal import compose from '../../../libs/compose'; import KeyboardAvoidingView from '../../../components/KeyboardAvoidingView/index'; import Text from '../../../components/Text'; -import {getPaymentMethods} from '../../../libs/actions/PaymentMethods'; +import * as PaymentMethods from '../../../libs/actions/PaymentMethods'; import Popover from '../../../components/Popover'; -import {PayPal, CreditCard} from '../../../components/Icon/Expensicons'; +import * as Expensicons from '../../../components/Icon/Expensicons'; import MenuItem from '../../../components/MenuItem'; import getClickedElementLocation from '../../../libs/getClickedElementLocation'; import CurrentWalletBalance from '../../../components/CurrentWalletBalance'; @@ -59,7 +59,7 @@ class PaymentsPage extends React.Component { } componentDidMount() { - getPaymentMethods(); + PaymentMethods.getPaymentMethods(); } /** @@ -146,14 +146,14 @@ class PaymentsPage extends React.Component { {!this.props.payPalMeUsername && ( this.addPaymentMethodTypePressed(PAYPAL)} wrapperStyle={styles.pr15} /> )} this.addPaymentMethodTypePressed(DEBIT_CARD)} wrapperStyle={styles.pr15} /> diff --git a/src/pages/settings/PreferencesPage.js b/src/pages/settings/PreferencesPage.js index c58ce69fbd47..f43998b565d0 100755 --- a/src/pages/settings/PreferencesPage.js +++ b/src/pages/settings/PreferencesPage.js @@ -14,7 +14,7 @@ import styles from '../../styles/styles'; import Text from '../../components/Text'; import NameValuePair from '../../libs/actions/NameValuePair'; import CONST from '../../CONST'; -import {setExpensifyNewsStatus, setShouldUseSecureStaging} from '../../libs/actions/User'; +import * as User from '../../libs/actions/User'; import ScreenWrapper from '../../components/ScreenWrapper'; import Switch from '../../components/Switch'; import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize'; @@ -78,7 +78,7 @@ const PreferencesPage = (props) => { @@ -115,7 +115,7 @@ const PreferencesPage = (props) => { diff --git a/src/pages/settings/Profile/LoginField.js b/src/pages/settings/Profile/LoginField.js index 314507a2c0cb..8f304112fce4 100755 --- a/src/pages/settings/Profile/LoginField.js +++ b/src/pages/settings/Profile/LoginField.js @@ -4,12 +4,12 @@ import PropTypes from 'prop-types'; import Text from '../../../components/Text'; import styles from '../../../styles/styles'; import colors from '../../../styles/colors'; -import {Plus, Checkmark} from '../../../components/Icon/Expensicons'; +import * as Expensicons from '../../../components/Icon/Expensicons'; import Icon from '../../../components/Icon'; import ROUTES from '../../../ROUTES'; import CONST from '../../../CONST'; import Navigation from '../../../libs/Navigation/Navigation'; -import {resendValidateCode} from '../../../libs/actions/User'; +import * as User from '../../../libs/actions/User'; import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize'; import Button from '../../../components/Button'; import MenuItem from '../../../components/MenuItem'; @@ -47,7 +47,7 @@ class LoginField extends Component { * Resend validation code and show the checkmark icon */ onResendClicked() { - resendValidateCode(this.props.login.partnerUserID); + User.resendValidateCode(this.props.login.partnerUserID); this.setState({showCheckmarkIcon: true}); // Revert checkmark back to "Resend" after 5 seconds @@ -92,7 +92,7 @@ class LoginField extends Component { Navigation.navigate(ROUTES.getSettingsAddLoginRoute(this.props.type))} /> @@ -108,7 +108,7 @@ class LoginField extends Component { style={[styles.mb2]} onPress={this.onResendClicked} ContentComponent={() => (this.state.showCheckmarkIcon ? ( - + ) : ( {this.props.translate('common.resend')} diff --git a/src/pages/settings/Profile/ProfilePage.js b/src/pages/settings/Profile/ProfilePage.js index 77082817204e..85294fae504a 100755 --- a/src/pages/settings/Profile/ProfilePage.js +++ b/src/pages/settings/Profile/ProfilePage.js @@ -9,12 +9,7 @@ import _ from 'underscore'; import HeaderWithCloseButton from '../../../components/HeaderWithCloseButton'; import Navigation from '../../../libs/Navigation/Navigation'; import ScreenWrapper from '../../../components/ScreenWrapper'; -import { - getFirstAndLastNameErrors, - setPersonalDetails, - setAvatar, - deleteAvatar, -} from '../../../libs/actions/PersonalDetails'; +import * as PersonalDetails from '../../../libs/actions/PersonalDetails'; import ROUTES from '../../../ROUTES'; import ONYXKEYS from '../../../ONYXKEYS'; import CONST from '../../../CONST'; @@ -152,7 +147,7 @@ class ProfilePage extends Component { return; } - setPersonalDetails({ + PersonalDetails.setPersonalDetails({ firstName: this.state.firstName.trim(), lastName: this.state.lastName.trim(), pronouns: this.state.pronouns.trim(), @@ -164,7 +159,7 @@ class ProfilePage extends Component { } validateInputs() { - const {firstNameError, lastNameError} = getFirstAndLastNameErrors(this.state.firstName, this.state.lastName); + const {firstNameError, lastNameError} = PersonalDetails.getFirstAndLastNameErrors(this.state.firstName, this.state.lastName); this.setState({ firstNameError, @@ -204,8 +199,8 @@ class ProfilePage extends Component { deleteAvatar(this.props.myPersonalDetails.login)} + onImageSelected={PersonalDetails.setAvatar} + onImageRemoved={() => PersonalDetails.deleteAvatar(this.props.myPersonalDetails.login)} // eslint-disable-next-line max-len isUsingDefaultAvatar={this.props.myPersonalDetails.avatar.includes('/images/avatars/avatar')} anchorPosition={styles.createMenuPositionProfile} diff --git a/src/pages/signin/ChangeExpensifyLoginLink.js b/src/pages/signin/ChangeExpensifyLoginLink.js index 2d9576a737ba..f600438ec401 100755 --- a/src/pages/signin/ChangeExpensifyLoginLink.js +++ b/src/pages/signin/ChangeExpensifyLoginLink.js @@ -9,7 +9,7 @@ import themeColors from '../../styles/themes/default'; import ONYXKEYS from '../../ONYXKEYS'; import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize'; import compose from '../../libs/compose'; -import {clearSignInData} from '../../libs/actions/Session'; +import * as Session from '../../libs/actions/Session'; const propTypes = { /** The credentials of the logged in person */ @@ -33,7 +33,7 @@ const ChangeExpensifyLoginLink = props => ( diff --git a/src/pages/signin/LoginForm.js b/src/pages/signin/LoginForm.js index 602be57d2a64..3ce6a7673f03 100755 --- a/src/pages/signin/LoginForm.js +++ b/src/pages/signin/LoginForm.js @@ -7,7 +7,7 @@ import Str from 'expensify-common/lib/str'; import styles from '../../styles/styles'; import Button from '../../components/Button'; import Text from '../../components/Text'; -import {clearAccountMessages, fetchAccountDetails} from '../../libs/actions/Session'; +import * as Session from '../../libs/actions/Session'; import ONYXKEYS from '../../ONYXKEYS'; import withWindowDimensions, {windowDimensionsPropTypes} from '../../components/withWindowDimensions'; import compose from '../../libs/compose'; @@ -15,7 +15,7 @@ import canFocusInputOnScreenFocus from '../../libs/canFocusInputOnScreenFocus'; import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize'; import getEmailKeyboardType from '../../libs/getEmailKeyboardType'; import ExpensiTextInput from '../../components/ExpensiTextInput'; -import {isNumericWithSpecialChars} from '../../libs/ValidationUtils'; +import * as ValidationUtils from '../../libs/ValidationUtils'; import LoginUtil from '../../libs/LoginUtil'; const propTypes = { @@ -67,7 +67,7 @@ class LoginForm extends React.Component { }); if (this.props.account.error) { - clearAccountMessages(); + Session.clearAccountMessages(); } } @@ -84,7 +84,7 @@ class LoginForm extends React.Component { const isValidPhoneLogin = Str.isValidPhone(phoneLogin); if (!Str.isValidEmail(this.state.login) && !isValidPhoneLogin) { - if (isNumericWithSpecialChars(this.state.login)) { + if (ValidationUtils.isNumericWithSpecialChars(this.state.login)) { this.setState({formError: 'messages.errorMessageInvalidPhone'}); } else { this.setState({formError: 'loginForm.error.invalidFormatEmailLogin'}); @@ -97,7 +97,7 @@ class LoginForm extends React.Component { }); // Check if this login has an account associated with it or not - fetchAccountDetails(isValidPhoneLogin ? phoneLogin : this.state.login); + Session.fetchAccountDetails(isValidPhoneLogin ? phoneLogin : this.state.login); } render() { diff --git a/src/pages/signin/PasswordForm.js b/src/pages/signin/PasswordForm.js index bc9b4c6ee9cb..b92c0373fcda 100755 --- a/src/pages/signin/PasswordForm.js +++ b/src/pages/signin/PasswordForm.js @@ -9,7 +9,7 @@ import styles from '../../styles/styles'; import Button from '../../components/Button'; import Text from '../../components/Text'; import themeColors from '../../styles/themes/default'; -import {signIn, resetPassword} from '../../libs/actions/Session'; +import * as Session from '../../libs/actions/Session'; import ONYXKEYS from '../../ONYXKEYS'; import CONST from '../../CONST'; import ChangeExpensifyLoginLink from './ChangeExpensifyLoginLink'; @@ -75,7 +75,7 @@ class PasswordForm extends React.Component { formError: null, }); - signIn(this.state.password, this.state.twoFactorAuthCode); + Session.signIn(this.state.password, this.state.twoFactorAuthCode); } render() { @@ -97,7 +97,7 @@ class PasswordForm extends React.Component { diff --git a/src/pages/signin/ResendValidationForm.js b/src/pages/signin/ResendValidationForm.js index 27c63c217a63..f92ffc6f84b7 100755 --- a/src/pages/signin/ResendValidationForm.js +++ b/src/pages/signin/ResendValidationForm.js @@ -7,13 +7,13 @@ import Str from 'expensify-common/lib/str'; import styles from '../../styles/styles'; import Button from '../../components/Button'; import Text from '../../components/Text'; -import {reopenAccount, resendValidationLink, resetPassword} from '../../libs/actions/Session'; +import * as Session from '../../libs/actions/Session'; import ONYXKEYS from '../../ONYXKEYS'; import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize'; import compose from '../../libs/compose'; import redirectToSignIn from '../../libs/actions/SignInRedirect'; import Avatar from '../../components/Avatar'; -import {getDefaultAvatar} from '../../libs/OptionsListUtils'; +import * as OptionsListUtils from '../../libs/OptionsListUtils'; const propTypes = { /* Onyx Props */ @@ -74,11 +74,11 @@ class ResendValidationForm extends React.Component { }); if (this.props.account.closed) { - reopenAccount(); + Session.reopenAccount(); } else if (!this.props.account.validated) { - resendValidationLink(); + Session.resendValidationLink(); } else { - resetPassword(); + Session.resetPassword(); } this.successMessageTimer = setTimeout(() => { @@ -111,7 +111,7 @@ class ResendValidationForm extends React.Component { <> diff --git a/src/pages/signin/SignInPageLayout/SignInPageLayoutNarrow.js b/src/pages/signin/SignInPageLayout/SignInPageLayoutNarrow.js index 380e5793b6c8..381f02273d39 100755 --- a/src/pages/signin/SignInPageLayout/SignInPageLayoutNarrow.js +++ b/src/pages/signin/SignInPageLayout/SignInPageLayoutNarrow.js @@ -2,7 +2,8 @@ import React from 'react'; import {ScrollView, View} from 'react-native'; import PropTypes from 'prop-types'; import {withSafeAreaInsets} from 'react-native-safe-area-context'; -import styles, {getModalPaddingStyles} from '../../../styles/styles'; +import styles from '../../../styles/styles'; +import * as StyleUtils from '../../../styles/StyleUtils'; import variables from '../../../styles/variables'; import ExpensifyCashLogo from '../../../components/ExpensifyCashLogo'; import Text from '../../../components/Text'; @@ -50,7 +51,7 @@ const SignInPageLayoutNarrow = props => ( contentContainerStyle={[ styles.mt40Percentage, styles.mb3, - getModalPaddingStyles({ + StyleUtils.getModalPaddingStyles({ shouldAddBottomSafeAreaPadding: true, modalContainerStylePaddingBottom: 20, safeAreaPaddingBottom: props.insets.bottom, diff --git a/src/pages/signin/SignInPageLayout/SignInPageLayoutWide.js b/src/pages/signin/SignInPageLayout/SignInPageLayoutWide.js index 46909aef119e..065fb892a415 100755 --- a/src/pages/signin/SignInPageLayout/SignInPageLayoutWide.js +++ b/src/pages/signin/SignInPageLayout/SignInPageLayoutWide.js @@ -2,7 +2,8 @@ import React from 'react'; import {View} from 'react-native'; import PropTypes from 'prop-types'; import SVGImage from '../../../components/SVGImage'; -import styles, {getBackgroundColorStyle, getLoginPagePromoStyle} from '../../../styles/styles'; +import styles from '../../../styles/styles'; +import * as StyleUtils from '../../../styles/StyleUtils'; import ExpensifyCashLogo from '../../../components/ExpensifyCashLogo'; import Text from '../../../components/Text'; import variables from '../../../styles/variables'; @@ -26,7 +27,7 @@ const propTypes = { ...withLocalizePropTypes, }; -const backgroundStyle = getLoginPagePromoStyle(); +const backgroundStyle = StyleUtils.getLoginPagePromoStyle(); const SignInPageLayoutWide = props => ( @@ -64,7 +65,7 @@ const SignInPageLayoutWide = props => ( diff --git a/src/pages/workspace/WorkspaceBankAccountPage.js b/src/pages/workspace/WorkspaceBankAccountPage.js index e4ced1e11611..219c1c3f27c5 100644 --- a/src/pages/workspace/WorkspaceBankAccountPage.js +++ b/src/pages/workspace/WorkspaceBankAccountPage.js @@ -2,12 +2,12 @@ import lodashGet from 'lodash/get'; import React from 'react'; import {withOnyx} from 'react-native-onyx'; import HeaderWithCloseButton from '../../components/HeaderWithCloseButton'; -import {Bank, RotateLeft} from '../../components/Icon/Expensicons'; -import {BankArrowPink} from '../../components/Icon/Illustrations'; +import * as Expensicons from '../../components/Icon/Expensicons'; +import * as Illustrations from '../../components/Icon/Illustrations'; import ScreenWrapper from '../../components/ScreenWrapper'; import Text from '../../components/Text'; import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize'; -import {requestResetFreePlanBankAccount} from '../../libs/actions/BankAccounts'; +import * as BankAccounts from '../../libs/actions/BankAccounts'; import compose from '../../libs/compose'; import BankAccount from '../../libs/models/BankAccount'; import Navigation from '../../libs/Navigation/Navigation'; @@ -94,18 +94,18 @@ class WorkspaceBankAccountPage extends React.Component { /> { const menuItems = [ { translationKey: 'workspace.common.settings', - icon: Gear, + icon: Expensicons.Gear, action: () => Navigation.navigate(ROUTES.getWorkspaceSettingsRoute(props.policy.id)), isActive: Navigation.isActiveRoute(ROUTES.getWorkspaceSettingsRoute(props.policy.id)), }, { translationKey: 'workspace.common.card', - icon: ExpensifyCard, + icon: Expensicons.ExpensifyCard, action: () => Navigation.navigate(ROUTES.getWorkspaceCardRoute(props.policy.id)), isActive: Navigation.isActiveRoute(ROUTES.getWorkspaceCardRoute(props.policy.id)), }, { translationKey: 'workspace.common.reimburse', - icon: Receipt, + icon: Expensicons.Receipt, action: () => Navigation.navigate(ROUTES.getWorkspaceReimburseRoute(props.policy.id)), isActive: Navigation.isActiveRoute(ROUTES.getWorkspaceReimburseRoute(props.policy.id)), }, { translationKey: 'workspace.common.bills', - icon: Bill, + icon: Expensicons.Bill, action: () => Navigation.navigate(ROUTES.getWorkspaceBillsRoute(props.policy.id)), isActive: Navigation.isActiveRoute(ROUTES.getWorkspaceBillsRoute(props.policy.id)), }, { translationKey: 'workspace.common.invoices', - icon: Invoice, + icon: Expensicons.Invoice, action: () => Navigation.navigate(ROUTES.getWorkspaceInvoicesRoute(props.policy.id)), isActive: Navigation.isActiveRoute(ROUTES.getWorkspaceInvoicesRoute(props.policy.id)), }, { translationKey: 'workspace.common.travel', - icon: Luggage, + icon: Expensicons.Luggage, action: () => Navigation.navigate(ROUTES.getWorkspaceTravelRoute(props.policy.id)), isActive: Navigation.isActiveRoute(ROUTES.getWorkspaceTravelRoute(props.policy.id)), }, { translationKey: 'workspace.common.members', - icon: Users, + icon: Expensicons.Users, action: () => Navigation.navigate(ROUTES.getWorkspaceMembersRoute(props.policy.id)), isActive: Navigation.isActiveRoute(ROUTES.getWorkspaceMembersRoute(props.policy.id)), }, { translationKey: 'workspace.common.bankAccount', - icon: Bank, + icon: Expensicons.Bank, action: () => Navigation.navigate(ROUTES.getWorkspaceBankAccountRoute(props.policy.id)), isActive: Navigation.isActiveRoute(ROUTES.getWorkspaceBankAccountRoute(props.policy.id)), }, @@ -132,7 +122,7 @@ const WorkspaceInitialPage = (props) => { ) : ( option.login); - invite(logins, this.state.welcomeNote || this.getWelcomeNotePlaceholder(), this.props.route.params.policyID); + Policy.invite(logins, this.state.welcomeNote || this.getWelcomeNotePlaceholder(), this.props.route.params.policyID); } /** @@ -226,13 +226,13 @@ class WorkspaceInvitePage extends React.Component { errors.noUserSelected = true; } - setWorkspaceErrors(this.props.route.params.policyID, errors); + Policy.setWorkspaceErrors(this.props.route.params.policyID, errors); return _.size(errors) <= 0; } render() { const sections = this.getSections(); - const headerMessage = getHeaderMessage( + const headerMessage = OptionsListUtils.getHeaderMessage( this.state.personalDetails.length !== 0, Boolean(this.state.userToInvite), this.state.searchValue, @@ -263,7 +263,7 @@ class WorkspaceInvitePage extends React.Component { const { personalDetails, userToInvite, - } = getNewChatOptions( + } = OptionsListUtils.getNewChatOptions( [], this.props.personalDetails, this.props.betas, @@ -312,7 +312,7 @@ class WorkspaceInvitePage extends React.Component { { e.preventDefault(); - openExternalLink(CONST.PRIVACY_URL); + Link.openExternalLink(CONST.PRIVACY_URL); }} accessibilityRole="link" href={CONST.PRIVACY_URL} diff --git a/src/pages/workspace/WorkspaceMembersPage.js b/src/pages/workspace/WorkspaceMembersPage.js index bbf639f02256..6b90b4077561 100644 --- a/src/pages/workspace/WorkspaceMembersPage.js +++ b/src/pages/workspace/WorkspaceMembersPage.js @@ -15,7 +15,7 @@ import Navigation from '../../libs/Navigation/Navigation'; import ScreenWrapper from '../../components/ScreenWrapper'; import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize'; import compose from '../../libs/compose'; -import {removeMembers} from '../../libs/actions/Policy'; +import * as Policy from '../../libs/actions/Policy'; import Button from '../../components/Button'; import Checkbox from '../../components/Checkbox'; import Text from '../../components/Text'; @@ -83,7 +83,7 @@ class WorkspaceMembersPage extends React.Component { removeUsers() { // Remove the admin from the list const membersToRemove = _.without(this.state.selectedEmployees, this.props.session.email); - removeMembers(membersToRemove, this.props.route.params.policyID); + Policy.removeMembers(membersToRemove, this.props.route.params.policyID); this.setState({ selectedEmployees: [], isRemoveMembersConfirmModalVisible: false, diff --git a/src/pages/workspace/WorkspacePageWithSections.js b/src/pages/workspace/WorkspacePageWithSections.js index 8d9eb32fbd11..e732ada8f603 100644 --- a/src/pages/workspace/WorkspacePageWithSections.js +++ b/src/pages/workspace/WorkspacePageWithSections.js @@ -11,7 +11,7 @@ import HeaderWithCloseButton from '../../components/HeaderWithCloseButton'; import ScreenWrapper from '../../components/ScreenWrapper'; import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize'; import ONYXKEYS from '../../ONYXKEYS'; -import {fetchFreePlanVerifiedBankAccount} from '../../libs/actions/BankAccounts'; +import * as BankAccounts from '../../libs/actions/BankAccounts'; import BankAccount from '../../libs/models/BankAccount'; import reimbursementAccountPropTypes from '../ReimbursementAccount/reimbursementAccountPropTypes'; import userPropTypes from '../settings/userPropTypes'; @@ -55,7 +55,7 @@ const defaultProps = { class WorkspacePageWithSections extends React.Component { componentDidMount() { const achState = lodashGet(this.props.reimbursementAccount, 'achData.state', ''); - fetchFreePlanVerifiedBankAccount('', achState); + BankAccounts.fetchFreePlanVerifiedBankAccount('', achState); } render() { diff --git a/src/pages/workspace/WorkspaceResetBankAccountModal.js b/src/pages/workspace/WorkspaceResetBankAccountModal.js index 984b0bea793d..23b6824ef032 100644 --- a/src/pages/workspace/WorkspaceResetBankAccountModal.js +++ b/src/pages/workspace/WorkspaceResetBankAccountModal.js @@ -4,7 +4,7 @@ import PropTypes from 'prop-types'; import React from 'react'; import {withOnyx} from 'react-native-onyx'; import ConfirmModal from '../../components/ConfirmModal'; -import {cancelResetFreePlanBankAccount, resetFreePlanBankAccount} from '../../libs/actions/BankAccounts'; +import * as BankAccounts from '../../libs/actions/BankAccounts'; import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize'; import reimbursementAccountPropTypes from '../ReimbursementAccount/reimbursementAccountPropTypes'; import compose from '../../libs/compose'; @@ -49,8 +49,8 @@ const WorkspaceResetBankAccountModal = (props) => { ) : props.translate('workspace.bankAccount.clearProgress')} danger - onCancel={cancelResetFreePlanBankAccount} - onConfirm={() => resetFreePlanBankAccount()} + onCancel={BankAccounts.cancelResetFreePlanBankAccount} + onConfirm={() => BankAccounts.resetFreePlanBankAccount()} shouldShowCancelButton isVisible={lodashGet(props.reimbursementAccount, 'shouldShowResetModal', false)} /> diff --git a/src/pages/workspace/WorkspaceSettingsPage.js b/src/pages/workspace/WorkspaceSettingsPage.js index fc45def9c876..e0873f2631ee 100644 --- a/src/pages/workspace/WorkspaceSettingsPage.js +++ b/src/pages/workspace/WorkspaceSettingsPage.js @@ -14,12 +14,12 @@ import Text from '../../components/Text'; import compose from '../../libs/compose'; import * as Policy from '../../libs/actions/Policy'; import Icon from '../../components/Icon'; -import {Workspace} from '../../components/Icon/Expensicons'; +import * as Expensicons from '../../components/Icon/Expensicons'; import AvatarWithImagePicker from '../../components/AvatarWithImagePicker'; import defaultTheme from '../../styles/themes/default'; import CONST from '../../CONST'; import ExpensiPicker from '../../components/ExpensiPicker'; -import {getCurrencyList} from '../../libs/actions/PersonalDetails'; +import * as PersonalDetails from '../../libs/actions/PersonalDetails'; import ExpensiTextInput from '../../components/ExpensiTextInput'; import FixedFooter from '../../components/FixedFooter'; import WorkspacePageWithSections from './WorkspacePageWithSections'; @@ -58,7 +58,7 @@ class WorkspaceSettingsPage extends React.Component { } componentDidMount() { - getCurrencyList(); + PersonalDetails.getCurrencyList(); } /** @@ -142,7 +142,7 @@ class WorkspaceSettingsPage extends React.Component { size={CONST.AVATAR_SIZE.LARGE} DefaultAvatar={() => ( { return ( openOldDotLink(`reports?policyID=${props.policyID}&from=all&type=bill&showStates=Open,Processing,Approved,Reimbursed,Archived&isAdvancedFilterMode=true`), - icon: Bill, + onPress: () => ( + Link.openOldDotLink(`reports?policyID=${props.policyID}&from=all&type=bill&showStates=Open,Processing,Approved,Reimbursed,Archived&isAdvancedFilterMode=true`) + ), + icon: Expensicons.Bill, shouldShowRightIcon: true, - iconRight: NewWindow, + iconRight: Expensicons.NewWindow, }, ]} > @@ -56,7 +55,7 @@ const WorkspaceBillsFirstSection = (props) => { {props.translate('workspace.bills.askYourVendorsBeforeEmail')} {props.user.isFromPublicDomain ? ( openExternalLink('https://community.expensify.com/discussion/7500/how-to-pay-your-company-bills-in-expensify/')} + onPress={() => Link.openExternalLink('https://community.expensify.com/discussion/7500/how-to-pay-your-company-bills-in-expensify/')} > example.com@expensify.cash diff --git a/src/pages/workspace/bills/WorkspaceBillsNoVBAView.js b/src/pages/workspace/bills/WorkspaceBillsNoVBAView.js index 8eb072d49412..d28201dfc52b 100644 --- a/src/pages/workspace/bills/WorkspaceBillsNoVBAView.js +++ b/src/pages/workspace/bills/WorkspaceBillsNoVBAView.js @@ -4,11 +4,8 @@ import PropTypes from 'prop-types'; import Text from '../../../components/Text'; import styles from '../../../styles/styles'; import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize'; -import { - ArrowRight, - Bank, -} from '../../../components/Icon/Expensicons'; -import {JewelBoxPink} from '../../../components/Icon/Illustrations'; +import * as Expensicons from '../../../components/Icon/Expensicons'; +import * as Illustrations from '../../../components/Icon/Illustrations'; import WorkspaceSection from '../WorkspaceSection'; import Navigation from '../../../libs/Navigation/Navigation'; import ROUTES from '../../../ROUTES'; @@ -27,14 +24,14 @@ const WorkspaceBillsNoVBAView = props => ( Navigation.navigate(ROUTES.getWorkspaceBankAccountRoute(props.policyID)), - icon: Bank, + icon: Expensicons.Bank, shouldShowRightIcon: true, - iconRight: ArrowRight, + iconRight: Expensicons.ArrowRight, }, ]} > diff --git a/src/pages/workspace/bills/WorkspaceBillsVBAView.js b/src/pages/workspace/bills/WorkspaceBillsVBAView.js index 9f57ab9cded5..abac76302b72 100644 --- a/src/pages/workspace/bills/WorkspaceBillsVBAView.js +++ b/src/pages/workspace/bills/WorkspaceBillsVBAView.js @@ -4,13 +4,10 @@ import PropTypes from 'prop-types'; import Text from '../../../components/Text'; import styles from '../../../styles/styles'; import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize'; -import { - Bill, - NewWindow, -} from '../../../components/Icon/Expensicons'; -import {MoneyMousePink} from '../../../components/Icon/Illustrations'; +import * as Expensicons from '../../../components/Icon/Expensicons'; +import * as Illustrations from '../../../components/Icon/Illustrations'; import WorkspaceSection from '../WorkspaceSection'; -import {openOldDotLink} from '../../../libs/actions/Link'; +import * as Link from '../../../libs/actions/Link'; import WorkspaceBillsFirstSection from './WorkspaceBillsFirstSection'; const propTypes = { @@ -26,14 +23,14 @@ const WorkspaceBillsVBAView = props => ( openOldDotLink(`reports?policyID=${props.policyID}&from=all&type=bill&showStates=Processing,Approved&isAdvancedFilterMode=true`), - icon: Bill, + onPress: () => Link.openOldDotLink(`reports?policyID=${props.policyID}&from=all&type=bill&showStates=Processing,Approved&isAdvancedFilterMode=true`), + icon: Expensicons.Bill, shouldShowRightIcon: true, - iconRight: NewWindow, + iconRight: Expensicons.NewWindow, }, ]} > diff --git a/src/pages/workspace/card/WorkspaceCardNoVBAView.js b/src/pages/workspace/card/WorkspaceCardNoVBAView.js index ac024d430546..4e455848a96d 100644 --- a/src/pages/workspace/card/WorkspaceCardNoVBAView.js +++ b/src/pages/workspace/card/WorkspaceCardNoVBAView.js @@ -6,8 +6,8 @@ import styles from '../../../styles/styles'; import Navigation from '../../../libs/Navigation/Navigation'; import ROUTES from '../../../ROUTES'; import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize'; -import {Bank} from '../../../components/Icon/Expensicons'; -import {JewelBoxBlue} from '../../../components/Icon/Illustrations'; +import * as Expensicons from '../../../components/Icon/Expensicons'; +import * as Illustrations from '../../../components/Icon/Illustrations'; import UnorderedList from '../../../components/UnorderedList'; import WorkspaceSection from '../WorkspaceSection'; @@ -21,12 +21,12 @@ const propTypes = { const WorkspaceCardNoVBAView = props => ( Navigation.navigate(ROUTES.getWorkspaceBankAccountRoute(props.policyID)), - icon: Bank, + icon: Expensicons.Bank, shouldShowRightIcon: true, }, ]} diff --git a/src/pages/workspace/card/WorkspaceCardVBANoECardView.js b/src/pages/workspace/card/WorkspaceCardVBANoECardView.js index b0a143519c0e..78f768e38bf8 100644 --- a/src/pages/workspace/card/WorkspaceCardVBANoECardView.js +++ b/src/pages/workspace/card/WorkspaceCardVBANoECardView.js @@ -1,16 +1,15 @@ import React from 'react'; -import {View} from 'react-native'; import {withOnyx} from 'react-native-onyx'; import Text from '../../../components/Text'; import styles from '../../../styles/styles'; import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize'; -import {Mail} from '../../../components/Icon/Expensicons'; -import {JewelBoxBlue} from '../../../components/Icon/Illustrations'; +import * as Expensicons from '../../../components/Icon/Expensicons'; +import * as Illustrations from '../../../components/Icon/Illustrations'; import UnorderedList from '../../../components/UnorderedList'; import WorkspaceSection from '../WorkspaceSection'; import Navigation from '../../../libs/Navigation/Navigation'; -import {openOldDotLink} from '../../../libs/actions/Link'; -import {subscribeToExpensifyCardUpdates} from '../../../libs/actions/User'; +import * as Link from '../../../libs/actions/Link'; +import * as User from '../../../libs/actions/User'; import ONYXKEYS from '../../../ONYXKEYS'; import compose from '../../../libs/compose'; @@ -22,24 +21,20 @@ const WorkspaceCardVBANoECardView = props => ( <> { Navigation.dismissModal(); - openOldDotLink('settings?param={"section":"account","openModal":"secondaryLogin"}'); - subscribeToExpensifyCardUpdates(); + Link.openOldDotLink('settings?param={"section":"account","openModal":"secondaryLogin"}'); + User.subscribeToExpensifyCardUpdates(); }, - icon: Mail, + icon: Expensicons.Mail, shouldShowRightIcon: true, }, ]} > - - {props.translate('workspace.card.VBANoECardCopy')} - - ( openOldDotLink('domain_companycards'), - icon: ExpensifyCard, + onPress: () => Link.openOldDotLink('domain_companycards'), + icon: Expensicons.ExpensifyCard, shouldShowRightIcon: true, - iconRight: NewWindow, + iconRight: Expensicons.NewWindow, }, { title: props.translate('workspace.common.reconcileCards'), - onPress: () => openOldDotLink('domain_companycards?param={"section":"cardReconciliation"}'), - icon: ReceiptSearch, + onPress: () => Link.openOldDotLink('domain_companycards?param={"section":"cardReconciliation"}'), + icon: Expensicons.ReceiptSearch, shouldShowRightIcon: true, - iconRight: NewWindow, + iconRight: Expensicons.NewWindow, }, ]} > diff --git a/src/pages/workspace/invoices/WorkspaceInvoicesFirstSection.js b/src/pages/workspace/invoices/WorkspaceInvoicesFirstSection.js index 3cd8cbd8344d..0850c5680a7a 100644 --- a/src/pages/workspace/invoices/WorkspaceInvoicesFirstSection.js +++ b/src/pages/workspace/invoices/WorkspaceInvoicesFirstSection.js @@ -4,14 +4,10 @@ import PropTypes from 'prop-types'; import Text from '../../../components/Text'; import styles from '../../../styles/styles'; import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize'; -import { - Invoice, - NewWindow, - Send, -} from '../../../components/Icon/Expensicons'; -import {MoneyEnvelopeBlue} from '../../../components/Icon/Illustrations'; +import * as Expensicons from '../../../components/Icon/Expensicons'; +import * as Illustrations from '../../../components/Icon/Illustrations'; import WorkspaceSection from '../WorkspaceSection'; -import {openOldDotLink} from '../../../libs/actions/Link'; +import * as Link from '../../../libs/actions/Link'; const propTypes = { /** The policy ID currently being configured */ @@ -23,21 +19,23 @@ const propTypes = { const WorkspaceInvoicesFirstSection = props => ( openOldDotLink('reports?param={"createInvoice":true}'), - icon: Send, + onPress: () => Link.openOldDotLink('reports?param={"createInvoice":true}'), + icon: Expensicons.Send, shouldShowRightIcon: true, - iconRight: NewWindow, + iconRight: Expensicons.NewWindow, }, { title: props.translate('workspace.invoices.viewAllInvoices'), - onPress: () => openOldDotLink(`reports?policyID=${props.policyID}&from=all&type=invoice&showStates=Open,Processing,Approved,Reimbursed,Archived&isAdvancedFilterMode=true`), - icon: Invoice, + onPress: () => ( + Link.openOldDotLink(`reports?policyID=${props.policyID}&from=all&type=invoice&showStates=Open,Processing,Approved,Reimbursed,Archived&isAdvancedFilterMode=true`) + ), + icon: Expensicons.Invoice, shouldShowRightIcon: true, - iconRight: NewWindow, + iconRight: Expensicons.NewWindow, }, ]} > diff --git a/src/pages/workspace/invoices/WorkspaceInvoicesNoVBAView.js b/src/pages/workspace/invoices/WorkspaceInvoicesNoVBAView.js index 724b47e10a2d..d8c6539acc8e 100644 --- a/src/pages/workspace/invoices/WorkspaceInvoicesNoVBAView.js +++ b/src/pages/workspace/invoices/WorkspaceInvoicesNoVBAView.js @@ -4,11 +4,8 @@ import PropTypes from 'prop-types'; import Text from '../../../components/Text'; import styles from '../../../styles/styles'; import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize'; -import { - ArrowRight, - Bank, -} from '../../../components/Icon/Expensicons'; -import {JewelBoxGreen} from '../../../components/Icon/Illustrations'; +import * as Expensicons from '../../../components/Icon/Expensicons'; +import * as Illustrations from '../../../components/Icon/Illustrations'; import WorkspaceSection from '../WorkspaceSection'; import Navigation from '../../../libs/Navigation/Navigation'; import ROUTES from '../../../ROUTES'; @@ -27,14 +24,14 @@ const WorkspaceInvoicesNoVBAView = props => ( Navigation.navigate(ROUTES.getWorkspaceBankAccountRoute(props.policyID)), - icon: Bank, + icon: Expensicons.Bank, shouldShowRightIcon: true, - iconRight: ArrowRight, + iconRight: Expensicons.ArrowRight, }, ]} > diff --git a/src/pages/workspace/invoices/WorkspaceInvoicesVBAView.js b/src/pages/workspace/invoices/WorkspaceInvoicesVBAView.js index 37ee7f0770c3..fcc4502853ab 100644 --- a/src/pages/workspace/invoices/WorkspaceInvoicesVBAView.js +++ b/src/pages/workspace/invoices/WorkspaceInvoicesVBAView.js @@ -4,14 +4,11 @@ import PropTypes from 'prop-types'; import Text from '../../../components/Text'; import styles from '../../../styles/styles'; import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize'; -import { - CircleHourglass, - NewWindow, -} from '../../../components/Icon/Expensicons'; -import {MoneyMousePink} from '../../../components/Icon/Illustrations'; +import * as Expensicons from '../../../components/Icon/Expensicons'; +import * as Illustrations from '../../../components/Icon/Illustrations'; import WorkspaceSection from '../WorkspaceSection'; import WorkspaceInvoicesFirstSection from './WorkspaceInvoicesFirstSection'; -import {openOldDotLink} from '../../../libs/actions/Link'; +import * as Link from '../../../libs/actions/Link'; const propTypes = { /** The policy ID currently being configured */ @@ -26,14 +23,14 @@ const WorkspaceInvoicesVBAView = props => ( openOldDotLink(`reports?policyID=${props.policyID}&from=all&type=invoice&showStates=Processing&isAdvancedFilterMode=true`), - icon: CircleHourglass, + onPress: () => Link.openOldDotLink(`reports?policyID=${props.policyID}&from=all&type=invoice&showStates=Processing&isAdvancedFilterMode=true`), + icon: Expensicons.CircleHourglass, shouldShowRightIcon: true, - iconRight: NewWindow, + iconRight: Expensicons.NewWindow, }, ]} > diff --git a/src/pages/workspace/reimburse/WorkspaceReimburseNoVBAView.js b/src/pages/workspace/reimburse/WorkspaceReimburseNoVBAView.js index ed4e4184ede4..efc467754001 100644 --- a/src/pages/workspace/reimburse/WorkspaceReimburseNoVBAView.js +++ b/src/pages/workspace/reimburse/WorkspaceReimburseNoVBAView.js @@ -4,17 +4,13 @@ import PropTypes from 'prop-types'; import Text from '../../../components/Text'; import styles from '../../../styles/styles'; import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize'; -import { - NewWindow, - Bank, - Receipt, -} from '../../../components/Icon/Expensicons'; -import {ReceiptYellow, JewelBoxGreen} from '../../../components/Icon/Illustrations'; +import * as Expensicons from '../../../components/Icon/Expensicons'; +import * as Illustrations from '../../../components/Icon/Illustrations'; import WorkspaceSection from '../WorkspaceSection'; import Navigation from '../../../libs/Navigation/Navigation'; import ROUTES from '../../../ROUTES'; import CopyTextToClipboard from '../../../components/CopyTextToClipboard'; -import {openOldDotLink} from '../../../libs/actions/Link'; +import * as Link from '../../../libs/actions/Link'; const propTypes = { /** The policy ID currently being configured */ @@ -27,14 +23,14 @@ const WorkspaceReimburseNoVBAView = props => ( <> openOldDotLink(`expenses?policyIDList=${props.policyID}&billableReimbursable=reimbursable&submitterEmail=%2B%2B`), - icon: Receipt, + onPress: () => Link.openOldDotLink(`expenses?policyIDList=${props.policyID}&billableReimbursable=reimbursable&submitterEmail=%2B%2B`), + icon: Expensicons.Receipt, shouldShowRightIcon: true, - iconRight: NewWindow, + iconRight: Expensicons.NewWindow, }, ]} > @@ -52,12 +48,12 @@ const WorkspaceReimburseNoVBAView = props => ( Navigation.navigate(ROUTES.getWorkspaceBankAccountRoute(props.policyID)), - icon: Bank, + icon: Expensicons.Bank, shouldShowRightIcon: true, }, ]} diff --git a/src/pages/workspace/reimburse/WorkspaceReimburseVBAView.js b/src/pages/workspace/reimburse/WorkspaceReimburseVBAView.js index 7e70f0ae8721..f16548f9bd94 100644 --- a/src/pages/workspace/reimburse/WorkspaceReimburseVBAView.js +++ b/src/pages/workspace/reimburse/WorkspaceReimburseVBAView.js @@ -4,15 +4,11 @@ import PropTypes from 'prop-types'; import Text from '../../../components/Text'; import styles from '../../../styles/styles'; import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize'; -import { - Bank, - Receipt, - NewWindow, -} from '../../../components/Icon/Expensicons'; -import {BankUserGreen, ReceiptYellow} from '../../../components/Icon/Illustrations'; +import * as Expensicons from '../../../components/Icon/Expensicons'; +import * as Illustrations from '../../../components/Icon/Illustrations'; import WorkspaceSection from '../WorkspaceSection'; import CopyTextToClipboard from '../../../components/CopyTextToClipboard'; -import {openOldDotLink} from '../../../libs/actions/Link'; +import * as Link from '../../../libs/actions/Link'; const propTypes = { /** The policy ID currently being configured */ @@ -25,14 +21,14 @@ const WorkspaceReimburseVBAView = props => ( <> openOldDotLink(`expenses?policyIDList=${props.policyID}&billableReimbursable=reimbursable&submitterEmail=%2B%2B`), - icon: Receipt, + onPress: () => Link.openOldDotLink(`expenses?policyIDList=${props.policyID}&billableReimbursable=reimbursable&submitterEmail=%2B%2B`), + icon: Expensicons.Receipt, shouldShowRightIcon: true, - iconRight: NewWindow, + iconRight: Expensicons.NewWindow, }, ]} > @@ -50,14 +46,14 @@ const WorkspaceReimburseVBAView = props => ( openOldDotLink(`reports?policyID=${props.policyID}&from=all&type=expense&showStates=Archived&isAdvancedFilterMode=true`), - icon: Bank, + onPress: () => Link.openOldDotLink(`reports?policyID=${props.policyID}&from=all&type=expense&showStates=Archived&isAdvancedFilterMode=true`), + icon: Expensicons.Bank, shouldShowRightIcon: true, - iconRight: NewWindow, + iconRight: Expensicons.NewWindow, }, ]} > diff --git a/src/pages/workspace/travel/WorkspaceTravelNoVBAView.js b/src/pages/workspace/travel/WorkspaceTravelNoVBAView.js index f193a6fc7b2a..149a2a728f6e 100644 --- a/src/pages/workspace/travel/WorkspaceTravelNoVBAView.js +++ b/src/pages/workspace/travel/WorkspaceTravelNoVBAView.js @@ -4,11 +4,8 @@ import PropTypes from 'prop-types'; import Text from '../../../components/Text'; import styles from '../../../styles/styles'; import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize'; -import { - ArrowRight, - Bank, -} from '../../../components/Icon/Expensicons'; -import {JewelBoxYellow} from '../../../components/Icon/Illustrations'; +import * as Expensicons from '../../../components/Icon/Expensicons'; +import * as Illustrations from '../../../components/Icon/Illustrations'; import WorkspaceSection from '../WorkspaceSection'; import Navigation from '../../../libs/Navigation/Navigation'; import ROUTES from '../../../ROUTES'; @@ -24,14 +21,14 @@ const WorkspaceTravelNoVBAView = props => ( <> Navigation.navigate(ROUTES.getWorkspaceBankAccountRoute(props.policyID)), - icon: Bank, + icon: Expensicons.Bank, shouldShowRightIcon: true, - iconRight: ArrowRight, + iconRight: Expensicons.ArrowRight, }, ]} > diff --git a/src/pages/workspace/travel/WorkspaceTravelVBAView.js b/src/pages/workspace/travel/WorkspaceTravelVBAView.js index 2ae098679d99..c4c97087390d 100644 --- a/src/pages/workspace/travel/WorkspaceTravelVBAView.js +++ b/src/pages/workspace/travel/WorkspaceTravelVBAView.js @@ -3,16 +3,11 @@ import {View} from 'react-native'; import Text from '../../../components/Text'; import styles from '../../../styles/styles'; import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize'; -import { - Concierge, - ExpensifyCard, - NewWindow, - Info, -} from '../../../components/Icon/Expensicons'; -import {RocketOrange} from '../../../components/Icon/Illustrations'; +import * as Expensicons from '../../../components/Icon/Expensicons'; +import * as Illustrations from '../../../components/Icon/Illustrations'; import WorkspaceSection from '../WorkspaceSection'; -import {openExternalLink, openOldDotLink} from '../../../libs/actions/Link'; -import {navigateToConciergeChat} from '../../../libs/actions/Report'; +import * as Link from '../../../libs/actions/Link'; +import * as Report from '../../../libs/actions/Report'; const propTypes = { ...withLocalizePropTypes, @@ -21,29 +16,29 @@ const propTypes = { const WorkspaceTravelVBAView = props => ( openOldDotLink('domain_companycards'), - icon: ExpensifyCard, + onPress: () => Link.openOldDotLink('domain_companycards'), + icon: Expensicons.ExpensifyCard, shouldShowRightIcon: true, - iconRight: NewWindow, + iconRight: Expensicons.NewWindow, }, { title: props.translate('workspace.travel.bookTravelWithConcierge'), onPress: () => { - navigateToConciergeChat(); + Report.navigateToConciergeChat(); }, - icon: Concierge, + icon: Expensicons.Concierge, shouldShowRightIcon: true, }, { title: props.translate('requestorStep.learnMore'), - onPress: () => openExternalLink('https://community.expensify.com/discussion/7066/introducing-concierge-travel'), - icon: Info, + onPress: () => Link.openExternalLink('https://community.expensify.com/discussion/7066/introducing-concierge-travel'), + icon: Expensicons.Info, shouldShowRightIcon: true, - iconRight: NewWindow, + iconRight: Expensicons.NewWindow, }, ]} > diff --git a/src/setup/index.js b/src/setup/index.js index b79550689783..09901fcf65fe 100644 --- a/src/setup/index.js +++ b/src/setup/index.js @@ -3,7 +3,7 @@ import ONYXKEYS from '../ONYXKEYS'; import CONST from '../CONST'; import listenToStorageEvents from '../libs/listenToStorageEvents'; import platformSetup from './platformSetup'; -import {canCaptureOnyxMetrics} from '../libs/canCaptureMetrics'; +import * as Metrics from '../libs/Metrics'; export default function () { /* @@ -22,7 +22,7 @@ export default function () { Onyx.init({ keys: ONYXKEYS, safeEvictionKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], - captureMetrics: canCaptureOnyxMetrics(), + captureMetrics: Metrics.canCaptureOnyxMetrics(), initialKeyStates: { // Clear any loading and error messages so they do not appear on app startup diff --git a/src/setup/platformSetup/index.native.js b/src/setup/platformSetup/index.native.js index a38b791b46b4..80fd3bfb20c6 100644 --- a/src/setup/platformSetup/index.native.js +++ b/src/setup/platformSetup/index.native.js @@ -1,5 +1,5 @@ import PushNotification from '../../libs/Notification/PushNotification'; -import {subscribeToReportCommentPushNotifications} from '../../libs/actions/Report'; +import * as Report from '../../libs/actions/Report'; import Performance from '../../libs/Performance'; export default function () { @@ -10,7 +10,7 @@ export default function () { * Otherwise, they will not be executed when the app is completely closed, and the push notification won't update the app data. */ PushNotification.init(); - subscribeToReportCommentPushNotifications(); + Report.subscribeToReportCommentPushNotifications(); // Setup Flipper plugins when on dev if (__DEV__) { diff --git a/src/styles/StyleUtils.js b/src/styles/StyleUtils.js new file mode 100644 index 000000000000..65aced74fe13 --- /dev/null +++ b/src/styles/StyleUtils.js @@ -0,0 +1,372 @@ +import _ from 'underscore'; +import CONST from '../CONST'; +import fontFamily from './fontFamily'; +import themeColors from './themes/default'; +import variables from './variables'; +import colors from './colors'; +import positioning from './utilities/positioning'; +import styles from './styles'; + +/** + * Takes safe area insets and returns padding to use for a View + * + * @param {Object} insets + * @returns {Object} + */ +function getSafeAreaPadding(insets) { + return { + paddingTop: insets.top, + paddingBottom: insets.bottom * variables.safeInsertPercentage, + paddingLeft: insets.left * variables.safeInsertPercentage, + paddingRight: insets.right * variables.safeInsertPercentage, + }; +} + +/** + * Takes safe area insets and returns margin to use for a View + * + * @param {Object} insets + * @returns {Object} + */ +function getSafeAreaMargins(insets) { + return {marginBottom: insets.bottom * variables.safeInsertPercentage}; +} + +/** + * Return navigation menu styles. + * + * @param {Boolean} isSmallScreenWidth + * @returns {Object} + */ +function getNavigationDrawerStyle(isSmallScreenWidth) { + return isSmallScreenWidth + ? { + width: '100%', + height: '100%', + borderColor: themeColors.border, + } + : { + height: '100%', + width: variables.sideBarWidth, + borderRightColor: themeColors.border, + }; +} + +function getNavigationDrawerType(isSmallScreenWidth) { + return isSmallScreenWidth ? 'slide' : 'permanent'; +} + +function getNavigationModalCardStyle(isSmallScreenWidth) { + return { + position: 'absolute', + top: 0, + right: 0, + width: isSmallScreenWidth ? '100%' : variables.sideBarWidth, + backgroundColor: 'transparent', + height: '100%', + }; +} + +/** + * @param {Boolean} isZoomed + * @param {Boolean} isDragging + * @return {Object} + */ +function getZoomCursorStyle(isZoomed, isDragging) { + if (!isZoomed) { + return {cursor: 'zoom-in'}; + } + + return { + cursor: isDragging ? 'grabbing' : 'zoom-out', + }; +} + +/** + * @param {Boolean} isZoomed + * @param {Number} imgWidth + * @param {Number} imgHeight + * @param {Number} zoomScale + * @param {Number} containerHeight + * @return {Object} + */ +function getZoomSizingStyle(isZoomed, imgWidth, imgHeight, zoomScale, containerHeight) { + if (imgWidth === 0 || imgHeight === 0) { + return { + height: isZoomed ? '250%' : '100%', + width: isZoomed ? '250%' : '100%', + }; + } + if (isZoomed) { + return { + height: `${(imgHeight * zoomScale)}px`, + width: `${(imgWidth * zoomScale)}px`, + }; + } + + const top = `${(containerHeight - imgHeight) / 2}px`; + const left = `calc(50% - ${imgWidth / 2}px)`; + return { + height: `${imgHeight}px`, + width: `${imgWidth}px`, + top, + left, + }; +} + +/** + * Returns auto grow text input style + * + * @param {Number} width + * @return {Object} + */ +function getAutoGrowTextInputStyle(width) { + return { + minWidth: 5, + width, + }; +} + +/** + * Returns a style with backgroundColor and borderColor set to the same color + * + * @param {String} backgroundColor + * @returns {Object} + */ +function getBackgroundAndBorderStyle(backgroundColor) { + return { + backgroundColor, + borderColor: backgroundColor, + }; +} + +/** + * Returns a style with the specified backgroundColor + * + * @param {String} backgroundColor + * @returns {Object} + */ +function getBackgroundColorStyle(backgroundColor) { + return { + backgroundColor, + }; +} + +/** + * Generate a style for the background color of the Badge + * + * @param {Boolean} success + * @param {Boolean} error + * @param {boolean} [isPressed=false] + * @return {Object} + */ +function getBadgeColorStyle(success, error, isPressed = false) { + if (success) { + return isPressed ? styles.badgeSuccessPressed : styles.badgeSuccess; + } + if (error) { + return isPressed ? styles.badgeDangerPressed : styles.badgeDanger; + } + return {}; +} + +/** + * Generate a style for the background color of the button, based on its current state. + * + * @param {String} [buttonState] - One of {'default', 'hovered', 'pressed'} + * @returns {Object} + */ +function getButtonBackgroundColorStyle(buttonState = CONST.BUTTON_STATES.DEFAULT) { + switch (buttonState) { + case CONST.BUTTON_STATES.ACTIVE: + return {backgroundColor: themeColors.buttonHoveredBG}; + case CONST.BUTTON_STATES.PRESSED: + return {backgroundColor: themeColors.buttonPressedBG}; + case CONST.BUTTON_STATES.DISABLED: + case CONST.BUTTON_STATES.DEFAULT: + default: + return {}; + } +} + +/** + * Generate fill color of an icon based on its state. + * + * @param {String} [buttonState] - One of {'default', 'hovered', 'pressed'} + * @returns {Object} + */ +function getIconFillColor(buttonState = CONST.BUTTON_STATES.DEFAULT) { + switch (buttonState) { + case CONST.BUTTON_STATES.ACTIVE: + return themeColors.text; + case CONST.BUTTON_STATES.PRESSED: + return themeColors.heading; + case CONST.BUTTON_STATES.COMPLETE: + return themeColors.iconSuccessFill; + case CONST.BUTTON_STATES.DEFAULT: + case CONST.BUTTON_STATES.DISABLED: + default: + return themeColors.icon; + } +} + +/** + * @param {Animated.Value} rotate + * @param {Animated.Value} backgroundColor + * @returns {Object} + */ +function getAnimatedFABStyle(rotate, backgroundColor) { + return { + transform: [{rotate}], + backgroundColor, + }; +} + +/** + * @param {Number} width + * @param {Number} height + * @returns {Object} + */ +function getWidthAndHeightStyle(width, height) { + return { + width, + height, + }; +} + +/** + * @param {Object} params + * @returns {Object} + */ +function getModalPaddingStyles({ + shouldAddBottomSafeAreaPadding, + shouldAddTopSafeAreaPadding, + safeAreaPaddingTop, + safeAreaPaddingBottom, + safeAreaPaddingLeft, + safeAreaPaddingRight, + modalContainerStylePaddingTop, + modalContainerStylePaddingBottom, +}) { + return { + paddingTop: shouldAddTopSafeAreaPadding + ? (modalContainerStylePaddingTop || 0) + safeAreaPaddingTop + : modalContainerStylePaddingTop || 0, + paddingBottom: shouldAddBottomSafeAreaPadding + ? (modalContainerStylePaddingBottom || 0) + safeAreaPaddingBottom + : modalContainerStylePaddingBottom || 0, + paddingLeft: safeAreaPaddingLeft || 0, + paddingRight: safeAreaPaddingRight || 0, + }; +} + +/** + * Takes fontStyle and fontWeight and returns the correct fontFamily + * + * @param {Object} params + * @returns {String} + */ +function getFontFamilyMonospace({fontStyle, fontWeight}) { + const italic = fontStyle === 'italic' && fontFamily.MONOSPACE_ITALIC; + const bold = fontWeight === 'bold' && fontFamily.MONOSPACE_BOLD; + const italicBold = italic && bold && fontFamily.MONOSPACE_BOLD_ITALIC; + + return italicBold || bold || italic || fontFamily.MONOSPACE; +} + +/** + * Gives the width for Emoji picker Widget + * + * @param {Boolean} isSmallScreenWidth + * @returns {String} + */ +function getEmojiPickerStyle(isSmallScreenWidth) { + return { + width: isSmallScreenWidth ? '100%' : CONST.EMOJI_PICKER_SIZE, + }; +} + +/** + * Get the random promo color and image for Login page + * + * @return {Object} + */ +function getLoginPagePromoStyle() { + const promos = [ + { + backgroundColor: colors.green, + backgroundImageUri: `${CONST.CLOUDFRONT_URL}/images/homepage/brand-stories/freeplan_green.svg`, + }, + { + backgroundColor: colors.orange, + backgroundImageUri: `${CONST.CLOUDFRONT_URL}/images/homepage/brand-stories/freeplan_orange.svg`, + }, + { + backgroundColor: colors.pink, + backgroundImageUri: `${CONST.CLOUDFRONT_URL}/images/homepage/brand-stories/freeplan_pink.svg`, + }, + { + backgroundColor: colors.blue, + backgroundImageUri: `${CONST.CLOUDFRONT_URL}/images/homepage/brand-stories/freeplan_blue.svg`, + }, + ]; + return promos[_.random(0, 3)]; +} + +/** + * Generate the styles for the ReportActionItem wrapper view. + * + * @param {Boolean} [isHovered] + * @returns {Object} + */ +function getReportActionItemStyle(isHovered = false) { + return { + display: 'flex', + justifyContent: 'space-between', + backgroundColor: isHovered + ? themeColors.hoverComponentBG + + // Warning: Setting this to a non-transparent color will cause unread indicator to break on Android + : colors.transparent, + cursor: 'default', + }; +} + +/** + * Generate the wrapper styles for the mini ReportActionContextMenu. + * + * @param {Boolean} isReportActionItemGrouped + * @returns {Object} + */ +function getMiniReportActionContextMenuWrapperStyle(isReportActionItemGrouped) { + return { + ...(isReportActionItemGrouped ? positioning.tn8 : positioning.tn4), + ...positioning.r4, + position: 'absolute', + zIndex: 1, + }; +} + +export { + getSafeAreaPadding, + getSafeAreaMargins, + getNavigationDrawerStyle, + getNavigationDrawerType, + getNavigationModalCardStyle, + getZoomCursorStyle, + getZoomSizingStyle, + getAutoGrowTextInputStyle, + getBackgroundAndBorderStyle, + getBackgroundColorStyle, + getBadgeColorStyle, + getButtonBackgroundColorStyle, + getIconFillColor, + getAnimatedFABStyle, + getWidthAndHeightStyle, + getModalPaddingStyles, + getFontFamilyMonospace, + getEmojiPickerStyle, + getLoginPagePromoStyle, + getReportActionItemStyle, + getMiniReportActionContextMenuWrapperStyle, +}; diff --git a/src/styles/getReportActionItemStyles.js b/src/styles/getReportActionItemStyles.js deleted file mode 100644 index 122581d384ff..000000000000 --- a/src/styles/getReportActionItemStyles.js +++ /dev/null @@ -1,42 +0,0 @@ -import colors from './colors'; -import themeColors from './themes/default'; -import positioning from './utilities/positioning'; - -/** - * Generate the styles for the ReportActionItem wrapper view. - * - * @param {Boolean} [isHovered] - * @returns {Object} - */ -function getReportActionItemStyle(isHovered = false) { - return { - display: 'flex', - justifyContent: 'space-between', - backgroundColor: isHovered - ? themeColors.hoverComponentBG - - // Warning: Setting this to a non-transparent color will cause unread indicator to break on Android - : colors.transparent, - cursor: 'default', - }; -} - -/** - * Generate the wrapper styles for the mini ReportActionContextMenu. - * - * @param {Boolean} isReportActionItemGrouped - * @returns {Object} - */ -function getMiniReportActionContextMenuWrapperStyle(isReportActionItemGrouped) { - return { - ...(isReportActionItemGrouped ? positioning.tn8 : positioning.tn4), - ...positioning.r4, - position: 'absolute', - zIndex: 1, - }; -} - -export { - getMiniReportActionContextMenuWrapperStyle, - getReportActionItemStyle, -}; diff --git a/src/styles/styles.js b/src/styles/styles.js index 2ffd1f4ff107..c7ec40e0ee57 100644 --- a/src/styles/styles.js +++ b/src/styles/styles.js @@ -1,4 +1,3 @@ -import _ from 'underscore'; import fontFamily from './fontFamily'; import addOutlineWidth from './addOutlineWidth'; import themeColors from './themes/default'; @@ -13,7 +12,6 @@ import overflow from './utilities/overflow'; import whiteSpace from './utilities/whiteSpace'; import wordBreak from './utilities/wordBreak'; import textInputAlignSelf from './utilities/textInputAlignSelf'; -import CONST from '../CONST'; import positioning from './utilities/positioning'; import codeStyles from './codeStyles'; import visibility from './utilities/visibility'; @@ -33,6 +31,103 @@ const expensiPicker = { borderRadius: variables.componentBorderRadiusNormal, }; +const link = { + color: themeColors.link, + textDecorationColor: themeColors.link, + fontFamily: fontFamily.GTA, +}; + +const baseCodeTagStyles = { + borderWidth: 1, + borderRadius: 5, + borderColor: themeColors.border, + backgroundColor: themeColors.textBackground, +}; + +const webViewStyles = { + // As of react-native-render-html v6, don't declare distinct styles for + // custom renderers, the API for custom renderers has changed. Declare the + // styles in the below "tagStyles" instead. If you need to reuse those + // styles from the renderer, just pass the "style" prop to the underlying + // component. + tagStyles: { + em: { + fontFamily: fontFamily.GTA_ITALIC, + fontStyle: 'italic', + }, + + del: { + textDecorationLine: 'line-through', + textDecorationStyle: 'solid', + }, + + strong: { + fontFamily: fontFamily.GTA_BOLD, + fontWeight: 'bold', + }, + + a: link, + + ul: { + maxWidth: '100%', + flex: 1, + }, + + ol: { + maxWidth: '100%', + flex: 1, + }, + + li: { + flexShrink: 1, + }, + + blockquote: { + borderLeftColor: themeColors.border, + borderLeftWidth: 4, + paddingLeft: 12, + marginTop: 4, + marginBottom: 4, + + // Overwrite default HTML margin for blockquotes + marginLeft: 0, + }, + + pre: { + ...baseCodeTagStyles, + paddingTop: 4, + paddingBottom: 5, + paddingRight: 8, + paddingLeft: 8, + fontFamily: fontFamily.MONOSPACE, + marginTop: 0, + marginBottom: 0, + }, + + code: { + ...baseCodeTagStyles, + ...codeStyles.codeTextStyle, + paddingLeft: 5, + paddingRight: 5, + fontFamily: fontFamily.MONOSPACE, + fontSize: 13, + }, + + img: { + borderColor: themeColors.border, + borderRadius: variables.componentBorderRadiusNormal, + borderWidth: 1, + }, + }, + + baseFontStyle: { + color: themeColors.text, + fontSize: variables.fontSizeNormal, + fontFamily: fontFamily.GTA, + flex: 1, + }, +}; + const styles = { // Add all of our utility and helper styles ...spacing, @@ -44,11 +139,9 @@ const styles = { ...wordBreak, ...whiteSpace, - link: { - color: themeColors.link, - textDecorationColor: themeColors.link, - fontFamily: fontFamily.GTA, - }, + webViewStyles, + + link, linkHovered: { color: themeColors.linkHover, @@ -2166,423 +2259,4 @@ const styles = { }, }; -const baseCodeTagStyles = { - borderWidth: 1, - borderRadius: 5, - borderColor: themeColors.border, - backgroundColor: themeColors.textBackground, -}; - -const webViewStyles = { - // As of react-native-render-html v6, don't declare distinct styles for - // custom renderers, the API for custom renderers has changed. Declare the - // styles in the below "tagStyles" instead. If you need to reuse those - // styles from the renderer, just pass the "style" prop to the underlying - // component. - tagStyles: { - em: { - fontFamily: fontFamily.GTA_ITALIC, - fontStyle: 'italic', - }, - - del: { - textDecorationLine: 'line-through', - textDecorationStyle: 'solid', - }, - - strong: { - fontFamily: fontFamily.GTA_BOLD, - fontWeight: 'bold', - }, - - a: styles.link, - - ul: { - maxWidth: '100%', - flex: 1, - }, - - ol: { - maxWidth: '100%', - flex: 1, - }, - - li: { - flexShrink: 1, - }, - - blockquote: { - borderLeftColor: themeColors.border, - borderLeftWidth: 4, - paddingLeft: 12, - marginTop: 4, - marginBottom: 4, - - // Overwrite default HTML margin for blockquotes - marginLeft: 0, - }, - - pre: { - ...baseCodeTagStyles, - paddingTop: 4, - paddingBottom: 5, - paddingRight: 8, - paddingLeft: 8, - fontFamily: fontFamily.MONOSPACE, - marginTop: 0, - marginBottom: 0, - }, - - code: { - ...baseCodeTagStyles, - ...codeStyles.codeTextStyle, - paddingLeft: 5, - paddingRight: 5, - fontFamily: fontFamily.MONOSPACE, - fontSize: 13, - }, - - img: { - borderColor: themeColors.border, - borderRadius: variables.componentBorderRadiusNormal, - borderWidth: 1, - }, - }, - - baseFontStyle: { - color: themeColors.text, - fontSize: variables.fontSizeNormal, - fontFamily: fontFamily.GTA, - flex: 1, - }, -}; - -/** - * Takes safe area insets and returns padding to use for a View - * - * @param {Object} insets - * @returns {Object} - */ -function getSafeAreaPadding(insets) { - return { - paddingTop: insets.top, - paddingBottom: insets.bottom * variables.safeInsertPercentage, - paddingLeft: insets.left * variables.safeInsertPercentage, - paddingRight: insets.right * variables.safeInsertPercentage, - }; -} - -/** - * Takes safe area insets and returns margin to use for a View - * - * @param {Object} insets - * @returns {Object} - */ -function getSafeAreaMargins(insets) { - return {marginBottom: insets.bottom * variables.safeInsertPercentage}; -} - -/** - * Return navigation menu styles. - * - * @param {Boolean} isSmallScreenWidth - * @returns {Object} - */ -function getNavigationDrawerStyle(isSmallScreenWidth) { - return isSmallScreenWidth - ? { - width: '100%', - height: '100%', - borderColor: themeColors.border, - } - : { - height: '100%', - width: variables.sideBarWidth, - borderRightColor: themeColors.border, - }; -} - -function getNavigationDrawerType(isSmallScreenWidth) { - return isSmallScreenWidth ? 'slide' : 'permanent'; -} - -function getNavigationModalCardStyle(isSmallScreenWidth) { - return { - position: 'absolute', - top: 0, - right: 0, - width: isSmallScreenWidth ? '100%' : variables.sideBarWidth, - backgroundColor: 'transparent', - height: '100%', - }; -} - -/** - * @param {Boolean} isZoomed - * @param {Boolean} isDragging - * @return {Object} - */ -function getZoomCursorStyle(isZoomed, isDragging) { - if (!isZoomed) { - return {cursor: 'zoom-in'}; - } - - return { - cursor: isDragging ? 'grabbing' : 'zoom-out', - }; -} - -/** - * @param {Boolean} isZoomed - * @param {Number} imgWidth - * @param {Number} imgHeight - * @param {Number} zoomScale - * @param {Number} containerHeight - * @return {Object} - */ -function getZoomSizingStyle(isZoomed, imgWidth, imgHeight, zoomScale, containerHeight) { - if (imgWidth === 0 || imgHeight === 0) { - return { - height: isZoomed ? '250%' : '100%', - width: isZoomed ? '250%' : '100%', - }; - } - if (isZoomed) { - return { - height: `${(imgHeight * zoomScale)}px`, - width: `${(imgWidth * zoomScale)}px`, - }; - } - - const top = `${(containerHeight - imgHeight) / 2}px`; - const left = `calc(50% - ${imgWidth / 2}px)`; - return { - height: `${imgHeight}px`, - width: `${imgWidth}px`, - top, - left, - }; -} - -/** - * Returns auto grow text input style - * - * @param {Number} width - * @return {Object} - */ -function getAutoGrowTextInputStyle(width) { - return { - minWidth: 5, - width, - }; -} - -/** - * Returns a style with backgroundColor and borderColor set to the same color - * - * @param {String} backgroundColor - * @returns {Object} - */ -function getBackgroundAndBorderStyle(backgroundColor) { - return { - backgroundColor, - borderColor: backgroundColor, - }; -} - -/** - * Returns a style with the specified backgroundColor - * - * @param {String} backgroundColor - * @returns {Object} - */ -function getBackgroundColorStyle(backgroundColor) { - return { - backgroundColor, - }; -} - -/** - * Generate a style for the background color of the Badge - * - * @param {Boolean} success - * @param {Boolean} error - * @param {boolean} [isPressed=false] - * @return {Object} - */ -function getBadgeColorStyle(success, error, isPressed = false) { - if (success) { - return isPressed ? styles.badgeSuccessPressed : styles.badgeSuccess; - } - if (error) { - return isPressed ? styles.badgeDangerPressed : styles.badgeDanger; - } - return {}; -} - -/** - * Generate a style for the background color of the button, based on its current state. - * - * @param {String} [buttonState] - One of {'default', 'hovered', 'pressed'} - * @returns {Object} - */ -function getButtonBackgroundColorStyle(buttonState = CONST.BUTTON_STATES.DEFAULT) { - switch (buttonState) { - case CONST.BUTTON_STATES.ACTIVE: - return {backgroundColor: themeColors.buttonHoveredBG}; - case CONST.BUTTON_STATES.PRESSED: - return {backgroundColor: themeColors.buttonPressedBG}; - case CONST.BUTTON_STATES.DISABLED: - case CONST.BUTTON_STATES.DEFAULT: - default: - return {}; - } -} - -/** - * Generate fill color of an icon based on its state. - * - * @param {String} [buttonState] - One of {'default', 'hovered', 'pressed'} - * @returns {Object} - */ -function getIconFillColor(buttonState = CONST.BUTTON_STATES.DEFAULT) { - switch (buttonState) { - case CONST.BUTTON_STATES.ACTIVE: - return themeColors.text; - case CONST.BUTTON_STATES.PRESSED: - return themeColors.heading; - case CONST.BUTTON_STATES.COMPLETE: - return themeColors.iconSuccessFill; - case CONST.BUTTON_STATES.DEFAULT: - case CONST.BUTTON_STATES.DISABLED: - default: - return themeColors.icon; - } -} - -/** - * @param {Animated.Value} rotate - * @param {Animated.Value} backgroundColor - * @returns {Object} - */ -function getAnimatedFABStyle(rotate, backgroundColor) { - return { - transform: [{rotate}], - backgroundColor, - }; -} - -/** - * @param {Number} width - * @param {Number} height - * @returns {Object} - */ -function getWidthAndHeightStyle(width, height) { - return { - width, - height, - }; -} - -/** - * @param {Object} params - * @returns {Object} - */ -function getModalPaddingStyles({ - shouldAddBottomSafeAreaPadding, - shouldAddTopSafeAreaPadding, - safeAreaPaddingTop, - safeAreaPaddingBottom, - safeAreaPaddingLeft, - safeAreaPaddingRight, - modalContainerStylePaddingTop, - modalContainerStylePaddingBottom, -}) { - return { - paddingTop: shouldAddTopSafeAreaPadding - ? (modalContainerStylePaddingTop || 0) + safeAreaPaddingTop - : modalContainerStylePaddingTop || 0, - paddingBottom: shouldAddBottomSafeAreaPadding - ? (modalContainerStylePaddingBottom || 0) + safeAreaPaddingBottom - : modalContainerStylePaddingBottom || 0, - paddingLeft: safeAreaPaddingLeft || 0, - paddingRight: safeAreaPaddingRight || 0, - }; -} - -/** - * Takes fontStyle and fontWeight and returns the correct fontFamily - * - * @param {Object} params - * @returns {String} - */ -function getFontFamilyMonospace({fontStyle, fontWeight}) { - const italic = fontStyle === 'italic' && fontFamily.MONOSPACE_ITALIC; - const bold = fontWeight === 'bold' && fontFamily.MONOSPACE_BOLD; - const italicBold = italic && bold && fontFamily.MONOSPACE_BOLD_ITALIC; - - return italicBold || bold || italic || fontFamily.MONOSPACE; -} - -/** - * Gives the width for Emoji picker Widget - * - * @param {Boolean} isSmallScreenWidth - * @returns {String} - */ -function getEmojiPickerStyle(isSmallScreenWidth) { - return { - width: isSmallScreenWidth ? '100%' : CONST.EMOJI_PICKER_SIZE, - }; -} - -/** - * Get the random promo color and image for Login page - * - * @return {Object} - */ -function getLoginPagePromoStyle() { - const promos = [ - { - backgroundColor: colors.green, - backgroundImageUri: `${CONST.CLOUDFRONT_URL}/images/homepage/brand-stories/freeplan_green.svg`, - }, - { - backgroundColor: colors.orange, - backgroundImageUri: `${CONST.CLOUDFRONT_URL}/images/homepage/brand-stories/freeplan_orange.svg`, - }, - { - backgroundColor: colors.pink, - backgroundImageUri: `${CONST.CLOUDFRONT_URL}/images/homepage/brand-stories/freeplan_pink.svg`, - }, - { - backgroundColor: colors.blue, - backgroundImageUri: `${CONST.CLOUDFRONT_URL}/images/homepage/brand-stories/freeplan_blue.svg`, - }, - ]; - return promos[_.random(0, 3)]; -} - export default styles; -export { - getSafeAreaPadding, - getSafeAreaMargins, - webViewStyles, - getNavigationDrawerStyle, - getNavigationDrawerType, - getNavigationModalCardStyle, - getZoomCursorStyle, - getZoomSizingStyle, - getAutoGrowTextInputStyle, - getBackgroundAndBorderStyle, - getBackgroundColorStyle, - getBadgeColorStyle, - getButtonBackgroundColorStyle, - getIconFillColor, - getAnimatedFABStyle, - getWidthAndHeightStyle, - getModalPaddingStyles, - getFontFamilyMonospace, - getEmojiPickerStyle, - getLoginPagePromoStyle, -}; diff --git a/tests/actions/ReimbursementAccountTest.js b/tests/actions/ReimbursementAccountTest.js index ae2516b66907..c711b0fbf35f 100644 --- a/tests/actions/ReimbursementAccountTest.js +++ b/tests/actions/ReimbursementAccountTest.js @@ -1,7 +1,7 @@ import Onyx from 'react-native-onyx'; -import {fetchFreePlanVerifiedBankAccount, setupWithdrawalAccount} from '../../src/libs/actions/BankAccounts'; +import * as BankAccounts from '../../src/libs/actions/BankAccounts'; import ONYXKEYS from '../../src/ONYXKEYS'; -import {signInWithTestUser} from '../utils/TestHelper'; +import * as TestHelper from '../utils/TestHelper'; import HttpUtils from '../../src/libs/HttpUtils'; import waitForPromisesToResolve from '../utils/waitForPromisesToResolve'; import CONST from '../../src/CONST'; @@ -36,7 +36,7 @@ Onyx.connect({ beforeEach(() => Onyx.clear() .then(() => { Network.setIsReady(true); - signInWithTestUser(); + TestHelper.signInWithTestUser(); return waitForPromisesToResolve(); })); @@ -57,7 +57,7 @@ describe('actions/BankAccounts', () => { })); // WHEN we fetch the bank account - fetchFreePlanVerifiedBankAccount(); + BankAccounts.fetchFreePlanVerifiedBankAccount(); return waitForPromisesToResolve() .then(() => { // THEN we should expect it to stop loading and bring us to the BankAccountStep @@ -70,7 +70,7 @@ describe('actions/BankAccounts', () => { HttpUtils.xhr.mockImplementationOnce(() => Promise.resolve({ jsonCode: 200, })); - setupWithdrawalAccount({ + BankAccounts.setupWithdrawalAccount({ acceptTerms: true, country: 'US', currency: 'USD', @@ -103,7 +103,7 @@ describe('actions/BankAccounts', () => { })); // WHEN we call setupWithdrawalAccount again with CompanyStep data - setupWithdrawalAccount({ + BankAccounts.setupWithdrawalAccount({ companyName: 'Alberta Bobbeth Charleson', companyPhone: '5165671515', companyTaxID: '123456789', @@ -147,7 +147,7 @@ describe('actions/BankAccounts', () => { })); // WHEN we fetch the bank account - fetchFreePlanVerifiedBankAccount(); + BankAccounts.fetchFreePlanVerifiedBankAccount(); return waitForPromisesToResolve() .then(() => { // THEN we should to navigate to the RequestorStep @@ -173,7 +173,7 @@ describe('actions/BankAccounts', () => { HttpUtils.xhr.mockImplementationOnce(() => Promise.resolve({jsonCode: 200})); // WHEN we call setupWithdrawalAccount on the RequestorStep - setupWithdrawalAccount({ + BankAccounts.setupWithdrawalAccount({ dob: '1980-01-01', firstName: 'Alberta', isControllingOfficer: true, @@ -219,7 +219,7 @@ describe('actions/BankAccounts', () => { })); // WHEN we fetch the bank account - fetchFreePlanVerifiedBankAccount(); + BankAccounts.fetchFreePlanVerifiedBankAccount(); return waitForPromisesToResolve() .then(() => { // THEN we should expect it redirect the user back to the RequestorStep because they still need to do Onfido @@ -251,7 +251,7 @@ describe('actions/BankAccounts', () => { })); // WHEN we fetch the bank account - fetchFreePlanVerifiedBankAccount(); + BankAccounts.fetchFreePlanVerifiedBankAccount(); return waitForPromisesToResolve() .then(() => { // THEN we should expect to be navigated to the ACHContractStep step @@ -280,7 +280,7 @@ describe('actions/BankAccounts', () => { })); // WHEN we call setupWithdrawalAccount via the ACHContractStep - setupWithdrawalAccount({ + BankAccounts.setupWithdrawalAccount({ acceptTermsAndConditions: true, beneficialOwners: [], certifyTrueInformation: true, @@ -321,7 +321,7 @@ describe('actions/BankAccounts', () => { })); // WHEN we fetch the account - fetchFreePlanVerifiedBankAccount(); + BankAccounts.fetchFreePlanVerifiedBankAccount(); return waitForPromisesToResolve() .then(() => { // THEN we should see that we are directed to the ValidationStep @@ -357,7 +357,7 @@ describe('actions/BankAccounts', () => { })); // WHEN we fetch the account - fetchFreePlanVerifiedBankAccount(); + BankAccounts.fetchFreePlanVerifiedBankAccount(); return waitForPromisesToResolve() .then(() => { // THEN it should have maxAttemptsReached set to true and show the correct data set in Onyx diff --git a/tests/actions/ReportTest.js b/tests/actions/ReportTest.js index 0d63bc878c67..27a1c10134fe 100644 --- a/tests/actions/ReportTest.js +++ b/tests/actions/ReportTest.js @@ -9,9 +9,9 @@ import * as Pusher from '../../src/libs/Pusher/pusher'; import PusherConnectionManager from '../../src/libs/PusherConnectionManager'; import CONFIG from '../../src/CONFIG'; import CONST from '../../src/CONST'; -import {addAction, togglePinnedState, subscribeToUserEvents} from '../../src/libs/actions/Report'; +import * as Report from '../../src/libs/actions/Report'; import waitForPromisesToResolve from '../utils/waitForPromisesToResolve'; -import {signInWithTestUser, fetchPersonalDetailsForTestUser} from '../utils/TestHelper'; +import * as TestHelper from '../utils/TestHelper'; import Log from '../../src/libs/Log'; describe('actions/Report', () => { @@ -71,12 +71,12 @@ describe('actions/Report', () => { let clientID; // Set up Onyx with some test user data - return signInWithTestUser(TEST_USER_ACCOUNT_ID, TEST_USER_LOGIN) + return TestHelper.signInWithTestUser(TEST_USER_ACCOUNT_ID, TEST_USER_LOGIN) .then(() => { - subscribeToUserEvents(); + Report.subscribeToUserEvents(); return waitForPromisesToResolve(); }) - .then(() => fetchPersonalDetailsForTestUser(TEST_USER_ACCOUNT_ID, TEST_USER_LOGIN, { + .then(() => TestHelper.fetchPersonalDetailsForTestUser(TEST_USER_ACCOUNT_ID, TEST_USER_LOGIN, { [TEST_USER_LOGIN]: { accountID: TEST_USER_ACCOUNT_ID, email: TEST_USER_LOGIN, @@ -87,7 +87,7 @@ describe('actions/Report', () => { .then(() => { // This is a fire and forget response, but once it completes we should be able to verify that we // have an "optimistic" report action in Onyx. - addAction(REPORT_ID, 'Testing a comment'); + Report.addAction(REPORT_ID, 'Testing a comment'); return waitForPromisesToResolve(); }) .then(() => { @@ -141,13 +141,13 @@ describe('actions/Report', () => { }); // Set up Onyx with some test user data - return signInWithTestUser(TEST_USER_ACCOUNT_ID, TEST_USER_LOGIN) + return TestHelper.signInWithTestUser(TEST_USER_ACCOUNT_ID, TEST_USER_LOGIN) .then(() => { - subscribeToUserEvents(); + Report.subscribeToUserEvents(); return waitForPromisesToResolve(); }) .then(() => { - togglePinnedState(REPORT); + Report.togglePinnedState(REPORT); return waitForPromisesToResolve(); }) .then(() => { @@ -181,8 +181,8 @@ describe('actions/Report', () => { const LOGGER_MAX_LOG_LINES = 50; // GIVEN a test user with initial data - return signInWithTestUser(TEST_USER_ACCOUNT_ID, TEST_USER_LOGIN) - .then(() => fetchPersonalDetailsForTestUser(TEST_USER_ACCOUNT_ID, TEST_USER_LOGIN, { + return TestHelper.signInWithTestUser(TEST_USER_ACCOUNT_ID, TEST_USER_LOGIN) + .then(() => TestHelper.fetchPersonalDetailsForTestUser(TEST_USER_ACCOUNT_ID, TEST_USER_LOGIN, { [TEST_USER_LOGIN]: { accountID: TEST_USER_ACCOUNT_ID, email: TEST_USER_LOGIN, @@ -204,7 +204,7 @@ describe('actions/Report', () => { } // And leave a comment on a report which will trigger the log packet to be sent in the same call - addAction(REPORT_ID, 'Testing a comment'); + Report.addAction(REPORT_ID, 'Testing a comment'); return waitForPromisesToResolve(); }) .then(() => { diff --git a/tests/actions/SessionTest.js b/tests/actions/SessionTest.js index 67ab478e4143..62604fd77c67 100644 --- a/tests/actions/SessionTest.js +++ b/tests/actions/SessionTest.js @@ -4,7 +4,7 @@ import * as API from '../../src/libs/API'; import HttpUtils from '../../src/libs/HttpUtils'; import waitForPromisesToResolve from '../utils/waitForPromisesToResolve'; import ONYXKEYS from '../../src/ONYXKEYS'; -import {signInWithTestUser} from '../utils/TestHelper'; +import * as TestHelper from '../utils/TestHelper'; // We are mocking this method so that we can later test to see if it was called and what arguments it was called with. // We test HttpUtils.xhr() since this means that our API command turned into a network request and isn't only queued. @@ -37,7 +37,7 @@ test('Authenticate is called with saved credentials when a session expires', () }); // When we sign in with the test user - return signInWithTestUser(TEST_USER_ACCOUNT_ID, TEST_USER_LOGIN, 'Password1', TEST_INITIAL_AUTH_TOKEN) + return TestHelper.signInWithTestUser(TEST_USER_ACCOUNT_ID, TEST_USER_LOGIN, 'Password1', TEST_INITIAL_AUTH_TOKEN) .then(() => { // Then our re-authentication credentials should be generated and our session data // have the correct information + initial authToken. diff --git a/tests/unit/EmojiRegexTest.js b/tests/unit/EmojiRegexTest.js index d23582280b1c..895e6f1acedf 100644 --- a/tests/unit/EmojiRegexTest.js +++ b/tests/unit/EmojiRegexTest.js @@ -1,7 +1,7 @@ import _ from 'underscore'; import Emoji from '../../assets/emojis'; import CONST from '../../src/CONST'; -import {isSingleEmoji} from '../../src/libs/EmojiUtils'; +import * as EmojiUtils from '../../src/libs/EmojiUtils'; describe('EmojiRegexTest', () => { it('matches all the emojis in the list', () => { @@ -12,11 +12,11 @@ describe('EmojiRegexTest', () => { } // When we match every Emoji Code - const isEmojiMatched = isSingleEmoji(emoji.code); + const isEmojiMatched = EmojiUtils.isSingleEmoji(emoji.code); let skinToneMatched = true; if (emoji.types) { // and every skin tone variant of the Emoji code - skinToneMatched = _.every(emoji.types, emojiWithSkinTone => isSingleEmoji(emojiWithSkinTone)); + skinToneMatched = _.every(emoji.types, emojiWithSkinTone => EmojiUtils.isSingleEmoji(emojiWithSkinTone)); } return skinToneMatched && isEmojiMatched; }); @@ -27,38 +27,38 @@ describe('EmojiRegexTest', () => { it('matches single emojis variants for size', () => { // GIVEN an emoji that has the default Unicode representation WHEN we check if it's a single emoji THEN it should return true - expect(isSingleEmoji('๐Ÿ‘‰')).toBe(true); - expect(isSingleEmoji('๐Ÿ˜ช๏ธ')).toBe(true); - expect(isSingleEmoji('๐Ÿ˜Ž๏ธ')).toBe(true); + expect(EmojiUtils.isSingleEmoji('๐Ÿ‘‰')).toBe(true); + expect(EmojiUtils.isSingleEmoji('๐Ÿ˜ช๏ธ')).toBe(true); + expect(EmojiUtils.isSingleEmoji('๐Ÿ˜Ž๏ธ')).toBe(true); // GIVEN an emoji that different cross-platform variations WHEN we check if it's a single emoji THEN it should return true - expect(isSingleEmoji('๐Ÿ”ซ๏ธ')).toBe(true); - expect(isSingleEmoji('๐Ÿ›')).toBe(true); - expect(isSingleEmoji('๐Ÿ•')).toBe(true); + expect(EmojiUtils.isSingleEmoji('๐Ÿ”ซ๏ธ')).toBe(true); + expect(EmojiUtils.isSingleEmoji('๐Ÿ›')).toBe(true); + expect(EmojiUtils.isSingleEmoji('๐Ÿ•')).toBe(true); // GIVEN an emoji that is symbol/numerical WHEN we check if it's a single emoji THEN it should return true - expect(isSingleEmoji('*๏ธโƒฃ')).toBe(true); - expect(isSingleEmoji('1๏ธโƒฃ๏ธ')).toBe(true); + expect(EmojiUtils.isSingleEmoji('*๏ธโƒฃ')).toBe(true); + expect(EmojiUtils.isSingleEmoji('1๏ธโƒฃ๏ธ')).toBe(true); // GIVEN an emoji that has text-variant WHEN we check if it's a single emoji THEN it should return true - expect(isSingleEmoji('โค๏ธ')).toBe(true); - expect(isSingleEmoji('โ‰๏ธ')).toBe(true); - expect(isSingleEmoji('โœณ๏ธ')).toBe(true); - expect(isSingleEmoji('โ˜ ๏ธ')).toBe(true); + expect(EmojiUtils.isSingleEmoji('โค๏ธ')).toBe(true); + expect(EmojiUtils.isSingleEmoji('โ‰๏ธ')).toBe(true); + expect(EmojiUtils.isSingleEmoji('โœณ๏ธ')).toBe(true); + expect(EmojiUtils.isSingleEmoji('โ˜ ๏ธ')).toBe(true); // GIVEN an emoji that has skin tone attached WHEN we check if it's a single emoji THEN it should return true - expect(isSingleEmoji('๐Ÿ‘ถ๐Ÿฝ')).toBe(true); - expect(isSingleEmoji('๐Ÿ‘ฉ๐Ÿพ')).toBe(true); - expect(isSingleEmoji('๐Ÿ‘Š๐Ÿพ')).toBe(true); + expect(EmojiUtils.isSingleEmoji('๐Ÿ‘ถ๐Ÿฝ')).toBe(true); + expect(EmojiUtils.isSingleEmoji('๐Ÿ‘ฉ๐Ÿพ')).toBe(true); + expect(EmojiUtils.isSingleEmoji('๐Ÿ‘Š๐Ÿพ')).toBe(true); // GIVEN an emoji that is composite(family) with 4+ unicode pairs WHEN we check if it's a single emoji THEN it should return true - expect(isSingleEmoji('๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘ฆ๏ธ')).toBe(true); - expect(isSingleEmoji('๐Ÿ‘ฉโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ๏ธ')).toBe(true); + expect(EmojiUtils.isSingleEmoji('๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘ฆ๏ธ')).toBe(true); + expect(EmojiUtils.isSingleEmoji('๐Ÿ‘ฉโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ๏ธ')).toBe(true); // GIVEN an emoji that has a length of 2 (flags) WHEN we check if it's a single emoji THEN it should return true - expect(isSingleEmoji('๐Ÿ‡บ๐Ÿ‡ฒ')).toBe(true); - expect(isSingleEmoji('๐Ÿ‡ฎ๐Ÿ‡ณ')).toBe(true); - expect(isSingleEmoji('๐Ÿ‡บ๐Ÿ‡ฆ๏ธ')).toBe(true); + expect(EmojiUtils.isSingleEmoji('๐Ÿ‡บ๐Ÿ‡ฒ')).toBe(true); + expect(EmojiUtils.isSingleEmoji('๐Ÿ‡ฎ๐Ÿ‡ณ')).toBe(true); + expect(EmojiUtils.isSingleEmoji('๐Ÿ‡บ๐Ÿ‡ฆ๏ธ')).toBe(true); }); }); diff --git a/tests/unit/GooglePlacesUtilsTest.js b/tests/unit/GooglePlacesUtilsTest.js index 2ec7445623d1..9c8552286b1c 100644 --- a/tests/unit/GooglePlacesUtilsTest.js +++ b/tests/unit/GooglePlacesUtilsTest.js @@ -1,4 +1,4 @@ -import {getAddressComponent, isAddressValidForVBA} from '../../src/libs/GooglePlacesUtils'; +import * as GooglePlacesUtils from '../../src/libs/GooglePlacesUtils'; describe('GooglePlacesUtilsTest', () => { describe('isAddressValidForVBA', () => { @@ -41,7 +41,7 @@ describe('GooglePlacesUtilsTest', () => { place_id: 'EihRdWFpbCBSaWRnZSBSZCwgRXNjb25kaWRvLCBDQSA5MjAyNywgVVNBIi4qLAoUChIJIQBiT7Pz24ARmaXMgCMhqAUSFAoSCXtDwoFe89uAEd_FlncPyNEB', types: ['route'], }; - const isValid = isAddressValidForVBA(googlePlacesRouteResult.address_components); + const isValid = GooglePlacesUtils.isAddressValidForVBA(googlePlacesRouteResult.address_components); expect(isValid).toStrictEqual(false); }); @@ -100,7 +100,7 @@ describe('GooglePlacesUtilsTest', () => { place_id: 'EiM2NCBOb2xsIFN0LCBCcm9va2x5biwgTlkgMTEyMDYsIFVTQSJQEk4KNAoyCReOha8HXMKJETjOQzBxX7M3Gh4LEO7B7qEBGhQKEgmJzguI-VvCiRFYR8sAAcN5KAwQQCoUChIJH0FG4AZcwokRvrvwkhWA_6A', types: ['street_address'], }; - const isValid = isAddressValidForVBA(brooklynAddressResult.address_components); + const isValid = GooglePlacesUtils.isAddressValidForVBA(brooklynAddressResult.address_components); expect(isValid).toStrictEqual(true); }); }); @@ -133,10 +133,10 @@ describe('GooglePlacesUtilsTest', () => { types: ['postal_code'], }, ]; - expect(getAddressComponent(addressComponents, 'sublocality', 'long_name')).toStrictEqual('Brooklyn'); - expect(getAddressComponent(addressComponents, 'administrative_area_level_1', 'short_name')).toStrictEqual('NY'); - expect(getAddressComponent(addressComponents, 'postal_code', 'long_name')).toStrictEqual('11206'); - expect(getAddressComponent(addressComponents, 'doesn-exist', 'long_name')).toStrictEqual(undefined); + expect(GooglePlacesUtils.getAddressComponent(addressComponents, 'sublocality', 'long_name')).toStrictEqual('Brooklyn'); + expect(GooglePlacesUtils.getAddressComponent(addressComponents, 'administrative_area_level_1', 'short_name')).toStrictEqual('NY'); + expect(GooglePlacesUtils.getAddressComponent(addressComponents, 'postal_code', 'long_name')).toStrictEqual('11206'); + expect(GooglePlacesUtils.getAddressComponent(addressComponents, 'doesn-exist', 'long_name')).toStrictEqual(undefined); }); }); }); diff --git a/tests/unit/NetworkTest.js b/tests/unit/NetworkTest.js index af2d90fcb6e1..5e4923f8517c 100644 --- a/tests/unit/NetworkTest.js +++ b/tests/unit/NetworkTest.js @@ -5,12 +5,12 @@ import { beforeEach, jest, test, expect, afterEach, } from '@jest/globals'; import * as API from '../../src/libs/API'; -import {signInWithTestUser} from '../utils/TestHelper'; +import * as TestHelper from '../utils/TestHelper'; import HttpUtils from '../../src/libs/HttpUtils'; import waitForPromisesToResolve from '../utils/waitForPromisesToResolve'; import ONYXKEYS from '../../src/ONYXKEYS'; import * as Network from '../../src/libs/Network'; -import {fetchAccountDetails} from '../../src/libs/actions/Session'; +import * as Session from '../../src/libs/actions/Session'; // Set up manual mocks for methods used in the actions so our test does not fail. jest.mock('../../src/libs/Notification/PushNotification', () => ({ @@ -49,7 +49,7 @@ test('failing to reauthenticate while offline should not log out user', () => { }); // Given a test user login and account ID - return signInWithTestUser(TEST_USER_ACCOUNT_ID, TEST_USER_LOGIN) + return TestHelper.signInWithTestUser(TEST_USER_ACCOUNT_ID, TEST_USER_LOGIN) .then(() => { expect(isOffline).toBe(null); @@ -150,7 +150,7 @@ test('consecutive API calls eventually succeed when authToken is expired', () => }); // When we sign in - return signInWithTestUser(TEST_USER_ACCOUNT_ID, TEST_USER_LOGIN) + return TestHelper.signInWithTestUser(TEST_USER_ACCOUNT_ID, TEST_USER_LOGIN) .then(() => { HttpUtils.xhr = jest.fn(); HttpUtils.xhr @@ -250,7 +250,7 @@ test('retry network request if auth and credentials are not read from Onyx yet', // When we make an arbitrary request that can be retried // And we wait for the Onyx.callbacks to be set - fetchAccountDetails(TEST_USER_LOGIN); + Session.fetchAccountDetails(TEST_USER_LOGIN); return waitForPromisesToResolve().then(() => { // Then we expect not having the Network ready and not making an http request expect(spyNetworkSetIsReady).not.toHaveBeenCalled(); diff --git a/tests/unit/OptionsListUtilsTest.js b/tests/unit/OptionsListUtilsTest.js index df49d4f11d48..df981f3631d5 100644 --- a/tests/unit/OptionsListUtilsTest.js +++ b/tests/unit/OptionsListUtilsTest.js @@ -4,7 +4,7 @@ import * as OptionsListUtils from '../../src/libs/OptionsListUtils'; import ONYXKEYS from '../../src/ONYXKEYS'; import waitForPromisesToResolve from '../utils/waitForPromisesToResolve'; import CONST from '../../src/CONST'; -import {setReportWithDraft} from '../../src/libs/actions/Report'; +import * as Report from '../../src/libs/actions/Report'; describe('OptionsListUtils', () => { // Given a set of reports with both single participants and multiple participants some pinned and some not @@ -559,7 +559,7 @@ describe('OptionsListUtils', () => { }, }; - return setReportWithDraft(1, true) + return Report.setReportWithDraft(1, true) .then(() => { // When we call getSidebarOptions() with no search value and default priority mode const results = OptionsListUtils.getSidebarOptions( @@ -594,7 +594,7 @@ describe('OptionsListUtils', () => { }); it('getSidebarOptions() with GSD priority mode', - () => setReportWithDraft(1, true) + () => Report.setReportWithDraft(1, true) .then(() => { // When we call getSidebarOptions() with no search value const results = OptionsListUtils.getSidebarOptions(REPORTS, PERSONAL_DETAILS, 0, CONST.PRIORITY_MODE.GSD); diff --git a/tests/unit/TranslateTest.js b/tests/unit/TranslateTest.js index 5d85bcd3f333..5504161a294f 100644 --- a/tests/unit/TranslateTest.js +++ b/tests/unit/TranslateTest.js @@ -1,6 +1,6 @@ const _ = require('underscore'); const {error: AnnotationError} = require('@actions/core'); -const translate = require('../../src/libs/translate'); +const Localize = require('../../src/libs/Localize'); const CONFIG = require('../../src/CONFIG'); const translations = require('../../src/languages/translations'); @@ -23,36 +23,36 @@ translations.default = { describe('translate', () => { it('Test present key in full locale', () => { - expect(translate.translate('es-ES', 'testKey1')).toBe('Spanish ES'); + expect(Localize.translate('es-ES', 'testKey1')).toBe('Spanish ES'); }); it('Test when key is not found in full locale, but present in language', () => { - expect(translate.translate('es-ES', 'testKey2')).toBe('Spanish Word 2'); - expect(translate.translate('es', 'testKey2')).toBe('Spanish Word 2'); + expect(Localize.translate('es-ES', 'testKey2')).toBe('Spanish Word 2'); + expect(Localize.translate('es', 'testKey2')).toBe('Spanish Word 2'); }); it('Test when key is not found in full locale and language, but present in default', () => { - expect(translate.translate('es-ES', 'testKey3')).toBe('Test Word 3'); + expect(Localize.translate('es-ES', 'testKey3')).toBe('Test Word 3'); }); test('Test when key is not found in default', () => { - expect(() => translate.translate('es-ES', 'testKey4')).toThrow(Error); - expect(() => translate.translate('es-ES', ['a', 'b', 'c'])).toThrow(Error); + expect(() => Localize.translate('es-ES', 'testKey4')).toThrow(Error); + expect(() => Localize.translate('es-ES', ['a', 'b', 'c'])).toThrow(Error); }); test('Test when key is not found in default (Production Mode)', () => { const ORIGINAL_IS_IN_PRODUCTION = CONFIG.default.IS_IN_PRODUCTION; CONFIG.default.IS_IN_PRODUCTION = true; - expect(translate.translate('es-ES', 'testKey4')).toBe('testKey4'); - expect(translate.translate('es-ES', ['a', 'b', 'c'])).toBe('a.b.c'); + expect(Localize.translate('es-ES', 'testKey4')).toBe('testKey4'); + expect(Localize.translate('es-ES', ['a', 'b', 'c'])).toBe('a.b.c'); CONFIG.default.IS_IN_PRODUCTION = ORIGINAL_IS_IN_PRODUCTION; }); it('Test when translation value is a function', () => { const expectedValue = 'With variable Test Variable'; const testVariable = 'Test Variable'; - expect(translate.translate('en', 'testKeyGroup.testFunction', {testVariable})).toBe(expectedValue); - expect(translate.translate('en', ['testKeyGroup', 'testFunction'], {testVariable})).toBe(expectedValue); + expect(Localize.translate('en', 'testKeyGroup.testFunction', {testVariable})).toBe(expectedValue); + expect(Localize.translate('en', ['testKeyGroup', 'testFunction'], {testVariable})).toBe(expectedValue); }); }); diff --git a/tests/utils/TestHelper.js b/tests/utils/TestHelper.js index f870cb61571c..e4efe68d1b99 100644 --- a/tests/utils/TestHelper.js +++ b/tests/utils/TestHelper.js @@ -1,5 +1,5 @@ -import {signIn, fetchAccountDetails} from '../../src/libs/actions/Session'; -import {fetchPersonalDetails} from '../../src/libs/actions/PersonalDetails'; +import * as Session from '../../src/libs/actions/Session'; +import * as PersonalDetails from '../../src/libs/actions/PersonalDetails'; import HttpUtils from '../../src/libs/HttpUtils'; import waitForPromisesToResolve from './waitForPromisesToResolve'; @@ -24,7 +24,7 @@ function signInWithTestUser(accountID = 1, login = 'test@user.com', password = ' })); // Simulate user entering their login and populating the credentials.login - fetchAccountDetails(login); + Session.fetchAccountDetails(login); return waitForPromisesToResolve() .then(() => { // First call to Authenticate @@ -43,7 +43,7 @@ function signInWithTestUser(accountID = 1, login = 'test@user.com', password = ' authToken, email: login, })); - signIn(password); + Session.signIn(password); return waitForPromisesToResolve() .then(() => { HttpUtils.xhr = originalXhr; @@ -70,7 +70,7 @@ function fetchPersonalDetailsForTestUser(accountID, email, personalDetailsList) personalDetailsList, })); - fetchPersonalDetails(); + PersonalDetails.fetchPersonalDetails(); return waitForPromisesToResolve() .then(() => { HttpUtils.xhr = originalXHR;