aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/settings/team/TeamDashboard.js
blob: 366b0113aa28d409072d10acf27ede9ee54a5605 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { observer } from 'mobx-react';
import { defineMessages, intlShape } from 'react-intl';
import ReactTooltip from 'react-tooltip';
import injectSheet from 'react-jss';
import classnames from 'classnames';

import { Badge } from '@meetfranz/ui';
import Loader from '../../ui/Loader';
import Button from '../../ui/Button';
import Infobox from '../../ui/Infobox';
import globalMessages from '../../../i18n/globalMessages';
import UpgradeButton from '../../ui/UpgradeButton';

const messages = defineMessages({
  headline: {
    id: 'settings.team.headline',
    defaultMessage: '!!!Team',
  },
  contentHeadline: {
    id: 'settings.team.contentHeadline',
    defaultMessage: '!!!Franz for Teams',
  },
  intro: {
    id: 'settings.team.intro',
    defaultMessage: '!!!You and your team use Franz? You can now manage Premium subscriptions for as many colleagues, friends or family members as you want, all from within one account.',
  },
  copy: {
    id: 'settings.team.copy',
    defaultMessage: '!!!Franz for Teams gives you the option to invite co-workers to your team by sending them email invitations and manage their subscriptions in your account’s preferences. Don’t waste time setting up subscriptions for every team member individually, forget about multiple invoices and different billing cycles - one team to rule them all!',
  },
  manageButton: {
    id: 'settings.team.manageAction',
    defaultMessage: '!!!Manage your Team on meetfranz.com',
  },
  upgradeButton: {
    id: 'settings.team.upgradeAction',
    defaultMessage: '!!!Upgrade your Account',
  },
});

const styles = {
  cta: {
    margin: [40, 'auto'],
    height: 'auto',
  },
  container: {
    display: 'flex',
    flexDirection: 'column',
    height: 'auto',

    '@media(min-width: 800px)': {
      flexDirection: 'row',
    },
  },
  content: {
    height: 'auto',
    order: 1,

    '@media(min-width: 800px)': {
      order: 0,
    },
  },
  image: {
    display: 'block',
    height: 150,
    order: 0,
    margin: [0, 'auto', 40, 'auto'],

    '@media(min-width: 800px)': {
      marginLeft: 40,
      order: 1,
    },
  },
  headline: {
    marginBottom: 0,
  },
  headlineWithSpacing: {
    marginBottom: 'inherit',
  },
  proRequired: {
    margin: [10, 0, 40],
    height: 'auto',
  },
  buttonContainer: {
    display: 'flex',
    height: 'auto',
  },
};


export default @injectSheet(styles) @observer class TeamDashboard extends Component {
  static propTypes = {
    isLoading: PropTypes.bool.isRequired,
    userInfoRequestFailed: PropTypes.bool.isRequired,
    retryUserInfoRequest: PropTypes.func.isRequired,
    openTeamManagement: PropTypes.func.isRequired,
    classes: PropTypes.object.isRequired,
    isProUser: PropTypes.bool.isRequired,
  };

  static contextTypes = {
    intl: intlShape,
  };

  render() {
    const {
      isLoading,
      userInfoRequestFailed,
      retryUserInfoRequest,
      openTeamManagement,
      isProUser,
      classes,
    } = this.props;
    const { intl } = this.context;

    return (
      <div className="settings__main">
        <div className="settings__header">
          <span className="settings__header-item">
            {intl.formatMessage(messages.headline)}
          </span>
        </div>
        <div className="settings__body">
          {isLoading && (
            <Loader />
          )}

          {!isLoading && userInfoRequestFailed && (
            <Infobox
              icon="alert"
              type="danger"
              ctaLabel={intl.formatMessage(messages.tryReloadUserInfoRequest)}
              ctaLoading={isLoading}
              ctaOnClick={retryUserInfoRequest}
            >
              {intl.formatMessage(messages.userInfoRequestFailed)}
            </Infobox>
          )}

          {!userInfoRequestFailed && (
            <>
              {!isLoading && (
                <>
                  <>
                    <h1 className={classnames({
                      [classes.headline]: true,
                      [classes.headlineWithSpacing]: isProUser,
                    })}
                    >
                      {intl.formatMessage(messages.contentHeadline)}

                    </h1>
                    {!isProUser && (
                      <Badge className={classes.proRequired}>{intl.formatMessage(globalMessages.proRequired)}</Badge>
                    )}
                    <div className={classes.container}>
                      <div className={classes.content}>
                        <p>{intl.formatMessage(messages.intro)}</p>
                        <p>{intl.formatMessage(messages.copy)}</p>
                      </div>
                      <img className={classes.image} src="https://cdn.franzinfra.com/announcements/assets/teams.png" alt="Franz for Teams" />
                    </div>
                    <div className={classes.buttonContainer}>
                      {!isProUser ? (
                        <UpgradeButton
                          className={classes.cta}
                          gaEventInfo={{ category: 'Todos', event: 'upgrade' }}
                          requiresPro
                          short
                        />
                      ) : (
                        <Button
                          label={intl.formatMessage(messages.manageButton)}
                          onClick={openTeamManagement}
                          className={classes.cta}
                        />
                      )}
                    </div>
                  </>
                </>
              )}
            </>
          )}
        </div>
        <ReactTooltip place="right" type="dark" effect="solid" />
      </div>
    );
  }
}