diff options
Diffstat (limited to 'src/components/settings/team/TeamDashboard.tsx')
-rw-r--r-- | src/components/settings/team/TeamDashboard.tsx | 204 |
1 files changed, 204 insertions, 0 deletions
diff --git a/src/components/settings/team/TeamDashboard.tsx b/src/components/settings/team/TeamDashboard.tsx new file mode 100644 index 000000000..3ef55fac6 --- /dev/null +++ b/src/components/settings/team/TeamDashboard.tsx | |||
@@ -0,0 +1,204 @@ | |||
1 | import { Component, ReactElement } from 'react'; | ||
2 | import { observer } from 'mobx-react'; | ||
3 | import { defineMessages, injectIntl, WrappedComponentProps } from 'react-intl'; | ||
4 | import ReactTooltip from 'react-tooltip'; | ||
5 | import withStyles, { WithStylesProps } from 'react-jss'; | ||
6 | import classnames from 'classnames'; | ||
7 | import Loader from '../../ui/Loader'; | ||
8 | import Button from '../../ui/button'; | ||
9 | import Infobox from '../../ui/Infobox'; | ||
10 | import { H1 } from '../../ui/headline'; | ||
11 | import { LIVE_FRANZ_API } from '../../../config'; | ||
12 | |||
13 | const messages = defineMessages({ | ||
14 | headline: { | ||
15 | id: 'settings.team.headline', | ||
16 | defaultMessage: 'Team', | ||
17 | }, | ||
18 | contentHeadline: { | ||
19 | id: 'settings.team.contentHeadline', | ||
20 | defaultMessage: 'Franz Team Management', | ||
21 | }, | ||
22 | intro: { | ||
23 | id: 'settings.team.intro', | ||
24 | defaultMessage: | ||
25 | 'You are currently using Franz Servers, which is why you have access to Team Management.', | ||
26 | }, | ||
27 | copy: { | ||
28 | id: 'settings.team.copy', | ||
29 | defaultMessage: | ||
30 | "Franz's Team Management allows you to manage Franz Subscriptions for multiple users. Please keep in mind that having a Franz Premium subscription will give you no advantages in using Ferdium: The only reason you still have access to Team Management is so you can manage your legacy Franz Teams and so that you don't loose any functionality in managing your account.", | ||
31 | }, | ||
32 | manageButton: { | ||
33 | id: 'settings.team.manageAction', | ||
34 | defaultMessage: 'Manage your Team on meetfranz.com', | ||
35 | }, | ||
36 | teamsUnavailable: { | ||
37 | id: 'settings.team.teamsUnavailable', | ||
38 | defaultMessage: 'Teams are unavailable', | ||
39 | }, | ||
40 | teamsUnavailableInfo: { | ||
41 | id: 'settings.team.teamsUnavailableInfo', | ||
42 | defaultMessage: | ||
43 | 'Teams are currently only available when using the Franz Server and after paying for Franz Professional. Please change your server to https://api.franzinfra.com to use teams.', | ||
44 | }, | ||
45 | tryReloadUserInfoRequest: { | ||
46 | id: 'settings.team.tryReloadUserInfoRequest', | ||
47 | defaultMessage: 'Try reloading', | ||
48 | }, | ||
49 | userInfoRequestFailed: { | ||
50 | id: 'settings.team.userInfoRequestFailed', | ||
51 | defaultMessage: 'User Info request failed', | ||
52 | }, | ||
53 | }); | ||
54 | |||
55 | const styles = { | ||
56 | cta: { | ||
57 | margin: [40, 'auto'], | ||
58 | height: 'auto', | ||
59 | }, | ||
60 | container: { | ||
61 | display: 'flex', | ||
62 | flexDirection: 'column', | ||
63 | height: 'auto', | ||
64 | |||
65 | '@media(min-width: 800px)': { | ||
66 | flexDirection: 'row', | ||
67 | }, | ||
68 | }, | ||
69 | content: { | ||
70 | height: 'auto', | ||
71 | order: 1, | ||
72 | |||
73 | '@media(min-width: 800px)': { | ||
74 | order: 0, | ||
75 | }, | ||
76 | }, | ||
77 | image: { | ||
78 | display: 'block', | ||
79 | height: 150, | ||
80 | order: 0, | ||
81 | margin: [0, 'auto', 40, 'auto'], | ||
82 | |||
83 | '@media(min-width: 800px)': { | ||
84 | marginLeft: 40, | ||
85 | order: 1, | ||
86 | }, | ||
87 | }, | ||
88 | headline: { | ||
89 | marginBottom: 0, | ||
90 | }, | ||
91 | headlineWithSpacing: { | ||
92 | marginBottom: 'inherit', | ||
93 | }, | ||
94 | buttonContainer: { | ||
95 | display: 'flex', | ||
96 | height: 'auto', | ||
97 | }, | ||
98 | }; | ||
99 | |||
100 | interface IProps extends WithStylesProps<typeof styles>, WrappedComponentProps { | ||
101 | isLoading: boolean; | ||
102 | userInfoRequestFailed: boolean; | ||
103 | retryUserInfoRequest: () => void; | ||
104 | openTeamManagement: () => void; | ||
105 | server: string; | ||
106 | } | ||
107 | |||
108 | @observer | ||
109 | class TeamDashboard extends Component<IProps> { | ||
110 | render(): ReactElement { | ||
111 | const { | ||
112 | isLoading, | ||
113 | userInfoRequestFailed, | ||
114 | retryUserInfoRequest, | ||
115 | openTeamManagement, | ||
116 | classes, | ||
117 | server, | ||
118 | intl, | ||
119 | } = this.props; | ||
120 | |||
121 | return server === LIVE_FRANZ_API ? ( | ||
122 | <div className="settings__main"> | ||
123 | <div className="settings__header"> | ||
124 | <span className="settings__header-item"> | ||
125 | {intl.formatMessage(messages.headline)} | ||
126 | </span> | ||
127 | </div> | ||
128 | <div className="settings__body"> | ||
129 | {isLoading && <Loader />} | ||
130 | |||
131 | {!isLoading && userInfoRequestFailed && ( | ||
132 | <Infobox | ||
133 | icon="alert" | ||
134 | type="danger" | ||
135 | ctaLabel={intl.formatMessage(messages.tryReloadUserInfoRequest)} | ||
136 | ctaLoading={isLoading} | ||
137 | ctaOnClick={retryUserInfoRequest} | ||
138 | > | ||
139 | {intl.formatMessage(messages.userInfoRequestFailed)} | ||
140 | </Infobox> | ||
141 | )} | ||
142 | |||
143 | {!userInfoRequestFailed && !isLoading && ( | ||
144 | <> | ||
145 | <H1 | ||
146 | className={classnames({ | ||
147 | [classes.headline]: true, | ||
148 | [classes.headlineWithSpacing]: true, | ||
149 | })} | ||
150 | > | ||
151 | {intl.formatMessage(messages.contentHeadline)} | ||
152 | </H1> | ||
153 | <div className={classes.container}> | ||
154 | <div className={classes.content}> | ||
155 | <p>{intl.formatMessage(messages.intro)}</p> | ||
156 | <p>{intl.formatMessage(messages.copy)}</p> | ||
157 | </div> | ||
158 | <img | ||
159 | className={classes.image} | ||
160 | src="https://cdn.franzinfra.com/announcements/assets/teams.png" | ||
161 | alt="Ferdium for Teams" | ||
162 | /> | ||
163 | </div> | ||
164 | <div className={classes.buttonContainer}> | ||
165 | <Button | ||
166 | label={intl.formatMessage(messages.manageButton)} | ||
167 | onClick={openTeamManagement} | ||
168 | className={classes.cta} | ||
169 | /> | ||
170 | </div> | ||
171 | </> | ||
172 | )} | ||
173 | </div> | ||
174 | <ReactTooltip place="right" type="dark" effect="solid" /> | ||
175 | </div> | ||
176 | ) : ( | ||
177 | <div className="settings__main"> | ||
178 | <div className="settings__header"> | ||
179 | <span className="settings__header-item"> | ||
180 | {intl.formatMessage(messages.headline)} | ||
181 | </span> | ||
182 | </div> | ||
183 | <div className="settings__body"> | ||
184 | <H1 className={classes.headline}> | ||
185 | {intl.formatMessage(messages.teamsUnavailable)} | ||
186 | </H1> | ||
187 | <p | ||
188 | className="settings__message" | ||
189 | style={{ | ||
190 | borderTop: 0, | ||
191 | marginTop: 0, | ||
192 | }} | ||
193 | > | ||
194 | {intl.formatMessage(messages.teamsUnavailableInfo)} | ||
195 | </p> | ||
196 | </div> | ||
197 | </div> | ||
198 | ); | ||
199 | } | ||
200 | } | ||
201 | |||
202 | export default injectIntl( | ||
203 | withStyles(styles, { injectTheme: true })(TeamDashboard), | ||
204 | ); | ||