import React from 'react';
import { Actions, IdentityStore } 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 (
You are using
Mailspring Basic, 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.{' '}
Mailspring is independent{' '}
open source software, and
subscription revenue allows us spend time maintaining and improving the product.
Upgrade to
Mailspring Pro to use all these great features
permanently:
-
Rich contact profiles
-
Follow-up reminders
-
Read receipts
-
Link tracking
-
Powerful template support
-
Send later
-
Company overviews
-
Snooze messages
-
Mailbox insights
-
... and much more!
);
}
_renderPaidPlan(planName, effectivePlanName) {
const planDisplayName = planName.replace('Annual', ' (Annual)');
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 ${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}
{stripePlan === 'Basic'
? this._renderBasic()
: this._renderPaidPlan(stripePlan, stripePlanEffective)}
);
}
}
export default PreferencesIdentity;