2016-05-28 05:05:27 +08:00
|
|
|
import React from 'react';
|
2016-08-26 01:44:23 +08:00
|
|
|
import {OAuthSignInPage} from 'nylas-component-kit';
|
2016-05-28 05:05:27 +08:00
|
|
|
|
|
|
|
import {
|
2016-08-26 01:44:23 +08:00
|
|
|
makeGmailOAuthRequest,
|
2016-05-28 05:05:27 +08:00
|
|
|
buildGmailSessionKey,
|
|
|
|
buildGmailAuthURL,
|
|
|
|
} from './onboarding-helpers';
|
|
|
|
|
|
|
|
import OnboardingActions from './onboarding-actions';
|
|
|
|
import AccountTypes from './account-types';
|
|
|
|
|
2016-07-27 06:55:31 +08:00
|
|
|
|
2016-05-28 05:05:27 +08:00
|
|
|
export default class AccountSettingsPageGmail extends React.Component {
|
|
|
|
static displayName = "AccountSettingsPageGmail";
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
accountInfo: React.PropTypes.object,
|
|
|
|
};
|
|
|
|
|
2016-07-27 06:55:31 +08:00
|
|
|
constructor() {
|
|
|
|
super()
|
2016-05-28 05:05:27 +08:00
|
|
|
this._sessionKey = buildGmailSessionKey();
|
2016-07-27 06:55:31 +08:00
|
|
|
this._gmailAuthUrl = buildGmailAuthURL(this._sessionKey)
|
2016-05-28 05:05:27 +08:00
|
|
|
}
|
|
|
|
|
2016-08-26 01:44:23 +08:00
|
|
|
onSuccess(account) {
|
|
|
|
OnboardingActions.accountJSONReceived(account);
|
2016-05-28 05:05:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const {accountInfo} = this.props;
|
|
|
|
const iconName = AccountTypes.find(a => a.type === accountInfo.type).headerIcon;
|
|
|
|
|
|
|
|
return (
|
2016-08-26 01:44:23 +08:00
|
|
|
<OAuthSignInPage
|
|
|
|
authUrl={this._gmailAuthUrl}
|
|
|
|
iconName={iconName}
|
|
|
|
makeRequest={makeGmailOAuthRequest}
|
|
|
|
onSuccess={this.onSuccess}
|
|
|
|
serviceName="Gmail"
|
|
|
|
sessionKey={this._sessionKey}
|
|
|
|
/>
|
2016-05-28 05:05:27 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|