From fffa3875f888aef2109dc7d91dc681069786fc0b Mon Sep 17 00:00:00 2001 From: Amine Mouafik Date: Wed, 18 Dec 2019 15:49:26 +0100 Subject: Better handling of account settings (if using without account) --- .../settings/account/AccountDashboard.js | 316 ++++++++++++--------- 1 file changed, 181 insertions(+), 135 deletions(-) (limited to 'src/components') diff --git a/src/components/settings/account/AccountDashboard.js b/src/components/settings/account/AccountDashboard.js index 83dc34a52..7d6bad883 100644 --- a/src/components/settings/account/AccountDashboard.js +++ b/src/components/settings/account/AccountDashboard.js @@ -3,9 +3,7 @@ import PropTypes from 'prop-types'; import { observer, PropTypes as MobxPropTypes } from 'mobx-react'; import { defineMessages, intlShape } from 'react-intl'; import ReactTooltip from 'react-tooltip'; -import { - ProBadge, H1, H2, -} from '@meetfranz/ui'; +import { ProBadge, H1, H2 } from '@meetfranz/ui'; import moment from 'moment'; import Loader from '../../ui/Loader'; @@ -13,6 +11,7 @@ import Button from '../../ui/Button'; import Infobox from '../../ui/Infobox'; import SubscriptionForm from '../../../containers/subscription/SubscriptionFormScreen'; import { i18nPlanName } from '../../../helpers/plan-helpers'; +import { LOCAL_SERVER } from '../../../config'; const messages = defineMessages({ headline: { @@ -69,11 +68,13 @@ const messages = defineMessages({ }, deleteInfo: { id: 'settings.account.deleteInfo', - defaultMessage: '!!!If you don\'t need your Ferdi account any longer, you can delete your account and all related data here.', + defaultMessage: + "!!!If you don't need your Ferdi account any longer, you can delete your account and all related data here.", }, deleteEmailSent: { id: 'settings.account.deleteEmailSent', - defaultMessage: '!!!You have received an email with a link to confirm your account deletion. Your account and data cannot be restored!', + defaultMessage: + '!!!You have received an email with a link to confirm your account deletion. Your account and data cannot be restored!', }, trial: { id: 'settings.account.trial', @@ -89,7 +90,16 @@ const messages = defineMessages({ }, trialUpdateBillingInformation: { id: 'settings.account.trialUpdateBillingInfo', - defaultMessage: '!!!Please update your billing info to continue using {license} after your trial period.', + defaultMessage: + '!!!Please update your billing info to continue using {license} after your trial period.', + }, + accountUnavailable: { + id: 'settings.account.accountUnavailable', + defaultMessage: 'Account is unavailable', + }, + accountUnavailableInfo: { + id: 'settings.account.accountUnavailableInfo', + defaultMessage: 'You are using Ferdi without an account. If you want to use Ferdi with an account and keep your services synchronized across installations, please select a server in the Settings tab then login.', }, }); @@ -110,6 +120,7 @@ class AccountDashboard extends Component { upgradeToPro: PropTypes.func.isRequired, openInvoices: PropTypes.func.isRequired, onCloseSubscriptionWindow: PropTypes.func.isRequired, + server: PropTypes.string.isRequired, }; static contextTypes = { @@ -132,6 +143,7 @@ class AccountDashboard extends Component { upgradeToPro, openInvoices, onCloseSubscriptionWindow, + server, } = this.props; const { intl } = this.context; @@ -141,6 +153,8 @@ class AccountDashboard extends Component { planName = i18nPlanName(user.team.plan, intl); } + const isUsingWithoutAccount = server === LOCAL_SERVER; + return (
@@ -149,154 +163,186 @@ class AccountDashboard extends Component {
- {isLoading && ( - + {isUsingWithoutAccount && ( + <> +

+ {intl.formatMessage(messages.accountUnavailable)} +

+

+ {intl.formatMessage(messages.accountUnavailableInfo)} +

+ )} + {!isUsingWithoutAccount && ( + <> + {isLoading && } - {!isLoading && userInfoRequestFailed && ( - - {intl.formatMessage(messages.userInfoRequestFailed)} - - )} + {!isLoading && userInfoRequestFailed && ( + + {intl.formatMessage(messages.userInfoRequestFailed)} + + )} - {!userInfoRequestFailed && ( - <> - {!isLoading && ( + {!userInfoRequestFailed && ( <> -
-
-
- -
-
-

- {`${user.firstname} ${user.lastname}`} - {user.isPremium && ( - <> - {' '} - - - )} -

-

- {user.organization && `${user.organization}, `} - {user.email} -

- {user.isPremium && ( -
+ {!isLoading && ( + <> +
+
+
+ +
+
+

+ {`${user.firstname} ${user.lastname}`} + {user.isPremium && ( + <> + {' '} + + + )} +

+

+ {user.organization && `${user.organization}, `} + {user.email} +

+ {user.isPremium && ( +
+
+ )} +
+ {!user.isPremium && (
- )} -
- {!user.isPremium && ( -
-
- {user.isPremium && user.isSubscriptionOwner && ( -
-
-

- {intl.formatMessage(messages.yourLicense)} -

-

- Franz - {' '} - {isPremiumOverrideUser ? 'Premium' : planName} - {user.team.isTrial && ( - <> - {' – '} - {intl.formatMessage(messages.trial)} - )} -

- {user.team.isTrial && ( - <> -
-

- {intl.formatMessage(messages.trialEndsIn, { - duration: moment.duration(moment().diff(user.team.trialEnd)).humanize(), - })} -

+
+
+ {user.isPremium && user.isSubscriptionOwner && ( +
+
+

{intl.formatMessage(messages.yourLicense)}

- {intl.formatMessage(messages.trialUpdateBillingInformation, { - license: planName, - })} + Franz + {' '} + {isPremiumOverrideUser ? 'Premium' : planName} + {user.team.isTrial && ( + <> + {' – '} + {intl.formatMessage(messages.trial)} + + )}

- - )} - {!isProUser && ( -
-
+ )} +
+
+
+
+ )} + {!user.isPremium && ( +
+
+
- )} -
-
+ )} + + )} + +
+
+

{intl.formatMessage(messages.headlineDangerZone)}

+ {!isDeleteAccountSuccessful && ( +
+

{intl.formatMessage(messages.deleteInfo)}

-
-
- )} - {!user.isPremium && ( -
-
- -
+ )} + {isDeleteAccountSuccessful && ( +

{intl.formatMessage(messages.deleteEmailSent)}

+ )}
- )} +
)} - -
-
-

{intl.formatMessage(messages.headlineDangerZone)}

- {!isDeleteAccountSuccessful && ( -
-

{intl.formatMessage(messages.deleteInfo)}

-
- )} - {isDeleteAccountSuccessful && ( -

{intl.formatMessage(messages.deleteEmailSent)}

- )} -
-
)}
-- cgit v1.2.3-70-g09d2