2019-01-26 19:23:47 -05:00
|
|
|
// @flow
|
2020-08-24 13:59:37 -04:00
|
|
|
import { SITE_NAME } from 'config';
|
2017-12-21 18:08:54 -03:00
|
|
|
import React from 'react';
|
2018-03-26 14:32:43 -07:00
|
|
|
import BusyIndicator from 'component/common/busy-indicator';
|
2017-12-21 18:08:54 -03:00
|
|
|
import InviteNew from 'component/inviteNew';
|
|
|
|
import InviteList from 'component/inviteList';
|
2019-09-26 12:07:11 -04:00
|
|
|
import Page from 'component/page';
|
2020-01-22 12:46:18 -05:00
|
|
|
import RewardAuthIntro from 'component/rewardAuthIntro';
|
2017-08-17 23:31:44 -04:00
|
|
|
|
2019-01-26 19:23:47 -05:00
|
|
|
type Props = {
|
|
|
|
isPending: boolean,
|
|
|
|
isFailed: boolean,
|
|
|
|
inviteAcknowledged: boolean,
|
2020-01-22 12:46:18 -05:00
|
|
|
authenticated: boolean,
|
2019-01-26 19:23:47 -05:00
|
|
|
acknowledgeInivte: () => void,
|
|
|
|
fetchInviteStatus: () => void,
|
|
|
|
};
|
|
|
|
|
|
|
|
class InvitePage extends React.PureComponent<Props> {
|
|
|
|
componentDidMount() {
|
|
|
|
const { fetchInviteStatus, inviteAcknowledged, acknowledgeInivte } = this.props;
|
|
|
|
fetchInviteStatus();
|
|
|
|
|
|
|
|
if (!inviteAcknowledged) {
|
|
|
|
acknowledgeInivte();
|
|
|
|
}
|
2017-08-17 23:31:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2020-01-22 12:46:18 -05:00
|
|
|
const { isPending, isFailed, authenticated } = this.props;
|
2017-08-17 23:31:44 -04:00
|
|
|
|
|
|
|
return (
|
2019-09-26 12:07:11 -04:00
|
|
|
<Page>
|
2020-01-22 12:46:18 -05:00
|
|
|
{!authenticated ? (
|
2020-08-24 13:59:37 -04:00
|
|
|
<RewardAuthIntro
|
2020-09-03 16:05:38 -04:00
|
|
|
title={__('Log in to %SITE_NAME% to earn rewards From Inviting Your Friends', { SITE_NAME })}
|
2020-08-24 13:59:37 -04:00
|
|
|
/>
|
2020-01-22 12:46:18 -05:00
|
|
|
) : (
|
2019-03-04 23:46:57 -05:00
|
|
|
<React.Fragment>
|
2020-01-22 12:46:18 -05:00
|
|
|
{isPending && <BusyIndicator message={__('Checking your invite status')} />}
|
|
|
|
{!isPending && isFailed && <span className="empty">{__('Failed to retrieve invite status.')}</span>}
|
|
|
|
{!isPending && !isFailed && (
|
|
|
|
<React.Fragment>
|
|
|
|
<InviteNew />
|
|
|
|
<InviteList />
|
|
|
|
</React.Fragment>
|
|
|
|
)}
|
2019-03-04 23:46:57 -05:00
|
|
|
</React.Fragment>
|
|
|
|
)}
|
2019-09-26 12:07:11 -04:00
|
|
|
</Page>
|
2017-08-17 23:31:44 -04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default InvitePage;
|