@openeventkit/event-site 1.0.33 → 1.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@openeventkit/event-site",
3
3
  "description": "Event Site",
4
- "version": "1.0.33",
4
+ "version": "1.0.35",
5
5
  "author": "Tipit LLC",
6
6
  "dependencies": {
7
7
  "@mui/base": "^5.0.0-alpha.114",
8
8
  "@ncwidgets/file-relation": "^0.8.0",
9
9
  "@ncwidgets/id": "^0.8.1",
10
+ "@react-pdf/renderer": "^3.1.12",
10
11
  "@react-spring/web": "^9.4.3",
11
12
  "@sentry/browser": "^7.39.0",
12
13
  "@sentry/cli": "^2.13.0",
@@ -116,7 +117,7 @@
116
117
  "stream-browserify": "^3.0.0",
117
118
  "stream-chat": "^2.7.2",
118
119
  "stream-chat-react": "3.1.7",
119
- "summit-registration-lite": "^4.0.16",
120
+ "summit-registration-lite": "^4.0.17",
120
121
  "superagent": "8.0.9",
121
122
  "sweetalert2": "^9.17.0",
122
123
  "upcoming-events-widget": "2.0.8",
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useState } from "react"
1
+ import React, { useEffect, useState, useMemo } from "react"
2
2
  import { navigate } from "gatsby"
3
3
  import { connect } from "react-redux";
4
4
  import URI from "urijs"
@@ -13,8 +13,13 @@ import { formatThirdPartyProviders } from "../utils/loginUtils";
13
13
  import 'summit-registration-lite/dist/index.css';
14
14
  import styles from '../styles/login-button.module.scss'
15
15
  import PropTypes from 'prop-types'
16
+ import Link from "./Link";
16
17
 
17
- const LoginButton = ({
18
+ import { PHASES } from "@utils/phasesUtils";
19
+ import { getDefaultLocation } from "@utils/loginUtils";
20
+ import { userHasAccessLevel, VirtualAccessLevel } from "../utils/authorizedGroups";
21
+
22
+ const AuthComponent = ({
18
23
  getThirdPartyProviders,
19
24
  thirdPartyProviders,
20
25
  setPasswordlessLogin,
@@ -22,9 +27,14 @@ const LoginButton = ({
22
27
  marketingPageSettings,
23
28
  allowsNativeAuth,
24
29
  allowsOtpAuth,
30
+ isLoggedUser,
31
+ summitPhase,
32
+ userProfile,
33
+ eventRedirect,
25
34
  location,
26
35
  style = {},
27
- children,
36
+ renderLoginButton = null,
37
+ renderEnterButton = null
28
38
  }) => {
29
39
  const [isActive, setIsActive] = useState(false);
30
40
  const [initialEmailValue, setInitialEmailValue] = useState('');
@@ -33,6 +43,11 @@ const LoginButton = ({
33
43
  const [otpLength, setOtpLength] = useState(null);
34
44
  const [otpError, setOtpError] = useState(false);
35
45
 
46
+ const hasVirtualBadge = useMemo(() =>
47
+ userProfile ? userHasAccessLevel(userProfile.summit_tickets, VirtualAccessLevel) : false
48
+ , [userProfile]);
49
+ const defaultPath = getDefaultLocation(eventRedirect, hasVirtualBadge);
50
+
36
51
  useEffect(() => {
37
52
  const fragmentParser = new FragmentParser();
38
53
  setIsActive(fragmentParser.getParam('login'));
@@ -51,7 +66,7 @@ const LoginButton = ({
51
66
  : '/';
52
67
  const fragmentParser = new FragmentParser();
53
68
  const paramBackUrl = fragmentParser.getParam('backurl');
54
- if(paramBackUrl)
69
+ if (paramBackUrl)
55
70
  backUrl = paramBackUrl;
56
71
  return encode ? URI.encode(backUrl) : backUrl;
57
72
  };
@@ -72,6 +87,10 @@ const LoginButton = ({
72
87
  setOtpError(false);
73
88
  }
74
89
 
90
+ const handleEnterEvent = () => {
91
+ navigate(defaultPath);
92
+ }
93
+
75
94
  const getPasswordlessCode = (email) => {
76
95
  const backUrl = getBackURL(true)
77
96
  const params = {
@@ -112,7 +131,7 @@ const LoginButton = ({
112
131
  const loginComponentProps = {
113
132
  loginOptions: formatThirdPartyProviders(thirdPartyProviders),
114
133
  login: (provider) => onClickLogin(provider),
115
- getLoginCode: (email) => sendCode(email),
134
+ getLoginCode: (email) => sendCode(email),
116
135
  allowsNativeAuth: allowsNativeAuth,
117
136
  allowsOtpAuth: allowsOtpAuth,
118
137
  initialEmailValue: initialEmailValue,
@@ -122,7 +141,7 @@ const LoginButton = ({
122
141
  const passwordlessLoginProps = {
123
142
  email: userEmail,
124
143
  codeLength: otpLength,
125
- passwordlessLogin: (code) => loginPasswordless(code, userEmail).then(() => navigate(getBackURL(false)) ).catch((e) => console.log(e)),
144
+ passwordlessLogin: (code) => loginPasswordless(code, userEmail).then(() => navigate(getBackURL(false))).catch((e) => console.log(e)),
126
145
  codeError: otpError,
127
146
  goToLogin: () => setOtpLogin(false),
128
147
  getLoginCode: (email) => sendCode(email),
@@ -130,15 +149,32 @@ const LoginButton = ({
130
149
 
131
150
  const { loginButton } = marketingPageSettings.hero.buttons;
132
151
 
152
+ const defaultLoginButton = () => (
153
+ <button className={`${styles.button} button is-large`} onClick={handleOpenPopup}>
154
+ <i className={`fa fa-2x fa-edit icon is-large`} />
155
+ <b>{loginButton.text}</b>
156
+ </button>
157
+ );
158
+
159
+ const defaultEnterButton = () => (
160
+ <Link className={styles.link} to={defaultPath}>
161
+ <button className={`${styles.button} button is-large`}>
162
+ <i className={`fa fa-2x fa-sign-in icon is-large`} />
163
+ <b>Enter</b>
164
+ </button>
165
+ </Link>
166
+ );
167
+
133
168
  return (
134
169
  <div style={style} className={styles.loginButtonWrapper}>
135
- {children ?
136
- React.cloneElement(children, { onClick: handleOpenPopup })
170
+ {!isLoggedUser ?
171
+ renderLoginButton ? renderLoginButton(handleOpenPopup) : defaultLoginButton()
137
172
  :
138
- <button className={`${styles.button} button is-large`} onClick={handleOpenPopup}>
139
- <i className={`fa fa-2x fa-edit icon is-large`} />
140
- <b>{loginButton.text}</b>
141
- </button>
173
+ (summitPhase >= PHASES.DURING && hasVirtualBadge ?
174
+ renderEnterButton ? renderEnterButton(handleEnterEvent) : defaultEnterButton()
175
+ :
176
+ null
177
+ )
142
178
  }
143
179
  {isActive &&
144
180
  <div id={`${styles.modal}`} className="modal is-active">
@@ -161,7 +197,7 @@ const LoginButton = ({
161
197
  )
162
198
  };
163
199
 
164
- const mapStateToProps = ({ userState, summitState, settingState }) => {
200
+ const mapStateToProps = ({ userState, summitState, settingState, clockState, loggedUserState }) => {
165
201
  return ({
166
202
  loadingProfile: userState.loading,
167
203
  loadingIDP: userState.loadingIDP,
@@ -170,7 +206,12 @@ const mapStateToProps = ({ userState, summitState, settingState }) => {
170
206
  allowsOtpAuth: summitState.allows_otp_auth,
171
207
  summit: summitState.summit,
172
208
  colorSettings: settingState.colorSettings,
209
+ userProfile: userState.userProfile,
173
210
  marketingPageSettings: settingState.marketingPageSettings,
211
+ summitPhase: clockState.summit_phase,
212
+ isLoggedUser: loggedUserState.isLoggedUser,
213
+ // TODO: move to site settings i/o marketing page settings
214
+ eventRedirect: settingState.marketingPageSettings.eventRedirect
174
215
  })
175
216
  };
176
217
 
@@ -179,8 +220,8 @@ export default connect(mapStateToProps, {
179
220
  setPasswordlessLogin,
180
221
  setUserOrder,
181
222
  checkOrderData
182
- })(LoginButton)
223
+ })(AuthComponent)
183
224
 
184
- LoginButton.propTypes = {
225
+ AuthComponent.propTypes = {
185
226
  location: PropTypes.object.isRequired,
186
227
  }
@@ -3,27 +3,16 @@ import React, {
3
3
  useState,
4
4
  useEffect
5
5
  } from "react";
6
- import { connect } from "react-redux";
7
6
  import { getSrc } from "gatsby-plugin-image";
8
7
  import Slider from "react-slick";
9
- import URI from "urijs";
10
- import Link from "../components/Link";
11
- import LoginButton from "./LoginButton";
8
+ import AuthComponent from "./AuthComponent";
12
9
  import RegistrationLiteComponent from "./RegistrationLiteComponent";
13
10
 
14
- import { PHASES } from "@utils/phasesUtils";
15
-
16
11
  import styles from "../styles/marketing-hero.module.scss";
17
12
 
18
13
  const MarketingHeroComponent = ({
19
14
  location,
20
15
  marketingPageSettings,
21
- summitPhase,
22
- isLoggedUser,
23
- summit,
24
- doLogin,
25
- hasVirtualBadge,
26
- defaultPath
27
16
  }) => {
28
17
 
29
18
  const sliderRef = useRef(null);
@@ -41,41 +30,10 @@ const MarketingHeroComponent = ({
41
30
  };
42
31
  }, []);
43
32
 
44
- const getBackURL = () => {
45
- const backUrl = location.state?.backUrl
46
- ? location.state.backUrl
47
- : defaultPath;
48
- return URI.encode(backUrl);
49
- };
50
-
51
- const onClickLogin = () => {
52
- doLogin(getBackURL());
53
- };
54
33
 
55
34
  const getButtons = () => {
56
35
  const { registerButton, loginButton } = marketingPageSettings.hero.buttons;
57
36
 
58
- if (summitPhase >= PHASES.DURING && isLoggedUser) {
59
- return (
60
- <>
61
- {registerButton.display &&
62
- (
63
- <span className={styles.link}>
64
- <RegistrationLiteComponent location={location} />
65
- </span>
66
- )}
67
- {hasVirtualBadge && /* only show button if we have virtual access */
68
- <Link className={styles.link} to={defaultPath}>
69
- <button className={`${styles.button} button is-large`}>
70
- <i className={`fa fa-2x fa-sign-in icon is-large`}/>
71
- <b>Enter</b>
72
- </button>
73
- </Link>
74
- }
75
- </>
76
- );
77
- }
78
-
79
37
  return (
80
38
  <>
81
39
  {registerButton.display &&
@@ -84,8 +42,8 @@ const MarketingHeroComponent = ({
84
42
  <RegistrationLiteComponent location={location} />
85
43
  </span>
86
44
  )}
87
- {loginButton.display && !isLoggedUser && (
88
- <LoginButton location={location} />
45
+ {loginButton.display && (
46
+ <AuthComponent location={location} />
89
47
  )}
90
48
  </>
91
49
  );
@@ -170,9 +128,4 @@ const MarketingHeroComponent = ({
170
128
  );
171
129
  }
172
130
 
173
- const mapStateToProps = ({ clockState, summitState }) => ({
174
- summitPhase: clockState.summit_phase,
175
- summit: summitState.summit
176
- });
177
-
178
- export default connect(mapStateToProps, null)(MarketingHeroComponent);
131
+ export default MarketingHeroComponent;
@@ -0,0 +1 @@
1
+ {}
@@ -1,16 +1,10 @@
1
1
  import * as React from "react";
2
- import { useMemo } from "react";
3
2
  import { connect } from "react-redux";
4
3
  import { graphql } from "gatsby";
5
4
  import Seo from "../components/Seo";
6
5
  import MarketingPageTemplate from "../templates/marketing-page-template";
7
6
  import withRealTimeUpdates from "@utils/real_time_updates/withRealTimeUpdates";
8
7
  import withFeedsWorker from "@utils/withFeedsWorker";
9
- import { getDefaultLocation } from "@utils/loginUtils";
10
-
11
- import { doLogin } from "openstack-uicore-foundation/lib/security/methods";
12
-
13
- import { userHasAccessLevel, VirtualAccessLevel } from "../utils/authorizedGroups";
14
8
 
15
9
  export const marketingPageQuery = graphql`
16
10
  query {
@@ -110,45 +104,28 @@ const MarketingPage = ({
110
104
  lastDataSync,
111
105
  summit,
112
106
  summitPhase,
113
- userProfile,
114
107
  isLoggedUser,
115
- eventRedirect
116
- }) => {
117
- // we store this calculation to use it later
118
- const hasVirtualBadge = useMemo(() =>
119
- userProfile ? userHasAccessLevel(userProfile.summit_tickets, VirtualAccessLevel) : false
120
- , [userProfile]);
121
- const defaultPath = getDefaultLocation(eventRedirect, hasVirtualBadge);
122
- return (
123
- <MarketingPageTemplate
124
- location={location}
125
- data={data}
126
- lastDataSync={lastDataSync}
127
- summit={summit}
128
- summitPhase={summitPhase}
129
- doLogin={doLogin}
130
- userProfile={userProfile}
131
- isLoggedUser={isLoggedUser}
132
- hasVirtualBadge={hasVirtualBadge}
133
- defaultPath={defaultPath}
134
- />
135
- )
136
- };
108
+ }) => (
109
+ <MarketingPageTemplate
110
+ location={location}
111
+ data={data}
112
+ lastDataSync={lastDataSync}
113
+ summit={summit}
114
+ summitPhase={summitPhase}
115
+ isLoggedUser={isLoggedUser}
116
+ />
117
+ );
137
118
 
138
119
  const mapStateToProps = ({
139
120
  settingState,
140
121
  summitState,
141
122
  clockState,
142
- userState,
143
123
  loggedUserState
144
124
  }) => ({
145
125
  lastDataSync: settingState.lastDataSync,
146
126
  summit: summitState.summit,
147
127
  summitPhase: clockState.summit_phase,
148
- userProfile: userState.userProfile,
149
128
  isLoggedUser: loggedUserState.isLoggedUser,
150
- // TODO: move to site settings i/o marketing page settings
151
- eventRedirect: settingState.marketingPageSettings.eventRedirect,
152
129
  });
153
130
 
154
131
  export default connect(mapStateToProps, {
@@ -3,7 +3,7 @@ import { connect } from 'react-redux'
3
3
  import { navigate } from "gatsby"
4
4
 
5
5
  import Layout from '../components/Layout'
6
- import LoginButton from '../components/LoginButton'
6
+ import AuthComponent from '../components/AuthComponent'
7
7
 
8
8
  import { getDefaultLocation } from '../utils/loginUtils'
9
9
  import {userHasAccessLevel, VirtualAccessLevel} from "../utils/authorizedGroups";
@@ -24,7 +24,7 @@ export const LoginPageTemplate = ({ loggedUserState, eventRedirect, location, us
24
24
 
25
25
  return (
26
26
  <React.Fragment>
27
- <LoginButton location={location} eventRedirect={eventRedirect} hasVirtualBadge={hasVirtualBadge}/>
27
+ <AuthComponent location={location} />
28
28
  </React.Fragment>
29
29
  )
30
30
  }
@@ -25,10 +25,7 @@ const MarketingPageTemplate = ({
25
25
  lastDataSync,
26
26
  summit,
27
27
  summitPhase,
28
- doLogin,
29
28
  isLoggedUser,
30
- hasVirtualBadge,
31
- defaultPath
32
29
  }) => {
33
30
 
34
31
  const {
@@ -58,11 +55,6 @@ const MarketingPageTemplate = ({
58
55
  <MarketingHeroComponent
59
56
  location={location}
60
57
  marketingPageSettings={marketingPageJson}
61
- summit={summit}
62
- doLogin={doLogin}
63
- isLoggedUser={isLoggedUser}
64
- hasVirtualBadge={hasVirtualBadge}
65
- defaultPath={defaultPath}
66
58
  />
67
59
  {summit && marketingPageJson.countdown?.display && <Countdown summit={summit} text={marketingPageJson?.countdown?.text} />}
68
60
  <div className="columns" id="marketing-columns">