import React from 'react'; import {Actions, IdentityStore} from 'nylas-exports'; import {OpenIdentityPageButton, BillingModal, RetinaImg} from 'nylas-component-kit'; import {shell} from 'electron'; class RefreshButton extends React.Component { constructor(props) { super(props); this.state = {refreshing: false}; } componentDidMount() { this._mounted = true; } componentWillUnmount() { this._mounted = false; } _onClick = () => { this.setState({refreshing: true}); IdentityStore.fetchIdentity().then(() => { setTimeout(() => { if (this._mounted) { this.setState({refreshing: false}); } }, 400); }); } render() { return (
) } } class PreferencesIdentity extends React.Component { static displayName = 'PreferencesIdentity'; constructor() { super(); this.state = this._getStateFromStores(); } componentDidMount() { this.unsubscribe = IdentityStore.listen(() => { this.setState(this._getStateFromStores()); }); } componentWillUnmount() { this.unsubscribe(); } _getStateFromStores() { return { identity: IdentityStore.identity() || {}, }; } _onUpgrade = () => { Actions.openModal({ component: ( ), width: BillingModal.IntrinsicWidth, height: BillingModal.IntrinsicHeight, }) } _renderBasic() { const learnMore = () => shell.openExternal("https://getmailspring.com/pro") return (
You are using Mailspring Basic. You can link up to four email accounts and try out pro features like snooze, send later, read receipts and reminders. Upgrade to Mailspring Pro to unlock a more powerful email experience.
Upgrade to Mailspring Pro
Learn More
) } _renderPaidPlan(planName, effectivePlanName) { const unpaidNote = (effectivePlanName !== planName) && (

{`Note: Due to issues with your most recent payment, you've been temporarily downgraded to Mailspring ${effectivePlanName}. Click 'Billing' below to correct the issue.`}

) return (
Thank you for using {`Mailspring ${planName}`} and supporting independent software. {unpaidNote}
) } render() { const {identity} = this.state; const {firstName, lastName, emailAddress, stripePlan, stripePlanEffective} = identity; const logout = () => Actions.logoutNylasIdentity() return (
{firstName} {lastName}
{emailAddress}
Sign Out
{stripePlan === 'Basic' ? this._renderBasic() : this._renderPaidPlan(stripePlan, stripePlanEffective)}
); } } export default PreferencesIdentity;