From 28065b44e3b856ec644accd79366b06ca95e4c53 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Fri, 25 Aug 2023 12:35:15 +0800 Subject: [PATCH] update proptypes --- src/pages/iou/IOUCurrencySelection.js | 19 +++++++++++ src/pages/iou/MoneyRequestDatePage.js | 13 +++++++ src/pages/iou/MoneyRequestDescriptionPage.js | 13 +++++++ src/pages/iou/MoneyRequestMerchantPage.js | 13 +++++++ src/pages/iou/MoneyRequestSelectorPage.js | 19 +++++++---- src/pages/iou/ReceiptSelector/index.js | 31 ++++++++--------- src/pages/iou/ReceiptSelector/index.native.js | 21 +++++++----- .../iou/steps/MoneyRequestConfirmPage.js | 32 ++++++++++++----- .../MoneyRequestParticipantsPage.js | 28 ++++++++++----- src/pages/iou/steps/NewRequestAmountPage.js | 34 ++++++++++--------- 10 files changed, 158 insertions(+), 65 deletions(-) diff --git a/src/pages/iou/IOUCurrencySelection.js b/src/pages/iou/IOUCurrencySelection.js index f9dc03c66f90..7b2d278681aa 100644 --- a/src/pages/iou/IOUCurrencySelection.js +++ b/src/pages/iou/IOUCurrencySelection.js @@ -24,6 +24,24 @@ const greenCheckmark = {src: Expensicons.Checkmark, color: themeColors.success}; * IOU Currency selection for selecting currency */ const propTypes = { + /** Route from navigation */ + route: PropTypes.shape({ + /** Params from the route */ + params: PropTypes.shape({ + /** The type of IOU report, i.e. bill, request, send */ + iouType: PropTypes.string, + + /** The report ID of the IOU */ + reportID: PropTypes.string, + + /** Currently selected currency */ + currency: PropTypes.string, + + /** Route to navigate back after selecting a currency */ + backTo: PropTypes.string, + }), + }).isRequired, + // The currency list constant object from Onyx currencyList: PropTypes.objectOf( PropTypes.shape({ @@ -40,6 +58,7 @@ const propTypes = { /** Holds data related to Money Request view state, rather than the underlying Money Request data. */ iou: PropTypes.shape({ + /** Currency of the request */ currency: PropTypes.string, }), diff --git a/src/pages/iou/MoneyRequestDatePage.js b/src/pages/iou/MoneyRequestDatePage.js index 3fcd3aba263c..e06794af51b7 100644 --- a/src/pages/iou/MoneyRequestDatePage.js +++ b/src/pages/iou/MoneyRequestDatePage.js @@ -19,10 +19,17 @@ const propTypes = { /** Onyx Props */ /** Holds data related to Money Request view state, rather than the underlying Money Request data. */ iou: PropTypes.shape({ + /** ID (iouType + reportID) of the request */ id: PropTypes.string, + + /** Amount of the request */ amount: PropTypes.number, + + /** Description of the request */ comment: PropTypes.string, created: PropTypes.string, + + /** List of the participants */ participants: PropTypes.arrayOf(optionPropTypes), receiptPath: PropTypes.string, }), @@ -31,6 +38,12 @@ const propTypes = { route: PropTypes.shape({ /** Params from the route */ params: PropTypes.shape({ + /** The type of IOU report, i.e. bill, request, send */ + iouType: PropTypes.string, + + /** The report ID of the IOU */ + reportID: PropTypes.string, + /** Which field we are editing */ field: PropTypes.string, diff --git a/src/pages/iou/MoneyRequestDescriptionPage.js b/src/pages/iou/MoneyRequestDescriptionPage.js index 2e6e459f1d96..7a9f666c5843 100644 --- a/src/pages/iou/MoneyRequestDescriptionPage.js +++ b/src/pages/iou/MoneyRequestDescriptionPage.js @@ -21,9 +21,16 @@ const propTypes = { /** Onyx Props */ /** Holds data related to Money Request view state, rather than the underlying Money Request data. */ iou: PropTypes.shape({ + /** ID (iouType + reportID) of the request */ id: PropTypes.string, + + /** Amount of the request */ amount: PropTypes.number, + + /** Description of the request */ comment: PropTypes.string, + + /** List of the participants */ participants: PropTypes.arrayOf(optionPropTypes), receiptPath: PropTypes.string, }), @@ -32,6 +39,12 @@ const propTypes = { route: PropTypes.shape({ /** Params from the route */ params: PropTypes.shape({ + /** The type of IOU report, i.e. bill, request, send */ + iouType: PropTypes.string, + + /** The report ID of the IOU */ + reportID: PropTypes.string, + /** Which field we are editing */ field: PropTypes.string, diff --git a/src/pages/iou/MoneyRequestMerchantPage.js b/src/pages/iou/MoneyRequestMerchantPage.js index e2d04288353f..21c7254d61a0 100644 --- a/src/pages/iou/MoneyRequestMerchantPage.js +++ b/src/pages/iou/MoneyRequestMerchantPage.js @@ -21,11 +21,18 @@ const propTypes = { /** Onyx Props */ /** Holds data related to Money Request view state, rather than the underlying Money Request data. */ iou: PropTypes.shape({ + /** ID (iouType + reportID) of the request */ id: PropTypes.string, + + /** Amount of the request */ amount: PropTypes.number, + + /** Description of the request */ comment: PropTypes.string, created: PropTypes.string, merchant: PropTypes.string, + + /** List of the participants */ participants: PropTypes.arrayOf(optionPropTypes), receiptPath: PropTypes.string, }), @@ -34,6 +41,12 @@ const propTypes = { route: PropTypes.shape({ /** Params from the route */ params: PropTypes.shape({ + /** The type of IOU report, i.e. bill, request, send */ + iouType: PropTypes.string, + + /** The report ID of the IOU */ + reportID: PropTypes.string, + /** Which field we are editing */ field: PropTypes.string, diff --git a/src/pages/iou/MoneyRequestSelectorPage.js b/src/pages/iou/MoneyRequestSelectorPage.js index 4dd688950fbd..f70412d9734e 100644 --- a/src/pages/iou/MoneyRequestSelectorPage.js +++ b/src/pages/iou/MoneyRequestSelectorPage.js @@ -25,17 +25,28 @@ import NewRequestAmountPage from './steps/NewRequestAmountPage'; const propTypes = { /** React Navigation route */ route: PropTypes.shape({ + /** Params from the route */ params: PropTypes.shape({ + /** The type of IOU report, i.e. bill, request, send */ iouType: PropTypes.string, + + /** The report ID of the IOU */ reportID: PropTypes.string, }), - }), + }).isRequired, /** Holds data related to Money Request view state, rather than the underlying Money Request data. */ iou: PropTypes.shape({ + /** ID (iouType + reportID) of the request */ id: PropTypes.string, + + /** Amount of the request */ amount: PropTypes.number, + + /** Currency of the request */ currency: PropTypes.string, + + /** List of the participants */ participants: PropTypes.arrayOf(participantPropTypes), }), @@ -44,12 +55,6 @@ const propTypes = { }; const defaultProps = { - route: { - params: { - iouType: '', - reportID: '', - }, - }, iou: { id: '', amount: 0, diff --git a/src/pages/iou/ReceiptSelector/index.js b/src/pages/iou/ReceiptSelector/index.js index 392e96887f8b..f37ea18842ad 100644 --- a/src/pages/iou/ReceiptSelector/index.js +++ b/src/pages/iou/ReceiptSelector/index.js @@ -5,6 +5,7 @@ import PropTypes from 'prop-types'; import {withOnyx} from 'react-native-onyx'; import * as IOU from '../../../libs/actions/IOU'; import reportPropTypes from '../../reportPropTypes'; +import participantPropTypes from '../../../components/participantPropTypes'; import CONST from '../../../CONST'; import ReceiptUpload from '../../../../assets/images/receipt-upload.svg'; import PressableWithFeedback from '../../../components/Pressable/PressableWithFeedback'; @@ -32,27 +33,31 @@ const propTypes = { /** The report on which the request is initiated on */ report: reportPropTypes, + /** React Navigation route */ route: PropTypes.shape({ + /** Params from the route */ params: PropTypes.shape({ + /** The type of IOU report, i.e. bill, request, send */ iouType: PropTypes.string, + + /** The report ID of the IOU */ reportID: PropTypes.string, }), - }), + }).isRequired, /** Holds data related to Money Request view state, rather than the underlying Money Request data. */ iou: PropTypes.shape({ + /** ID (iouType + reportID) of the request */ id: PropTypes.string, + + /** Amount of the request */ amount: PropTypes.number, + + /** Currency of the request */ currency: PropTypes.string, - participants: PropTypes.arrayOf( - PropTypes.shape({ - accountID: PropTypes.number, - login: PropTypes.string, - isPolicyExpenseChat: PropTypes.bool, - isOwnPolicyExpenseChat: PropTypes.bool, - selected: PropTypes.bool, - }), - ), + + /** List of the participants */ + participants: PropTypes.arrayOf(participantPropTypes), }), }; @@ -63,12 +68,6 @@ const defaultProps = { attachmentInvalidReason: '', }, report: {}, - route: { - params: { - iouType: '', - reportID: '', - }, - }, iou: { id: '', amount: 0, diff --git a/src/pages/iou/ReceiptSelector/index.native.js b/src/pages/iou/ReceiptSelector/index.native.js index 730e5d1e1dfb..727cbb05d395 100644 --- a/src/pages/iou/ReceiptSelector/index.native.js +++ b/src/pages/iou/ReceiptSelector/index.native.js @@ -23,35 +23,40 @@ import Log from '../../../libs/Log'; import participantPropTypes from '../../../components/participantPropTypes'; const propTypes = { - /** Route params */ + /** React Navigation route */ route: PropTypes.shape({ + /** Params from the route */ params: PropTypes.shape({ + /** The type of IOU report, i.e. bill, request, send */ iouType: PropTypes.string, + + /** The report ID of the IOU */ reportID: PropTypes.string, }), - }), + }).isRequired, /** The report on which the request is initiated on */ report: reportPropTypes, /** Holds data related to Money Request view state, rather than the underlying Money Request data. */ iou: PropTypes.shape({ + /** ID (iouType + reportID) of the request */ id: PropTypes.string, + + /** Amount of the request */ amount: PropTypes.number, + + /** Description of the request */ comment: PropTypes.string, created: PropTypes.string, merchant: PropTypes.string, + + /** List of the participants */ participants: PropTypes.arrayOf(participantPropTypes), }), }; const defaultProps = { - route: { - params: { - iouType: '', - reportID: '', - }, - }, report: {}, iou: { id: '', diff --git a/src/pages/iou/steps/MoneyRequestConfirmPage.js b/src/pages/iou/steps/MoneyRequestConfirmPage.js index c22a81cd7299..06d8f4c8b69d 100644 --- a/src/pages/iou/steps/MoneyRequestConfirmPage.js +++ b/src/pages/iou/steps/MoneyRequestConfirmPage.js @@ -20,29 +20,43 @@ import ONYXKEYS from '../../../ONYXKEYS'; import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsDefaultProps, withCurrentUserPersonalDetailsPropTypes} from '../../../components/withCurrentUserPersonalDetails'; import reportPropTypes from '../../reportPropTypes'; import personalDetailsPropType from '../../personalDetailsPropType'; +import participantPropTypes from '../../../components/participantPropTypes'; import * as FileUtils from '../../../libs/fileDownload/FileUtils'; import * as Policy from '../../../libs/actions/Policy'; const propTypes = { + /** React Navigation route */ + route: PropTypes.shape({ + /** Params from the route */ + params: PropTypes.shape({ + /** The type of IOU report, i.e. bill, request, send */ + iouType: PropTypes.string, + + /** The report ID of the IOU */ + reportID: PropTypes.string, + }), + }).isRequired, + report: reportPropTypes, /** Holds data related to Money Request view state, rather than the underlying Money Request data. */ iou: PropTypes.shape({ + /** ID (iouType + reportID) of the request */ id: PropTypes.string, + + /** Amount of the request */ amount: PropTypes.number, + + /** Description of the request */ comment: PropTypes.string, created: PropTypes.string, + + /** Currency of the request */ currency: PropTypes.string, merchant: PropTypes.string, - participants: PropTypes.arrayOf( - PropTypes.shape({ - accountID: PropTypes.number, - login: PropTypes.string, - isPolicyExpenseChat: PropTypes.bool, - isOwnPolicyExpenseChat: PropTypes.bool, - selected: PropTypes.bool, - }), - ), + + /** List of the participants */ + participants: PropTypes.arrayOf(participantPropTypes), receiptPath: PropTypes.string, }), diff --git a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js index d6d069dc0329..8ff6ce822991 100644 --- a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js +++ b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js @@ -16,21 +16,31 @@ import compose from '../../../../libs/compose'; import * as DeviceCapabilities from '../../../../libs/DeviceCapabilities'; import HeaderWithBackButton from '../../../../components/HeaderWithBackButton'; import * as IOU from '../../../../libs/actions/IOU'; +import participantPropTypes from '../../../../components/participantPropTypes'; const propTypes = { + /** React Navigation route */ + route: PropTypes.shape({ + /** Params from the route */ + params: PropTypes.shape({ + /** The type of IOU report, i.e. bill, request, send */ + iouType: PropTypes.string, + + /** The report ID of the IOU */ + reportID: PropTypes.string, + }), + }).isRequired, + /** Holds data related to Money Request view state, rather than the underlying Money Request data. */ iou: PropTypes.shape({ + /** ID (iouType + reportID) of the request */ id: PropTypes.string, + + /** Amount of the request */ amount: PropTypes.number, - participants: PropTypes.arrayOf( - PropTypes.shape({ - accountID: PropTypes.number, - login: PropTypes.string, - isPolicyExpenseChat: PropTypes.bool, - isOwnPolicyExpenseChat: PropTypes.bool, - selected: PropTypes.bool, - }), - ), + + /** List of the participants */ + participants: PropTypes.arrayOf(participantPropTypes), }), ...withLocalizePropTypes, diff --git a/src/pages/iou/steps/NewRequestAmountPage.js b/src/pages/iou/steps/NewRequestAmountPage.js index e0199d72b01a..7a6fcbfeb10b 100644 --- a/src/pages/iou/steps/NewRequestAmountPage.js +++ b/src/pages/iou/steps/NewRequestAmountPage.js @@ -12,6 +12,7 @@ import * as ReportUtils from '../../../libs/ReportUtils'; import * as CurrencyUtils from '../../../libs/CurrencyUtils'; import CONST from '../../../CONST'; import reportPropTypes from '../../reportPropTypes'; +import participantPropTypes from '../../../components/participantPropTypes'; import * as IOU from '../../../libs/actions/IOU'; import useLocalize from '../../../hooks/useLocalize'; import MoneyRequestAmountForm from './MoneyRequestAmountForm'; @@ -22,42 +23,43 @@ import HeaderWithBackButton from '../../../components/HeaderWithBackButton'; import ScreenWrapper from '../../../components/ScreenWrapper'; const propTypes = { + /** React Navigation route */ route: PropTypes.shape({ + /** Params from the route */ params: PropTypes.shape({ + /** The type of IOU report, i.e. bill, request, send */ iouType: PropTypes.string, + + /** The report ID of the IOU */ reportID: PropTypes.string, + + /** Selected currency from IOUCurrencySelection */ + currency: PropTypes.string, }), - }), + }).isRequired, /** The report on which the request is initiated on */ report: reportPropTypes, /** Holds data related to Money Request view state, rather than the underlying Money Request data. */ iou: PropTypes.shape({ + /** ID (iouType + reportID) of the request */ id: PropTypes.string, + + /** Amount of the request */ amount: PropTypes.number, + + /** Currency of the request */ currency: PropTypes.string, merchant: PropTypes.string, created: PropTypes.string, - participants: PropTypes.arrayOf( - PropTypes.shape({ - accountID: PropTypes.number, - login: PropTypes.string, - isPolicyExpenseChat: PropTypes.bool, - isOwnPolicyExpenseChat: PropTypes.bool, - selected: PropTypes.bool, - }), - ), + + /** List of the participants */ + participants: PropTypes.arrayOf(participantPropTypes), }), }; const defaultProps = { - route: { - params: { - iouType: '', - reportID: '', - }, - }, report: {}, iou: { id: '',