@openeventkit/event-site 2.0.87 → 2.0.88

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/env.template CHANGED
@@ -31,4 +31,5 @@ GATSBY_SENTRY_RELEASE=
31
31
  GATSBY_METADATA_TITLE=
32
32
  GATSBY_METADATA_DESCRIPTION=
33
33
  GATSBY_CMS_BACKEND_REPO=
34
- GATSBY_CMS_BACKEND_BRANCH=
34
+ GATSBY_CMS_BACKEND_BRANCH=
35
+ GATSBY_SITE_URL=
package/gatsby-ssr.js CHANGED
@@ -1,4 +1,3 @@
1
- import * as React from "react";
2
1
  import ReduxWrapper from "./src/state/ReduxWrapper";
3
2
  import {
4
3
  HtmlAttributes,
@@ -31,6 +30,4 @@ global.window.matchMedia = () => ({
31
30
  addListener: () => {},
32
31
  removeListener: () => {}
33
32
  });
34
- global.window.window.requestAnimationFrame = () => {};
35
- global.window.window.cancelAnimationFrame = () => {};
36
33
  global.XMLHttpRequest = XMLHttpRequest;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@openeventkit/event-site",
3
3
  "description": "Event Site",
4
- "version": "2.0.87",
4
+ "version": "2.0.88",
5
5
  "author": "Tipit LLC",
6
6
  "dependencies": {
7
7
  "@mui/base": "^5.0.0-alpha.114",
@@ -29,6 +29,7 @@
29
29
  "browser-tabs-lock": "^1.2.15",
30
30
  "buffer": "^6.0.3",
31
31
  "bulma": "^0.9.0",
32
+ "chain-function": "^1.0.1",
32
33
  "classnames": "^2.3.1",
33
34
  "clean-html": "^1.5.0",
34
35
  "codemirror": "^5.55.0",
@@ -87,6 +88,7 @@
87
88
  "react-bootstrap": "^0.33.1",
88
89
  "react-datetime": "^2.16.3",
89
90
  "react-dnd": "15.1.1",
91
+ "react-dnd-html5-backend": "^16.0.1",
90
92
  "react-dom": "^18.2.0",
91
93
  "react-final-form": "6.5.9",
92
94
  "react-i18next": "^11.16.9",
@@ -1,29 +1,34 @@
1
1
  import * as React from "react";
2
2
  import PropTypes from "prop-types";
3
+ import useSiteMetadata from "@utils/useSiteMetadata";
3
4
  import useSiteSettings from "@utils/useSiteSettings";
4
- import { Helmet } from "react-helmet";
5
5
  import { getSrc } from "gatsby-plugin-image";
6
- import { getUrl } from "@utils/urlFormating";
6
+ import { buildUrl } from "@utils/urlFormating";
7
+ import { getEnvVariable, SITE_URL } from "@utils/envVariables";
7
8
 
8
9
  const Seo = ({ title, description, location, children }) => {
9
10
  const {
10
- siteMetadata: {
11
- title: siteTitle,
12
- description: defaultDescription,
13
- image
14
- }
15
- } = useSiteSettings();
16
- const host = typeof window !== "undefined" ? window.location.host : null;
17
- const scheme = typeof window !== "undefined" ? window.location.protocol.replace(":", "") : "https";
11
+ title: siteTitle,
12
+ description: defaultDescription
13
+ } = useSiteMetadata();
14
+
15
+ const siteSettings = useSiteSettings();
16
+ const image = siteSettings.siteMetadata?.image
17
+
18
+ const siteUrl = getEnvVariable(SITE_URL);
19
+ const siteUrlInfo = siteUrl ? new URL(siteUrl) : null;
20
+ const scheme = siteUrlInfo ? siteUrlInfo.protocol.replace(":", "") : "https";
21
+ const host = siteUrlInfo ? siteUrlInfo.host : null;
18
22
  const { pathname } = location;
23
+
19
24
  const seo = {
20
25
  title: title ? `${siteTitle} - ${title}` : siteTitle,
21
26
  description: description || defaultDescription,
22
- url: getUrl(scheme, host, pathname),
23
- image: host && image ? getUrl(scheme, host, getSrc(image)) : null,
27
+ url: buildUrl(scheme, host, pathname),
28
+ image: host && image ? buildUrl(scheme, host, getSrc(image)) : null,
24
29
  };
25
30
  return (
26
- <Helmet>
31
+ <>
27
32
  {seo.title && <title>{seo.title}</title>}
28
33
  {seo.description && <meta name="description" content={seo.description} />}
29
34
  {seo.url && <meta property="og:url" content={seo.url} />}
@@ -38,7 +43,7 @@ const Seo = ({ title, description, location, children }) => {
38
43
  {seo.description && <meta name="twitter:description" content={seo.description} />}
39
44
  {seo.image && <meta name="twitter:image" content={seo.image} />}
40
45
  {children}
41
- </Helmet>
46
+ </>
42
47
  );
43
48
  };
44
49
 
@@ -0,0 +1,25 @@
1
+ import { loggedUserReducer } from "openstack-uicore-foundation/lib/security/reducers";
2
+ import settingReducer from "./setting-reducer";
3
+ import userReducer from "./user-reducer";
4
+ import clockReducer from "./clock-reducer";
5
+ import summitReducer from "./summit-reducer";
6
+ import allSchedulesReducer from "./all-schedules-reducer";
7
+ import presentationsReducer from "./presentations-reducer";
8
+ import eventReducer from "./event-reducer";
9
+ import speakerReducer from "./speaker-reducer";
10
+ import sponsorReducer from "./sponsor-reducer";
11
+ import extraQuestionsReducer from "./extra-questions-reducer";
12
+
13
+ export {
14
+ loggedUserReducer,
15
+ settingReducer,
16
+ userReducer,
17
+ clockReducer,
18
+ summitReducer,
19
+ allSchedulesReducer,
20
+ presentationsReducer,
21
+ eventReducer,
22
+ speakerReducer,
23
+ sponsorReducer,
24
+ extraQuestionsReducer,
25
+ };
@@ -1,31 +1,21 @@
1
- import React from "react";
2
- import {connect} from "react-redux";
3
- import {navigate} from "gatsby";
1
+ import * as React from "react";
2
+ import { navigate } from "gatsby";
4
3
 
5
4
  /**
6
- *
7
- * @param isLoggedIn
8
- * @param location
9
- * @param children
10
- * @returns {null|*}
11
- * @constructor
5
+ * @param {boolean} isLoggedIn - Indicates whether the user is logged in.
6
+ * @param {object} location - The location object from React Router.
7
+ * @param {ReactNode} children - The children components to be rendered.
8
+ * @returns {ReactNode|null} - Returns children if isLoggedIn is true, otherwise redirects to login.
12
9
  */
13
- const WithAuthRoute = ({
14
-
15
- isLoggedIn,
16
- location,
17
- children
18
- }) => {
19
-
10
+ const WithAuthRoute = ({ isLoggedIn, location, children }) => {
11
+ React.useEffect(() => {
20
12
  if (!isLoggedIn) {
21
- // reject it and redirect with current location to login
22
- navigate("/#login=1", {state: {backUrl: `${location.pathname}`,},});
23
- return null;
13
+ // Use navigate with state to redirect and add data to navigation state
14
+ navigate("/#login=1", { state: { backUrl: `${location.pathname}` } });
24
15
  }
16
+ }, [isLoggedIn, location.pathname]);
25
17
 
26
- return children;
18
+ return isLoggedIn ? children : null;
27
19
  };
28
20
 
29
- const mapStateToProps = ({}) => ({});
30
-
31
- export default connect(mapStateToProps, {})(WithAuthRoute);
21
+ export default WithAuthRoute;
@@ -1,23 +1,24 @@
1
- import React from "react";
1
+ import * as React from "react";
2
2
  import { Provider } from "react-redux";
3
3
  import { PersistGate } from "redux-persist/integration/react";
4
- import store, { persistor } from "./store";
5
-
4
+ import { store, persistor } from "./store";
6
5
  import { RESET_STATE } from "../actions/base-actions-definitions";
7
6
 
8
7
  const onBeforeLift = () => {
9
- const params = new URLSearchParams(window.location.search);
10
- const flush = params.has("flushState");
8
+ const params = new URLSearchParams(window.location.search);
9
+ const flush = params.has("flushState");
11
10
 
12
- if (flush) {
13
- store.dispatch({ type: RESET_STATE, payload: null });
14
- }
11
+ if (flush) {
12
+ store.dispatch({ type: RESET_STATE, payload: null });
13
+ }
15
14
  };
16
15
 
17
- export default ({ element }) => (
18
- <Provider store={store}>
19
- <PersistGate onBeforeLift={onBeforeLift} persistor={persistor}>
20
- {element}
21
- </PersistGate>
22
- </Provider>
16
+ const ReduxWrapper = ({ element }) => (
17
+ <Provider store={store}>
18
+ <PersistGate onBeforeLift={onBeforeLift} persistor={persistor}>
19
+ {() => element}
20
+ </PersistGate>
21
+ </Provider>
23
22
  );
23
+
24
+ export default ReduxWrapper;
@@ -1,68 +1,62 @@
1
1
  import { applyMiddleware, compose, createStore } from "redux";
2
2
  import { persistCombineReducers, persistStore } from "redux-persist";
3
+ import storage from "redux-persist/lib/storage";
3
4
  import thunk from "redux-thunk";
4
- import storage from "./reduxPersistStorage";
5
5
 
6
- import { loggedUserReducer } from "openstack-uicore-foundation/lib/security/reducers";
7
- import settingReducer from "../reducers/setting-reducer";
8
- import userReducer from "../reducers/user-reducer";
9
- import clockReducer from "../reducers/clock-reducer";
10
- import summitReducer from "../reducers/summit-reducer";
11
- import allSchedulesReducer from "../reducers/all-schedules-reducer";
12
- import presentationsReducer from "../reducers/presentations-reducer";
13
- import eventReducer from "../reducers/event-reducer";
14
- import speakerReducer from "../reducers/speaker-reducer";
15
- import sponsorReducer from "../reducers/sponsor-reducer";
16
- import extraQuestionReducer from "../reducers/extra-questions-reducer";
6
+ import * as reducers from "../reducers";
17
7
 
18
- // get from process.env bc window is not set yet
8
+ // Get from process.env because window is not set yet
19
9
  const clientId = process.env.GATSBY_OAUTH2_CLIENT_ID;
20
10
  const summitID = process.env.GATSBY_SUMMIT_ID;
21
11
 
22
12
  const config = {
23
13
  key: `root_${clientId}_${summitID}`,
24
- storage: storage,
14
+ storage,
25
15
  blacklist: [
26
16
  // this will be not saved to persistent storage see
27
17
  // https://github.com/rt2zz/redux-persist#blacklist--whitelist
28
- 'summitState',
29
- 'allSchedulesState',
30
- 'presentationsState',
31
- 'eventState',
32
- 'speakerState',
33
- 'sponsorState',
34
- ]
18
+ "summitState",
19
+ "allSchedulesState",
20
+ "presentationsState",
21
+ "eventState",
22
+ "speakerState",
23
+ "sponsorState",
24
+ ],
35
25
  };
36
26
 
37
- const persistedReducers = persistCombineReducers(config, {
38
- loggedUserState: loggedUserReducer,
39
- settingState: settingReducer,
40
- userState: userReducer,
41
- allSchedulesState: allSchedulesReducer,
42
- clockState: clockReducer,
43
- eventState: eventReducer,
44
- presentationsState: presentationsReducer,
45
- summitState: summitReducer,
46
- speakerState: speakerReducer,
47
- sponsorState: sponsorReducer,
48
- extraQuestionState: extraQuestionReducer
49
- });
27
+ const states = {
28
+ loggedUserState: reducers.loggedUserReducer,
29
+ settingState: reducers.settingReducer,
30
+ userState: reducers.userReducer,
31
+ clockState: reducers.clockReducer,
32
+ summitState: reducers.summitReducer,
33
+ allSchedulesState: reducers.allSchedulesReducer,
34
+ presentationsState: reducers.presentationsReducer,
35
+ eventState: reducers.eventReducer,
36
+ speakerState: reducers.speakerReducer,
37
+ sponsorState: reducers.sponsorReducer,
38
+ extraQuestionsReducer: reducers.extraQuestionsReducer
39
+ };
50
40
 
51
- function appendLoggedUser({ getState }) {
52
- return next => action => {
53
- const { userState: { userProfile } } = getState();
54
- // Call the next dispatch method in the middleware chain.
55
- action.userProfile = userProfile;
56
- return next(action);
57
- }
58
- }
41
+ const appendLoggedUser = ({ getState }) => (next) => (action) => {
42
+ const { userState: { userProfile } } = getState();
43
+ action.userProfile = userProfile;
44
+ return next(action);
45
+ };
59
46
 
60
- const composeEnhancers = typeof window === 'object' && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : compose;
47
+ const composeEnhancers = typeof window === "object" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
48
+ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
49
+ : compose;
61
50
 
62
- const store = createStore(persistedReducers, composeEnhancers(applyMiddleware(appendLoggedUser, thunk)));
51
+ const enhancer = composeEnhancers(applyMiddleware(appendLoggedUser, thunk));
63
52
 
64
- const onRehydrateComplete = () => {};
53
+ // Create store with persistor
54
+ export const { store, persistor } = (() => {
55
+ const persistedReducers = persistCombineReducers(config, states);
65
56
 
66
- export const persistor = persistStore(store, null, onRehydrateComplete);
57
+ const store = createStore(persistedReducers, enhancer);
58
+ const onRehydrateComplete = () => {};
59
+ const persistor = persistStore(store, null, onRehydrateComplete);
67
60
 
68
- export default store;
61
+ return { store, persistor };
62
+ })();
@@ -1,16 +1,17 @@
1
- import React from 'react'
2
- import {connect} from "react-redux";
3
- import PropTypes from 'prop-types'
4
- import {navigate} from 'gatsby'
5
- import {getEnvVariable, REGISTRATION_BASE_URL} from '../utils/envVariables'
6
- import HeroComponent from '../components/HeroComponent'
1
+ import * as React from "react";
2
+ import { connect } from "react-redux";
3
+ import PropTypes from "prop-types";
4
+ import { Redirect } from "@gatsbyjs/reach-router";
5
+ import { getEnvVariable, REGISTRATION_BASE_URL } from "../utils/envVariables";
6
+ import HeroComponent from "../components/HeroComponent";
7
+ import { navigate } from "gatsby";
7
8
 
8
9
  export const TicketErrorPageTemplate = class extends React.Component {
9
10
 
10
11
  constructor(props) {
11
12
  super(props);
12
13
 
13
- const {location} = this.props;
14
+ const { location } = this.props;
14
15
 
15
16
  this.state = {
16
17
  error: location.state?.error
@@ -18,21 +19,21 @@ export const TicketErrorPageTemplate = class extends React.Component {
18
19
  }
19
20
 
20
21
  redirect() {
21
- const {error} = this.state;
22
+ const { error } = this.state;
22
23
 
23
24
  if (getEnvVariable(REGISTRATION_BASE_URL)) {
24
25
 
25
26
  let targetUrl = null;
26
27
 
27
28
  switch (error) {
28
- case 'no-virtual-access':
29
- targetUrl = `/`;
29
+ case "no-virtual-access":
30
+ targetUrl = "/";
30
31
  break
31
- case 'no-ticket':
32
- targetUrl = `/#registration=1`;
32
+ case "no-ticket":
33
+ targetUrl = "/#registration=1";
33
34
  break;
34
- case 'incomplete':
35
- targetUrl = `/a/extra-questions`;
35
+ case "incomplete":
36
+ targetUrl = "/a/extra-questions";
36
37
  break;
37
38
  default:
38
39
  break;
@@ -46,25 +47,23 @@ export const TicketErrorPageTemplate = class extends React.Component {
46
47
  return;
47
48
  }
48
49
 
49
- setTimeout(() => {
50
- navigate('/')
51
- }, 5000);
50
+ setTimeout(() => navigate("/"), 5000);
52
51
  }
53
52
 
54
53
  getErrorMessage() {
55
- const {error} = this.state;
54
+ const { error } = this.state;
56
55
 
57
- let message = '';
56
+ let message = "";
58
57
 
59
58
  switch (error) {
60
- case 'no-virtual-access':
61
- message = 'I’m sorry your badge does not allow access to this section.';
59
+ case "no-virtual-access":
60
+ message = "I’m sorry your badge does not allow access to this section.";
62
61
  break;
63
- case 'no-ticket':
64
- message = 'I’m sorry you are not registered for this event.';
62
+ case "no-ticket":
63
+ message = "I’m sorry you are not registered for this event.";
65
64
  break;
66
- case 'incomplete':
67
- message = 'You have not answered questions required to join the event.';
65
+ case "incomplete":
66
+ message = "You have not answered questions required to join the event.";
68
67
  break;
69
68
  default:
70
69
  break;
@@ -74,11 +73,13 @@ export const TicketErrorPageTemplate = class extends React.Component {
74
73
  }
75
74
 
76
75
  getRedirectMessage() {
77
- const {error} = this.state;
78
- let message = '';
76
+ const { error } = this.state;
77
+
78
+ let message = "";
79
+
79
80
  switch (error) {
80
- case 'no-ticket':
81
- message = getEnvVariable(REGISTRATION_BASE_URL) ? 'You will be redirected to registration.' : '';
81
+ case "no-ticket":
82
+ message = getEnvVariable(REGISTRATION_BASE_URL) ? "You will be redirected to registration." : "";
82
83
  break;
83
84
  default:
84
85
  break;
@@ -88,7 +89,7 @@ export const TicketErrorPageTemplate = class extends React.Component {
88
89
  }
89
90
 
90
91
  render() {
91
- const {error} = this.state;
92
+ const { error } = this.state;
92
93
 
93
94
  if (error) {
94
95
  this.redirect();
@@ -100,8 +101,7 @@ export const TicketErrorPageTemplate = class extends React.Component {
100
101
  )
101
102
  }
102
103
 
103
- navigate('/');
104
- return null
104
+ return <Redirect to={"/"} noThrow />;
105
105
  }
106
106
  };
107
107
 
@@ -109,23 +109,19 @@ TicketErrorPageTemplate.propTypes = {
109
109
  location: PropTypes.object,
110
110
  };
111
111
 
112
- const TicketErrorPage = ({location, summit}) => {
113
-
114
- return (
115
- <TicketErrorPageTemplate
116
- location={location}
117
- summit={summit}
118
- />
119
- )
120
-
121
- };
112
+ const TicketErrorPage = ({ location, summit }) => (
113
+ <TicketErrorPageTemplate
114
+ location={location}
115
+ summit={summit}
116
+ />
117
+ );
122
118
 
123
119
  TicketErrorPage.propTypes = {
124
120
  location: PropTypes.object,
125
121
  };
126
122
 
127
- const mapStateToProps = ({summitState}) => ({
123
+ const mapStateToProps = ({ summitState }) => ({
128
124
  summit: summitState.summit,
129
125
  });
130
126
 
131
- export default connect(mapStateToProps, {})(TicketErrorPage);
127
+ export default connect(mapStateToProps, null)(TicketErrorPage);
@@ -1,3 +1,4 @@
1
+ export const SITE_URL = 'SITE_URL';
1
2
  export const IDP_BASE_URL = 'IDP_BASE_URL';
2
3
  export const SUMMIT_API_BASE_URL = 'SUMMIT_API_BASE_URL';
3
4
  export const SUMMIT_ID = 'SUMMIT_ID';
@@ -26,6 +27,15 @@ export const TIMEINTERVALSINCE1970_API_URL = 'TIMEINTERVALSINCE1970_API_URL';
26
27
  export const ABLY_API_KEY = 'ABLY_API_KEY';
27
28
 
28
29
  const processEnv = {
30
+ /**
31
+ * Retrieve the site URL from environment variable set by the deploy provider.
32
+ * See documentation for more details:
33
+ * - Netlify: {@link https://docs.netlify.com/configure-builds/environment-variables/#deploy-urls-and-metadata}
34
+ * - Cloudflare Pages: {@link https://developers.cloudflare.com/pages/platform/build-configuration#environment-variables}
35
+ *
36
+ * If not available, fallback to user-defined GATSBY_SITE_URL env var.
37
+ */
38
+ SITE_URL: process.env.GATSBY_URL || process.env.GATSBY_CF_PAGES_URL || process.env.GATSBY_SITE_URL,
29
39
  IDP_BASE_URL: process.env.GATSBY_IDP_BASE_URL,
30
40
  SUMMIT_API_BASE_URL: process.env.GATSBY_SUMMIT_API_BASE_URL,
31
41
  API_BASE_URL: process.env.GATSBY_SUMMIT_API_BASE_URL,
@@ -62,6 +72,7 @@ export const getEnvVariable = (name) => {
62
72
  }
63
73
 
64
74
  if (typeof window === 'object') {
75
+ window.SITE_URL = processEnv[SITE_URL];
65
76
  window.OAUTH2_FLOW = processEnv[OAUTH2_FLOW];
66
77
  window.OAUTH2_CLIENT_ID = processEnv[OAUTH2_CLIENT_ID];
67
78
  window.SCOPES = processEnv[SCOPES];
@@ -1,5 +1,5 @@
1
1
 
2
- export const getUrl = (scheme, host, pathname) => {
2
+ export const buildUrl = (scheme, host, pathname) => {
3
3
  if (!host) return null;
4
4
  const domain = `${scheme}://${host}`;
5
5
  return `${domain}${pathname ?? "/"}`;
@@ -1,26 +0,0 @@
1
- /**
2
- * Create dummy storage on the server-side and wrapper for localStorage on the client-side.
3
- * @see https://github.com/rt2zz/redux-persist/issues/1208#issuecomment-658695446
4
- * @see https://stackoverflow.com/questions/57781527/how-to-solve-console-error-redux-persist-failed-to-create-sync-storage-falli
5
- * @see https://github.com/vercel/next.js/discussions/15687#discussioncomment-45319
6
- */
7
-
8
- import createWebStorage from 'redux-persist/lib/storage/createWebStorage';
9
-
10
- const createNoopStorage = () => {
11
- return {
12
- getItem(_key) {
13
- return Promise.resolve(null);
14
- },
15
- setItem(_key, value) {
16
- return Promise.resolve(value);
17
- },
18
- removeItem(_key) {
19
- return Promise.resolve();
20
- },
21
- };
22
- };
23
-
24
- const storage = typeof window !== 'undefined' ? createWebStorage('local') : createNoopStorage();
25
-
26
- export default storage;