@plusscommunities/pluss-core-web 1.6.13-beta.0 → 1.6.15-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 (112) hide show
  1. package/package.json +1 -2
  2. package/rollup.config.js +45 -45
  3. package/src/actions/AuthActions.js +40 -40
  4. package/src/actions/LocalActions.js +5 -5
  5. package/src/actions/NavActions.js +5 -5
  6. package/src/actions/ScheduledActionsActions.js +5 -5
  7. package/src/actions/TemplateActions.js +9 -9
  8. package/src/actions/UsersActions.js +74 -70
  9. package/src/actions/index.js +6 -6
  10. package/src/actions/types.js +17 -17
  11. package/src/analytics.js +178 -158
  12. package/src/apis/analyticsActions.js +50 -50
  13. package/src/apis/authActions.js +55 -55
  14. package/src/apis/fileActions.js +147 -142
  15. package/src/apis/index.js +10 -10
  16. package/src/apis/profileActions.js +130 -130
  17. package/src/apis/scheduledActionsActions.js +9 -9
  18. package/src/apis/stringActions.js +26 -22
  19. package/src/apis/templateActions.js +38 -38
  20. package/src/apis/typeActions.js +183 -183
  21. package/src/apis/userActions.js +166 -166
  22. package/src/apis/utilityActions.js +32 -32
  23. package/src/colours.js +79 -77
  24. package/src/components/AddButton.js +29 -20
  25. package/src/components/AnalyticsFilter.js +136 -102
  26. package/src/components/Attachment.js +36 -22
  27. package/src/components/AudienceIncluder.js +209 -165
  28. package/src/components/AudienceSelector.js +680 -680
  29. package/src/components/Button.js +79 -56
  30. package/src/components/CheckBox.js +77 -65
  31. package/src/components/ColourOptions.js +205 -181
  32. package/src/components/ColourPicker.js +286 -244
  33. package/src/components/Comment.js +48 -39
  34. package/src/components/CommentSection.js +113 -103
  35. package/src/components/DatePicker.js +298 -255
  36. package/src/components/DropdownInput.js +236 -215
  37. package/src/components/DurationInput.js +46 -43
  38. package/src/components/ExportCsvPopup.js +236 -217
  39. package/src/components/FileInput.js +359 -346
  40. package/src/components/GenericInput.js +184 -153
  41. package/src/components/Header.js +88 -65
  42. package/src/components/HubSidebar.js +136 -124
  43. package/src/components/ImageInput.js +1182 -973
  44. package/src/components/InputGroup.js +20 -13
  45. package/src/components/MakerPopup.js +285 -278
  46. package/src/components/MoreMenu.js +21 -17
  47. package/src/components/OptionsSection.js +86 -74
  48. package/src/components/OverlayPage.js +61 -61
  49. package/src/components/OverlayPageBottomButtons.js +38 -38
  50. package/src/components/OverlayPageContents.js +38 -38
  51. package/src/components/OverlayPageSection.js +24 -24
  52. package/src/components/P60Icon.js +38 -33
  53. package/src/components/PageTitle.js +8 -8
  54. package/src/components/Popup.js +114 -95
  55. package/src/components/ProfilePic.js +40 -40
  56. package/src/components/RadioButton.js +142 -126
  57. package/src/components/Reactions.js +66 -66
  58. package/src/components/SVGIcon.js +31 -25
  59. package/src/components/SideNavItem.js +112 -83
  60. package/src/components/StatBox.js +54 -44
  61. package/src/components/StatusButton.js +31 -17
  62. package/src/components/SuccessPopup.js +61 -48
  63. package/src/components/Tabs.js +50 -47
  64. package/src/components/Tag.js +54 -54
  65. package/src/components/Text.js +18 -14
  66. package/src/components/TextFormatPopup.js +77 -49
  67. package/src/components/TimePicker.js +214 -200
  68. package/src/components/ToggleSwitch.js +60 -0
  69. package/src/components/UserListing.js +110 -97
  70. package/src/components/index.js +46 -46
  71. package/src/components/svg-icons.json +819 -819
  72. package/src/config.js +22 -22
  73. package/src/helper/HelpDeskWidget.js +4 -4
  74. package/src/helper/api/getUrl.js +16 -11
  75. package/src/helper/api/getUrlParams.js +8 -5
  76. package/src/helper/api/safeReadParams.js +3 -2
  77. package/src/helper/auth/getUserFromState.js +4 -4
  78. package/src/helper/colours/getAppColourFromState.js +10 -5
  79. package/src/helper/files/canvasImageUploader.js +152 -140
  80. package/src/helper/files/generateImageName.js +6 -6
  81. package/src/helper/files/get1400.js +33 -25
  82. package/src/helper/files/getExtension.js +5 -5
  83. package/src/helper/files/getFileName.js +9 -9
  84. package/src/helper/files/getThumb300.js +37 -29
  85. package/src/helper/files/isVideo.js +3 -3
  86. package/src/helper/helper.js +59 -56
  87. package/src/helper/index.js +29 -29
  88. package/src/helper/site/getMerchantsFromState.js +8 -4
  89. package/src/helper/site/getSiteLevelFromState.js +29 -29
  90. package/src/helper/site/getSiteName.js +11 -11
  91. package/src/helper/site/getSiteNameFromRoles.js +7 -7
  92. package/src/helper/site/getSiteSettingFromState.js +10 -5
  93. package/src/helper/storage/readJSONFromStorage.js +5 -5
  94. package/src/helper/storage/readStorageWithCookie.js +17 -17
  95. package/src/helper/storage/setLocalStorage.js +1 -1
  96. package/src/helper/strings/getFirstName.js +5 -5
  97. package/src/helper/strings/htmlDecode.js +2 -2
  98. package/src/helper/strings/htmlEncode.js +2 -2
  99. package/src/helper/strings/isEmail.js +7 -6
  100. package/src/helper/strings/isUrl.js +7 -7
  101. package/src/helper/strings/onlyAlphanumeric.js +4 -4
  102. package/src/helper/strings/randomString.js +6 -6
  103. package/src/helper/strings/toParagraphed.js +12 -12
  104. package/src/index.js +22 -11
  105. package/src/reducers/ScheduledActionsReducer.js +8 -8
  106. package/src/reducers/TemplatesReducer.js +22 -22
  107. package/src/reducers/index.js +4 -4
  108. package/src/session.js +70 -70
  109. package/src/urls.js +17 -16
  110. package/dist/index.cjs.js +0 -11623
  111. package/dist/index.esm.js +0 -11583
  112. package/dist/index.umd.js +0 -11595
package/src/analytics.js CHANGED
@@ -1,183 +1,203 @@
1
- import _ from 'lodash';
2
- import moment from 'moment';
1
+ import _ from "lodash";
2
+ import moment from "moment";
3
3
 
4
4
  export const compileStats = (stats) => {
5
- const totalStats = {};
6
- Object.keys(stats).forEach((id) => {
7
- Object.keys(stats[id]).forEach((activityId) => {
8
- if (Array.isArray(stats[id][activityId])) {
9
- if (!totalStats[activityId]) {
10
- totalStats[activityId] = [];
11
- }
12
- Array.prototype.push.apply(totalStats[activityId], stats[id][activityId]);
13
- totalStats[activityId] = _.uniq(totalStats[activityId]);
14
- } else {
15
- if (!totalStats[activityId]) {
16
- totalStats[activityId] = 0;
17
- }
18
- totalStats[activityId] += stats[id][activityId];
19
- }
20
- });
21
- });
22
- return totalStats;
5
+ const totalStats = {};
6
+ Object.keys(stats).forEach((id) => {
7
+ Object.keys(stats[id]).forEach((activityId) => {
8
+ if (Array.isArray(stats[id][activityId])) {
9
+ if (!totalStats[activityId]) {
10
+ totalStats[activityId] = [];
11
+ }
12
+ Array.prototype.push.apply(
13
+ totalStats[activityId],
14
+ stats[id][activityId],
15
+ );
16
+ totalStats[activityId] = _.uniq(totalStats[activityId]);
17
+ } else {
18
+ if (!totalStats[activityId]) {
19
+ totalStats[activityId] = 0;
20
+ }
21
+ totalStats[activityId] += stats[id][activityId];
22
+ }
23
+ });
24
+ });
25
+ return totalStats;
23
26
  };
24
27
 
25
28
  export const getInsight = (stats, previousStats, source, key, activity) => {
26
- let top = { Stats: { [activity]: 0 } };
27
- Object.keys(stats).forEach((entityId) => {
28
- if (stats[entityId][activity] && stats[entityId][activity] > top.Stats[activity]) {
29
- const entity = _.find(source, (s) => {
30
- return s[key] === entityId;
31
- });
32
- if (entity) {
33
- top = { Stats: stats[entityId], Entity: entity };
34
- }
35
- }
36
- });
37
- if (top.Stats[activity] === 0) {
38
- return null;
39
- }
40
- if (previousStats) {
41
- top.PreviousStats = previousStats[top.Entity[key]];
42
- }
43
- return top;
29
+ let top = { Stats: { [activity]: 0 } };
30
+ Object.keys(stats).forEach((entityId) => {
31
+ if (
32
+ stats[entityId][activity] &&
33
+ stats[entityId][activity] > top.Stats[activity]
34
+ ) {
35
+ const entity = _.find(source, (s) => {
36
+ return s[key] === entityId;
37
+ });
38
+ if (entity) {
39
+ top = { Stats: stats[entityId], Entity: entity };
40
+ }
41
+ }
42
+ });
43
+ if (top.Stats[activity] === 0) {
44
+ return null;
45
+ }
46
+ if (previousStats) {
47
+ top.PreviousStats = previousStats[top.Entity[key]];
48
+ }
49
+ return top;
44
50
  };
45
51
 
46
52
  export const getAnalyticsFilterOptions = () => {
47
- return [
48
- {
49
- text: 'Yesterday',
50
- dayCount: 1,
51
- prevText: 'day before',
52
- },
53
- {
54
- text: 'Last 7 days',
55
- dayCount: 7,
56
- prevText: 'previous 7 days',
57
- },
58
- {
59
- text: 'Last 14 days',
60
- dayCount: 14,
61
- prevText: 'previous 14 days',
62
- },
63
- {
64
- text: 'Last 30 days',
65
- dayCount: 30,
66
- prevText: 'previous 30 days',
67
- },
68
- {
69
- text: 'Last 90 days',
70
- dayCount: 90,
71
- prevText: 'previous 90 days',
72
- },
73
- {
74
- text: 'Last 365 days',
75
- dayCount: 365,
76
- prevText: 'previous 365 days',
77
- },
78
- {
79
- text: 'Custom Range',
80
- dayCount: 0,
81
- prevText: 'previous * days',
82
- },
83
- ];
53
+ return [
54
+ {
55
+ text: "Yesterday",
56
+ dayCount: 1,
57
+ prevText: "day before",
58
+ },
59
+ {
60
+ text: "Last 7 days",
61
+ dayCount: 7,
62
+ prevText: "previous 7 days",
63
+ },
64
+ {
65
+ text: "Last 14 days",
66
+ dayCount: 14,
67
+ prevText: "previous 14 days",
68
+ },
69
+ {
70
+ text: "Last 30 days",
71
+ dayCount: 30,
72
+ prevText: "previous 30 days",
73
+ },
74
+ {
75
+ text: "Last 90 days",
76
+ dayCount: 90,
77
+ prevText: "previous 90 days",
78
+ },
79
+ {
80
+ text: "Last 365 days",
81
+ dayCount: 365,
82
+ prevText: "previous 365 days",
83
+ },
84
+ {
85
+ text: "Custom Range",
86
+ dayCount: 0,
87
+ prevText: "previous * days",
88
+ },
89
+ ];
84
90
  };
85
91
 
86
92
  export const countActivities = (data, activityKey, countType) => {
87
- let count = 0;
88
- let set = new Set();
93
+ let count = 0;
94
+ let set = new Set();
89
95
 
90
- data.forEach((entry) => {
91
- const stats = entry.Stats;
96
+ data.forEach((entry) => {
97
+ const stats = entry.Stats;
92
98
 
93
- for (const entity in stats) {
94
- const entityStats = stats[entity];
99
+ for (const entity in stats) {
100
+ const entityStats = stats[entity];
95
101
 
96
- switch (countType) {
97
- case 'unique':
98
- if (entityStats[activityKey]) {
99
- set.add(entity);
100
- }
101
- break;
102
- case 'uniquearray':
103
- if (entityStats[activityKey]) {
104
- _.values(entityStats[activityKey]).forEach((value) => {
105
- set.add(value);
106
- });
107
- }
108
- break;
109
- case 'total':
110
- if (entityStats[activityKey]) {
111
- count += entityStats[activityKey];
112
- }
113
- break;
114
- default:
115
- break;
116
- }
117
- }
118
- });
102
+ switch (countType) {
103
+ case "unique":
104
+ if (entityStats[activityKey]) {
105
+ set.add(entity);
106
+ }
107
+ break;
108
+ case "uniquearray":
109
+ if (entityStats[activityKey]) {
110
+ _.values(entityStats[activityKey]).forEach((value) => {
111
+ set.add(value);
112
+ });
113
+ }
114
+ break;
115
+ case "total":
116
+ if (entityStats[activityKey]) {
117
+ count += entityStats[activityKey];
118
+ }
119
+ break;
120
+ default:
121
+ break;
122
+ }
123
+ }
124
+ });
119
125
 
120
- switch (countType) {
121
- case 'unique':
122
- case 'uniquearray':
123
- console.log(countType, set);
124
- return set.size;
125
- case 'total':
126
- return count;
127
- default:
128
- return 0;
129
- }
126
+ switch (countType) {
127
+ case "unique":
128
+ case "uniquearray":
129
+ console.log(countType, set);
130
+ return set.size;
131
+ case "total":
132
+ return count;
133
+ default:
134
+ return 0;
135
+ }
130
136
  };
131
137
 
132
- export const generateDateRangeObjects = (startTime, endTime, groupBy = 'day') => {
133
- const startDate = moment(startTime);
134
- const endDate = moment(endTime);
135
- const dates = {};
138
+ export const generateDateRangeObjects = (
139
+ startTime,
140
+ endTime,
141
+ groupBy = "day",
142
+ ) => {
143
+ const startDate = moment(startTime);
144
+ const endDate = moment(endTime);
145
+ const dates = {};
136
146
 
137
- while (startDate.isSameOrBefore(endDate)) {
138
- const dateString = startDate.format('DD-MM-YYYY');
139
- dates[dateString] = {
140
- Date: dateString,
141
- Timestamp: startDate.valueOf(),
142
- Stats: {},
143
- };
144
- startDate.add(1, groupBy);
145
- }
147
+ while (startDate.isSameOrBefore(endDate)) {
148
+ const dateString = startDate.format("DD-MM-YYYY");
149
+ dates[dateString] = {
150
+ Date: dateString,
151
+ Timestamp: startDate.valueOf(),
152
+ Stats: {},
153
+ };
154
+ startDate.add(1, groupBy);
155
+ }
146
156
 
147
- return dates;
157
+ return dates;
148
158
  };
149
159
 
150
- export const generateDateActivities = (data, activityKey, countType, startTime, endTime, groupBy = 'day') => {
151
- const dates = generateDateRangeObjects(startTime, endTime, groupBy);
160
+ export const generateDateActivities = (
161
+ data,
162
+ activityKey,
163
+ countType,
164
+ startTime,
165
+ endTime,
166
+ groupBy = "day",
167
+ ) => {
168
+ const dates = generateDateRangeObjects(startTime, endTime, groupBy);
152
169
 
153
- const result = [];
154
- let formatToUse = 'DD-MM-YYYY';
155
- let labelFormat = 'D MMM';
156
- switch (groupBy) {
157
- case 'month':
158
- formatToUse = 'MM-YYYY';
159
- labelFormat = 'MMMM';
160
- break;
161
- case 'week':
162
- formatToUse = 'w-gggg';
163
- labelFormat = '[Week of] D MMM';
164
- break;
165
- default:
166
- break;
167
- }
170
+ const result = [];
171
+ let formatToUse = "DD-MM-YYYY";
172
+ let labelFormat = "D MMM";
173
+ switch (groupBy) {
174
+ case "month":
175
+ formatToUse = "MM-YYYY";
176
+ labelFormat = "MMMM";
177
+ break;
178
+ case "week":
179
+ formatToUse = "w-gggg";
180
+ labelFormat = "[Week of] D MMM";
181
+ break;
182
+ default:
183
+ break;
184
+ }
168
185
 
169
- Object.keys(dates).forEach((d) => {
170
- const datesToUse = _.filter(data, (date) => {
171
- return moment(date.Date, 'DD-MM-YYYY').format(formatToUse) === moment(d, 'DD-MM-YYYY').format(formatToUse);
172
- }) || [dates[d]];
173
- const compiledValue = {
174
- date: d,
175
- label: moment(d, 'DD-MM-YYYY').format(labelFormat),
176
- value: countActivities(datesToUse, activityKey, countType),
177
- };
186
+ Object.keys(dates).forEach((d) => {
187
+ const datesToUse = _.filter(data, (date) => {
188
+ return (
189
+ moment(date.Date, "DD-MM-YYYY").format(formatToUse) ===
190
+ moment(d, "DD-MM-YYYY").format(formatToUse)
191
+ );
192
+ }) || [dates[d]];
193
+ const compiledValue = {
194
+ date: d,
195
+ label: moment(d, "DD-MM-YYYY").format(labelFormat),
196
+ value: countActivities(datesToUse, activityKey, countType),
197
+ };
178
198
 
179
- result.push(compiledValue);
180
- });
181
- console.log(result);
182
- return result;
199
+ result.push(compiledValue);
200
+ });
201
+ console.log(result);
202
+ return result;
183
203
  };
@@ -1,53 +1,53 @@
1
- import { authedFunction } from '../session';
2
- import { getUrl } from '../helper';
1
+ import { authedFunction } from "../session";
2
+ import { getUrl } from "../helper";
3
3
 
4
4
  export const analyticsActions = {
5
- log: (site, actionType, entityType, entityId, data) => {
6
- return authedFunction({
7
- method: 'POST',
8
- url: getUrl('analytics', 'log'),
9
- data: {
10
- site,
11
- actionType,
12
- entityType,
13
- entityId,
14
- data,
15
- },
16
- });
17
- },
18
- getEntityStats: (entityId, entityType) => {
19
- return authedFunction({
20
- method: 'GET',
21
- url: getUrl('analytics', 'getentity', { entityId, entityType }),
22
- });
23
- },
24
- getActivityLog: (entityId, entityType, actionType, minTime, maxTime) => {
25
- const query = { entityId, entityType, actionType };
26
- if (minTime) {
27
- query.minTime = minTime;
28
- }
29
- if (maxTime) {
30
- query.maxTime = maxTime;
31
- }
32
- return authedFunction({
33
- method: 'GET',
34
- url: getUrl('analytics', 'activity', query),
35
- });
36
- },
37
- getAggregateUserStats: (site) => {
38
- return authedFunction({
39
- method: 'GET',
40
- url: getUrl('analytics', 'users', { site }),
41
- });
42
- },
43
- getAggregateEntityStats: (site, type, minTime, maxTime, raw) => {
44
- const query = { site, type, minTime, maxTime };
45
- if (raw) {
46
- query.raw = raw;
47
- }
48
- return authedFunction({
49
- method: 'GET',
50
- url: getUrl('analytics', 'aggregate', query),
51
- });
52
- },
5
+ log: (site, actionType, entityType, entityId, data) => {
6
+ return authedFunction({
7
+ method: "POST",
8
+ url: getUrl("analytics", "log"),
9
+ data: {
10
+ site,
11
+ actionType,
12
+ entityType,
13
+ entityId,
14
+ data,
15
+ },
16
+ });
17
+ },
18
+ getEntityStats: (entityId, entityType) => {
19
+ return authedFunction({
20
+ method: "GET",
21
+ url: getUrl("analytics", "getentity", { entityId, entityType }),
22
+ });
23
+ },
24
+ getActivityLog: (entityId, entityType, actionType, minTime, maxTime) => {
25
+ const query = { entityId, entityType, actionType };
26
+ if (minTime) {
27
+ query.minTime = minTime;
28
+ }
29
+ if (maxTime) {
30
+ query.maxTime = maxTime;
31
+ }
32
+ return authedFunction({
33
+ method: "GET",
34
+ url: getUrl("analytics", "activity", query),
35
+ });
36
+ },
37
+ getAggregateUserStats: (site) => {
38
+ return authedFunction({
39
+ method: "GET",
40
+ url: getUrl("analytics", "users", { site }),
41
+ });
42
+ },
43
+ getAggregateEntityStats: (site, type, minTime, maxTime, raw) => {
44
+ const query = { site, type, minTime, maxTime };
45
+ if (raw) {
46
+ query.raw = raw;
47
+ }
48
+ return authedFunction({
49
+ method: "GET",
50
+ url: getUrl("analytics", "aggregate", query),
51
+ });
52
+ },
53
53
  };
@@ -1,58 +1,58 @@
1
- import axios from 'axios';
2
- import { getUrl } from '../helper';
3
- import { authedFunction } from '../session';
1
+ import axios from "axios";
2
+ import { getUrl } from "../helper";
3
+ import { authedFunction } from "../session";
4
4
 
5
5
  export const authActions = {
6
- checkUserAuth: (userId) => {
7
- let url = getUrl('auth', 'checkUserAuth');
8
- return authedFunction({
9
- method: 'POST',
10
- url,
11
- data: {
12
- userId,
13
- },
14
- });
15
- },
16
- fetchForgotPasswordId: (input) => {
17
- return axios({
18
- method: 'POST',
19
- url: getUrl('auth', 'checkForgotUser'),
20
- data: {
21
- user: {
22
- email: input,
23
- phoneNumber: input,
24
- },
25
- },
26
- headers: { authorization: 'GwegChicken' },
27
- });
28
- },
29
- disableUser: (username, site) => {
30
- let url = getUrl('users', 'testUserDisbale');
31
- const request = {
32
- method: 'POST',
33
- url,
34
- data: {
35
- username,
36
- site,
37
- },
38
- };
39
- return authedFunction(request);
40
- },
41
- getUserSignin: async () => {
42
- return authedFunction({
43
- method: 'POST',
44
- url: getUrl('auth', 'getUserSignin'),
45
- });
46
- },
47
- copyDummy: (site) => {
48
- let url = getUrl('auth', 'copyDummy');
49
- const request = {
50
- method: 'POST',
51
- url,
52
- data: {
53
- site,
54
- },
55
- };
56
- return authedFunction(request);
57
- },
6
+ checkUserAuth: (userId) => {
7
+ let url = getUrl("auth", "checkUserAuth");
8
+ return authedFunction({
9
+ method: "POST",
10
+ url,
11
+ data: {
12
+ userId,
13
+ },
14
+ });
15
+ },
16
+ fetchForgotPasswordId: (input) => {
17
+ return axios({
18
+ method: "POST",
19
+ url: getUrl("auth", "checkForgotUser"),
20
+ data: {
21
+ user: {
22
+ email: input,
23
+ phoneNumber: input,
24
+ },
25
+ },
26
+ headers: { authorization: "GwegChicken" },
27
+ });
28
+ },
29
+ disableUser: (username, site) => {
30
+ let url = getUrl("users", "testUserDisbale");
31
+ const request = {
32
+ method: "POST",
33
+ url,
34
+ data: {
35
+ username,
36
+ site,
37
+ },
38
+ };
39
+ return authedFunction(request);
40
+ },
41
+ getUserSignin: async () => {
42
+ return authedFunction({
43
+ method: "POST",
44
+ url: getUrl("auth", "getUserSignin"),
45
+ });
46
+ },
47
+ copyDummy: (site) => {
48
+ let url = getUrl("auth", "copyDummy");
49
+ const request = {
50
+ method: "POST",
51
+ url,
52
+ data: {
53
+ site,
54
+ },
55
+ };
56
+ return authedFunction(request);
57
+ },
58
58
  };