@plusscommunities/pluss-core-web 1.0.2 → 1.0.6

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.
Files changed (62) hide show
  1. package/dist/index.cjs.js +7349 -1360
  2. package/dist/index.esm.js +7341 -1358
  3. package/dist/index.umd.js +7346 -1364
  4. package/package.json +5 -3
  5. package/src/actions/AuthActions.js +83 -0
  6. package/src/actions/UsersActions.js +65 -0
  7. package/src/actions/index.js +2 -2
  8. package/src/actions/types.js +9 -9
  9. package/src/analytics.js +73 -0
  10. package/src/apis/analyticsActions.js +49 -0
  11. package/src/apis/authActions.js +58 -0
  12. package/src/apis/fileActions.js +92 -94
  13. package/src/apis/index.js +7 -0
  14. package/src/apis/profileActions.js +133 -0
  15. package/src/apis/stringActions.js +25 -0
  16. package/src/apis/typeActions.js +186 -0
  17. package/src/apis/userActions.js +128 -0
  18. package/src/apis/utilityActions.js +35 -0
  19. package/src/colours.js +16 -16
  20. package/src/components/AnalyticsFilter.js +110 -0
  21. package/src/components/AudienceIncluder.js +174 -0
  22. package/src/components/AudienceSelector.js +549 -0
  23. package/src/components/CheckBox.js +77 -0
  24. package/src/components/DatePicker.js +268 -0
  25. package/src/components/DropdownInput.js +223 -0
  26. package/src/components/FileInput.js +314 -0
  27. package/src/components/ImageInput.js +971 -0
  28. package/src/components/MakerPopup.js +300 -0
  29. package/src/components/OptionsSection.js +64 -0
  30. package/src/components/P60Icon.js +40 -0
  31. package/src/components/ProfilePic.js +35 -0
  32. package/src/components/Reactions.js +77 -0
  33. package/src/components/Tag.js +62 -0
  34. package/src/components/TextFormatPopup.js +54 -0
  35. package/src/components/TimePicker.js +205 -0
  36. package/src/components/UserListing.js +64 -0
  37. package/src/components/index.js +23 -7
  38. package/src/components/svg-icons.json +6 -0
  39. package/src/config.js +10 -0
  40. package/src/helper/HelpDeskWidget.js +52 -0
  41. package/src/helper/api/getUrl.js +15 -0
  42. package/src/helper/api/getUrlParams.js +9 -0
  43. package/src/helper/api/safeReadParams.js +6 -0
  44. package/src/helper/colours.js/getAppColourFromState.js +10 -0
  45. package/src/helper/files/canvasImageUploader.js +159 -0
  46. package/src/helper/files/get1400.js +28 -0
  47. package/src/helper/files/getExtension.js +9 -0
  48. package/src/helper/files/getFileName.js +13 -0
  49. package/src/helper/files/getThumb300.js +32 -0
  50. package/src/helper/files/isVideo.js +8 -0
  51. package/src/{helper.js → helper/helper.js} +19 -130
  52. package/src/helper/index.js +29 -0
  53. package/src/helper/site/getSiteName.js +16 -0
  54. package/src/helper/site/getSiteNameFromRoles.js +12 -0
  55. package/src/helper/storage/readJSONFromStorage.js +9 -0
  56. package/src/helper/storage/setLocalStorage.js +5 -0
  57. package/src/helper/strings/isEmail.js +11 -0
  58. package/src/helper/strings/onlyAlphanumeric.js +8 -0
  59. package/src/helper/strings/randomString.js +10 -0
  60. package/src/helper/strings/toParagraphed.js +17 -0
  61. package/src/index.js +2 -1
  62. package/src/session.js +107 -107
@@ -0,0 +1,29 @@
1
+ // api
2
+ export { default as getUrl } from './api/getUrl';
3
+ export { default as getUrlParams } from './api/getUrlParams';
4
+ export { default as safeReadParams } from './api/safeReadParams';
5
+
6
+ // files
7
+ export { default as get1400 } from './files/get1400';
8
+ export { default as getExtension } from './files/getExtension';
9
+ export { default as getFileName } from './files/getFileName';
10
+ export { default as getThumb300 } from './files/getThumb300';
11
+ export { default as isVideo } from './files/isVideo';
12
+
13
+ // strings
14
+ export { default as isEmail } from './strings/isEmail';
15
+ export { default as randomString } from './strings/randomString';
16
+ export { default as toParagraphed } from './strings/toParagraphed';
17
+ export { default as onlyAlphanumeric } from './strings/onlyAlphanumeric';
18
+
19
+ // site
20
+ export { default as getSiteName } from './site/getSiteName';
21
+ export { default as getSiteNameFromRoles } from './site/getSiteNameFromRoles';
22
+
23
+ // storage
24
+ export { default as readJSONFromStorage } from './storage/readJSONFromStorage';
25
+ export { default as setLocalStorage } from './storage/setLocalStorage';
26
+
27
+ // misc
28
+ export * from './helper';
29
+ export * from './HelpDeskWidget';
@@ -0,0 +1,16 @@
1
+ import _ from 'lodash';
2
+
3
+ const getSiteName = (site, sites) => {
4
+ if (site === 'hq') {
5
+ return 'HQ';
6
+ }
7
+ const siteObject = _.find(sites, (t) => {
8
+ return t.Id === site;
9
+ });
10
+ if (siteObject) {
11
+ return siteObject.siteName;
12
+ }
13
+ return site;
14
+ };
15
+
16
+ export default getSiteName;
@@ -0,0 +1,12 @@
1
+ import getSiteName from './getSiteName';
2
+
3
+ const getSiteNameFromRoles = (site, roles) => {
4
+ return getSiteName(
5
+ site,
6
+ roles.map((r) => {
7
+ return r.siteInfo;
8
+ }),
9
+ );
10
+ };
11
+
12
+ export default getSiteNameFromRoles;
@@ -0,0 +1,9 @@
1
+ const readJSONFromStorage = (storage, key, fallback) => {
2
+ const value = storage.getItem(key);
3
+ if (value) {
4
+ return JSON.parse(value);
5
+ }
6
+ return fallback;
7
+ };
8
+
9
+ export default readJSONFromStorage;
@@ -0,0 +1,5 @@
1
+ const setLocalStorage = (key, value, isJson) => {
2
+ window.localStorage.setItem(key, isJson ? JSON.stringify(value) : value);
3
+ };
4
+
5
+ export default setLocalStorage;
@@ -0,0 +1,11 @@
1
+ import _ from 'lodash';
2
+
3
+ const isEmail = (email) => {
4
+ if (_.isEmpty(email)) return false;
5
+ const atpos = email.indexOf('@');
6
+ const dotpos = email.lastIndexOf('.');
7
+ if (atpos < 1 || dotpos < atpos + 2 || dotpos + 2 >= email.length) return false;
8
+ return true;
9
+ };
10
+
11
+ export default isEmail;
@@ -0,0 +1,8 @@
1
+ const onlyAlphanumeric = (input) => {
2
+ if (!input) {
3
+ return input;
4
+ }
5
+ return input.replace(/[^a-z0-9]/gi, '');
6
+ };
7
+
8
+ export default onlyAlphanumeric;
@@ -0,0 +1,10 @@
1
+ const randomString = () => {
2
+ return 'xxxxxxxx4xxxyxxxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
3
+ // eslint-disable-next-line
4
+ var r = (Math.random() * 16) | 0,
5
+ v = c === 'x' ? r : (r & 0x3) | 0x8;
6
+ return v.toString(16);
7
+ });
8
+ };
9
+
10
+ export default randomString;
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import _ from 'lodash';
3
+
4
+ const toParagraphed = (text, style) => {
5
+ if (!text) return text;
6
+ text = text.replace(/\t/g, '\u00a0\u00a0\u00a0\u00a0');
7
+ const textSplit = text.split('\n');
8
+ return _.map(textSplit, (t, i) => {
9
+ return (
10
+ <span key={`paragraph_${i}`} style={{ display: 'block', ...style }}>
11
+ {t || '\u00A0'}
12
+ </span>
13
+ );
14
+ });
15
+ };
16
+
17
+ export default toParagraphed;
package/src/index.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import Config from './config';
2
2
  import * as Session from './session';
3
+ import * as Analytics from './analytics';
3
4
  import * as Helper from './helper';
4
5
  import * as Colours from './colours';
5
6
  import * as Actions from './actions';
6
7
  import * as Apis from './apis';
7
8
  import * as Components from './components';
8
9
 
9
- export { Config, Session, Helper, Colours, Actions, Apis, Components };
10
+ export { Config, Session, Analytics, Helper, Colours, Actions, Apis, Components };
package/src/session.js CHANGED
@@ -27,9 +27,9 @@ export const authedFunction = async (request) => {
27
27
  }
28
28
  };
29
29
 
30
- // export const unauthedFunction = (request) => {
31
- // return axios(request);
32
- // };
30
+ export const unauthedFunction = (request) => {
31
+ return axios(request);
32
+ };
33
33
 
34
34
  export const getCurrentUserSub = async () => {
35
35
  try {
@@ -88,17 +88,17 @@ export const checkLoggedIn = async (self) => {
88
88
  // });
89
89
  // };
90
90
 
91
- // export const isTheBest = (auth, isPlussSpaceMaster) => {
92
- // if (auth && auth.user) {
93
- // if (isPlussSpaceMaster) {
94
- // // only plussSpace master
95
- // return validateAccess('plussSpace', 'master', auth);
96
- // }
97
- // // any master
98
- // return validateAccess('hq', 'master', auth);
99
- // }
100
- // return false;
101
- // };
91
+ export const isTheBest = (auth, isPlussSpaceMaster) => {
92
+ if (auth && auth.user) {
93
+ if (isPlussSpaceMaster) {
94
+ // only plussSpace master
95
+ return validateAccess('plussSpace', 'master', auth);
96
+ }
97
+ // any master
98
+ return validateAccess('hq', 'master', auth);
99
+ }
100
+ return false;
101
+ };
102
102
 
103
103
  // export const getRolesWithAccess = (roles, type) => {
104
104
  // return _.filter(roles, (role) => {
@@ -156,103 +156,103 @@ export const validateAccess = (site, type, auth, noRole) => {
156
156
  return !_.isEmpty(role.Permissions) && _.includes(role.Permissions, type);
157
157
  };
158
158
 
159
- // export const getApiError = (error) => {
160
- // try {
161
- // const errorData = error.response.data;
162
- // const errorMessage = errorData && errorData.error;
163
- // return errorMessage || errorData || error;
164
- // } catch (e) {
165
- // return error;
166
- // }
167
- // };
159
+ export const getApiError = (error) => {
160
+ try {
161
+ const errorData = error.response.data;
162
+ const errorMessage = errorData && errorData.error;
163
+ return errorMessage || errorData || error;
164
+ } catch (e) {
165
+ return error;
166
+ }
167
+ };
168
168
 
169
- // export const getEnabledFeatures = (siteInfo, interfaces) => {
170
- // const interfaceSettings = !_.isEmpty(interfaces)
171
- // ? interfaces.map((t) => {
172
- // if (t.Type === 'TV') {
173
- // return t;
174
- // }
175
- // return t.Settings;
176
- // })
177
- // : [];
169
+ export const getEnabledFeatures = (siteInfo, interfaces) => {
170
+ const interfaceSettings = !_.isEmpty(interfaces)
171
+ ? interfaces.map((t) => {
172
+ if (t.Type === 'TV') {
173
+ return t;
174
+ }
175
+ return t.Settings;
176
+ })
177
+ : [];
178
178
 
179
- // const siteSettings = siteInfo && siteInfo.Settings ? siteInfo.Settings : {};
180
- // const hidden = siteInfo && siteInfo.Hidden ? siteInfo.Hidden : [];
181
- // const notHidden = siteInfo && siteInfo.NotHidden ? siteInfo.NotHidden : [];
182
- // const defaultFeatures = ['users', 'alerts'];
183
- // let features = [...defaultFeatures];
184
- // if (siteSettings.TabSettings) {
185
- // interfaceSettings.push(siteSettings.TabSettings);
186
- // } else {
187
- // features = [...features, ...(siteSettings.HomeWidgets || ['events', 'news'])];
188
- // if (!_.includes(hidden, 'whatsOn')) {
189
- // // second tab is enabled - add features
190
- // features.push(siteSettings.MainWidget1 || 'events');
191
- // }
192
- // if (!_.includes(hidden, 'marketplace')) {
193
- // // third tab is enabled - add features
194
- // features = [...features, ...(siteSettings.Widgets2 || ['services', 'offers', 'facilities'])];
195
- // }
196
- // if (!_.includes(hidden, 'people')) {
197
- // // fourth tab is enabled - add features
198
- // features.push(siteSettings.MainWidget3 || 'people');
199
- // }
200
- // }
179
+ const siteSettings = siteInfo && siteInfo.Settings ? siteInfo.Settings : {};
180
+ const hidden = siteInfo && siteInfo.Hidden ? siteInfo.Hidden : [];
181
+ const notHidden = siteInfo && siteInfo.NotHidden ? siteInfo.NotHidden : [];
182
+ const defaultFeatures = ['users', 'alerts'];
183
+ let features = [...defaultFeatures];
184
+ if (siteSettings.TabSettings) {
185
+ interfaceSettings.push(siteSettings.TabSettings);
186
+ } else {
187
+ features = [...features, ...(siteSettings.HomeWidgets || ['events', 'news'])];
188
+ if (!_.includes(hidden, 'whatsOn')) {
189
+ // second tab is enabled - add features
190
+ features.push(siteSettings.MainWidget1 || 'events');
191
+ }
192
+ if (!_.includes(hidden, 'marketplace')) {
193
+ // third tab is enabled - add features
194
+ features = [...features, ...(siteSettings.Widgets2 || ['services', 'offers', 'facilities'])];
195
+ }
196
+ if (!_.includes(hidden, 'people')) {
197
+ // fourth tab is enabled - add features
198
+ features.push(siteSettings.MainWidget3 || 'people');
199
+ }
200
+ }
201
201
 
202
- // interfaceSettings.forEach((s) => {
203
- // if (!Array.isArray(s) && s.Type && s.Type === 'TV') {
204
- // // TV Views
205
- // features = [
206
- // ...features,
207
- // ...s.Settings.widgets.map((w) => {
208
- // return w.key;
209
- // }),
210
- // ];
211
- // } else {
212
- // // App Views
213
- // (s || []).forEach((t) => {
214
- // if (t.isEnabled) {
215
- // features = [...features, ...t.widgets];
216
- // }
217
- // });
218
- // }
219
- // });
202
+ interfaceSettings.forEach((s) => {
203
+ if (!Array.isArray(s) && s.Type && s.Type === 'TV') {
204
+ // TV Views
205
+ features = [
206
+ ...features,
207
+ ...s.Settings.widgets.map((w) => {
208
+ return w.key;
209
+ }),
210
+ ];
211
+ } else {
212
+ // App Views
213
+ (s || []).forEach((t) => {
214
+ if (t.isEnabled) {
215
+ features = [...features, ...t.widgets];
216
+ }
217
+ });
218
+ }
219
+ });
220
220
 
221
- // if (
222
- // (siteSettings.TabSettings &&
223
- // _.some(siteSettings.TabSettings, (t) => {
224
- // return t.type === 'menu' && t.isEnabled;
225
- // })) ||
226
- // (!siteSettings.TabSettings && !_.includes(hidden, 'more'))
227
- // ) {
228
- // // more tab is enabled - add features
229
- // if (!_.includes(hidden, 'maintenanceRequest')) {
230
- // features.push('maintenance');
231
- // }
232
- // if (!_.includes(hidden, 'infoPages')) {
233
- // features.push('infoPages');
234
- // }
235
- // if (!_.includes(hidden, 'maps')) {
236
- // features.push('maps');
237
- // }
238
- // if (!_.includes(hidden, 'importantContacts')) {
239
- // features.push('importantContacts');
240
- // }
241
- // if (!_.includes(hidden, 'feedback')) {
242
- // features.push('feedback');
243
- // }
244
- // if (!_.includes(hidden, 'surveys')) {
245
- // features.push('surveys');
246
- // }
247
- // }
248
- // if (_.includes(notHidden, 'visitors')) {
249
- // features.push('visitors');
250
- // }
251
- // if (_.includes(features, 'services')) {
252
- // features.push('sponsors');
253
- // }
254
- // return _.uniq(features);
255
- // };
221
+ if (
222
+ (siteSettings.TabSettings &&
223
+ _.some(siteSettings.TabSettings, (t) => {
224
+ return t.type === 'menu' && t.isEnabled;
225
+ })) ||
226
+ (!siteSettings.TabSettings && !_.includes(hidden, 'more'))
227
+ ) {
228
+ // more tab is enabled - add features
229
+ if (!_.includes(hidden, 'maintenanceRequest')) {
230
+ features.push('maintenance');
231
+ }
232
+ if (!_.includes(hidden, 'infoPages')) {
233
+ features.push('infoPages');
234
+ }
235
+ if (!_.includes(hidden, 'maps')) {
236
+ features.push('maps');
237
+ }
238
+ if (!_.includes(hidden, 'importantContacts')) {
239
+ features.push('importantContacts');
240
+ }
241
+ if (!_.includes(hidden, 'feedback')) {
242
+ features.push('feedback');
243
+ }
244
+ if (!_.includes(hidden, 'surveys')) {
245
+ features.push('surveys');
246
+ }
247
+ }
248
+ if (_.includes(notHidden, 'visitors')) {
249
+ features.push('visitors');
250
+ }
251
+ if (_.includes(features, 'services')) {
252
+ features.push('sponsors');
253
+ }
254
+ return _.uniq(features);
255
+ };
256
256
 
257
257
  // export const isFeatureEnabled = (features, key) => {
258
258
  // if (_.includes(features, key)) {