@plusscommunities/pluss-core-web 1.7.3-beta.1 → 1.7.4-beta.0

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 (116) hide show
  1. package/dist/components.js +37233 -474
  2. package/dist/components.js.map +1 -1
  3. package/dist/index.js +37233 -474
  4. package/dist/index.js.map +1 -1
  5. package/package.json +22 -31
  6. package/.babelrc +0 -3
  7. package/dist/index.cjs.js +0 -10388
  8. package/dist/index.esm.js +0 -10349
  9. package/dist/index.umd.js +0 -10361
  10. package/rollup.config.js +0 -57
  11. package/src/actions/AuthActions.js +0 -83
  12. package/src/actions/LocalActions.js +0 -8
  13. package/src/actions/NavActions.js +0 -8
  14. package/src/actions/ScheduledActionsActions.js +0 -8
  15. package/src/actions/TemplateActions.js +0 -15
  16. package/src/actions/UsersActions.js +0 -95
  17. package/src/actions/index.js +0 -6
  18. package/src/actions/types.js +0 -23
  19. package/src/analytics.js +0 -183
  20. package/src/apis/analyticsActions.js +0 -53
  21. package/src/apis/authActions.js +0 -58
  22. package/src/apis/fileActions.js +0 -152
  23. package/src/apis/index.js +0 -10
  24. package/src/apis/profileActions.js +0 -133
  25. package/src/apis/scheduledActionsActions.js +0 -12
  26. package/src/apis/stringActions.js +0 -25
  27. package/src/apis/templateActions.js +0 -41
  28. package/src/apis/typeActions.js +0 -186
  29. package/src/apis/userActions.js +0 -169
  30. package/src/apis/utilityActions.js +0 -35
  31. package/src/colours.js +0 -134
  32. package/src/components/AddButton.js +0 -27
  33. package/src/components/AnalyticsFilter.js +0 -115
  34. package/src/components/Attachment.js +0 -27
  35. package/src/components/AudienceIncluder.js +0 -175
  36. package/src/components/AudienceSelector.js +0 -700
  37. package/src/components/Button.js +0 -66
  38. package/src/components/CheckBox.js +0 -77
  39. package/src/components/ColourOptions.js +0 -197
  40. package/src/components/ColourPicker.js +0 -267
  41. package/src/components/Comment.js +0 -46
  42. package/src/components/CommentSection.js +0 -116
  43. package/src/components/DatePicker.js +0 -290
  44. package/src/components/DropdownInput.js +0 -223
  45. package/src/components/DurationInput.js +0 -51
  46. package/src/components/ExportCsvPopup.js +0 -222
  47. package/src/components/FileInput.js +0 -389
  48. package/src/components/GenericInput.js +0 -169
  49. package/src/components/Header.js +0 -82
  50. package/src/components/HubSidebar.js +0 -134
  51. package/src/components/ImageInput.js +0 -987
  52. package/src/components/InputGroup.js +0 -18
  53. package/src/components/MakerPopup.js +0 -310
  54. package/src/components/MoreMenu.js +0 -22
  55. package/src/components/OptionsSection.js +0 -84
  56. package/src/components/OverlayPage.js +0 -74
  57. package/src/components/OverlayPageBottomButtons.js +0 -48
  58. package/src/components/OverlayPageContents.js +0 -48
  59. package/src/components/OverlayPageSection.js +0 -38
  60. package/src/components/P60Icon.js +0 -40
  61. package/src/components/PageTitle.js +0 -13
  62. package/src/components/Popup.js +0 -104
  63. package/src/components/ProfilePic.js +0 -50
  64. package/src/components/RadioButton.js +0 -144
  65. package/src/components/Reactions.js +0 -77
  66. package/src/components/SVGIcon.js +0 -33
  67. package/src/components/SideNavItem.js +0 -98
  68. package/src/components/StatBox.js +0 -49
  69. package/src/components/StatusButton.js +0 -22
  70. package/src/components/SuccessPopup.js +0 -57
  71. package/src/components/Tabs.js +0 -56
  72. package/src/components/Tag.js +0 -62
  73. package/src/components/Text.js +0 -20
  74. package/src/components/TextFormatPopup.js +0 -54
  75. package/src/components/TimePicker.js +0 -225
  76. package/src/components/UserListing.js +0 -111
  77. package/src/components/index.js +0 -46
  78. package/src/components/svg-icons.json +0 -821
  79. package/src/config.js +0 -25
  80. package/src/helper/HelpDeskWidget.js +0 -16
  81. package/src/helper/api/getUrl.js +0 -15
  82. package/src/helper/api/getUrlParams.js +0 -9
  83. package/src/helper/api/safeReadParams.js +0 -6
  84. package/src/helper/auth/getUserFromState.js +0 -8
  85. package/src/helper/colours/getAppColourFromState.js +0 -10
  86. package/src/helper/files/canvasImageUploader.js +0 -159
  87. package/src/helper/files/generateImageName.js +0 -10
  88. package/src/helper/files/get1400.js +0 -32
  89. package/src/helper/files/getExtension.js +0 -9
  90. package/src/helper/files/getFileName.js +0 -13
  91. package/src/helper/files/getThumb300.js +0 -36
  92. package/src/helper/files/isVideo.js +0 -8
  93. package/src/helper/helper.js +0 -97
  94. package/src/helper/index.js +0 -44
  95. package/src/helper/site/getMerchantsFromState.js +0 -9
  96. package/src/helper/site/getSiteLevelFromState.js +0 -34
  97. package/src/helper/site/getSiteName.js +0 -16
  98. package/src/helper/site/getSiteNameFromRoles.js +0 -12
  99. package/src/helper/site/getSiteSettingFromState.js +0 -10
  100. package/src/helper/storage/readJSONFromStorage.js +0 -9
  101. package/src/helper/storage/readStorageWithCookie.js +0 -22
  102. package/src/helper/storage/setLocalStorage.js +0 -5
  103. package/src/helper/strings/getFirstName.js +0 -10
  104. package/src/helper/strings/htmlDecode.js +0 -4
  105. package/src/helper/strings/htmlEncode.js +0 -4
  106. package/src/helper/strings/isEmail.js +0 -11
  107. package/src/helper/strings/isUrl.js +0 -13
  108. package/src/helper/strings/onlyAlphanumeric.js +0 -8
  109. package/src/helper/strings/randomString.js +0 -10
  110. package/src/helper/strings/toParagraphed.js +0 -17
  111. package/src/index.js +0 -12
  112. package/src/reducers/ScheduledActionsReducer.js +0 -14
  113. package/src/reducers/TemplatesReducer.js +0 -29
  114. package/src/reducers/index.js +0 -7
  115. package/src/session.js +0 -289
  116. package/src/urls.js +0 -21
package/src/config.js DELETED
@@ -1,25 +0,0 @@
1
- const CoreConfig = {
2
- env: {
3
- baseStage: '',
4
- baseAPIUrl: '',
5
- baseUploadsUrl: '',
6
- baseLibraryUrl: '',
7
- uploadBucket: '',
8
- colourBrandingMain: '',
9
- colourBrandingOff: '',
10
- colourBrandingApp: '',
11
- defaultProfileImage:
12
- 'https://pluss60-demo-uploads.s3.ap-southeast-2.amazonaws.com/uploads/users/ap-southeast-2:97769b56-25ec-41c0-a73c-6c2c4140f629/public/3d2433c6419383beb1078036b7/tinydefaultprofile.png',
13
- utcOffset: '',
14
- hasAvailableNews: false,
15
- newsHaveTags: true,
16
- defaultAllowComments: true,
17
- makeApiKey: '',
18
- logo: '',
19
- clientName: '',
20
- },
21
- init: (environment) => {
22
- CoreConfig.env = environment;
23
- },
24
- };
25
- export default CoreConfig;
@@ -1,16 +0,0 @@
1
- import Config from '../config';
2
-
3
- // deprecated
4
- export const setChatUser = (auth) => {
5
- return;
6
- };
7
-
8
- // deprecated
9
- export const openChat = () => {
10
- return;
11
- };
12
-
13
- // deprecated
14
- export const hideChat = () => {
15
- return;
16
- };
@@ -1,15 +0,0 @@
1
- import _ from 'lodash';
2
- import Config from '../../config';
3
-
4
- const getUrl = (baseAction, action, query, { url, stage } = { url: null, stage: null }) => {
5
- const { baseAPIUrl, baseStage } = Config.env;
6
- let queryPart = '';
7
- if (query) {
8
- _.keys(query).forEach((key, index) => {
9
- queryPart += `${index === 0 ? '?' : '&'}${key}=${encodeURIComponent(query[key])}`;
10
- });
11
- }
12
- return `${url || baseAPIUrl}/${baseAction}-${stage || baseStage}/${action}${queryPart}`;
13
- };
14
-
15
- export default getUrl;
@@ -1,9 +0,0 @@
1
- const getUrlParams = () => {
2
- var vars = {};
3
- window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function (m, key, value) {
4
- vars[key] = value;
5
- });
6
- return vars;
7
- };
8
-
9
- export default getUrlParams;
@@ -1,6 +0,0 @@
1
- const safeReadParams = (props, key) => {
2
- if (props && props.match && props.match.params) return props.match.params[key];
3
- return null;
4
- };
5
-
6
- export default safeReadParams;
@@ -1,8 +0,0 @@
1
- const getUserFromState = (state) => {
2
- if (!state || !state.auth || !state.auth.user) {
3
- return {};
4
- }
5
- return state.auth.user;
6
- };
7
-
8
- export default getUserFromState;
@@ -1,10 +0,0 @@
1
- import Config from '../../config';
2
-
3
- const getAppColourFromState = (state) => {
4
- if (!state || !state.auth || !state.auth.siteBranding || !state.auth.siteBranding.MainBrandingColour) {
5
- return Config.env.colourBrandingApp;
6
- }
7
- return state.auth.siteBranding.MainBrandingColour;
8
- };
9
-
10
- export default getAppColourFromState;
@@ -1,159 +0,0 @@
1
- /**
2
- * ADAPTED FROM:
3
- *
4
- * Resize and rotate images by EXIF orientation on the client side during upload. This uses
5
- * the HTML Canvas element and HTML5 FileReader.
6
- *
7
- * This class requires the Javascript file from https://github.com/jseidelin/exif-js
8
- *
9
- * See the GitHub repo for examples: https://github.com/ajgarn/CanvasImageUploader.
10
- *
11
- * @class CanvasImageUploader
12
- * @author ajgarn
13
- * @see https://github.com/ajgarn/CanvasImageUploader
14
- */
15
-
16
- function CanvasImageUploader(options) {
17
- options = options || {};
18
- if (typeof options.maxSize === 'undefined') options.maxSize = 1500;
19
- if (typeof options.jpegQuality === 'undefined') options.jpegQuality = 0.7;
20
-
21
- var image; // Image object (<img>)
22
- var imageData; // Image from canvas as byte array
23
-
24
- /**
25
- * Converts a base64 string to byte array.
26
- */
27
- function base64toBlob(base64Data, contentType, sliceSize) {
28
- contentType = contentType || '';
29
- sliceSize = sliceSize || 512;
30
-
31
- var byteCharacters = atob(base64Data);
32
- var byteArrays = [];
33
-
34
- for (var offset = 0; offset < byteCharacters.length; offset += sliceSize) {
35
- var slice = byteCharacters.slice(offset, offset + sliceSize);
36
- var byteNumbers = new Array(slice.length);
37
- for (var i = 0; i < slice.length; i++) {
38
- byteNumbers[i] = slice.charCodeAt(i);
39
- }
40
- var byteArray = new Uint8Array(byteNumbers);
41
- byteArrays.push(byteArray);
42
- }
43
-
44
- return new Blob(byteArrays, { type: contentType });
45
- }
46
-
47
- function calculateSize(image, maxSize) {
48
- var size = { width: image.width, height: image.height };
49
- if (image.width > maxSize || image.height > maxSize) {
50
- var ratio = image.width / image.height;
51
- if (image.width >= image.height) {
52
- size.width = maxSize;
53
- size.height = maxSize / ratio;
54
- } else {
55
- size.height = maxSize;
56
- size.width = maxSize * ratio;
57
- }
58
- }
59
- return size;
60
- }
61
-
62
- function setDimensions($canvas, size) {
63
- $canvas.attr('width', size.width);
64
- $canvas.attr('height', size.height);
65
- }
66
-
67
- function drawOnCanvas(image, $canvas, maxSize) {
68
- var canvas = $canvas[0];
69
- var ctx = canvas.getContext('2d');
70
-
71
- var size = calculateSize(image, maxSize);
72
- setDimensions($canvas, size);
73
-
74
- // Clear canvas
75
- ctx.clearRect(0, 0, $canvas.width(), $canvas.height());
76
-
77
- ctx.drawImage(
78
- image,
79
- 0,
80
- 0,
81
- image.width,
82
- image.height, // Source rectangle
83
- 0,
84
- 0,
85
- size.width,
86
- size.height,
87
- ); // Destination rectangle
88
- }
89
-
90
- function readImageToCanvasOnLoad(image, $canvas, callback) {
91
- drawOnCanvas(image, $canvas, options.maxSize);
92
- if (callback) callback();
93
- else console.warn('No callback for readImageToCanvas');
94
- }
95
-
96
- return {
97
- /**
98
- * Run to initialize CanvasImageUploader.
99
- */
100
- newImage: function () {
101
- imageData = null;
102
- image = new Image();
103
- },
104
-
105
- /**
106
- * Returns the image data if any file has been read.
107
- * @returns {Blob|null}
108
- */
109
- getImageData: function () {
110
- return imageData;
111
- },
112
-
113
- /**
114
- * Draw an image (<img>) or contents of a canvas to another canvas. The destination
115
- * canvas is resized properly.
116
- * @param source The image or source canvas to draw on a new canvas.
117
- * @param $destination The destination canvas to draw onto.
118
- * @param maxSize Maximum width or height of the destination canvas.
119
- */
120
- copyToCanvas: function (source, $destination, maxSize) {
121
- var size = calculateSize(source, maxSize);
122
- setDimensions($destination, size, 1);
123
- var destCtx = $destination[0].getContext('2d');
124
- destCtx.drawImage(source, 0, 0, source.width, source.height, 0, 0, size.width, size.height);
125
- },
126
-
127
- /**
128
- * Draw an image from a file on a canvas.
129
- * @param file The uploaded file.
130
- * @param $canvas The canvas (jQuery) object to draw on.
131
- * @param callback Function that is called when the operation has finished.
132
- */
133
- readImageToCanvas: function (file, $canvas, callback) {
134
- this.newImage();
135
- if (!file) return;
136
-
137
- var reader = new FileReader();
138
- reader.onload = function (fileReaderEvent) {
139
- image.onload = function () {
140
- readImageToCanvasOnLoad(this, $canvas, callback);
141
- };
142
- image.src = fileReaderEvent.target.result; // The URL from FileReader
143
- };
144
- reader.readAsDataURL(file);
145
- },
146
-
147
- /**
148
- * Read the canvas data and save it as a binary byte array to image data variable.
149
- * Get this data using the method getImageData().
150
- * @param canvas
151
- */
152
- saveCanvasToImageData: function (canvas) {
153
- var base64 = canvas.toDataURL('image/jpeg', options.jpegQuality).replace(/^data:image\/(png|jpeg|jpg|gif);base64,/, '');
154
- imageData = base64toBlob(base64, 'image/jpeg'); // Byte array
155
- },
156
- };
157
- }
158
-
159
- export default CanvasImageUploader;
@@ -1,10 +0,0 @@
1
- const generateImageName = (name) => {
2
- return `xxxxxxxx4xxxyxxxxxxxxxxxxx${name}`.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 generateImageName;
@@ -1,32 +0,0 @@
1
- import Config from '../../config';
2
- import getExtension from './getExtension';
3
- import isVideo from './isVideo';
4
-
5
- const get1400 = (url) => {
6
- if (!url) {
7
- return url;
8
- }
9
- if (isVideo(url)) {
10
- return 'https://pluss60-demo-uploads.s3.ap-southeast-2.amazonaws.com/uploads/users/ap-southeast-2:97769b56-25ec-41c0-a73c-6c2c4140f629/public/9d0bbec64614b1ed654a03f7e7/movie.jpg';
11
- }
12
- if (url.indexOf('https://plussprdstorage.blob.core.windows.net/') !== -1) {
13
- return url.replace('https://plussprdstorage.blob.core.windows.net/', 'https://plusscdn.azureedge.net/');
14
- }
15
- if (url.indexOf('https://plusscdn.azureedge.net/') !== -1) {
16
- return url.replace('/uploads/', '/uploads1400/').replace('/general/', '/general1400/');
17
- }
18
-
19
- const { baseUploadsUrl, baseLibraryUrl } = Config.env;
20
-
21
- if (url.indexOf(baseUploadsUrl) !== -1 || url.indexOf(baseLibraryUrl) !== -1) {
22
- const extension = getExtension(url);
23
- let urlToUse = url;
24
- if (extension !== 'jpg') {
25
- urlToUse = `${url.substring(0, url.length - (extension.length + 1))}.jpg`;
26
- }
27
- return urlToUse.replace('/uploads/', '/1400/');
28
- }
29
- return url;
30
- };
31
-
32
- export default get1400;
@@ -1,9 +0,0 @@
1
- const getExtension = (url) => {
2
- if (!url) {
3
- return null;
4
- }
5
- const fileSplit = url.split('.');
6
- return fileSplit[fileSplit.length - 1].toLowerCase();
7
- };
8
-
9
- export default getExtension;
@@ -1,13 +0,0 @@
1
- const getFileName = (url, noExtension) => {
2
- if (!url) {
3
- return null;
4
- }
5
- const fileSplit = url.split('/');
6
- const name = fileSplit[fileSplit.length - 1].toLowerCase();
7
- if (!noExtension) {
8
- return name;
9
- }
10
- return name.split('.')[0];
11
- };
12
-
13
- export default getFileName;
@@ -1,36 +0,0 @@
1
- import Config from '../../config';
2
- import getExtension from './getExtension';
3
- import isVideo from './isVideo';
4
-
5
- const getThumb300 = (url) => {
6
- if (!url) {
7
- return url;
8
- }
9
- if (isVideo(url)) {
10
- return 'https://pluss60-demo-uploads.s3.ap-southeast-2.amazonaws.com/uploads/users/ap-southeast-2:97769b56-25ec-41c0-a73c-6c2c4140f629/public/9d0bbec64614b1ed654a03f7e7/movie.jpg';
11
- }
12
- if (url.indexOf('https://plussprdstorage.blob.core.windows.net/') !== -1) {
13
- return url.replace('https://plussprdstorage.blob.core.windows.net/', 'https://plusscdn.azureedge.net/');
14
- }
15
- if (url.indexOf('https://plusscdn.azureedge.net/') !== -1) {
16
- return url
17
- .replace('/uploads/', '/uploads-thumb/')
18
- .replace('/general/', '/general300/')
19
- .replace('/uploads1400/', '/uploads-thumb/')
20
- .replace('/general1400/', '/general300/');
21
- }
22
-
23
- const { baseUploadsUrl, baseLibraryUrl } = Config.env;
24
-
25
- if (url.indexOf(baseUploadsUrl) !== -1 || url.indexOf(baseLibraryUrl) !== -1) {
26
- const extension = getExtension(url);
27
- let urlToUse = url;
28
- if (extension !== 'jpg') {
29
- urlToUse = `${url.substring(0, url.length - (extension.length + 1))}.jpg`;
30
- }
31
- return urlToUse.replace('/1400/', '/thumb300/').replace('/uploads/', '/thumb300/');
32
- }
33
- return url;
34
- };
35
-
36
- export default getThumb300;
@@ -1,8 +0,0 @@
1
- import getExtension from './getExtension';
2
-
3
- const isVideo = (url) => {
4
- const extension = getExtension(url);
5
- return ['mov', 'mp4'].includes(extension);
6
- };
7
-
8
- export default isVideo;
@@ -1,97 +0,0 @@
1
- import _ from 'lodash';
2
- import moment from 'moment';
3
-
4
- export const getTimepickerTime = (input) => {
5
- var timeSplit = input.split(':');
6
- if (timeSplit[1].indexOf('pm') > -1) {
7
- if (timeSplit[0] !== '12') {
8
- timeSplit[0] = (parseInt(timeSplit[0], 10) + 12).toString();
9
- }
10
- }
11
- if (timeSplit[1].indexOf('am') > -1) {
12
- if (timeSplit[0] === '12') {
13
- timeSplit[0] = '00';
14
- }
15
- }
16
- return {
17
- hours: timeSplit[0],
18
- minutes: timeSplit[1].substring(0, 2),
19
- };
20
- };
21
-
22
- //converts the result of getTimePickerTime into a number representing minutes since midnight
23
- export const timeToMinutes = (time) => {
24
- return parseInt(time.hours, 10) * 60 + parseInt(time.minutes, 10);
25
- };
26
-
27
- // checks whether there is an overlap between two time frames given time and end times in minutes since midnight
28
- export const hasTimeframeOverlap = (aStart, aEnd, bStart, bEnd) => {
29
- return (aStart < bEnd && bStart < aEnd) || (bStart < aEnd && aStart < bEnd);
30
- };
31
-
32
- // converts a time picker input into midnights since midnight
33
- export const timepickerToMinutes = (input) => {
34
- return timeToMinutes(getTimepickerTime(input));
35
- };
36
-
37
- export const getDateFromTimeDatePickers = (dateInput, timeInput) => {
38
- const dateObject = new Date(dateInput);
39
- const time = getTimepickerTime(timeInput);
40
- dateObject.setHours(time.hours);
41
- dateObject.setMinutes(time.minutes);
42
- return dateObject;
43
- };
44
-
45
- export const formatTime = (hours, minutes) => {
46
- const period = hours >= 12 ? 'pm' : 'am'; // Convert 24-hour format to 12-hour format
47
-
48
- const adjustedHours = hours > 12 ? hours - 12 : hours === 0 ? 12 : hours; // Ensure minutes are two digits
49
-
50
- const adjustedMinutes = String(minutes).padStart(2, '0');
51
- return `${adjustedHours}:${adjustedMinutes}${period}`;
52
- };
53
-
54
- export const minutesToString = (minutes, isTimeOfDay) => {
55
- const hours = Math.floor(minutes / 60);
56
- const remainingMinutes = minutes % 60;
57
-
58
- if (isTimeOfDay) {
59
- return formatTime(hours, remainingMinutes);
60
- }
61
-
62
- const hoursString = hours > 1 ? `${hours} hours` : `${hours} hour`;
63
- const minutesString = remainingMinutes > 1 ? `${remainingMinutes} minutes` : `${remainingMinutes} minute`;
64
-
65
- if (hours && remainingMinutes) {
66
- return `${hoursString} ${minutesString}`;
67
- }
68
-
69
- if (hours) {
70
- return hoursString;
71
- }
72
-
73
- if (remainingMinutes) {
74
- return minutesString;
75
- }
76
-
77
- return '0 minutes';
78
- };
79
-
80
- export const getUTCFromTimeDatePickers = (dateInput, timeInput) => {
81
- const dateObject = getDateFromTimeDatePickers(dateInput, timeInput);
82
- return moment.utc(dateObject);
83
- };
84
-
85
- export const getPluralS = (count) => {
86
- if (count === 1) {
87
- return '';
88
- }
89
- return 's';
90
- };
91
-
92
- export const getPluralOptions = (count, singular, plural) => {
93
- if (count === 1) {
94
- return singular;
95
- }
96
- return plural;
97
- };
@@ -1,44 +0,0 @@
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
- // auth
7
- export { default as getUserFromState } from './auth/getUserFromState';
8
-
9
- // colours
10
- export { default as getAppColourFromState } from './colours/getAppColourFromState';
11
-
12
- // files
13
- export { default as get1400 } from './files/get1400';
14
- export { default as generateImageName } from './files/generateImageName';
15
- export { default as getExtension } from './files/getExtension';
16
- export { default as getFileName } from './files/getFileName';
17
- export { default as getThumb300 } from './files/getThumb300';
18
- export { default as isVideo } from './files/isVideo';
19
-
20
- // strings
21
- export { default as getFirstName } from './strings/getFirstName';
22
- export { default as isEmail } from './strings/isEmail';
23
- export { default as isUrl } from './strings/isUrl';
24
- export { default as randomString } from './strings/randomString';
25
- export { default as toParagraphed } from './strings/toParagraphed';
26
- export { default as onlyAlphanumeric } from './strings/onlyAlphanumeric';
27
- export { default as htmlDecode } from './strings/htmlDecode';
28
- export { default as htmlEncode } from './strings/htmlEncode';
29
-
30
- // site
31
- export { default as getSiteName } from './site/getSiteName';
32
- export { default as getSiteNameFromRoles } from './site/getSiteNameFromRoles';
33
- export { default as getSiteSettingFromState } from './site/getSiteSettingFromState';
34
- export { default as getSiteLevelFromState } from './site/getSiteLevelFromState';
35
- export { default as getMerchantsFromState } from './site/getMerchantsFromState';
36
-
37
- // storage
38
- export { default as readJSONFromStorage } from './storage/readJSONFromStorage';
39
- export { default as setLocalStorage } from './storage/setLocalStorage';
40
- export { default as readStorageWithCookie } from './storage/readStorageWithCookie';
41
-
42
- // misc
43
- export * from './helper';
44
- export * from './HelpDeskWidget';
@@ -1,9 +0,0 @@
1
- import _ from 'lodash';
2
-
3
- const getMerchantsFromState = (state) => {
4
- if (!state || !state.auth || !state.auth.user) return [];
5
- const currentSite = state.auth.user.Roles.find((r) => r.site === state.auth.site);
6
- return currentSite && !_.isEmpty(currentSite.siteInfo.Accounts) ? currentSite.siteInfo.Accounts : [];
7
- };
8
-
9
- export default getMerchantsFromState;
@@ -1,34 +0,0 @@
1
- const getSiteLevelFromState = (state) => {
2
- let siteType = 'legacy';
3
- if (state && state.auth && state.auth.siteType) {
4
- siteType = state.auth.siteType;
5
- }
6
- const siteConfig = {
7
- type: siteType,
8
- featurePickerUrl: '/featurepicker',
9
- hasTV: true,
10
- hasKiosk: false,
11
- hasPayments: true,
12
- hasLinkedContent: true,
13
- hasPersonalNotes: true,
14
- hasEmergencyContacts: true,
15
- hasPersonalDocuments: true,
16
- };
17
-
18
- switch (siteType) {
19
- case 'free':
20
- siteConfig.featurePickerUrl = '/features';
21
- siteConfig.hasTV = false;
22
- siteConfig.hasPayments = false;
23
- siteConfig.hasLinkedContent = false;
24
- siteConfig.hasPersonalNotes = false;
25
- siteConfig.hasEmergencyContacts = false;
26
- siteConfig.hasPersonalDocuments = false;
27
- break;
28
- default:
29
- break;
30
- }
31
- return siteConfig;
32
- };
33
-
34
- export default getSiteLevelFromState;
@@ -1,16 +0,0 @@
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;
@@ -1,12 +0,0 @@
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;
@@ -1,10 +0,0 @@
1
- import _ from 'lodash';
2
-
3
- const getSiteSettingFromState = (state, key, defaultValue) => {
4
- if (state && state.auth && state.auth.siteSettings && !_.isUndefined(state.auth.siteSettings[key])) {
5
- return state.auth.siteSettings[key];
6
- }
7
- return defaultValue || null;
8
- };
9
-
10
- export default getSiteSettingFromState;
@@ -1,9 +0,0 @@
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;
@@ -1,22 +0,0 @@
1
- import Cookies from 'js-cookie';
2
-
3
- const readStorageWithCookie = (key, isJson) => {
4
- const value = window.localStorage.getItem(key);
5
- if (value) {
6
- if (isJson) {
7
- try {
8
- return JSON.parse(value);
9
- } catch (e) {
10
- console.log('parse error', e);
11
- }
12
- return null;
13
- }
14
- return value;
15
- }
16
- if (isJson) {
17
- return Cookies.getJSON(key);
18
- }
19
- return Cookies.get(key);
20
- };
21
-
22
- export default readStorageWithCookie;
@@ -1,5 +0,0 @@
1
- const setLocalStorage = (key, value, isJson) => {
2
- window.localStorage.setItem(key, isJson ? JSON.stringify(value) : value);
3
- };
4
-
5
- export default setLocalStorage;
@@ -1,10 +0,0 @@
1
- import _ from 'lodash';
2
-
3
- const getFirstName = (string) => {
4
- if (_.isEmpty(string)) {
5
- return '';
6
- }
7
- return string.split(' ')[0];
8
- };
9
-
10
- export default getFirstName;
@@ -1,4 +0,0 @@
1
- import $ from 'jquery';
2
-
3
- const htmlDecode = (value) => $('<textare/>').html(value).text();
4
- export default htmlDecode;
@@ -1,4 +0,0 @@
1
- import $ from 'jquery';
2
-
3
- const htmlEncode = (value) => $('<textare/>').text(value).html();
4
- export default htmlEncode;