diff --git a/src/ONYXKEYS.js b/src/ONYXKEYS.js index 40675a1a6a89..867447e1b530 100755 --- a/src/ONYXKEYS.js +++ b/src/ONYXKEYS.js @@ -104,6 +104,7 @@ export default { REPORTS_WITH_DRAFT: 'reportWithDraft_', REPORT_IS_COMPOSER_FULL_SIZE: 'reportIsComposerFullSize_', IS_LOADING_REPORT_ACTIONS: 'isLoadingReportActions_', + POLICY_MEMBER_LIST: 'policyMemberList_', }, // Indicates which locale should be used diff --git a/src/components/MenuItem.js b/src/components/MenuItem.js index 0be18a83a916..08b3085c0be3 100644 --- a/src/components/MenuItem.js +++ b/src/components/MenuItem.js @@ -14,6 +14,8 @@ import Badge from './Badge'; import CONST from '../CONST'; import menuItemPropTypes from './menuItemPropTypes'; import SelectCircle from './SelectCircle'; +import colors from '../styles/colors'; +import variables from '../styles/variables'; const propTypes = { ...menuItemPropTypes, @@ -40,6 +42,7 @@ const defaultProps = { onPress: () => {}, interactive: true, fallbackIcon: Expensicons.FallbackAvatar, + brickRoadIndicator: undefined, }; const MenuItem = props => ( @@ -119,7 +122,6 @@ const MenuItem = props => ( {props.badgeText && } - {/* Since subtitle can be of type number, we should allow 0 to be shown */} {(props.subtitle || props.subtitle === 0) && ( @@ -130,6 +132,16 @@ const MenuItem = props => ( )} + {props.brickRoadIndicator && ( + + + + )} {props.shouldShowRightIcon && ( !_.isEmpty(member.errors)); +} + export { getPolicyList, loadFullPolicy, @@ -557,4 +567,5 @@ export { setCustomUnitRate, updateLastAccessedWorkspace, subscribeToPolicyEvents, + hasPolicyMemberError, }; diff --git a/src/pages/policyMemberPropType.js b/src/pages/policyMemberPropType.js new file mode 100644 index 000000000000..0e5c39e02369 --- /dev/null +++ b/src/pages/policyMemberPropType.js @@ -0,0 +1,12 @@ +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), +}); diff --git a/src/pages/settings/InitialSettingsPage.js b/src/pages/settings/InitialSettingsPage.js index 6d1996630d5c..cd1762ee6748 100755 --- a/src/pages/settings/InitialSettingsPage.js +++ b/src/pages/settings/InitialSettingsPage.js @@ -2,6 +2,7 @@ import React from 'react'; import {View, ScrollView, Pressable} from 'react-native'; import PropTypes from 'prop-types'; import _ from 'underscore'; +import lodashGet from 'lodash/get'; import {withOnyx} from 'react-native-onyx'; import Str from 'expensify-common/lib/str'; import styles from '../../styles/styles'; @@ -24,6 +25,8 @@ import Permissions from '../../libs/Permissions'; import networkPropTypes from '../../components/networkPropTypes'; import {withNetwork} from '../../components/OnyxProvider'; import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsPropTypes, withCurrentUserPersonalDetailsDefaultProps} from '../../components/withCurrentUserPersonalDetails'; +import * as Policy from '../../libs/actions/Policy'; +import policyMemberPropType from '../policyMemberPropType'; const propTypes = { /* Onyx Props */ @@ -52,6 +55,9 @@ const propTypes = { role: PropTypes.string, })), + /** List of policy members */ + policyMembers: PropTypes.objectOf(policyMemberPropType), + /** The user's wallet account */ userWallet: PropTypes.shape({ /** The user's current wallet balance */ @@ -72,6 +78,7 @@ const defaultProps = { currentBalance: 0, }, betas: [], + policyMembers: {}, ...withCurrentUserPersonalDetailsDefaultProps, }; @@ -135,6 +142,7 @@ const InitialSettingsPage = (props) => { iconStyles: policy.avatarURL ? [] : [styles.popoverMenuIconEmphasized], iconFill: themeColors.iconReversed, fallbackIcon: Expensicons.FallbackWorkspaceAvatar, + brickRoadIndicator: Policy.hasPolicyMemberError(lodashGet(props.policyMembers, `${ONYXKEYS.COLLECTION.POLICY_MEMBER_LIST}${policy.id}`, {})) ? 'error' : null, })) .value(); menuItems.push(...defaultMenuItems); @@ -190,6 +198,7 @@ const InitialSettingsPage = (props) => { shouldShowRightIcon badgeText={(isPaymentItem && Permissions.canUseWallet(props.betas)) ? walletBalance : undefined} fallbackIcon={item.fallbackIcon} + brickRoadIndicator={item.brickRoadIndicator} /> ); })} @@ -214,6 +223,9 @@ export default compose( policies: { key: ONYXKEYS.COLLECTION.POLICY, }, + policyMembers: { + key: ONYXKEYS.COLLECTION.POLICY_MEMBER_LIST, + }, userWallet: { key: ONYXKEYS.USER_WALLET, },