import React from 'react'; import { Actions, IdentityStore, localized, localizedReactFragment } from 'mailspring-exports'; import { OpenIdentityPageButton, BillingModal, RetinaImg } from 'mailspring-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 onLearnMore = () => shell.openExternal('https://getmailspring.com/pro'); return (
{localizedReactFragment( `You are using %@, which is free! You can link up to four email accounts and try pro features like snooze, send later, read receipts and reminders a few times a week.`, {localized('Mailspring Basic')} )} {localizedReactFragment( `Mailspring is independent %@ software, and subscription revenue allows us spend time maintaining and improving the product.`, {localized('open source')} )}

{localizedReactFragment( `Upgrade to %@ to use all these great features permanently:`, {localized('Mailspring Pro')} )}
  • {localized(`Rich contact profiles`)}
  • {localized(`Follow-up reminders`)}
  • {localized(`Read Receipts`)}
  • {localized(`Link tracking`)}
  • {localized(`Powerful template support`)}
  • {localized(`Send Later`)}
  • {localized(`Company overviews`)}
  • {localized(`Snooze messages`)}
  • {localized(`Mailbox insights`)}
  • {localized(`... and much more!`)}
$8
{localized('monthly')}
{' '} {localized(`Get Mailspring Pro`)}
); } _renderPaidPlan(planName, effectivePlanName) { const planDisplayName = planName.replace('Annual', ` (${localized('Annual')})`); const unpaidNote = effectivePlanName !== planName && (

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

); return (
Thank you for using{' '} {`Mailspring ${planDisplayName}`}{' '} and supporting independent software. Get the most out of your subscription: visit the{' '} Help Center {' '} to learn more about great features like reminders, templates, and activity insights. {unpaidNote}
); } render() { const { identity } = this.state; const { firstName, lastName, emailAddress, stripePlan = '', stripePlanEffective = '', } = identity; const logout = () => Actions.logoutNylasIdentity(); return (
{firstName} {lastName}
{emailAddress}
{localized('Sign Out')}
{stripePlan === 'Basic' ? this._renderBasic() : this._renderPaidPlan(stripePlan, stripePlanEffective)}
); } } export default PreferencesIdentity;