jamespot-front-business 1.1.45 → 1.1.47

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/README.md CHANGED
@@ -4,7 +4,7 @@ This project contains features shared across Jamespot Fronts (Mobile/Desktop)
4
4
 
5
5
  You can access all redux-toolkit slice, actions, selectors.
6
6
 
7
- ## How to use
7
+ ### How to use
8
8
 
9
9
  ```jsx
10
10
  import React, { useEffect } from 'react';
package/dist/cjs.js CHANGED
@@ -125,7 +125,7 @@ const getAnimationsRTHandlers = function (dispatch) {
125
125
  ];
126
126
  };
127
127
 
128
- const initialState$k = {
128
+ const initialState$m = {
129
129
  animationConfiguration: null,
130
130
  isActiveForCurrentUser: false,
131
131
  isInitialized: false,
@@ -133,7 +133,7 @@ const initialState$k = {
133
133
  };
134
134
  const animationsSlice = toolkit.createSlice({
135
135
  name: 'animations',
136
- initialState: initialState$k,
136
+ initialState: initialState$m,
137
137
  reducers: {},
138
138
  extraReducers: (builder) => {
139
139
  builder.addCase(fetchCurrentAnimation.fulfilled, (state, action) => {
@@ -245,7 +245,7 @@ const Application = {
245
245
  selectors: selectors$1,
246
246
  };
247
247
 
248
- const initialState$j = {
248
+ const initialState$l = {
249
249
  entities: [],
250
250
  loading: 'idle',
251
251
  nbResults: 0,
@@ -256,7 +256,7 @@ const fetchBookableAsset = toolkit.createAsyncThunk('BookableAsset/fetchBookable
256
256
  }));
257
257
  const BookableAssetSlice = toolkit.createSlice({
258
258
  name: 'bookableAsset',
259
- initialState: initialState$j,
259
+ initialState: initialState$l,
260
260
  reducers: {},
261
261
  extraReducers: (builder) => {
262
262
  builder
@@ -277,7 +277,7 @@ const BookableAssetSlice = toolkit.createSlice({
277
277
  const fetchConfiguration = toolkit.createAsyncThunk('AssetReservation/configuration', (_, { extra }) => __awaiter(void 0, void 0, void 0, function* () {
278
278
  return yield extra.jApi.assetReservation.configuration();
279
279
  }));
280
- const initialState$i = {
280
+ const initialState$k = {
281
281
  description: '',
282
282
  right: {
283
283
  manage: false,
@@ -291,7 +291,7 @@ const initialState$i = {
291
291
  };
292
292
  const AssetReservationConfigurationSlice = toolkit.createSlice({
293
293
  name: 'configuration',
294
- initialState: initialState$i,
294
+ initialState: initialState$k,
295
295
  reducers: {},
296
296
  extraReducers: (builder) => {
297
297
  builder
@@ -312,7 +312,7 @@ const initForm = {
312
312
  hourStart: '',
313
313
  hourEnd: '',
314
314
  };
315
- const initialState$h = {
315
+ const initialState$j = {
316
316
  entities: [],
317
317
  loading: 'idle',
318
318
  nbResults: 0,
@@ -324,7 +324,7 @@ const fetchReservation = toolkit.createAsyncThunk('Reservation/fetchReservation'
324
324
  }));
325
325
  const ReservationSlice = toolkit.createSlice({
326
326
  name: 'reservation',
327
- initialState: initialState$h,
327
+ initialState: initialState$j,
328
328
  reducers: {
329
329
  setForm: (state, action) => {
330
330
  state.form = action.payload;
@@ -380,7 +380,7 @@ const AssetReservation = {
380
380
  },
381
381
  };
382
382
 
383
- const initialState$g = {
383
+ const initialState$i = {
384
384
  loading: 'idle',
385
385
  comments: [],
386
386
  };
@@ -397,7 +397,7 @@ const fetchComments = toolkit.createAsyncThunk('commentList/fetchCommentList', (
397
397
  }));
398
398
  const CommentListSlice = toolkit.createSlice({
399
399
  name: 'commentList',
400
- initialState: initialState$g,
400
+ initialState: initialState$i,
401
401
  reducers: {
402
402
  discardComments: (state, action) => {
403
403
  state.comments = state.comments.filter((c) => c.idArticle !== action.payload.idArticle);
@@ -488,7 +488,7 @@ const Comment = {
488
488
  getCommentsLikeRTHandlers,
489
489
  };
490
490
 
491
- const initialState$f = {
491
+ const initialState$h = {
492
492
  bookmarks: [],
493
493
  loading: 'idle',
494
494
  status: undefined,
@@ -551,7 +551,7 @@ const deleteBookmark = toolkit.createAsyncThunk('bookmarkList/deleteBookmark', (
551
551
  }));
552
552
  const BookmarkListSlice = toolkit.createSlice({
553
553
  name: 'bookmarkList',
554
- initialState: initialState$f,
554
+ initialState: initialState$h,
555
555
  reducers: {
556
556
  resetAddBookmarkStatus: (state, action) => {
557
557
  if (state.add[action.payload]) {
@@ -714,7 +714,7 @@ const getBookmarkRTHandlers = function (dispatch) {
714
714
  ];
715
715
  };
716
716
 
717
- const initialState$e = {
717
+ const initialState$g = {
718
718
  bookmark: undefined,
719
719
  status: undefined,
720
720
  loading: 'idle',
@@ -736,7 +736,7 @@ const editBookmark = toolkit.createAsyncThunk('bookmarkEdit/editBookmark', (book
736
736
  }));
737
737
  const BookmarkEditSlice = toolkit.createSlice({
738
738
  name: 'bookmarkEdit',
739
- initialState: initialState$e,
739
+ initialState: initialState$g,
740
740
  reducers: {
741
741
  setEditBookmark: (state, action) => {
742
742
  state.bookmark = Object.assign({}, action.payload);
@@ -789,7 +789,7 @@ const Bookmark = {
789
789
  getRTHandlers: getBookmarkRTHandlers,
790
790
  };
791
791
 
792
- const initialState$d = {
792
+ const initialState$f = {
793
793
  loading: 'idle',
794
794
  access: { createCategory: false },
795
795
  };
@@ -818,7 +818,7 @@ const fetchFaqConfig = toolkit.createAsyncThunk('faqConfig/fetch', () => __await
818
818
  }));
819
819
  const FaqConfigSlice = toolkit.createSlice({
820
820
  name: 'config',
821
- initialState: initialState$d,
821
+ initialState: initialState$f,
822
822
  reducers: {},
823
823
  extraReducers: (builder) => {
824
824
  builder
@@ -853,7 +853,7 @@ const FaqConfigSlice = toolkit.createSlice({
853
853
  },
854
854
  });
855
855
 
856
- const initialState$c = {
856
+ const initialState$e = {
857
857
  loading: 'idle',
858
858
  categories: null,
859
859
  };
@@ -865,7 +865,7 @@ const fetchFaqCategories = toolkit.createAsyncThunk('faqCategories/fetch', () =>
865
865
  }));
866
866
  const FaqCategoriesSlice = toolkit.createSlice({
867
867
  name: 'categories',
868
- initialState: initialState$c,
868
+ initialState: initialState$e,
869
869
  reducers: {},
870
870
  extraReducers: (builder) => {
871
871
  builder
@@ -1173,7 +1173,7 @@ const initialMap = {
1173
1173
  illustration: '',
1174
1174
  assignLicense: false,
1175
1175
  };
1176
- const initialState$b = {
1176
+ const initialState$d = {
1177
1177
  map: Object.assign({}, initialMap),
1178
1178
  loading: 'idle',
1179
1179
  status: undefined,
@@ -1217,13 +1217,13 @@ const createMap = toolkit.createAsyncThunk('mapCreate/create', ({ map, jlandUrlB
1217
1217
  }));
1218
1218
  const MapCreateSlice = toolkit.createSlice({
1219
1219
  name: 'mapCreate',
1220
- initialState: initialState$b,
1220
+ initialState: initialState$d,
1221
1221
  reducers: {
1222
1222
  setMap: (state, action) => {
1223
1223
  state.map = action.payload;
1224
1224
  },
1225
1225
  resetCreateMapState: () => {
1226
- return initialState$b;
1226
+ return initialState$d;
1227
1227
  },
1228
1228
  },
1229
1229
  extraReducers: (builder) => {
@@ -1277,6 +1277,217 @@ const jland = {
1277
1277
  utils: { buildUrlToJland },
1278
1278
  };
1279
1279
 
1280
+ const initialState$c = {
1281
+ loading: 'idle',
1282
+ pads: [],
1283
+ query: '',
1284
+ page: 1,
1285
+ tab: 'all-pads',
1286
+ filters: [],
1287
+ orders: [],
1288
+ limit: 10,
1289
+ nbResults: 0,
1290
+ };
1291
+ const magicPadSlice = toolkit.createSlice({
1292
+ name: 'magicPad',
1293
+ initialState: initialState$c,
1294
+ reducers: {
1295
+ setTab: (state, action) => {
1296
+ state.tab = action.payload;
1297
+ state.page = 1;
1298
+ state.orders = [];
1299
+ state.filters = [];
1300
+ },
1301
+ setQuery: (state, action) => {
1302
+ state.query = action.payload;
1303
+ state.page = 1;
1304
+ state.orders = [];
1305
+ state.filters = [];
1306
+ },
1307
+ setPage: (state, action) => {
1308
+ state.page = action.payload;
1309
+ },
1310
+ setFilters: (state, action) => {
1311
+ state.filters = action.payload;
1312
+ },
1313
+ setOrders: (state, action) => {
1314
+ state.orders = action.payload;
1315
+ },
1316
+ },
1317
+ extraReducers: (builder) => {
1318
+ builder
1319
+ .addCase(fetchPads.pending, (state) => {
1320
+ if (state.loading === 'idle')
1321
+ state.loading = 'pending';
1322
+ })
1323
+ .addCase(fetchPads.fulfilled, (state, action) => {
1324
+ if (state.loading == 'pending')
1325
+ state.loading = 'idle';
1326
+ state.pads = action.payload.data;
1327
+ state.nbResults = action.payload.cnt;
1328
+ return state;
1329
+ })
1330
+ .addCase(fetchPads.rejected, (state) => {
1331
+ if (state.loading == 'pending')
1332
+ state.loading = 'idle';
1333
+ });
1334
+ },
1335
+ });
1336
+ const fetchPads = toolkit.createAsyncThunk('magicPad/fetchPads', (params, { extra, rejectWithValue, dispatch, getState }) => __awaiter(void 0, void 0, void 0, function* () {
1337
+ var _a;
1338
+ try {
1339
+ const state = getState().magicPad;
1340
+ const page = state.page;
1341
+ const query = state.query;
1342
+ const filters = [
1343
+ ...state.filters,
1344
+ ...(state.tab === 'my-pads'
1345
+ ? [
1346
+ {
1347
+ name: 'idUser',
1348
+ value: params.idUserLogged,
1349
+ },
1350
+ ]
1351
+ : []),
1352
+ ];
1353
+ const orders = state.orders.length > 0 ? state.orders : [{ name: 'dateCreation', sort: 'DESC' }];
1354
+ return (yield extra.jApi.article.list({
1355
+ type: 'magicpad',
1356
+ limit: state.limit,
1357
+ format: 'raw-list',
1358
+ page,
1359
+ query,
1360
+ orders,
1361
+ filters,
1362
+ })).result;
1363
+ }
1364
+ catch (e) {
1365
+ dispatch(Toast.actions.error({ label: (_a = e.errorMsg) !== null && _a !== void 0 ? _a : 'GLOBAL_Technical_Error' }));
1366
+ return rejectWithValue({ error: 1, errorMsg: 'Cannot fetch pads' });
1367
+ }
1368
+ }));
1369
+ const selectMagicPad = (state) => state.magicPad;
1370
+ const MagicPad = {
1371
+ slice: magicPadSlice,
1372
+ actions: {
1373
+ fetchPads,
1374
+ },
1375
+ selectors: { selectMagicPad },
1376
+ };
1377
+
1378
+ const MediaLibraryAppConst = {
1379
+ route: 'media-library',
1380
+ moduleName: 'MediaLibraryHook',
1381
+ typeMediaLibraryFolder: 'mediaLibraryFolder',
1382
+ typeMediaLibraryFile: 'mediaLibraryFile',
1383
+ };
1384
+ const FILES_PER_PAGE = 18;
1385
+
1386
+ const initialState$b = {
1387
+ loading: 'idle',
1388
+ page: 1,
1389
+ nbResults: 0,
1390
+ folders: [],
1391
+ unclassifiedFiles: { list: [], page: 0, totalPages: 0 },
1392
+ mediaLibraryAccess: false,
1393
+ };
1394
+ const mediaLibrarySlice = toolkit.createSlice({
1395
+ name: 'mediaLibrary',
1396
+ initialState: initialState$b,
1397
+ reducers: {
1398
+ setPage(state, action) {
1399
+ return Object.assign(Object.assign({}, state), { page: action.payload });
1400
+ },
1401
+ setFolderList(state, action) {
1402
+ return Object.assign(Object.assign({}, state), { entities: [...action.payload] });
1403
+ },
1404
+ setFileUnclassifiedList(state, action) {
1405
+ return Object.assign(Object.assign({}, state), { entitiesUnclassified: Object.assign({}, action.payload) });
1406
+ },
1407
+ },
1408
+ extraReducers: (builder) => {
1409
+ builder
1410
+ .addCase(fetchMediaLibraryFolders.pending, (state) => {
1411
+ state.loading = 'pending';
1412
+ })
1413
+ .addCase(fetchMediaLibraryFolders.fulfilled, (state, action) => {
1414
+ state.loading = 'idle';
1415
+ state.folders = [...action.payload.result.data];
1416
+ state.nbResults = 0;
1417
+ })
1418
+ .addCase(fetchMediaLibraryFolders.rejected, (state) => {
1419
+ state.loading = 'idle';
1420
+ })
1421
+ .addCase(fetchMediaLibraryUnclassifiedFiles.pending, (state) => {
1422
+ state.loading = 'pending';
1423
+ })
1424
+ .addCase(fetchMediaLibraryUnclassifiedFiles.fulfilled, (state, action) => {
1425
+ state.loading = 'idle';
1426
+ state.unclassifiedFiles = {
1427
+ list: [...action.payload.result.data],
1428
+ page: action.payload.result.page,
1429
+ totalPages: Math.ceil(action.payload.result.cnt / action.payload.result.limit),
1430
+ };
1431
+ state.nbResults = 0;
1432
+ })
1433
+ .addCase(fetchMediaLibraryUnclassifiedFiles.rejected, (state) => {
1434
+ state.loading = 'idle';
1435
+ })
1436
+ .addCase(fetchMediaLibraryConfig.fulfilled, (state, action) => {
1437
+ var _a, _b;
1438
+ state.loading = 'idle';
1439
+ state.mediaLibraryAccess = (_b = (_a = action.payload) === null || _a === void 0 ? void 0 : _a.result) !== null && _b !== void 0 ? _b : false;
1440
+ })
1441
+ .addCase(fetchMediaLibraryConfig.rejected, (state) => {
1442
+ state.loading = 'idle';
1443
+ state.mediaLibraryAccess = false;
1444
+ })
1445
+ .addCase(fetchMediaLibraryConfig.pending, (state) => {
1446
+ state.loading = 'pending';
1447
+ state.mediaLibraryAccess = false;
1448
+ });
1449
+ },
1450
+ });
1451
+ const fetchMediaLibraryFolders = toolkit.createAsyncThunk('MediaLibrary/fetchMediaLibraryFolders', (_, { extra, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
1452
+ const args = { type: MediaLibraryAppConst.typeMediaLibraryFolder, format: 'raw-little', limit: 10 };
1453
+ try {
1454
+ return yield extra.jApi.article.list(args);
1455
+ }
1456
+ catch (error) {
1457
+ dispatch(Toast.actions.error({ label: error.errorMsg }));
1458
+ return rejectWithValue({ error: 1, errorMsg: 'Cannot retrieve folders' });
1459
+ }
1460
+ }));
1461
+ const fetchMediaLibraryUnclassifiedFiles = toolkit.createAsyncThunk('MediaLibrary/fetchMediaLibraryUnclassifiedFiles', (page, { extra, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
1462
+ try {
1463
+ return yield extra.jApi.mediaLibrary.GetUnclassifiedFiles({
1464
+ format: 'raw-little',
1465
+ page,
1466
+ limit: FILES_PER_PAGE,
1467
+ });
1468
+ }
1469
+ catch (error) {
1470
+ dispatch(Toast.actions.error({ label: error.errorMsg }));
1471
+ return rejectWithValue({ error: 1, errorMsg: 'Cannot retrieve UnclassifiedFiles' });
1472
+ }
1473
+ }));
1474
+ const fetchMediaLibraryConfig = toolkit.createAsyncThunk('MediaLibrary/fetchMediaLibraryConfig', (_, { extra, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
1475
+ try {
1476
+ return yield extra.jApi.mediaLibrary.getAccess();
1477
+ }
1478
+ catch (error) {
1479
+ dispatch(Toast.actions.error({ label: error.errorMsg }));
1480
+ return rejectWithValue({ error: 1, errorMsg: 'Cannot get MediaLibrary Config' });
1481
+ }
1482
+ }));
1483
+ const selectMediaLibrary = (state) => state.mediaLibrary;
1484
+ const mediaLibraryReducer = mediaLibrarySlice.reducer;
1485
+ const MediaLibrary = {
1486
+ slice: mediaLibrarySlice,
1487
+ actions: { fetchMediaLibraryFolders, fetchMediaLibraryUnclassifiedFiles, fetchMediaLibraryConfig },
1488
+ selectors: { selectMediaLibrary }
1489
+ };
1490
+
1280
1491
  const adapter = toolkit.createEntityAdapter({
1281
1492
  selectId: (model) => model.type,
1282
1493
  sortComparer: (a, b) => a.label.localeCompare(b.label),
@@ -3572,7 +3783,9 @@ exports.Faq = Faq;
3572
3783
  exports.Hook = Hook;
3573
3784
  exports.MODE_EDIT = MODE_EDIT;
3574
3785
  exports.MODE_VIEW = MODE_VIEW;
3786
+ exports.MagicPad = MagicPad;
3575
3787
  exports.MapExtraFieldsWithView = MapExtraFieldsWithView;
3788
+ exports.MediaLibrary = MediaLibrary;
3576
3789
  exports.Model = Model;
3577
3790
  exports.Network = Network;
3578
3791
  exports.Platform = Platform;
@@ -3591,7 +3804,14 @@ exports.animationsSlice = animationsSlice;
3591
3804
  exports.deleteCurrentAnimation = deleteCurrentAnimation;
3592
3805
  exports.fetchCurrentAnimation = fetchCurrentAnimation;
3593
3806
  exports.fetchCurrentAnimationApp = fetchCurrentAnimationApp;
3807
+ exports.fetchMediaLibraryConfig = fetchMediaLibraryConfig;
3808
+ exports.fetchMediaLibraryFolders = fetchMediaLibraryFolders;
3809
+ exports.fetchMediaLibraryUnclassifiedFiles = fetchMediaLibraryUnclassifiedFiles;
3810
+ exports.fetchPads = fetchPads;
3594
3811
  exports.jland = jland;
3812
+ exports.magicPadSlice = magicPadSlice;
3813
+ exports.mediaLibraryReducer = mediaLibraryReducer;
3814
+ exports.mediaLibrarySlice = mediaLibrarySlice;
3595
3815
  exports.saveCurrentAnimation = saveCurrentAnimation;
3596
3816
  exports.slice = slice;
3597
3817
  exports.studio = studio;