From 7503447ca1428a55e701d961565bec5d0be1984c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Henriques?= Date: Fri, 19 Apr 2024 12:06:57 +0100 Subject: [PATCH 1/3] Remove almost all JS leftovers --- src/CONST.ts | 71 ++++--- src/components/Modal/modalPropTypes.js | 89 --------- src/components/PDFView/pdfViewPropTypes.js | 51 ----- src/components/Popover/popoverPropTypes.js | 48 ----- .../Reactions/EmojiReactionsPropTypes.js | 31 --- .../BaseTextInput/baseTextInputPropTypes.js | 139 -------------- .../textInputWithCurrencySymbolPropTypes.js | 49 ----- src/components/bankAccountPropTypes.js | 15 -- src/components/cardPropTypes.js | 12 -- src/components/menuItemPropTypes.js | 179 ------------------ src/components/networkPropTypes.js | 12 -- src/components/refPropTypes.js | 3 - src/components/taxPropTypes.js | 29 --- src/components/transactionsDraftPropTypes.js | 37 ---- .../withCurrentUserPersonalDetails.tsx | 11 -- src/libs/actions/BankAccounts.ts | 3 +- src/libs/actions/Plaid.ts | 4 +- .../resetFreePlanBankAccount.ts | 6 +- .../EnablePayments/userWalletPropTypes.js | 31 --- .../BankInfo/substeps/Confirmation.tsx | 2 +- .../ConfirmationUBO.tsx | 2 +- .../substeps/ConfirmationBusiness.tsx | 2 +- .../PersonalInfo/substeps/Confirmation.tsx | 2 +- .../ReimbursementAccountPage.tsx | 5 +- .../plaidDataPropTypes.js | 52 ----- .../reimbursementAccountPropTypes.js | 47 ----- .../validateLinkPropTypes.js | 24 --- .../home/report/reportActionSourcePropType.js | 3 - .../step/IOURequestStepRoutePropTypes.js | 29 --- src/pages/iouReportPropTypes.js | 18 -- src/pages/nextStepPropTypes.js | 48 ----- src/pages/personalDetailsPropType.js | 53 ------ src/pages/policyMemberPropType.js | 15 -- src/pages/reportMetadataPropTypes.js | 12 -- src/pages/safeAreaInsetPropTypes.js | 10 - .../settings/Wallet/assignedCardPropTypes.js | 18 -- .../workspace/WorkspacePageWithSections.tsx | 4 +- src/pages/workspace/withPolicy.tsx | 31 ++- src/types/onyx/PlaidData.ts | 1 + 39 files changed, 89 insertions(+), 1109 deletions(-) delete mode 100644 src/components/Modal/modalPropTypes.js delete mode 100644 src/components/PDFView/pdfViewPropTypes.js delete mode 100644 src/components/Popover/popoverPropTypes.js delete mode 100644 src/components/Reactions/EmojiReactionsPropTypes.js delete mode 100644 src/components/TextInput/BaseTextInput/baseTextInputPropTypes.js delete mode 100644 src/components/TextInputWithCurrencySymbol/textInputWithCurrencySymbolPropTypes.js delete mode 100644 src/components/bankAccountPropTypes.js delete mode 100644 src/components/cardPropTypes.js delete mode 100644 src/components/menuItemPropTypes.js delete mode 100644 src/components/networkPropTypes.js delete mode 100644 src/components/refPropTypes.js delete mode 100644 src/components/taxPropTypes.js delete mode 100644 src/components/transactionsDraftPropTypes.js delete mode 100644 src/pages/EnablePayments/userWalletPropTypes.js delete mode 100644 src/pages/ReimbursementAccount/plaidDataPropTypes.js delete mode 100644 src/pages/ReimbursementAccount/reimbursementAccountPropTypes.js delete mode 100644 src/pages/ValidateLoginPage/validateLinkPropTypes.js delete mode 100644 src/pages/home/report/reportActionSourcePropType.js delete mode 100644 src/pages/iou/request/step/IOURequestStepRoutePropTypes.js delete mode 100644 src/pages/iouReportPropTypes.js delete mode 100644 src/pages/nextStepPropTypes.js delete mode 100644 src/pages/personalDetailsPropType.js delete mode 100644 src/pages/policyMemberPropType.js delete mode 100644 src/pages/reportMetadataPropTypes.js delete mode 100644 src/pages/safeAreaInsetPropTypes.js delete mode 100644 src/pages/settings/Wallet/assignedCardPropTypes.js diff --git a/src/CONST.ts b/src/CONST.ts index a840cb481a1a..078612dbe0cb 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -4,6 +4,7 @@ import dateSubtract from 'date-fns/sub'; import Config from 'react-native-config'; import * as KeyCommand from 'react-native-key-command'; import type {ValueOf} from 'type-fest'; +import BankAccount from './libs/models/BankAccount'; import * as Url from './libs/Url'; import SCREENS from './SCREENS'; @@ -1343,6 +1344,14 @@ const CONST = { ERROR: 'ERROR', EXIT: 'EXIT', }, + DEFAULT_DATA: { + bankName: '', + plaidAccessToken: '', + bankAccounts: [] as [], + isLoading: false, + error: '', + errors: {}, + }, }, ONFIDO: { @@ -3625,31 +3634,43 @@ const CONST = { DEBUG: 'DEBUG', }, }, - REIMBURSEMENT_ACCOUNT_SUBSTEP_INDEX: { - BANK_ACCOUNT: { - ACCOUNT_NUMBERS: 0, - }, - PERSONAL_INFO: { - LEGAL_NAME: 0, - DATE_OF_BIRTH: 1, - SSN: 2, - ADDRESS: 3, - }, - BUSINESS_INFO: { - BUSINESS_NAME: 0, - TAX_ID_NUMBER: 1, - COMPANY_WEBSITE: 2, - PHONE_NUMBER: 3, - COMPANY_ADDRESS: 4, - COMPANY_TYPE: 5, - INCORPORATION_DATE: 6, - INCORPORATION_STATE: 7, - }, - UBO: { - LEGAL_NAME: 0, - DATE_OF_BIRTH: 1, - SSN: 2, - ADDRESS: 3, + REIMBURSEMENT_ACCOUNT: { + DEFAULT_DATA: { + achData: { + state: BankAccount.STATE.SETUP, + }, + isLoading: false, + errorFields: {}, + errors: {}, + maxAttemptsReached: false, + shouldShowResetModal: false, + }, + SUBSTEP_INDEX: { + BANK_ACCOUNT: { + ACCOUNT_NUMBERS: 0, + }, + PERSONAL_INFO: { + LEGAL_NAME: 0, + DATE_OF_BIRTH: 1, + SSN: 2, + ADDRESS: 3, + }, + BUSINESS_INFO: { + BUSINESS_NAME: 0, + TAX_ID_NUMBER: 1, + COMPANY_WEBSITE: 2, + PHONE_NUMBER: 3, + COMPANY_ADDRESS: 4, + COMPANY_TYPE: 5, + INCORPORATION_DATE: 6, + INCORPORATION_STATE: 7, + }, + UBO: { + LEGAL_NAME: 0, + DATE_OF_BIRTH: 1, + SSN: 2, + ADDRESS: 3, + }, }, }, CURRENCY_TO_DEFAULT_MILEAGE_RATE: JSON.parse(`{ diff --git a/src/components/Modal/modalPropTypes.js b/src/components/Modal/modalPropTypes.js deleted file mode 100644 index 84e610b694e4..000000000000 --- a/src/components/Modal/modalPropTypes.js +++ /dev/null @@ -1,89 +0,0 @@ -import PropTypes from 'prop-types'; -import _ from 'underscore'; -import {windowDimensionsPropTypes} from '@components/withWindowDimensions'; -import stylePropTypes from '@styles/stylePropTypes'; -import CONST from '@src/CONST'; - -const propTypes = { - /** Decides whether the modal should cover fullscreen. FullScreen modal has backdrop */ - fullscreen: PropTypes.bool, - - /** Should we close modal on outside click */ - shouldCloseOnOutsideClick: PropTypes.bool, - - /** Should we announce the Modal visibility changes? */ - shouldSetModalVisibility: PropTypes.bool, - - /** Callback method fired when the user requests to close the modal */ - onClose: PropTypes.func.isRequired, - - /** State that determines whether to display the modal or not */ - isVisible: PropTypes.bool.isRequired, - - /** Modal contents */ - children: PropTypes.node.isRequired, - - /** Callback method fired when the user requests to submit the modal content. */ - onSubmit: PropTypes.func, - - /** Callback method fired when the modal is hidden */ - onModalHide: PropTypes.func, - - /** Callback method fired when the modal is shown */ - onModalShow: PropTypes.func, - - /** Style of modal to display */ - type: PropTypes.oneOf(_.values(CONST.MODAL.MODAL_TYPE)), - - /** A react-native-animatable animation definition for the modal display animation. */ - animationIn: PropTypes.oneOfType([PropTypes.string, PropTypes.object]), - - /** A react-native-animatable animation definition for the modal hide animation. */ - animationOut: PropTypes.oneOfType([PropTypes.string, PropTypes.object]), - - /** The anchor position of a popover modal. Has no effect on other modal types. */ - popoverAnchorPosition: PropTypes.shape({ - top: PropTypes.number, - right: PropTypes.number, - bottom: PropTypes.number, - left: PropTypes.number, - }), - - /** Modal container styles */ - innerContainerStyle: stylePropTypes, - - /** Whether the modal should go under the system statusbar */ - statusBarTranslucent: PropTypes.bool, - - /** Whether the modal should avoid the keyboard */ - avoidKeyboard: PropTypes.bool, - - /** - * Whether the modal should hide its content while animating. On iOS, set to true - * if `useNativeDriver` is also true, to avoid flashes in the UI. - * - * See: https://github.com/react-native-modal/react-native-modal/pull/116 - * */ - hideModalContentWhileAnimating: PropTypes.bool, - - ...windowDimensionsPropTypes, -}; - -const defaultProps = { - fullscreen: true, - shouldCloseOnOutsideClick: false, - shouldSetModalVisibility: true, - onSubmit: null, - type: '', - onModalHide: () => {}, - onModalShow: () => {}, - animationIn: null, - animationOut: null, - popoverAnchorPosition: {}, - innerContainerStyle: {}, - statusBarTranslucent: true, - avoidKeyboard: false, - hideModalContentWhileAnimating: false, -}; - -export {propTypes, defaultProps}; diff --git a/src/components/PDFView/pdfViewPropTypes.js b/src/components/PDFView/pdfViewPropTypes.js deleted file mode 100644 index 546f9b1a8933..000000000000 --- a/src/components/PDFView/pdfViewPropTypes.js +++ /dev/null @@ -1,51 +0,0 @@ -import PropTypes from 'prop-types'; -import {withThemeStylesPropTypes} from '@components/withThemeStyles'; -import {windowDimensionsPropTypes} from '@components/withWindowDimensions'; -import stylePropTypes from '@styles/stylePropTypes'; - -const propTypes = { - /** URL to full-sized image */ - sourceURL: PropTypes.string, - - /** PDF file name */ - fileName: PropTypes.string, - - /** Additional style props */ - style: stylePropTypes, - - /** Notify parent that the keyboard has opened or closed */ - onToggleKeyboard: PropTypes.func, - - /** Handles press events like toggling attachment arrows natively */ - onPress: PropTypes.func, - - /** Handles scale changed event in PDF component */ - onScaleChanged: PropTypes.func, - - /** Handles load complete event in PDF component */ - onLoadComplete: PropTypes.func, - - /** Should focus to the password input */ - isFocused: PropTypes.bool, - - /** Styles for the error label */ - errorLabelStyles: stylePropTypes, - - ...windowDimensionsPropTypes, - - ...withThemeStylesPropTypes, -}; - -const defaultProps = { - sourceURL: '', - fileName: '', - style: {}, - onPress: undefined, - onToggleKeyboard: () => {}, - onScaleChanged: () => {}, - onLoadComplete: () => {}, - isFocused: false, - errorLabelStyles: [], -}; - -export {propTypes, defaultProps}; diff --git a/src/components/Popover/popoverPropTypes.js b/src/components/Popover/popoverPropTypes.js deleted file mode 100644 index c758c4e6d311..000000000000 --- a/src/components/Popover/popoverPropTypes.js +++ /dev/null @@ -1,48 +0,0 @@ -import PropTypes from 'prop-types'; -import _ from 'underscore'; -import {defaultProps as defaultModalProps, propTypes as modalPropTypes} from '@components/Modal/modalPropTypes'; -import refPropTypes from '@components/refPropTypes'; -import CONST from '@src/CONST'; - -const propTypes = { - ..._.omit(modalPropTypes, ['type', 'popoverAnchorPosition']), - - /** The anchor position of the popover */ - anchorPosition: PropTypes.shape({ - top: PropTypes.number, - right: PropTypes.number, - bottom: PropTypes.number, - left: PropTypes.number, - }), - - /** The anchor ref of the popover */ - anchorRef: refPropTypes, - - /** A react-native-animatable animation timing for the modal display animation. */ - animationInTiming: PropTypes.number, - - /** Whether disable the animations */ - disableAnimation: PropTypes.bool, - - /** The ref of the popover */ - withoutOverlayRef: refPropTypes, - - /** Whether we want to show the popover on the right side of the screen */ - fromSidebarMediumScreen: PropTypes.bool, -}; - -const defaultProps = { - ..._.omit(defaultModalProps, ['type', 'popoverAnchorPosition']), - - animationIn: 'fadeIn', - animationOut: 'fadeOut', - animationInTiming: CONST.ANIMATED_TRANSITION, - - // Anchor position is optional only because it is not relevant on mobile - anchorPosition: {}, - anchorRef: () => {}, - disableAnimation: true, - withoutOverlayRef: () => {}, -}; - -export {propTypes, defaultProps}; diff --git a/src/components/Reactions/EmojiReactionsPropTypes.js b/src/components/Reactions/EmojiReactionsPropTypes.js deleted file mode 100644 index ace88abefcd9..000000000000 --- a/src/components/Reactions/EmojiReactionsPropTypes.js +++ /dev/null @@ -1,31 +0,0 @@ -import PropTypes from 'prop-types'; - -/** All the emoji reactions for the report action. An object that looks like this: - "emojiReactions": { - "+1": { // The emoji added to the action - "createdAt": "2021-01-01 00:00:00", - "users": { - 2352342: { // The accountID of the user who added this emoji - "skinTones": { - "1": "2021-01-01 00:00:00", - "2": "2021-01-01 00:00:00", - }, - }, - }, - }, - }, -*/ -export default PropTypes.objectOf( - PropTypes.shape({ - /** The time the emoji was added */ - createdAt: PropTypes.string, - - /** All the users who have added this emoji */ - users: PropTypes.objectOf( - PropTypes.shape({ - /** The skin tone which was used and also the timestamp of when it was added */ - skinTones: PropTypes.objectOf(PropTypes.string), - }), - ), - }), -); diff --git a/src/components/TextInput/BaseTextInput/baseTextInputPropTypes.js b/src/components/TextInput/BaseTextInput/baseTextInputPropTypes.js deleted file mode 100644 index b0a73a650d82..000000000000 --- a/src/components/TextInput/BaseTextInput/baseTextInputPropTypes.js +++ /dev/null @@ -1,139 +0,0 @@ -import PropTypes from 'prop-types'; -import sourcePropTypes from '@components/Image/sourcePropTypes'; -import {translatableTextPropTypes} from '@libs/Localize'; - -const propTypes = { - /** Input label */ - label: PropTypes.string, - - /** Name attribute for the input */ - name: PropTypes.string, - - /** Input value */ - value: PropTypes.string, - - /** Default value - used for non controlled inputs */ - defaultValue: PropTypes.string, - - /** Input value placeholder */ - placeholder: PropTypes.string, - - /** Error text to display */ - errorText: translatableTextPropTypes, - - /** Icon to display in right side of text input */ - icon: sourcePropTypes, - - /** Customize the TextInput container */ - textInputContainerStyles: PropTypes.arrayOf(PropTypes.object), - - /** Customizes the touchable wrapper of the TextInput component */ - touchableInputWrapperStyle: PropTypes.arrayOf(PropTypes.object), - - /** Customize the main container */ - containerStyles: PropTypes.arrayOf(PropTypes.object), - - /** input style */ - inputStyle: PropTypes.arrayOf(PropTypes.object), - - /** If present, this prop forces the label to remain in a position where it will not collide with input text */ - forceActiveLabel: PropTypes.bool, - - /** Should the input auto focus? */ - autoFocus: PropTypes.bool, - - /** Disable the virtual keyboard */ - disableKeyboard: PropTypes.bool, - - /** - * Autogrow input container length based on the entered text. - * Note: If you use this prop, the text input has to be controlled - * by a value prop. - */ - autoGrow: PropTypes.bool, - - /** - * Autogrow input container height based on the entered text - * Note: If you use this prop, the text input has to be controlled - * by a value prop. - */ - autoGrowHeight: PropTypes.bool, - - /** Hide the focus styles on TextInput */ - hideFocusedState: PropTypes.bool, - - /** Forward the inner ref */ - innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), - - /** Maximum characters allowed */ - maxLength: PropTypes.number, - - /** Hint text to display below the TextInput */ - hint: translatableTextPropTypes, - - /** Prefix character */ - prefixCharacter: PropTypes.string, - - /** Whether autoCorrect functionality should enable */ - autoCorrect: PropTypes.bool, - - /** Form props */ - /** The ID used to uniquely identify the input in a Form */ - inputID: PropTypes.string, - - /** Saves a draft of the input value when used in a form */ - shouldSaveDraft: PropTypes.bool, - - /** Callback to update the value on Form when input is used in the Form component. */ - onInputChange: PropTypes.func, - - /** Whether we should wait before focusing the TextInput, useful when using transitions */ - shouldDelayFocus: PropTypes.bool, - - /** Indicate whether input is multiline */ - multiline: PropTypes.bool, - - /** Set the default value to the input if there is a valid saved value */ - shouldUseDefaultValue: PropTypes.bool, - - /** Indicate whether or not the input should prevent swipe actions in tabs */ - shouldInterceptSwipe: PropTypes.bool, -}; - -const defaultProps = { - label: '', - name: '', - errorText: '', - placeholder: '', - hasError: false, - containerStyles: [], - textInputContainerStyles: [], - inputStyle: [], - autoFocus: false, - autoCorrect: true, - - /** - * To be able to function as either controlled or uncontrolled component we should not - * assign a default prop value for `value` or `defaultValue` props - */ - value: undefined, - defaultValue: undefined, - forceActiveLabel: false, - disableKeyboard: false, - autoGrow: false, - autoGrowHeight: false, - hideFocusedState: false, - innerRef: () => {}, - shouldSaveDraft: false, - maxLength: null, - hint: '', - prefixCharacter: '', - onInputChange: () => {}, - shouldDelayFocus: false, - icon: null, - shouldUseDefaultValue: false, - multiline: false, - shouldInterceptSwipe: false, -}; - -export {propTypes, defaultProps}; diff --git a/src/components/TextInputWithCurrencySymbol/textInputWithCurrencySymbolPropTypes.js b/src/components/TextInputWithCurrencySymbol/textInputWithCurrencySymbolPropTypes.js deleted file mode 100644 index bf292b331b81..000000000000 --- a/src/components/TextInputWithCurrencySymbol/textInputWithCurrencySymbolPropTypes.js +++ /dev/null @@ -1,49 +0,0 @@ -import PropTypes from 'prop-types'; -import refPropTypes from '@components/refPropTypes'; - -const propTypes = { - /** A ref to forward to amount text input */ - forwardedRef: refPropTypes, - - /** Formatted amount in local currency */ - formattedAmount: PropTypes.string.isRequired, - - /** Function to call when amount in text input is changed */ - onChangeAmount: PropTypes.func, - - /** Function to call when currency button is pressed */ - onCurrencyButtonPress: PropTypes.func, - - /** Placeholder value for amount text input */ - placeholder: PropTypes.string.isRequired, - - /** Currency code of user's selected currency */ - selectedCurrencyCode: PropTypes.string.isRequired, - - /** Selection Object */ - selection: PropTypes.shape({ - start: PropTypes.number, - end: PropTypes.number, - }), - - /** Function to call when selection in text input is changed */ - onSelectionChange: PropTypes.func, - - /** Function to call to handle key presses in the text input */ - onKeyPress: PropTypes.func, - - /** Whether the currency symbol is pressable */ - isCurrencyPressable: PropTypes.bool, -}; - -const defaultProps = { - forwardedRef: undefined, - onChangeAmount: () => {}, - onCurrencyButtonPress: () => {}, - selection: undefined, - onSelectionChange: () => {}, - onKeyPress: () => {}, - isCurrencyPressable: true, -}; - -export {propTypes, defaultProps}; diff --git a/src/components/bankAccountPropTypes.js b/src/components/bankAccountPropTypes.js deleted file mode 100644 index 3331a617cbce..000000000000 --- a/src/components/bankAccountPropTypes.js +++ /dev/null @@ -1,15 +0,0 @@ -import PropTypes from 'prop-types'; - -export default PropTypes.shape({ - /** The name of the institution (bank of america, etc */ - addressName: PropTypes.string, - - /** The masked bank account number */ - accountNumber: PropTypes.string, - - /** The bankAccountID in the bankAccounts db */ - bankAccountID: PropTypes.number, - - /** The bank account type */ - type: PropTypes.string, -}); diff --git a/src/components/cardPropTypes.js b/src/components/cardPropTypes.js deleted file mode 100644 index 306f10a992c1..000000000000 --- a/src/components/cardPropTypes.js +++ /dev/null @@ -1,12 +0,0 @@ -import PropTypes from 'prop-types'; - -export default PropTypes.shape({ - /** The name of the institution (bank of america, etc) */ - cardName: PropTypes.string, - - /** The masked credit card number */ - cardNumber: PropTypes.string, - - /** The ID of the card in the cards DB */ - cardID: PropTypes.number, -}); diff --git a/src/components/menuItemPropTypes.js b/src/components/menuItemPropTypes.js deleted file mode 100644 index 80ae1edd5176..000000000000 --- a/src/components/menuItemPropTypes.js +++ /dev/null @@ -1,179 +0,0 @@ -import PropTypes from 'prop-types'; -import _ from 'underscore'; -import stylePropTypes from '@styles/stylePropTypes'; -import CONST from '@src/CONST'; -import avatarPropTypes from './avatarPropTypes'; -import sourcePropTypes from './Image/sourcePropTypes'; -import refPropTypes from './refPropTypes'; - -const propTypes = { - /** Text to be shown as badge near the right end. */ - badgeText: PropTypes.string, - - /** Any additional styles to apply */ - // eslint-disable-next-line react/forbid-prop-types - wrapperStyle: stylePropTypes, - - /** Used to apply offline styles to child text components */ - style: stylePropTypes, - - /** Used to apply styles specifically to the title */ - titleStyle: stylePropTypes, - - /** Function to fire when component is pressed */ - onPress: PropTypes.func, - - /** Icon to display on the left side of component */ - icon: PropTypes.oneOfType([PropTypes.string, sourcePropTypes, PropTypes.arrayOf(avatarPropTypes)]), - - /** Secondary icon to display on the left side of component, right of the icon */ - secondaryIcon: sourcePropTypes, - - /** Icon Width */ - iconWidth: PropTypes.number, - - /** Icon Height */ - iconHeight: PropTypes.number, - - /** Text to display for the item */ - title: PropTypes.string, - - /** Text that appears above the title */ - label: PropTypes.string, - - /** Boolean whether to display the title right icon */ - shouldShowTitleIcon: PropTypes.bool, - - /** Icon to display at right side of title */ - titleIcon: sourcePropTypes, - - /** Boolean whether to display the right icon */ - shouldShowRightIcon: PropTypes.bool, - - /** Should we make this selectable with a checkbox */ - shouldShowSelectedState: PropTypes.bool, - - /** Should the title show with normal font weight (not bold) */ - shouldShowBasicTitle: PropTypes.bool, - - /** Should the description be shown above the title (instead of the other way around) */ - shouldShowDescriptionOnTop: PropTypes.bool, - - /** Whether this item is selected */ - isSelected: PropTypes.bool, - - /** A boolean flag that gives the icon a green fill if true */ - success: PropTypes.bool, - - /** Overrides the icon for shouldShowRightIcon */ - iconRight: sourcePropTypes, - - /** A description text to show under the title */ - description: PropTypes.string, - - /** Any additional styles to pass to the icon container. */ - iconStyles: PropTypes.arrayOf(PropTypes.object), - - /** The fill color to pass into the icon. */ - iconFill: PropTypes.string, - - /** The fill color to pass into the secondary icon. */ - secondaryIconFill: PropTypes.string, - - /** Whether item is focused or active */ - focused: PropTypes.bool, - - /** Should we disable this menu item? */ - disabled: PropTypes.bool, - - /** A right-aligned subtitle for this menu option */ - subtitle: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), - - /** Flag to choose between avatar image or an icon */ - iconType: PropTypes.oneOf([CONST.ICON_TYPE_AVATAR, CONST.ICON_TYPE_ICON, CONST.ICON_TYPE_WORKSPACE]), - - /** Whether the menu item should be interactive at all */ - interactive: PropTypes.bool, - - /** A fallback avatar icon to display when there is an error on loading avatar from remote URL. */ - fallbackIcon: PropTypes.oneOfType([PropTypes.string, sourcePropTypes]), - - /** Avatars to show on the right of the menu item */ - floatRightAvatars: PropTypes.arrayOf(avatarPropTypes), - - /** The type of brick road indicator to show. */ - brickRoadIndicator: PropTypes.oneOf([CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR, CONST.BRICK_ROAD_INDICATOR_STATUS.INFO, '']), - - /** Prop to identify if we should load avatars vertically instead of diagonally */ - shouldStackHorizontally: PropTypes.bool, - - /** Prop to represent the size of the float right avatar images to be shown */ - floatRightAvatarSize: PropTypes.oneOf(_.values(CONST.AVATAR_SIZE)), - - /** Prop to represent the size of the avatar images to be shown */ - avatarSize: PropTypes.oneOf(_.values(CONST.AVATAR_SIZE)), - - /** The function that should be called when this component is LongPressed or right-clicked. */ - onSecondaryInteraction: PropTypes.func, - - /** Flag to indicate whether or not text selection should be disabled from long-pressing the menu item. */ - shouldBlockSelection: PropTypes.bool, - - /** The ref to the menu item */ - forwardedRef: refPropTypes, - - /** Any adjustments to style when menu item is hovered or pressed */ - hoverAndPressStyle: PropTypes.arrayOf(PropTypes.object), - - /** Text to display under the main item */ - furtherDetails: PropTypes.string, - - /** An icon to display under the main item */ - furtherDetailsIcon: PropTypes.oneOfType([PropTypes.elementType, PropTypes.string]), - - /** The action accept for anonymous user or not */ - isAnonymousAction: PropTypes.bool, - - /** Whether we should use small avatar subscript sizing the for menu item */ - isSmallAvatarSubscriptMenu: PropTypes.bool, - - /** The max number of lines the title text should occupy before ellipses are added */ - numberOfLines: PropTypes.number, - - /** Should we grey out the menu item when it is disabled? */ - shouldGreyOutWhenDisabled: PropTypes.bool, - - /** Error to display below the title */ - error: PropTypes.string, - - /** Should render the content in HTML format */ - shouldRenderAsHTML: PropTypes.bool, - - /** Label to be displayed on the right */ - rightLabel: PropTypes.string, - - /** Component to be displayed on the right */ - rightComponent: PropTypes.node, - - /** Should render component on the right */ - shouldShowRightComponent: PropTypes.bool, - - /** Array of objects that map display names to their corresponding tooltip */ - titleWithTooltips: PropTypes.arrayOf(PropTypes.object), - - /** Should check anonymous user in onPress function */ - shouldCheckActionAllowedOnPress: PropTypes.bool, - - shouldPutLeftPaddingWhenNoIcon: PropTypes.bool, - - /** The menu item link or function to get the link */ - link: PropTypes.oneOfType(PropTypes.func, PropTypes.string), - - /** Icon should be displayed in its own color */ - displayInDefaultIconColor: PropTypes.bool, - - /** Is this menu item in the settings pane */ - isPaneMenu: PropTypes.bool, -}; - -export default propTypes; diff --git a/src/components/networkPropTypes.js b/src/components/networkPropTypes.js deleted file mode 100644 index 40cbf990d81f..000000000000 --- a/src/components/networkPropTypes.js +++ /dev/null @@ -1,12 +0,0 @@ -import PropTypes from 'prop-types'; - -export default PropTypes.shape({ - /** Is the network currently offline or not */ - isOffline: PropTypes.bool, - - /** Should the network be forced offline */ - shouldForceOffline: PropTypes.bool, - - /** Whether we should fail all network requests */ - shouldFailAllRequests: PropTypes.bool, -}); diff --git a/src/components/refPropTypes.js b/src/components/refPropTypes.js deleted file mode 100644 index a67f6323d1d9..000000000000 --- a/src/components/refPropTypes.js +++ /dev/null @@ -1,3 +0,0 @@ -import PropTypes from 'prop-types'; - -export default PropTypes.oneOfType([PropTypes.func, PropTypes.object]); diff --git a/src/components/taxPropTypes.js b/src/components/taxPropTypes.js deleted file mode 100644 index 98c3a4a75257..000000000000 --- a/src/components/taxPropTypes.js +++ /dev/null @@ -1,29 +0,0 @@ -import PropTypes from 'prop-types'; - -const taxPropTypes = PropTypes.shape({ - /** Name of a tax */ - name: PropTypes.string, - - /** The value of a tax */ - value: PropTypes.string, - - /** Whether the tax is disabled */ - isDisabled: PropTypes.bool, -}); - -export default PropTypes.shape({ - /** Name of the tax */ - name: PropTypes.string, - - /** Default policy tax ID */ - defaultExternalID: PropTypes.string, - - /** Default value of taxes */ - defaultValue: PropTypes.string, - - /** Default foreign policy tax ID */ - foreignTaxDefault: PropTypes.string, - - /** List of tax names and values */ - taxes: PropTypes.objectOf(taxPropTypes), -}); diff --git a/src/components/transactionsDraftPropTypes.js b/src/components/transactionsDraftPropTypes.js deleted file mode 100644 index ca14c4537aa7..000000000000 --- a/src/components/transactionsDraftPropTypes.js +++ /dev/null @@ -1,37 +0,0 @@ -import PropTypes from 'prop-types'; - -const dataPropTypes = PropTypes.shape({ - name: PropTypes.string.isRequired, - value: PropTypes.string.isRequired, - code: PropTypes.string, -}); - -const taxRatePropTypes = PropTypes.shape({ - text: PropTypes.string.isRequired, - keyForList: PropTypes.string.isRequired, - searchText: PropTypes.string.isRequired, - tooltipText: PropTypes.string.isRequired, - isDisabled: PropTypes.bool, - data: dataPropTypes, -}); - -const transactionsDraftPropTypes = PropTypes.shape({ - taxRate: taxRatePropTypes, - taxAmount: PropTypes.number, -}); - -const taxRateDefaultProps = { - text: '', - keyForList: '', - searchText: '', - tooltipText: '', - isDisabled: false, - data: {}, -}; - -const transactionsDraftDefaultProps = { - taxRate: taxRateDefaultProps, - taxAmount: 0, -}; - -export {transactionsDraftPropTypes, transactionsDraftDefaultProps}; diff --git a/src/components/withCurrentUserPersonalDetails.tsx b/src/components/withCurrentUserPersonalDetails.tsx index 8431ededcb56..8bbaf1c9305c 100644 --- a/src/components/withCurrentUserPersonalDetails.tsx +++ b/src/components/withCurrentUserPersonalDetails.tsx @@ -2,7 +2,6 @@ import type {ComponentType, ForwardedRef, RefAttributes} from 'react'; import React from 'react'; import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import getComponentDisplayName from '@libs/getComponentDisplayName'; -import personalDetailsPropType from '@pages/personalDetailsPropType'; import type {PersonalDetails} from '@src/types/onyx'; type CurrentUserPersonalDetails = PersonalDetails | Record; @@ -13,15 +12,6 @@ type HOCProps = { type WithCurrentUserPersonalDetailsProps = HOCProps; -// TODO: remove when all components that use it will be migrated to TS -const withCurrentUserPersonalDetailsPropTypes = { - currentUserPersonalDetails: personalDetailsPropType, -}; - -const withCurrentUserPersonalDetailsDefaultProps: HOCProps = { - currentUserPersonalDetails: {}, -}; - export default function ( WrappedComponent: ComponentType>, ): ComponentType & RefAttributes> { @@ -42,5 +32,4 @@ export default function { Onyx.set(ONYXKEYS.PLAID_LINK_TOKEN, ''); Onyx.set(ONYXKEYS.PLAID_CURRENT_EVENT, null); - return Onyx.set(ONYXKEYS.PLAID_DATA, PlaidDataProps.plaidDataDefaultProps); + return Onyx.set(ONYXKEYS.PLAID_DATA, CONST.PLAID.DEFAULT_DATA); } function openPlaidView() { diff --git a/src/libs/actions/Plaid.ts b/src/libs/actions/Plaid.ts index 7f63b3920e01..e44e72579819 100644 --- a/src/libs/actions/Plaid.ts +++ b/src/libs/actions/Plaid.ts @@ -3,7 +3,7 @@ import * as API from '@libs/API'; import type {OpenPlaidBankAccountSelectorParams, OpenPlaidBankLoginParams} from '@libs/API/parameters'; import {READ_COMMANDS} from '@libs/API/types'; import getPlaidLinkTokenParameters from '@libs/getPlaidLinkTokenParameters'; -import * as PlaidDataProps from '@pages/ReimbursementAccount/plaidDataPropTypes'; +import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; /** @@ -24,7 +24,7 @@ function openPlaidBankLogin(allowDebit: boolean, bankAccountID: number) { { onyxMethod: Onyx.METHOD.SET, key: ONYXKEYS.PLAID_DATA, - value: {...PlaidDataProps.plaidDataDefaultProps, isLoading: true}, + value: {...CONST.PLAID.DEFAULT_DATA, isLoading: true}, }, { onyxMethod: Onyx.METHOD.SET, diff --git a/src/libs/actions/ReimbursementAccount/resetFreePlanBankAccount.ts b/src/libs/actions/ReimbursementAccount/resetFreePlanBankAccount.ts index 41fa0a4ccbd0..3ad8b9ffe599 100644 --- a/src/libs/actions/ReimbursementAccount/resetFreePlanBankAccount.ts +++ b/src/libs/actions/ReimbursementAccount/resetFreePlanBankAccount.ts @@ -3,8 +3,6 @@ import Onyx from 'react-native-onyx'; import * as API from '@libs/API'; import {WRITE_COMMANDS} from '@libs/API/types'; import {getDefaultCompanyWebsite} from '@libs/BankAccountUtils'; -import * as PlaidDataProps from '@pages/ReimbursementAccount/plaidDataPropTypes'; -import * as ReimbursementAccountProps from '@pages/ReimbursementAccount/reimbursementAccountPropTypes'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import INPUT_IDS from '@src/types/form/ReimbursementAccountForm'; @@ -71,7 +69,7 @@ function resetFreePlanBankAccount(bankAccountID: number | undefined, session: On { onyxMethod: Onyx.METHOD.SET, key: ONYXKEYS.PLAID_DATA, - value: PlaidDataProps.plaidDataDefaultProps, + value: CONST.PLAID.DEFAULT_DATA, }, { onyxMethod: Onyx.METHOD.SET, @@ -82,7 +80,7 @@ function resetFreePlanBankAccount(bankAccountID: number | undefined, session: On { onyxMethod: Onyx.METHOD.SET, key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, - value: ReimbursementAccountProps.reimbursementAccountDefaultProps, + value: CONST.REIMBURSEMENT_ACCOUNT.DEFAULT_DATA, }, { onyxMethod: Onyx.METHOD.SET, diff --git a/src/pages/EnablePayments/userWalletPropTypes.js b/src/pages/EnablePayments/userWalletPropTypes.js deleted file mode 100644 index 53332479d4ec..000000000000 --- a/src/pages/EnablePayments/userWalletPropTypes.js +++ /dev/null @@ -1,31 +0,0 @@ -import PropTypes from 'prop-types'; - -/** User's wallet information */ -export default PropTypes.shape({ - /** The user's available wallet balance */ - availableBalance: PropTypes.number, - - /** The user's current wallet balance */ - currentBalance: PropTypes.number, - - /** What step in the activation flow are we on? */ - currentStep: PropTypes.string, - - /** Error code returned by the server */ - errorCode: PropTypes.string, - - /** If we should show the FailedKYC view after the user submitted their info with a non fixable error */ - shouldShowFailedKYC: PropTypes.bool, - - /** Status of wallet - e.g. SILVER or GOLD */ - tierName: PropTypes.string, - - /** Whether the kyc is pending and is yet to be confirmed */ - isPendingOnfidoResult: PropTypes.bool, - - /** The wallet's programID, used to show the correct terms. */ - walletProgramID: PropTypes.string, - - /** Whether the user has failed Onfido completely */ - hasFailedOnfido: PropTypes.bool, -}); diff --git a/src/pages/ReimbursementAccount/BankInfo/substeps/Confirmation.tsx b/src/pages/ReimbursementAccount/BankInfo/substeps/Confirmation.tsx index 4aec290a4da9..f3ba4c07acf0 100644 --- a/src/pages/ReimbursementAccount/BankInfo/substeps/Confirmation.tsx +++ b/src/pages/ReimbursementAccount/BankInfo/substeps/Confirmation.tsx @@ -31,7 +31,7 @@ type ConfirmationOnyxProps = { type ConfirmationProps = ConfirmationOnyxProps & SubStepProps; const BANK_INFO_STEP_KEYS = INPUT_IDS.BANK_INFO_STEP; -const BANK_INFO_STEP_INDEXES = CONST.REIMBURSEMENT_ACCOUNT_SUBSTEP_INDEX.BANK_ACCOUNT; +const BANK_INFO_STEP_INDEXES = CONST.REIMBURSEMENT_ACCOUNT.SUBSTEP_INDEX.BANK_ACCOUNT; function Confirmation({reimbursementAccount, reimbursementAccountDraft, onNext, onMove}: ConfirmationProps) { const {translate} = useLocalize(); diff --git a/src/pages/ReimbursementAccount/BeneficialOwnerInfo/substeps/BeneficialOwnerDetailsFormSubsteps/ConfirmationUBO.tsx b/src/pages/ReimbursementAccount/BeneficialOwnerInfo/substeps/BeneficialOwnerDetailsFormSubsteps/ConfirmationUBO.tsx index 939c52bfed27..13aa2b4056bc 100644 --- a/src/pages/ReimbursementAccount/BeneficialOwnerInfo/substeps/BeneficialOwnerDetailsFormSubsteps/ConfirmationUBO.tsx +++ b/src/pages/ReimbursementAccount/BeneficialOwnerInfo/substeps/BeneficialOwnerDetailsFormSubsteps/ConfirmationUBO.tsx @@ -29,7 +29,7 @@ type ConfirmationUBOOnyxProps = { }; type ConfirmationUBOProps = SubStepProps & ConfirmationUBOOnyxProps & {beneficialOwnerBeingModifiedID: string}; -const UBO_STEP_INDEXES = CONST.REIMBURSEMENT_ACCOUNT_SUBSTEP_INDEX.UBO; +const UBO_STEP_INDEXES = CONST.REIMBURSEMENT_ACCOUNT.SUBSTEP_INDEX.UBO; function ConfirmationUBO({reimbursementAccount, reimbursementAccountDraft, onNext, onMove, beneficialOwnerBeingModifiedID}: ConfirmationUBOProps) { const {translate} = useLocalize(); diff --git a/src/pages/ReimbursementAccount/BusinessInfo/substeps/ConfirmationBusiness.tsx b/src/pages/ReimbursementAccount/BusinessInfo/substeps/ConfirmationBusiness.tsx index a5b839118edc..6311a63a4059 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/substeps/ConfirmationBusiness.tsx +++ b/src/pages/ReimbursementAccount/BusinessInfo/substeps/ConfirmationBusiness.tsx @@ -35,7 +35,7 @@ type ConfirmationBusinessProps = ConfirmationBusinessOnyxProps & SubStepProps; type States = keyof typeof COMMON_CONST.STATES; const BUSINESS_INFO_STEP_KEYS = INPUT_IDS.BUSINESS_INFO_STEP; -const BUSINESS_INFO_STEP_INDEXES = CONST.REIMBURSEMENT_ACCOUNT_SUBSTEP_INDEX.BUSINESS_INFO; +const BUSINESS_INFO_STEP_INDEXES = CONST.REIMBURSEMENT_ACCOUNT.SUBSTEP_INDEX.BUSINESS_INFO; const validate = (values: FormOnyxValues): FormInputErrors => { const errors = ValidationUtils.getFieldRequiredErrors(values, [BUSINESS_INFO_STEP_KEYS.HAS_NO_CONNECTION_TO_CANNABIS]); diff --git a/src/pages/ReimbursementAccount/PersonalInfo/substeps/Confirmation.tsx b/src/pages/ReimbursementAccount/PersonalInfo/substeps/Confirmation.tsx index 0e11aff395de..af1f081cc3da 100644 --- a/src/pages/ReimbursementAccount/PersonalInfo/substeps/Confirmation.tsx +++ b/src/pages/ReimbursementAccount/PersonalInfo/substeps/Confirmation.tsx @@ -32,7 +32,7 @@ type ConfirmationOnyxProps = { type ConfirmationProps = ConfirmationOnyxProps & SubStepProps; const PERSONAL_INFO_STEP_KEYS = INPUT_IDS.PERSONAL_INFO_STEP; -const PERSONAL_INFO_STEP_INDEXES = CONST.REIMBURSEMENT_ACCOUNT_SUBSTEP_INDEX.PERSONAL_INFO; +const PERSONAL_INFO_STEP_INDEXES = CONST.REIMBURSEMENT_ACCOUNT.SUBSTEP_INDEX.PERSONAL_INFO; function Confirmation({reimbursementAccount, reimbursementAccountDraft, onNext, onMove}: ConfirmationProps) { const {translate} = useLocalize(); diff --git a/src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx b/src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx index 5950cc796e48..eff403a66637 100644 --- a/src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx +++ b/src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx @@ -40,7 +40,6 @@ import CompanyStep from './CompanyStep'; import ConnectBankAccount from './ConnectBankAccount/ConnectBankAccount'; import ContinueBankAccountSetup from './ContinueBankAccountSetup'; import EnableBankAccount from './EnableBankAccount/EnableBankAccount'; -import * as ReimbursementAccountProps from './reimbursementAccountPropTypes'; import RequestorStep from './RequestorStep'; type ReimbursementAccountOnyxProps = { @@ -204,7 +203,7 @@ function ReimbursementAccountPage({ the full `reimbursementAccount` data from the server. This logic is handled within the useEffect hook, which acts similarly to `componentDidUpdate` when the `reimbursementAccount` dependency changes. */ - const [hasACHDataBeenLoaded, setHasACHDataBeenLoaded] = useState(reimbursementAccount !== ReimbursementAccountProps.reimbursementAccountDefaultProps); + const [hasACHDataBeenLoaded, setHasACHDataBeenLoaded] = useState(reimbursementAccount !== CONST.REIMBURSEMENT_ACCOUNT.DEFAULT_DATA); const [shouldShowContinueSetupButton, setShouldShowContinueSetupButton] = useState(hasACHDataBeenLoaded ? getShouldShowContinueSetupButtonInitialValue() : false); const [isReimbursementAccountLoading, setIsReimbursementAccountLoading] = useState(true); @@ -257,7 +256,7 @@ function ReimbursementAccountPage({ } if (!hasACHDataBeenLoaded) { - if (reimbursementAccount !== ReimbursementAccountProps.reimbursementAccountDefaultProps && isReimbursementAccountLoading === false) { + if (reimbursementAccount !== CONST.REIMBURSEMENT_ACCOUNT.DEFAULT_DATA && isReimbursementAccountLoading === false) { setShouldShowContinueSetupButton(getShouldShowContinueSetupButtonInitialValue()); setHasACHDataBeenLoaded(true); } diff --git a/src/pages/ReimbursementAccount/plaidDataPropTypes.js b/src/pages/ReimbursementAccount/plaidDataPropTypes.js deleted file mode 100644 index bd7b68b67d09..000000000000 --- a/src/pages/ReimbursementAccount/plaidDataPropTypes.js +++ /dev/null @@ -1,52 +0,0 @@ -import PropTypes from 'prop-types'; - -const plaidDataPropTypes = PropTypes.shape({ - /** Whether we are fetching the bank accounts from the API */ - isLoading: PropTypes.bool, - - /** Any additional error message to show */ - errors: PropTypes.objectOf(PropTypes.string), - - /** Name of the bank */ - bankName: PropTypes.string, - - /** Access token returned by Plaid once the user has logged into their bank. This token can be used along with internal credentials to query for Plaid Balance or Assets */ - plaidAccessToken: PropTypes.string, - - /** List of plaid bank accounts */ - bankAccounts: PropTypes.arrayOf( - PropTypes.shape({ - /** Masked account number */ - accountNumber: PropTypes.string, - - /** Name of account */ - addressName: PropTypes.string, - - /** Is the account a savings account? */ - isSavings: PropTypes.bool, - - /** Unique identifier for this account in Plaid */ - plaidAccountID: PropTypes.string, - - /** Routing number for the account */ - routingNumber: PropTypes.string, - - /** last 4 digits of the account number */ - mask: PropTypes.string, - - /** Plaid access token, used to then retrieve Assets and Balances */ - plaidAccessToken: PropTypes.string, - }), - ), -}); - -const plaidDataDefaultProps = { - bankName: '', - plaidAccessToken: '', - bankAccounts: [], - isLoading: false, - error: '', - errors: {}, -}; - -export {plaidDataPropTypes, plaidDataDefaultProps}; diff --git a/src/pages/ReimbursementAccount/reimbursementAccountPropTypes.js b/src/pages/ReimbursementAccount/reimbursementAccountPropTypes.js deleted file mode 100644 index 8e94e2ad8f30..000000000000 --- a/src/pages/ReimbursementAccount/reimbursementAccountPropTypes.js +++ /dev/null @@ -1,47 +0,0 @@ -import PropTypes from 'prop-types'; -import BankAccount from '@libs/models/BankAccount'; - -const reimbursementAccountPropTypes = PropTypes.shape({ - /** Whether we are loading the data via the API */ - isLoading: PropTypes.bool, - - /** A date that indicates the user has been throttled */ - throttledDate: PropTypes.string, - - /** Additional data for the account in setup */ - achData: PropTypes.shape({ - /** Step of the setup flow that we are on. Determines which view is presented. */ - currentStep: PropTypes.string, - - /** Bank account state */ - state: PropTypes.string, - - /** Bank account ID of the VBA that we are validating is required */ - bankAccountID: PropTypes.number, - }), - - /** Disable validation button if max attempts exceeded */ - maxAttemptsReached: PropTypes.bool, - - /** Alert message to display above submit button */ - error: PropTypes.string, - - /** Which field needs attention? */ - errorFields: PropTypes.objectOf(PropTypes.oneOfType([PropTypes.bool, PropTypes.array])), - - /** Any additional error message to show */ - errors: PropTypes.objectOf(PropTypes.string), -}); - -const reimbursementAccountDefaultProps = { - achData: { - state: BankAccount.STATE.SETUP, - }, - isLoading: false, - errorFields: {}, - errors: {}, - maxAttemptsReached: false, - shouldShowResetModal: false, -}; - -export {reimbursementAccountPropTypes, reimbursementAccountDefaultProps}; diff --git a/src/pages/ValidateLoginPage/validateLinkPropTypes.js b/src/pages/ValidateLoginPage/validateLinkPropTypes.js deleted file mode 100644 index f3db0e5dc5c2..000000000000 --- a/src/pages/ValidateLoginPage/validateLinkPropTypes.js +++ /dev/null @@ -1,24 +0,0 @@ -import PropTypes from 'prop-types'; - -const propTypes = PropTypes.shape({ - // The name of the route - name: PropTypes.string, - - // Unique key associated with the route - key: PropTypes.string, - - // Each parameter passed via the URL - params: PropTypes.shape({ - // AccountID associated with the validation link - accountID: PropTypes.string, - - // Validation code associated with the validation link - validateCode: PropTypes.string, - }), -}); - -const defaultProps = { - params: {}, -}; - -export {propTypes, defaultProps}; diff --git a/src/pages/home/report/reportActionSourcePropType.js b/src/pages/home/report/reportActionSourcePropType.js deleted file mode 100644 index 0ad9662eb693..000000000000 --- a/src/pages/home/report/reportActionSourcePropType.js +++ /dev/null @@ -1,3 +0,0 @@ -import PropTypes from 'prop-types'; - -export default PropTypes.oneOf(['Chronos', 'email', 'ios', 'android', 'web', 'email', '']); diff --git a/src/pages/iou/request/step/IOURequestStepRoutePropTypes.js b/src/pages/iou/request/step/IOURequestStepRoutePropTypes.js deleted file mode 100644 index f69e2b122c24..000000000000 --- a/src/pages/iou/request/step/IOURequestStepRoutePropTypes.js +++ /dev/null @@ -1,29 +0,0 @@ -import PropTypes from 'prop-types'; -import _ from 'underscore'; -import CONST from '@src/CONST'; - -export default PropTypes.shape({ - /** Route specific parameters used on this screen via route :iouType/new/category/:reportID? */ - params: PropTypes.shape({ - /** What action is being performed, ie. create, edit */ - action: PropTypes.oneOf(_.values(CONST.IOU.ACTION)), - - /** The type of IOU report, i.e. split, request, send, track */ - iouType: PropTypes.oneOf(_.values(CONST.IOU.TYPE)).isRequired, - - /** The ID of the transaction being configured */ - transactionID: PropTypes.string.isRequired, - - /** The report ID of the IOU */ - reportID: PropTypes.string.isRequired, - - /** Index of the waypoint being edited */ - pageIndex: PropTypes.string, - - /** A path to go to when the user presses the back button */ - backTo: PropTypes.string, - - /** Indicates which tag list index was selected */ - tagIndex: PropTypes.string, - }), -}); diff --git a/src/pages/iouReportPropTypes.js b/src/pages/iouReportPropTypes.js deleted file mode 100644 index 284f0915dbbc..000000000000 --- a/src/pages/iouReportPropTypes.js +++ /dev/null @@ -1,18 +0,0 @@ -import PropTypes from 'prop-types'; - -export default PropTypes.shape({ - /** The report ID of the IOU */ - reportID: PropTypes.string, - - /** The report ID of the chat associated with the IOU */ - chatReportID: PropTypes.string, - - /** The total amount in cents */ - total: PropTypes.number, - - /** The owner of the IOUReport */ - ownerAccountID: PropTypes.number, - - /** The currency of the IOUReport */ - currency: PropTypes.string, -}); diff --git a/src/pages/nextStepPropTypes.js b/src/pages/nextStepPropTypes.js deleted file mode 100644 index 4bf4d265ddef..000000000000 --- a/src/pages/nextStepPropTypes.js +++ /dev/null @@ -1,48 +0,0 @@ -import PropTypes from 'prop-types'; - -const messagePropType = PropTypes.shape({ - text: PropTypes.string, - type: PropTypes.string, - action: PropTypes.string, -}); - -export default PropTypes.shape({ - /** The message parts of the next step */ - message: PropTypes.arrayOf(messagePropType), - - /** The title for the next step */ - title: PropTypes.string, - - /** Whether the user should take some sort of action in order to unblock the report */ - requiresUserAction: PropTypes.bool, - - /** The type of next step */ - type: PropTypes.oneOf(['neutral', 'alert', null]), - - /** If the "Undo submit" button should be visible */ - showUndoSubmit: PropTypes.bool, - - /** Deprecated - If the next step should be displayed on mobile, related to OldApp */ - showForMobile: PropTypes.bool, - - /** If the next step should be displayed at the expense level */ - showForExpense: PropTypes.bool, - - /** An optional alternate message to display on expenses instead of what is provided in the "message" field */ - expenseMessage: PropTypes.arrayOf(messagePropType), - - /** The next person in the approval chain of the report */ - nextReceiver: PropTypes.string, - - /** An array of buttons to be displayed next to the next step */ - buttons: PropTypes.objectOf( - PropTypes.shape({ - text: PropTypes.string, - tooltip: PropTypes.string, - disabled: PropTypes.bool, - hidden: PropTypes.bool, - // eslint-disable-next-line react/forbid-prop-types - data: PropTypes.object, - }), - ), -}); diff --git a/src/pages/personalDetailsPropType.js b/src/pages/personalDetailsPropType.js deleted file mode 100644 index 37cab8e56abd..000000000000 --- a/src/pages/personalDetailsPropType.js +++ /dev/null @@ -1,53 +0,0 @@ -import PropTypes from 'prop-types'; - -export default PropTypes.shape({ - // First name of the current user from their personal details - firstName: PropTypes.string, - - // Last name of the current user from their personal details - lastName: PropTypes.string, - - // Display name of the current user from their personal details - displayName: PropTypes.string, - - // Avatar URL of the current user from their personal details - avatar: PropTypes.string, - - // Flag to set when Avatar uploading - avatarUploading: PropTypes.bool, - - // accountID of the current user from their personal details - accountID: PropTypes.number, - - // login of the current user from their personal details - login: PropTypes.string, - - // pronouns of the current user from their personal details - pronouns: PropTypes.string, - - // local currency for the user - localCurrencyCode: PropTypes.string, - - // timezone of the current user from their personal details - timezone: PropTypes.shape({ - // Value of selected timezone - selected: PropTypes.string, - - // Whether timezone is automatically set - // TODO: remove string type after backend fix - // Some personal details return 'true' (string) for this value instead of true (boolean) - automatic: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]), - }), - - // custom status - status: PropTypes.shape({ - // The emoji code of the draft status - emojiCode: PropTypes.string, - - // The text of the draft status - text: PropTypes.string, - - // The timestamp of when the status should be cleared - clearAfter: PropTypes.string, // ISO 8601 format - }), -}); diff --git a/src/pages/policyMemberPropType.js b/src/pages/policyMemberPropType.js deleted file mode 100644 index 22a4d355fbfb..000000000000 --- a/src/pages/policyMemberPropType.js +++ /dev/null @@ -1,15 +0,0 @@ -import PropTypes from 'prop-types'; - -export default PropTypes.shape({ - /** Role of the user in the policy */ - role: PropTypes.string, - - /** - * Errors from api calls on the specific user - * {: 'error message', : 'error message 2'} - */ - errors: PropTypes.objectOf(PropTypes.string), - - /** Is this action pending? */ - pendingAction: PropTypes.string, -}); diff --git a/src/pages/reportMetadataPropTypes.js b/src/pages/reportMetadataPropTypes.js deleted file mode 100644 index 65ed01952977..000000000000 --- a/src/pages/reportMetadataPropTypes.js +++ /dev/null @@ -1,12 +0,0 @@ -import PropTypes from 'prop-types'; - -export default PropTypes.shape({ - /** Are we loading newer report actions? */ - isLoadingNewerReportActions: PropTypes.bool, - - /** Are we loading older report actions? */ - isLoadingOlderReportActions: PropTypes.bool, - - /** Flag to check if the report actions data are loading */ - isLoadingInitialReportActions: PropTypes.bool, -}); diff --git a/src/pages/safeAreaInsetPropTypes.js b/src/pages/safeAreaInsetPropTypes.js deleted file mode 100644 index 9b301463fcae..000000000000 --- a/src/pages/safeAreaInsetPropTypes.js +++ /dev/null @@ -1,10 +0,0 @@ -import PropTypes from 'prop-types'; - -const safeAreaInsetPropTypes = PropTypes.shape({ - top: PropTypes.number, - left: PropTypes.number, - right: PropTypes.number, - bottom: PropTypes.number, -}); - -export default safeAreaInsetPropTypes; diff --git a/src/pages/settings/Wallet/assignedCardPropTypes.js b/src/pages/settings/Wallet/assignedCardPropTypes.js deleted file mode 100644 index a560c0250388..000000000000 --- a/src/pages/settings/Wallet/assignedCardPropTypes.js +++ /dev/null @@ -1,18 +0,0 @@ -import PropTypes from 'prop-types'; -import CONST from '@src/CONST'; - -/** Assigned Card props */ -const assignedCardPropTypes = PropTypes.shape({ - cardID: PropTypes.number, - state: PropTypes.number, - bank: PropTypes.string, - availableSpend: PropTypes.number, - domainName: PropTypes.string, - maskedPan: PropTypes.string, - isVirtual: PropTypes.bool, - fraud: PropTypes.oneOf([CONST.EXPENSIFY_CARD.FRAUD_TYPES.DOMAIN, CONST.EXPENSIFY_CARD.FRAUD_TYPES.INDIVIDUAL, CONST.EXPENSIFY_CARD.FRAUD_TYPES.NONE]), - cardholderFirstName: PropTypes.string, - cardholderLastName: PropTypes.string, -}); - -export default assignedCardPropTypes; diff --git a/src/pages/workspace/WorkspacePageWithSections.tsx b/src/pages/workspace/WorkspacePageWithSections.tsx index 4889c1dbe350..58288f213818 100644 --- a/src/pages/workspace/WorkspacePageWithSections.tsx +++ b/src/pages/workspace/WorkspacePageWithSections.tsx @@ -16,8 +16,8 @@ import useWindowDimensions from '@hooks/useWindowDimensions'; import BankAccount from '@libs/models/BankAccount'; import Navigation from '@libs/Navigation/Navigation'; import * as PolicyUtils from '@libs/PolicyUtils'; -import * as ReimbursementAccountProps from '@pages/ReimbursementAccount/reimbursementAccountPropTypes'; import * as BankAccounts from '@userActions/BankAccounts'; +import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type {Route} from '@src/ROUTES'; import type {Policy, ReimbursementAccount, User} from '@src/types/onyx'; @@ -103,7 +103,7 @@ function WorkspacePageWithSections({ headerText, policy, policyDraft, - reimbursementAccount = ReimbursementAccountProps.reimbursementAccountDefaultProps, + reimbursementAccount = CONST.REIMBURSEMENT_ACCOUNT.DEFAULT_DATA, route, shouldUseScrollView = false, shouldSkipVBBACall = false, diff --git a/src/pages/workspace/withPolicy.tsx b/src/pages/workspace/withPolicy.tsx index 9c2926aaaa17..2c06bf208482 100644 --- a/src/pages/workspace/withPolicy.tsx +++ b/src/pages/workspace/withPolicy.tsx @@ -5,7 +5,6 @@ import type {ComponentType, ForwardedRef, RefAttributes} from 'react'; import React, {forwardRef} from 'react'; import type {OnyxEntry} from 'react-native-onyx'; import {withOnyx} from 'react-native-onyx'; -import taxPropTypes from '@components/taxPropTypes'; import {translatableTextPropTypes} from '@libs/Localize'; import type { BottomTabNavigatorParamList, @@ -54,6 +53,34 @@ function getPolicyIDFromRoute(route: PolicyRoute): string { return route?.params?.policyID ?? ''; } +const taxPropTypes = PropTypes.shape({ + /** Name of a tax */ + name: PropTypes.string, + + /** The value of a tax */ + value: PropTypes.string, + + /** Whether the tax is disabled */ + isDisabled: PropTypes.bool, +}); + +const taxRatesPropTypes = PropTypes.shape({ + /** Name of the tax */ + name: PropTypes.string, + + /** Default policy tax ID */ + defaultExternalID: PropTypes.string, + + /** Default value of taxes */ + defaultValue: PropTypes.string, + + /** Default foreign policy tax ID */ + foreignTaxDefault: PropTypes.string, + + /** List of tax names and values */ + taxes: PropTypes.objectOf(taxPropTypes), +}); + const policyPropTypes = { /** The policy object for the current route */ policy: PropTypes.shape({ @@ -114,7 +141,7 @@ const policyPropTypes = { }), /** Collection of tax rates attached to a policy */ - taxRates: taxPropTypes, + taxRates: taxRatesPropTypes, }), }; diff --git a/src/types/onyx/PlaidData.ts b/src/types/onyx/PlaidData.ts index 8ec93119cbd8..3a538efe3623 100644 --- a/src/types/onyx/PlaidData.ts +++ b/src/types/onyx/PlaidData.ts @@ -15,6 +15,7 @@ type PlaidData = { bankAccounts?: PlaidBankAccount[]; isLoading?: boolean; + error?: string; errors: OnyxCommon.Errors; }; From 3a32eb245076999b7c0ec594853bcb19cd16766e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Henriques?= Date: Thu, 25 Apr 2024 08:42:37 +0100 Subject: [PATCH 2/3] Address review comments --- src/CONST.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/CONST.ts b/src/CONST.ts index dbc4b0416b18..c52aed9090b6 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -7,6 +7,7 @@ import type {ValueOf} from 'type-fest'; import BankAccount from './libs/models/BankAccount'; import * as Url from './libs/Url'; import SCREENS from './SCREENS'; +import type PlaidBankAccount from './types/onyx/PlaidBankAccount'; import type {Unit} from './types/onyx/Policy'; type RateAndUnit = { @@ -1374,7 +1375,7 @@ const CONST = { DEFAULT_DATA: { bankName: '', plaidAccessToken: '', - bankAccounts: [] as [], + bankAccounts: [] as PlaidBankAccount[], isLoading: false, error: '', errors: {}, From be992f14158f1e245d2330fc20b4af815dd6f355 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Henriques?= Date: Fri, 26 Apr 2024 10:34:57 +0100 Subject: [PATCH 3/3] Remove `error` property from PlaidData --- src/CONST.ts | 1 - src/types/onyx/PlaidData.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 0640d7686d19..c2612a8a6695 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1379,7 +1379,6 @@ const CONST = { plaidAccessToken: '', bankAccounts: [] as PlaidBankAccount[], isLoading: false, - error: '', errors: {}, }, }, diff --git a/src/types/onyx/PlaidData.ts b/src/types/onyx/PlaidData.ts index 3a538efe3623..8ec93119cbd8 100644 --- a/src/types/onyx/PlaidData.ts +++ b/src/types/onyx/PlaidData.ts @@ -15,7 +15,6 @@ type PlaidData = { bankAccounts?: PlaidBankAccount[]; isLoading?: boolean; - error?: string; errors: OnyxCommon.Errors; };