Skip to content

Commit

Permalink
update ShareCodePage
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph Pader committed May 9, 2023
1 parent 281a8be commit fe000c0
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/pages/ShareCodePage.js
Original file line number Diff line number Diff line change
@@ -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 */
Expand All @@ -19,11 +23,15 @@ const propTypes = {
}).isRequired,
}).isRequired,

/** The report currently being looked at */
report: reportPropTypes,

...withLocalizePropTypes,
...withCurrentUserPersonalDetailsPropTypes,
};

const defaultProps = {
report: undefined,
...withCurrentUserPersonalDetailsDefaultProps,
};

Expand All @@ -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 (
<ScreenWrapper>
Expand All @@ -46,8 +54,10 @@ class ShareCodePage extends React.Component {
<View style={styles.shareCodePage}>
<QRShare
type={isReport ? 'report' : 'profile'}
value={isReport ? reportId : this.props.currentUserPersonalDetails.email}
logo={isReport ? undefined : this.props.currentUserPersonalDetails.avatar}
value={isReport ? reportId : this.props.session.email}
title={isReport ? this.props.report.reportName : this.props.currentUserPersonalDetails.displayName}
subtitle={isReport ? undefined : this.props.session.email}
logo={isReport ? roomAvatar : this.props.currentUserPersonalDetails.avatar}
download={() => null}
/>
</View>
Expand All @@ -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);

0 comments on commit fe000c0

Please sign in to comment.