jamespot-front-business 1.1.80 → 1.1.82

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/dist/esm.js CHANGED
@@ -45,6 +45,10 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
45
45
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
46
46
  };
47
47
 
48
+ const isAbortError = (error) => {
49
+ return !!error && typeof error === 'object' && 'aborted' in error && !!error.aborted;
50
+ };
51
+
48
52
  const toastAdapter = createEntityAdapter({
49
53
  selectId: (toast) => toast.id,
50
54
  });
@@ -82,8 +86,234 @@ const Toast = {
82
86
  selectors: selectors$3,
83
87
  };
84
88
 
85
- const isAbortError = (error) => {
86
- return !!error && typeof error === 'object' && 'aborted' in error && !!error.aborted;
89
+ const formatDate$2 = (date) => date.toISOString().slice(0, 19).replace(/T/g, ' ');
90
+ const oneMonthAgo$2 = () => {
91
+ const date = new Date();
92
+ date.setMonth(date.getMonth() - 1);
93
+ return date;
94
+ };
95
+ const initialState$p = {
96
+ data: [],
97
+ loading: 'idle',
98
+ page: 1,
99
+ filters: [
100
+ {
101
+ name: 'dateCreation',
102
+ method: 'between',
103
+ value: {
104
+ start: formatDate$2(oneMonthAgo$2()),
105
+ end: formatDate$2(new Date()),
106
+ }
107
+ }
108
+ ],
109
+ orders: [],
110
+ limit: 30,
111
+ nbResults: 0,
112
+ };
113
+ const fetchLogsNavigation = createAsyncThunk('admin/fetchLogsNavigation', (params, { extra, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
114
+ try {
115
+ const logs = (yield extra.jApi.admin.logs.getLogsNavigation(params)).result;
116
+ return logs;
117
+ }
118
+ catch (err) {
119
+ if (!isAbortError(err)) {
120
+ dispatch(Toast.actions.error({ label: 'GLOBAL_Technical_Error' }));
121
+ }
122
+ return rejectWithValue({ error: 1, errorMsg: 'Cannot retrieve admin logs navigation' });
123
+ }
124
+ }));
125
+ const adminLogsNavigationSlice = createSlice({
126
+ name: 'logsNavigation',
127
+ initialState: initialState$p,
128
+ reducers: {
129
+ setNavigationOrder: (state, action) => {
130
+ state.orders = [...action.payload];
131
+ state.page = 1;
132
+ },
133
+ setNavigationFilter: (state, action) => {
134
+ state.filters = [...action.payload];
135
+ state.page = 1;
136
+ },
137
+ setNavigationPage: (state, action) => {
138
+ state.page = action.payload;
139
+ },
140
+ },
141
+ extraReducers: (builder) => {
142
+ builder.addCase(fetchLogsNavigation.pending, (state) => {
143
+ state.loading = 'pending';
144
+ });
145
+ builder.addCase(fetchLogsNavigation.fulfilled, (state, action) => {
146
+ var _a;
147
+ state.data = action.payload.data;
148
+ state.nbResults = action.payload.cnt;
149
+ state.limit = (_a = action.payload.limit) !== null && _a !== void 0 ? _a : 30;
150
+ state.page = action.payload.page;
151
+ state.loading = 'idle';
152
+ });
153
+ builder.addCase(fetchLogsNavigation.rejected, (state) => {
154
+ state.loading = 'idle';
155
+ });
156
+ },
157
+ });
158
+
159
+ const formatDate$1 = (date) => date.toISOString().slice(0, 19).replace(/T/g, ' ');
160
+ const oneMonthAgo$1 = () => {
161
+ const date = new Date();
162
+ date.setMonth(date.getMonth() - 1);
163
+ return date;
164
+ };
165
+ const initialState$o = {
166
+ data: [],
167
+ loading: 'idle',
168
+ page: 1,
169
+ filters: [
170
+ {
171
+ name: 'dateCreation',
172
+ method: 'between',
173
+ value: {
174
+ start: formatDate$1(oneMonthAgo$1()),
175
+ end: formatDate$1(new Date()),
176
+ }
177
+ }
178
+ ],
179
+ orders: [],
180
+ limit: 30,
181
+ nbResults: 0,
182
+ };
183
+ const fetchLogsObjects = createAsyncThunk('admin/fetchLogsObjects', (params, { extra, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
184
+ try {
185
+ const logs = (yield extra.jApi.admin.logs.getLogsObjects(params)).result;
186
+ return logs;
187
+ }
188
+ catch (err) {
189
+ if (!isAbortError(err)) {
190
+ dispatch(Toast.actions.error({ label: 'GLOBAL_Technical_Error' }));
191
+ }
192
+ return rejectWithValue({ error: 1, errorMsg: 'Cannot retrieve admin logs Objects' });
193
+ }
194
+ }));
195
+ const adminLogsObjectsSlice = createSlice({
196
+ name: 'logsObjects',
197
+ initialState: initialState$o,
198
+ reducers: {
199
+ setObjectsOrder: (state, action) => {
200
+ state.orders = [...action.payload];
201
+ state.page = 1;
202
+ },
203
+ setObjectsFilter: (state, action) => {
204
+ state.filters = [...action.payload];
205
+ state.page = 1;
206
+ },
207
+ setObjectsPage: (state, action) => {
208
+ state.page = action.payload;
209
+ },
210
+ },
211
+ extraReducers: (builder) => {
212
+ builder.addCase(fetchLogsObjects.pending, (state) => {
213
+ state.loading = 'pending';
214
+ });
215
+ builder.addCase(fetchLogsObjects.fulfilled, (state, action) => {
216
+ state.data = action.payload.data;
217
+ state.nbResults = action.payload.cnt;
218
+ state.limit = action.payload.limit || 30;
219
+ state.page = action.payload.page;
220
+ state.loading = 'idle';
221
+ });
222
+ builder.addCase(fetchLogsObjects.rejected, (state) => {
223
+ state.loading = 'idle';
224
+ });
225
+ },
226
+ });
227
+
228
+ const formatDate = (date) => date.toISOString().slice(0, 19).replace(/T/g, ' ');
229
+ const oneMonthAgo = () => {
230
+ const date = new Date();
231
+ date.setMonth(date.getMonth() - 1);
232
+ return date;
233
+ };
234
+ const initialState$n = {
235
+ data: [],
236
+ loading: 'idle',
237
+ page: 1,
238
+ filters: [
239
+ {
240
+ name: 'dateCreation',
241
+ method: 'between',
242
+ value: {
243
+ start: formatDate(oneMonthAgo()),
244
+ end: formatDate(new Date()),
245
+ }
246
+ }
247
+ ],
248
+ orders: [],
249
+ limit: 30,
250
+ nbResults: 0,
251
+ };
252
+ const fetchLogsSearch = createAsyncThunk('admin/fetchLogsSearch', (params, { extra, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
253
+ try {
254
+ const logs = (yield extra.jApi.admin.logs.getLogsSearch(params)).result;
255
+ return logs;
256
+ }
257
+ catch (err) {
258
+ if (!isAbortError(err)) {
259
+ dispatch(Toast.actions.error({ label: 'GLOBAL_Technical_Error' }));
260
+ }
261
+ return rejectWithValue({ error: 1, errorMsg: 'Cannot retrieve admin logs Search' });
262
+ }
263
+ }));
264
+ const adminLogsSearchSlice = createSlice({
265
+ name: 'logsSearch',
266
+ initialState: initialState$n,
267
+ reducers: {
268
+ setSearchOrder: (state, action) => {
269
+ state.orders = [...action.payload];
270
+ state.page = 1;
271
+ },
272
+ setSearchFilter: (state, action) => {
273
+ state.filters = [...action.payload];
274
+ state.page = 1;
275
+ },
276
+ setSearchPage: (state, action) => {
277
+ state.page = action.payload;
278
+ },
279
+ },
280
+ extraReducers: (builder) => {
281
+ builder.addCase(fetchLogsSearch.pending, (state) => {
282
+ state.loading = 'pending';
283
+ });
284
+ builder.addCase(fetchLogsSearch.fulfilled, (state, action) => {
285
+ var _a;
286
+ state.data = action.payload.data;
287
+ state.nbResults = action.payload.cnt;
288
+ state.limit = (_a = action.payload.limit) !== null && _a !== void 0 ? _a : 30;
289
+ state.page = action.payload.page;
290
+ state.loading = 'idle';
291
+ });
292
+ builder.addCase(fetchLogsSearch.rejected, (state) => {
293
+ state.loading = 'idle';
294
+ });
295
+ },
296
+ });
297
+
298
+ const selectAdminLogsNavigation = (state) => state.adminLogs.logsNavigation;
299
+ const selectAdminLogsObjects = (state) => state.adminLogs.logsObjects;
300
+ const selectAdminLogsSearch = (state) => state.adminLogs.logsSearch;
301
+ const adminLogsSliceReducer = combineReducers({
302
+ [adminLogsNavigationSlice.name]: adminLogsNavigationSlice.reducer,
303
+ [adminLogsObjectsSlice.name]: adminLogsObjectsSlice.reducer,
304
+ [adminLogsSearchSlice.name]: adminLogsSearchSlice.reducer,
305
+ });
306
+ const adminLogsSlice = {
307
+ name: 'adminLogs',
308
+ reducer: adminLogsSliceReducer,
309
+ };
310
+ const adminLogsReducer = adminLogsSlice.reducer;
311
+ const AdminLogs = {
312
+ slice: adminLogsSlice,
313
+ actions: Object.assign(Object.assign(Object.assign(Object.assign({}, adminLogsNavigationSlice.actions), adminLogsObjectsSlice.actions), adminLogsSearchSlice.actions), { fetchLogsNavigation,
314
+ fetchLogsObjects,
315
+ fetchLogsSearch }),
316
+ selectors: { selectAdminLogsNavigation, selectAdminLogsObjects, selectAdminLogsSearch },
87
317
  };
88
318
 
89
319
  const initialState$m = {
@@ -495,19 +725,19 @@ const CommentListSlice = createSlice({
495
725
  ...state.comments.filter((c) => c.idArticle !== idArticle),
496
726
  {
497
727
  idArticle,
498
- list,
728
+ list: Array.isArray(list) ? list : [],
499
729
  },
500
730
  ];
501
731
  return;
502
732
  }
503
733
  const initialUris = [];
504
734
  const allUris = state.comments.reduce((uris, c) => {
505
- return [...uris, ...c.list.map((el) => el.uri)];
735
+ return Array.isArray(c.list) ? [...uris, ...c.list.map((el) => el.uri)] : [...uris];
506
736
  }, initialUris);
507
- const safeList = list.filter((el) => !allUris.includes(el.uri));
737
+ const safeList = Array.isArray(list) ? list.filter((el) => !allUris.includes(el.uri)) : [];
508
738
  state.comments = state.comments.map((c) => {
509
739
  return c.idArticle === idArticle
510
- ? Object.assign(Object.assign({}, c), { list: [...c.list, ...safeList] }) : c;
740
+ ? Object.assign(Object.assign({}, c), { list: Array.isArray(c.list) ? [...c.list, ...safeList] : [...safeList] }) : c;
511
741
  });
512
742
  },
513
743
  updateComment: (state, action) => {
@@ -594,7 +824,12 @@ const commentSlice = {
594
824
  name: 'comment',
595
825
  reducer: CommentReducer,
596
826
  };
597
- const selectCommentList = (state, idArticle) => state.comment.commentList.comments.find((c) => c.idArticle === idArticle);
827
+ const selectCommentList = (state, idArticle, limit = 0) => {
828
+ const data = state.comment.commentList.comments.find((c) => c.idArticle === idArticle);
829
+ const dataList = data && Array.isArray(data.list) ? data.list : [];
830
+ const list = [...dataList].sort((c1, c2) => c1.id - c2.id);
831
+ return limit !== 0 ? list.slice(-limit) : list;
832
+ };
598
833
  const Comment = {
599
834
  slice: commentSlice,
600
835
  actions: Object.assign({ fetchComments }, CommentListSlice.actions),
@@ -5198,5 +5433,5 @@ const studio = {
5198
5433
  },
5199
5434
  };
5200
5435
 
5201
- export { APP_STATUS_TYPE, AUDIENCE, Animations, AppColumnsDefaultTypes, AppFieldFormPropertyTypes, AppFormBannedFromViews$1 as AppFormBannedFromViews, AppFormFieldOnlyInView, AppFormFixedList$1 as AppFormFixedList, AppFormItemTypes, AppFormNoAsFieldList, AppFormNonPrimaryList, AppFormPrimaryList, AppFormPrimaryListValues, AppFormUniqueList, AppFormUniqueListCheck, Application, AssetReservation, Bookmark, Comment, Description, Element, ExtraAppFieldsItemViews, Faq, Hook, MagicPad, MapExtraFieldsWithView, MediaLibrary, Model, Network, Platform, STUDIO_VIEW, Share, SocialActions, StatusType$1 as StatusType, TVDisplay, TinyMCE, Toast, UserCurrent, WedocApp, Widget, WidgetEditor, actions, animationsReducer, animationsSlice, fetchMediaLibraryConfig, fetchMediaLibraryFilesStats, fetchMediaLibraryFolders, fetchMediaLibraryFoldersStats, fetchMediaLibraryStats, fetchMediaLibraryUnclassifiedFiles, fetchPads, jland, magicPadSlice, mediaLibraryReducer, mediaLibrarySlice, slice$1 as slice, studio, updateWidgetContent, viewsList };
5436
+ export { APP_STATUS_TYPE, AUDIENCE, AdminLogs, Animations, AppColumnsDefaultTypes, AppFieldFormPropertyTypes, AppFormBannedFromViews$1 as AppFormBannedFromViews, AppFormFieldOnlyInView, AppFormFixedList$1 as AppFormFixedList, AppFormItemTypes, AppFormNoAsFieldList, AppFormNonPrimaryList, AppFormPrimaryList, AppFormPrimaryListValues, AppFormUniqueList, AppFormUniqueListCheck, Application, AssetReservation, Bookmark, Comment, Description, Element, ExtraAppFieldsItemViews, Faq, Hook, MagicPad, MapExtraFieldsWithView, MediaLibrary, Model, Network, Platform, STUDIO_VIEW, Share, SocialActions, StatusType$1 as StatusType, TVDisplay, TinyMCE, Toast, UserCurrent, WedocApp, Widget, WidgetEditor, actions, adminLogsReducer, adminLogsSlice, animationsReducer, animationsSlice, fetchMediaLibraryConfig, fetchMediaLibraryFilesStats, fetchMediaLibraryFolders, fetchMediaLibraryFoldersStats, fetchMediaLibraryStats, fetchMediaLibraryUnclassifiedFiles, fetchPads, jland, magicPadSlice, mediaLibraryReducer, mediaLibrarySlice, slice$1 as slice, studio, updateWidgetContent, viewsList };
5202
5437
  //# sourceMappingURL=esm.js.map