-
Notifications
You must be signed in to change notification settings - Fork 2.9k
/
ConciergePage.js
44 lines (38 loc) · 1.28 KB
/
ConciergePage.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import _ from 'underscore';
import React from 'react';
import PropTypes from 'prop-types';
import {withOnyx} from 'react-native-onyx';
import CONST from '../CONST';
import ONYXKEYS from '../ONYXKEYS';
import FullScreenLoadingIndicator from '../components/FullscreenLoadingIndicator';
import Navigation from '../libs/Navigation/Navigation';
import * as Report from '../libs/actions/Report';
const propTypes = {
/** Session info for the currently logged in user. */
session: PropTypes.shape({
/** Currently logged in user authToken */
authToken: PropTypes.string,
/** Currently logged in user email */
email: PropTypes.string,
}).isRequired,
};
/*
* This is a "utility page", that does this:
* - If the user is authenticated, find their concierge chat and re-route to it
* - Else re-route to the login page
*/
const ConciergePage = (props) => {
if (_.has(props.session, 'authToken')) {
Report.fetchOrCreateChatReport([props.session.email, CONST.EMAIL.CONCIERGE]);
} else {
Navigation.navigate();
}
return <FullScreenLoadingIndicator />;
};
ConciergePage.propTypes = propTypes;
ConciergePage.displayName = 'ConciergePage';
export default withOnyx({
session: {
key: ONYXKEYS.SESSION,
},
})(ConciergePage);