diff --git a/src/pages/ShareCodePage.js b/src/pages/ShareCodePage.js index cfde085d3847..eaf00a5cbed1 100644 --- a/src/pages/ShareCodePage.js +++ b/src/pages/ShareCodePage.js @@ -1,14 +1,18 @@ import React from 'react'; import {View} from 'react-native'; import PropTypes from 'prop-types'; +import {withOnyx} from 'react-native-onyx'; import ScreenWrapper from '../components/ScreenWrapper'; import HeaderWithCloseButton from '../components/HeaderWithCloseButton'; import Navigation from '../libs/Navigation/Navigation'; import withLocalize, {withLocalizePropTypes} from '../components/withLocalize'; import QRShare from '../components/QRShare'; import compose from '../libs/compose'; +import reportPropTypes from './reportPropTypes'; import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsDefaultProps, withCurrentUserPersonalDetailsPropTypes} from '../components/withCurrentUserPersonalDetails'; import styles from '../styles/styles'; +import roomAvatar from '../../assets/images/avatars/room.svg'; +import ONYXKEYS from '../ONYXKEYS'; const propTypes = { /** Navigation route context info provided by react navigation */ @@ -19,11 +23,15 @@ const propTypes = { }).isRequired, }).isRequired, + /** The report currently being looked at */ + report: reportPropTypes, + ...withLocalizePropTypes, ...withCurrentUserPersonalDetailsPropTypes, }; const defaultProps = { + report: undefined, ...withCurrentUserPersonalDetailsDefaultProps, }; @@ -32,7 +40,7 @@ class ShareCodePage extends React.Component { render() { // eslint-disable-next-line es/no-optional-chaining const reportId = this.props.route?.params?.reportID; - const isReport = reportId != null; + const isReport = this.props.report != null && this.props.report.reportID != null; return ( @@ -46,8 +54,10 @@ class ShareCodePage extends React.Component { null} /> @@ -61,5 +71,11 @@ ShareCodePage.defaultProps = defaultProps; export default compose( withLocalize, + withOnyx({ + report: { + // eslint-disable-next-line es/no-optional-chaining + key: ({route}) => (route.params?.reportId != null ? `${ONYXKEYS.COLLECTION.REPORT}${route.params.reportID}` : undefined), + }, + }), withCurrentUserPersonalDetails, )(ShareCodePage);