@griddo/ax 10.4.36 → 10.5.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 (38) hide show
  1. package/package.json +2 -2
  2. package/src/api/checkgroups.tsx +1 -1
  3. package/src/api/structuredData.tsx +109 -18
  4. package/src/components/Fields/AsyncCheckGroup/index.tsx +56 -19
  5. package/src/components/Fields/AsyncCheckGroup/style.tsx +21 -4
  6. package/src/components/Fields/CheckField/style.tsx +1 -1
  7. package/src/components/Fields/NoteField/style.tsx +1 -1
  8. package/src/components/Fields/ReferenceField/AutoPanel/AutoItem/index.tsx +58 -20
  9. package/src/components/Fields/ReferenceField/AutoPanel/AutoItem/style.tsx +20 -1
  10. package/src/components/Fields/ReferenceField/Context/index.tsx +9 -9
  11. package/src/components/LanguageMenu/index.tsx +1 -1
  12. package/src/components/Tag/index.tsx +3 -2
  13. package/src/components/Tag/style.tsx +5 -4
  14. package/src/containers/StructuredData/actions.tsx +169 -82
  15. package/src/containers/StructuredData/constants.tsx +2 -2
  16. package/src/containers/StructuredData/interfaces.tsx +16 -9
  17. package/src/containers/StructuredData/reducer.tsx +11 -7
  18. package/src/containers/StructuredData/utils.tsx +2 -2
  19. package/src/global.d.ts +0 -1
  20. package/src/modules/Categories/CategoriesList/BulkHeader/TableHeader/index.tsx +10 -3
  21. package/src/modules/Categories/CategoriesList/BulkHeader/TableHeader/style.tsx +12 -6
  22. package/src/modules/Categories/CategoriesList/BulkHeader/index.tsx +21 -2
  23. package/src/modules/Categories/CategoriesList/CategoryItem/index.tsx +131 -63
  24. package/src/modules/Categories/CategoriesList/CategoryItem/style.tsx +67 -7
  25. package/src/modules/Categories/CategoriesList/CategoryNav/index.tsx +2 -8
  26. package/src/modules/Categories/CategoriesList/CategoryPanel/Form/index.tsx +88 -33
  27. package/src/modules/Categories/CategoriesList/CategoryPanel/index.tsx +130 -56
  28. package/src/modules/Categories/CategoriesList/CategoryPanel/style.tsx +1 -1
  29. package/src/modules/Categories/CategoriesList/atoms.tsx +46 -19
  30. package/src/modules/Categories/CategoriesList/helpers.tsx +116 -0
  31. package/src/modules/Categories/CategoriesList/hooks.tsx +61 -0
  32. package/src/modules/Categories/CategoriesList/index.tsx +283 -97
  33. package/src/modules/Categories/CategoriesList/style.tsx +54 -2
  34. package/src/modules/Categories/CategoriesList/utils.tsx +34 -14
  35. package/src/modules/StructuredData/StructuredDataList/StructuredDataItem/index.tsx +1 -1
  36. package/src/modules/Users/UserList/hooks.tsx +5 -4
  37. package/src/types/index.tsx +64 -3
  38. package/tsconfig.paths.json +0 -1
@@ -4,7 +4,7 @@ import { Icon } from "@ax/components";
4
4
  import * as S from "./style";
5
5
 
6
6
  const Tag = (props: ITagProps): JSX.Element => {
7
- const { type, text, color, icon, rounded = true, className, onDeleteAction } = props;
7
+ const { type, text, color, icon, textColor, rounded = true, onDeleteAction, className } = props;
8
8
 
9
9
  const handleClick = () => {
10
10
  if (onDeleteAction) {
@@ -28,7 +28,7 @@ const Tag = (props: ITagProps): JSX.Element => {
28
28
  );
29
29
  case "square":
30
30
  return (
31
- <S.TagSquare color={color} className={className} data-testid="tag-square">
31
+ <S.TagSquare color={color} textColor={textColor} className={className} data-testid="tag-square">
32
32
  {icon && (
33
33
  <S.IconTag>
34
34
  <Icon name={icon} size="16" />
@@ -55,6 +55,7 @@ export interface ITagProps {
55
55
  color?: string;
56
56
  rounded?: boolean;
57
57
  icon?: string;
58
+ textColor?: string;
58
59
  onDeleteAction?: () => void;
59
60
  className?: string;
60
61
  }
@@ -12,13 +12,14 @@ const TagStatus = styled.div`
12
12
  text-transform: capitalize;
13
13
  `;
14
14
 
15
- const TagSquare = styled.div<{ color?: string; }>`
15
+ const TagSquare = styled.div<{ color?: string; textColor?: string }>`
16
16
  ${(p) => p.theme.textStyle.uiXS};
17
17
  display: flex;
18
18
  background-color: ${(p) => (p.color ? p.color : p.theme.colors.uiBackground01)};
19
19
  box-sizing: border-box;
20
20
  border-radius: ${(p) => p.theme.radii.xs};
21
- color: ${(p) => (p.color ? p.theme.color.textMediumEmphasisInverse : p.theme.color.textMediumEmphasis)};
21
+ color: ${(p) =>
22
+ p.textColor ? p.textColor : p.color ? p.theme.color.textMediumEmphasisInverse : p.theme.color.textMediumEmphasis};
22
23
  white-space: nowrap;
23
24
  padding: 3px 8px;
24
25
  text-transform: capitalize;
@@ -33,10 +34,10 @@ const Bullet = styled.span<{ color?: string }>`
33
34
  margin-right: 4px;
34
35
  `;
35
36
 
36
- const TagFixed = styled.div<{ color?: string; rounded: boolean; }>`
37
+ const TagFixed = styled.div<{ color?: string; rounded: boolean }>`
37
38
  ${(p) => p.theme.textStyle.uiS};
38
39
  background-color: ${(p) => (p.color ? p.color : p.theme.color.interactive02)};
39
- border-radius: ${(p) => p.rounded ? p.theme.spacing.s : "0"};
40
+ border-radius: ${(p) => (p.rounded ? p.theme.spacing.s : "0")};
40
41
  box-sizing: border-box;
41
42
  color: ${(p) => p.theme.color.textMediumEmphasis};
42
43
  display: inline-block;
@@ -5,7 +5,6 @@ import {
5
5
  SET_CURRENT_STRUCTURED_DATA,
6
6
  SET_CURRENT_STRUCTURED_DATA_ID,
7
7
  SET_CURRENT_STRUCTURED_DATA_CONTENTS,
8
- SET_CATEGORY,
9
8
  SET_SCHEMA,
10
9
  UPDATE_FORM,
11
10
  CREATE_FORM,
@@ -18,6 +17,7 @@ import {
18
17
  SET_VALIDATED,
19
18
  SET_CONTENT_FILTERS,
20
19
  SET_IS_IA_TRANSLATED,
20
+ SET_CURRENT_DATA_CATEGORY,
21
21
  SET_CURRENT_SEARCH,
22
22
  } from "./constants";
23
23
 
@@ -28,13 +28,13 @@ import {
28
28
  ISetCurrentDataID,
29
29
  ISetCurrentDataContent,
30
30
  ISetIsActive,
31
- ISetCategory,
32
31
  ISetFilter,
33
32
  ISetSchemaVersion,
34
33
  ISetErrors,
35
34
  ISetValidated,
36
35
  ISetContentFilters,
37
36
  ISetIsIATranslated,
37
+ ISetCurrentCategories,
38
38
  ISetCurrentSearch,
39
39
  } from "./interfaces";
40
40
  import {
@@ -47,10 +47,13 @@ import {
47
47
  import {
48
48
  IStructuredData,
49
49
  IStructuredDataContent,
50
- ICategory,
51
50
  IGetStructuredDataParams,
52
51
  IErrorItem,
53
52
  IStructuredDataQueryValues,
53
+ IStructuredDataCategory,
54
+ ICategoryGroupParams,
55
+ IRootState,
56
+ IOrderCategoryParams,
54
57
  } from "@ax/types";
55
58
  import { structuredData } from "@ax/api";
56
59
  import { setTotalItems } from "@ax/containers/Sites/actions";
@@ -73,20 +76,20 @@ function setStructuredData(structuredData: { global: IStructuredData[]; site: IS
73
76
  return { type: SET_STRUCTURED_DATA, payload: { structuredData } };
74
77
  }
75
78
 
76
- function setCurrentData(currentStructuredData: any): ISetCurrentData {
79
+ function setCurrentData(currentStructuredData: IStructuredData | null): ISetCurrentData {
77
80
  return { type: SET_CURRENT_STRUCTURED_DATA, payload: { currentStructuredData } };
78
81
  }
79
82
 
80
- function setCurrentDataID(currentStructuredDataId: any): ISetCurrentDataID {
83
+ function setCurrentDataID(currentStructuredDataId: number | null): ISetCurrentDataID {
81
84
  return { type: SET_CURRENT_STRUCTURED_DATA_ID, payload: { currentStructuredDataId } };
82
85
  }
83
86
 
84
- function setCurrentDataContent(currentDataContent: any): ISetCurrentDataContent {
87
+ function setCurrentDataContent(currentDataContent: IStructuredDataContent[]): ISetCurrentDataContent {
85
88
  return { type: SET_CURRENT_STRUCTURED_DATA_CONTENTS, payload: { currentDataContent } };
86
89
  }
87
90
 
88
- function setCategory(category: ICategory): ISetCategory {
89
- return { type: SET_CATEGORY, payload: { category } };
91
+ function setCurrentDataCategory(currentDataCategory: IStructuredDataCategory[]): ISetCurrentCategories {
92
+ return { type: SET_CURRENT_DATA_CATEGORY, payload: { currentDataCategory } };
90
93
  }
91
94
 
92
95
  function setSchema(schema: any) {
@@ -101,7 +104,7 @@ function updateForm(form: any) {
101
104
  return { type: UPDATE_FORM, payload: { form } };
102
105
  }
103
106
 
104
- function setEntity(entity: any) {
107
+ function setEntity(entity: string | null) {
105
108
  return { type: SET_ENTITY, payload: { entity } };
106
109
  }
107
110
 
@@ -240,11 +243,18 @@ function setSelectedCategory(id: string, scope: string): (dispatch: Dispatch, ge
240
243
 
241
244
  function getStructuredDataContents(
242
245
  params: IGetStructuredDataParams,
243
- siteID?: number | null
246
+ siteID?: number | null,
247
+ hasLoading = true
244
248
  ): (dispatch: Dispatch, getState: any) => Promise<void> {
245
249
  return async (dispatch, getState) => {
250
+ const { groupingCategories } = params;
251
+
246
252
  if (!params.dataID) {
247
- dispatch(setCurrentDataContent([]));
253
+ if (groupingCategories) {
254
+ dispatch(setCurrentDataCategory([]));
255
+ } else {
256
+ dispatch(setCurrentDataContent([]));
257
+ }
248
258
  dispatch(setIsLoading(false));
249
259
  return;
250
260
  }
@@ -263,7 +273,11 @@ function getStructuredDataContents(
263
273
  const responseActions = {
264
274
  handleSuccess: (response: any) => {
265
275
  const { items, totalItems, schemasTimestamp } = response;
266
- dispatch(setCurrentDataContent(items));
276
+ if (groupingCategories) {
277
+ dispatch(setCurrentDataCategory(items));
278
+ } else {
279
+ dispatch(setCurrentDataContent(items));
280
+ }
267
281
  dispatch(setTotalItems(totalItems));
268
282
 
269
283
  if (!schemaVersion || schemaVersion < schemasTimestamp) {
@@ -275,7 +289,9 @@ function getStructuredDataContents(
275
289
 
276
290
  const callback = async () => structuredData.getDataContents(params, siteID);
277
291
 
278
- await handleRequest(callback, responseActions, [appActions.setIsLoading])(dispatch);
292
+ const loading = hasLoading ? [appActions.setIsLoading] : [];
293
+
294
+ await handleRequest(callback, responseActions, loading)(dispatch);
279
295
  } catch (e) {
280
296
  console.log(e);
281
297
  }
@@ -301,40 +317,8 @@ function getDataContent(id: number, lang?: { locale: string; id: number }): (dis
301
317
  };
302
318
  }
303
319
 
304
- function getTranslatedCategory(
305
- id: number,
306
- lang: { locale: string; id: number }
307
- ): (dispatch: Dispatch) => Promise<void> {
308
- return async (dispatch) => {
309
- try {
310
- const responseActions = {
311
- handleSuccess: (response: any) => {
312
- const { content } = response;
313
- dispatch(
314
- setCategory({
315
- id: response.id,
316
- name: content.title,
317
- code: content.code,
318
- lang,
319
- isTranslation: true,
320
- isNew: false,
321
- })
322
- );
323
- },
324
- handleError: (response: any) => appActions.handleError(response)(dispatch),
325
- };
326
-
327
- const callback = async () => structuredData.getDataContent(id, lang.id);
328
-
329
- await handleRequest(callback, responseActions, [])(dispatch);
330
- } catch (e) {
331
- console.log(e); // TODO: capturar error bien
332
- }
333
- };
334
- }
335
-
336
320
  function createStructuredDataContent(
337
- structuredDataContent: IStructuredDataContent,
321
+ structuredDataContent: IStructuredDataContent | IStructuredDataCategory,
338
322
  langId?: number | null
339
323
  ): (dispatch: Dispatch, getState: any) => Promise<boolean> {
340
324
  return async (dispatch, getState) => {
@@ -373,7 +357,7 @@ function createStructuredDataContent(
373
357
  }
374
358
 
375
359
  function updateStructuredDataContent(
376
- structuredDataContent: IStructuredDataContent
360
+ structuredDataContent: IStructuredDataContent | IStructuredDataCategory
377
361
  ): (dispatch: Dispatch, getState: any) => Promise<boolean> {
378
362
  return async (dispatch, getState) => {
379
363
  try {
@@ -395,28 +379,35 @@ function updateStructuredDataContent(
395
379
 
396
380
  return await handleRequest(callback, responseActions, [appActions.setIsSaving])(dispatch);
397
381
  } catch (e) {
398
- console.log(e); // TODO: capturar error bien
382
+ console.log(e);
399
383
  return false;
400
384
  }
401
385
  };
402
386
  }
403
387
 
404
- function deleteStructuredDataContent(id: number | number[]): (dispatch: Dispatch, getState: any) => Promise<boolean> {
388
+ function deleteStructuredDataContent(
389
+ id: number | number[],
390
+ refresh = true
391
+ ): (dispatch: Dispatch, getState: any) => Promise<boolean> {
405
392
  return async (dispatch, getState) => {
406
393
  try {
407
394
  dispatch(setIsLoading(true));
408
395
 
409
396
  const {
410
- structuredData: { currentFilter },
397
+ structuredData: { currentFilter, currentStructuredData },
411
398
  sites: { currentSiteInfo },
412
- } = getState();
399
+ }: IRootState = getState();
413
400
 
414
- const params = { ...DEFAULT_PARAMS, dataID: currentFilter };
401
+ const params = {
402
+ ...DEFAULT_PARAMS,
403
+ dataID: currentFilter,
404
+ groupingCategories: currentStructuredData?.taxonomy || false,
405
+ };
415
406
 
416
407
  const siteID = currentSiteInfo && currentSiteInfo.id;
417
408
 
418
409
  const responseActions = {
419
- handleSuccess: () => getStructuredDataContents(params, siteID)(dispatch, getState),
410
+ handleSuccess: () => refresh && getStructuredDataContents(params, siteID)(dispatch, getState),
420
411
  handleError: (response: any) => {
421
412
  const {
422
413
  data: { message },
@@ -432,7 +423,7 @@ function deleteStructuredDataContent(id: number | number[]): (dispatch: Dispatch
432
423
 
433
424
  return await handleRequest(callback, responseActions, [])(dispatch);
434
425
  } catch (e) {
435
- console.log(e); // TODO: capturar error bien
426
+ console.log(e);
436
427
  return false;
437
428
  }
438
429
  };
@@ -471,34 +462,13 @@ function restoreStructuredDataContent(dataID: number | number[]): (dispatch: Dis
471
462
 
472
463
  await handleRequest(callback, responseActions, [])(dispatch);
473
464
  } catch (e) {
474
- console.log(e); // TODO: capturar error bien
475
- }
476
- };
477
- }
478
-
479
- function setCategoryValues(category: ICategory): (dispatch: Dispatch) => Promise<void> {
480
- return async (dispatch) => {
481
- try {
482
- dispatch(setCategory(category));
483
- } catch (e) {
484
- console.log("Error", e);
485
- }
486
- };
487
- }
488
-
489
- function resetCategoryValues(): (dispatch: Dispatch) => Promise<void> {
490
- return async (dispatch) => {
491
- try {
492
- dispatch(setCategory({ name: "", code: "", lang: null, isTranslation: false, isNew: true }));
493
- dispatch(setEntity(null));
494
- } catch (e) {
495
- console.log("Error", e);
465
+ console.log(e);
496
466
  }
497
467
  };
498
468
  }
499
469
 
500
- function getDistributorContent(data: any): (dispatch: Dispatch, getState: any) => Promise<any> {
501
- return async (dispatch, getState) => {
470
+ function getDistributorContent(data: any): (getState: any) => Promise<any> {
471
+ return async (getState) => {
502
472
  try {
503
473
  const {
504
474
  sites: {
@@ -664,6 +634,123 @@ function resetCurrentData(): (dispatch: Dispatch) => Promise<void> {
664
634
  };
665
635
  }
666
636
 
637
+ function createCategoryGroup(data: ICategoryGroupParams): (dispatch: Dispatch, getState: any) => Promise<boolean> {
638
+ return async (dispatch, getState) => {
639
+ try {
640
+ const {
641
+ sites: { currentSiteInfo },
642
+ app: { lang },
643
+ }: IRootState = getState();
644
+
645
+ const dataGroup: ICategoryGroupParams = {
646
+ ...data,
647
+ language: data.language ? data.language : lang.id,
648
+ relatedSite: currentSiteInfo ? currentSiteInfo.id : "global",
649
+ };
650
+
651
+ const responseActions = {
652
+ handleSuccess: () => null,
653
+ handleError: (response: any) => appActions.handleError(response)(dispatch),
654
+ };
655
+
656
+ const callback = async () => structuredData.createGroup(dataGroup);
657
+
658
+ return await handleRequest(callback, responseActions, [appActions.setIsLoading])(dispatch);
659
+ } catch (e) {
660
+ console.log(e);
661
+ return false;
662
+ }
663
+ };
664
+ }
665
+
666
+ function updateCategoryGroup(groupID: number, data: ICategoryGroupParams): (dispatch: Dispatch) => Promise<boolean> {
667
+ return async (dispatch) => {
668
+ try {
669
+ const responseActions = {
670
+ handleSuccess: () => null,
671
+ handleError: (response: any) => appActions.handleError(response)(dispatch),
672
+ };
673
+
674
+ const callback = async () => structuredData.updateGroup(groupID, data);
675
+
676
+ return await handleRequest(callback, responseActions, [appActions.setIsLoading])(dispatch);
677
+ } catch (e) {
678
+ console.log(e);
679
+ return false;
680
+ }
681
+ };
682
+ }
683
+
684
+ function deleteCategoryGroup(
685
+ id: number | number[],
686
+ deleteChildren: boolean,
687
+ refresh = true
688
+ ): (dispatch: Dispatch, getState: any) => Promise<boolean> {
689
+ return async (dispatch, getState) => {
690
+ try {
691
+ const {
692
+ structuredData: { currentFilter, currentStructuredData },
693
+ sites: { currentSiteInfo },
694
+ }: IRootState = getState();
695
+
696
+ if (!currentStructuredData) return false;
697
+
698
+ dispatch(setIsLoading(true));
699
+
700
+ const params = { ...DEFAULT_PARAMS, dataID: currentFilter, groupingCategories: true };
701
+
702
+ const siteID = currentSiteInfo ? currentSiteInfo.id : "global";
703
+
704
+ const responseActions = {
705
+ handleSuccess: () => refresh && getStructuredDataContents(params, currentSiteInfo?.id)(dispatch, getState),
706
+ handleError: (response: any) => {
707
+ const {
708
+ data: { message },
709
+ } = response;
710
+ const isMultiple = Array.isArray(message) && message.length > 1;
711
+ const msg = isMultiple ? `The delete action failed due to ${message.length} errors.` : undefined;
712
+ appActions.handleError(response, isMultiple, msg)(dispatch);
713
+ },
714
+ };
715
+
716
+ const callback = async () =>
717
+ Array.isArray(id)
718
+ ? structuredData.deleteGroupBulk(currentStructuredData.id, siteID, id, deleteChildren)
719
+ : structuredData.deleteGroup(currentStructuredData.id, siteID, id, deleteChildren);
720
+
721
+ return await handleRequest(callback, responseActions, [])(dispatch);
722
+ } catch (e) {
723
+ console.log(e);
724
+ return false;
725
+ }
726
+ };
727
+ }
728
+
729
+ function orderCategory(data: IOrderCategoryParams): (dispatch: Dispatch, getState: any) => Promise<boolean> {
730
+ return async (dispatch, getState) => {
731
+ try {
732
+ const {
733
+ structuredData: { currentFilter },
734
+ sites: { currentSiteInfo },
735
+ }: IRootState = getState();
736
+
737
+ const params = { ...DEFAULT_PARAMS, dataID: currentFilter, groupingCategories: true };
738
+
739
+ const responseActions = {
740
+ handleSuccess: () => getStructuredDataContents(params, currentSiteInfo?.id, false)(dispatch, getState),
741
+ handleError: (response: any) => appActions.handleError(response)(dispatch),
742
+ };
743
+
744
+ const callback = async () => structuredData.orderCategory(data);
745
+
746
+ return await handleRequest(callback, responseActions, [])(dispatch);
747
+ } catch (e) {
748
+ console.log(e);
749
+ return false;
750
+ }
751
+ };
752
+ }
753
+
667
754
  function updateCurrentSearch(query: string): (dispatch: Dispatch) => Promise<void> {
668
755
  return async (dispatch) => {
669
756
  try {
@@ -680,7 +767,6 @@ export {
680
767
  setStructuredData,
681
768
  setCurrentData,
682
769
  setCurrentDataID,
683
- setCategory,
684
770
  setSchema,
685
771
  setForm,
686
772
  updateForm,
@@ -693,11 +779,8 @@ export {
693
779
  createStructuredDataContent,
694
780
  updateStructuredDataContent,
695
781
  deleteStructuredDataContent,
696
- setCategoryValues,
697
- resetCategoryValues,
698
782
  getDistributorContent,
699
783
  setEntity,
700
- getTranslatedCategory,
701
784
  getDataContent,
702
785
  restoreStructuredDataContent,
703
786
  setStatusStructuredDataContent,
@@ -711,5 +794,9 @@ export {
711
794
  setFormValues,
712
795
  setIsTranslated,
713
796
  resetCurrentData,
797
+ createCategoryGroup,
798
+ updateCategoryGroup,
799
+ deleteCategoryGroup,
800
+ orderCategory,
714
801
  updateCurrentSearch,
715
802
  };
@@ -6,7 +6,7 @@ const SET_STRUCTURED_DATA = `${NAME}/SET_STRUCTURED_DATA`;
6
6
  const SET_CURRENT_STRUCTURED_DATA = `${NAME}/SET_CURRENT_STRUCTURED_DATA`;
7
7
  const SET_CURRENT_STRUCTURED_DATA_ID = `${NAME}/SET_CURRENT_STRUCTURED_DATA_ID`;
8
8
  const SET_CURRENT_STRUCTURED_DATA_CONTENTS = `${NAME}/SET_CURRENT_STRUCTURED_DATA_CONTENTS`;
9
- const SET_CATEGORY = `${NAME}/SET_CATEGORY`;
9
+ const SET_CURRENT_DATA_CATEGORY = `${NAME}/SET_CURRENT_CATEGORIES`;
10
10
  const SET_SCHEMA = `${NAME}/SET_SCHEMA`;
11
11
  const CREATE_FORM = `${NAME}/CREATE_FORM`;
12
12
  const UPDATE_FORM = `${NAME}/UPDATE_FORM`;
@@ -36,7 +36,7 @@ export {
36
36
  SET_CURRENT_STRUCTURED_DATA,
37
37
  SET_CURRENT_STRUCTURED_DATA_ID,
38
38
  SET_CURRENT_STRUCTURED_DATA_CONTENTS,
39
- SET_CATEGORY,
39
+ SET_CURRENT_DATA_CATEGORY,
40
40
  SET_SCHEMA,
41
41
  CREATE_FORM,
42
42
  UPDATE_FORM,
@@ -7,17 +7,23 @@ import {
7
7
  SET_SCHEMA,
8
8
  UPDATE_FORM,
9
9
  SET_IS_ACTIVE,
10
- SET_CATEGORY,
11
10
  SET_FILTER,
12
11
  SET_SCHEMA_VERSION,
13
12
  SET_ERRORS,
14
13
  SET_VALIDATED,
15
14
  SET_CONTENT_FILTERS,
16
15
  SET_IS_IA_TRANSLATED,
16
+ SET_CURRENT_DATA_CATEGORY,
17
17
  SET_CURRENT_SEARCH,
18
18
  } from "./constants";
19
19
 
20
- import { IStructuredData, IStructuredDataContent, ICategory, IErrorItem, IStructuredDataQueryValues } from "@ax/types";
20
+ import {
21
+ IStructuredData,
22
+ IStructuredDataContent,
23
+ IErrorItem,
24
+ IStructuredDataQueryValues,
25
+ IStructuredDataCategory,
26
+ } from "@ax/types";
21
27
 
22
28
  export interface ISetCategories {
23
29
  type: typeof SET_CATEGORIES;
@@ -36,12 +42,7 @@ export interface ISetCurrentData {
36
42
 
37
43
  export interface ISetCurrentDataID {
38
44
  type: typeof SET_CURRENT_STRUCTURED_DATA_ID;
39
- payload: { currentStructuredDataId: number };
40
- }
41
-
42
- export interface ISetCategory {
43
- type: typeof SET_CATEGORY;
44
- payload: { category: ICategory };
45
+ payload: { currentStructuredDataId: number | null };
45
46
  }
46
47
 
47
48
  export interface ISetSchema {
@@ -53,6 +54,11 @@ export interface ISetCurrentDataContent {
53
54
  payload: { currentDataContent: IStructuredDataContent[] };
54
55
  }
55
56
 
57
+ export interface ISetCurrentCategories {
58
+ type: typeof SET_CURRENT_DATA_CATEGORY;
59
+ payload: { currentDataCategory: IStructuredDataCategory[] };
60
+ }
61
+
56
62
  export interface IUpdateForm {
57
63
  type: typeof UPDATE_FORM;
58
64
  payload: { value: any };
@@ -104,4 +110,5 @@ export type StructuredDataActionsCreators = CategoryActionsCreators &
104
110
  ISetStructuredData &
105
111
  ISetCurrentData &
106
112
  ISetCurrentDataID &
107
- ISetCurrentDataContent;
113
+ ISetCurrentDataContent &
114
+ ISetCurrentCategories;
@@ -1,11 +1,16 @@
1
- import { IStructuredData, IStructuredDataContent, ICategory, IErrorItem, IStructuredDataQueryValues } from "@ax/types";
1
+ import {
2
+ IStructuredData,
3
+ IStructuredDataContent,
4
+ IErrorItem,
5
+ IStructuredDataQueryValues,
6
+ IStructuredDataCategory,
7
+ } from "@ax/types";
2
8
  import {
3
9
  SET_CATEGORIES,
4
10
  SET_STRUCTURED_DATA,
5
11
  SET_CURRENT_STRUCTURED_DATA,
6
12
  SET_CURRENT_STRUCTURED_DATA_ID,
7
13
  SET_CURRENT_STRUCTURED_DATA_CONTENTS,
8
- SET_CATEGORY,
9
14
  SET_SCHEMA,
10
15
  CREATE_FORM,
11
16
  UPDATE_FORM,
@@ -17,11 +22,10 @@ import {
17
22
  SET_VALIDATED,
18
23
  SET_CONTENT_FILTERS,
19
24
  SET_IS_IA_TRANSLATED,
25
+ SET_CURRENT_DATA_CATEGORY,
20
26
  SET_CURRENT_SEARCH,
21
27
  } from "./constants";
22
28
 
23
- import { StructuredDataActionsCreators } from "./interfaces";
24
-
25
29
  export interface IStructuredDataState {
26
30
  isActive: boolean;
27
31
  categories: { global: IStructuredData[]; site: IStructuredData[] };
@@ -29,7 +33,7 @@ export interface IStructuredDataState {
29
33
  currentStructuredData: IStructuredData | null;
30
34
  currentStructuredDataId: number | null;
31
35
  currentDataContent: IStructuredDataContent[];
32
- category: ICategory;
36
+ currentDataCategory: IStructuredDataCategory[];
33
37
  schema: any;
34
38
  form: any;
35
39
  entity: string | null;
@@ -49,7 +53,7 @@ export const initialState = {
49
53
  currentStructuredData: null,
50
54
  currentStructuredDataId: null,
51
55
  currentDataContent: [],
52
- category: { name: "", code: "", lang: null, isTranslation: false, isNew: true },
56
+ currentDataCategory: [],
53
57
  schema: {},
54
58
  form: {},
55
59
  entity: null,
@@ -69,7 +73,7 @@ export function reducer(state = initialState, action: any): IStructuredDataState
69
73
  case SET_CURRENT_STRUCTURED_DATA:
70
74
  case SET_CURRENT_STRUCTURED_DATA_ID:
71
75
  case SET_CURRENT_STRUCTURED_DATA_CONTENTS:
72
- case SET_CATEGORY:
76
+ case SET_CURRENT_DATA_CATEGORY:
73
77
  case SET_SCHEMA:
74
78
  case CREATE_FORM:
75
79
  case UPDATE_FORM:
@@ -1,7 +1,7 @@
1
1
  import { deepClone } from "@ax/helpers";
2
- import { IStructuredDataContent, IStructuredData, ISchemaField } from "@ax/types";
2
+ import { IStructuredDataContent, IStructuredData, ISchemaField, IStructuredDataCategory } from "@ax/types";
3
3
 
4
- const prepareStructuredDataContent = (structuredDataContent: IStructuredDataContent) => {
4
+ const prepareStructuredDataContent = (structuredDataContent: IStructuredDataContent | IStructuredDataCategory) => {
5
5
  return { ...structuredDataContent, content: structuredDataContent.content };
6
6
  };
7
7
 
package/src/global.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  declare module "node";
2
2
  declare module "components";
3
- declare module "@thesaurus/themes";
4
3
  declare module "react-froala-wysiwyg";
5
4
  declare module "lodash.isequal";
6
5
  declare module "is-wsl";
@@ -1,10 +1,12 @@
1
1
  import React from "react";
2
2
 
3
- import { CheckField, TableCounter } from "@ax/components";
3
+ import { CheckField, TableCounter, TranslationsFilter } from "@ax/components";
4
+ import { IQueryValue } from "@ax/types";
5
+
4
6
  import * as S from "./style";
5
7
 
6
8
  const TableHeader = (props: IProps) => {
7
- const { totalItems, selectAllItems, isScrolling } = props;
9
+ const { totalItems, selectAllItems, isScrolling, filterItems, filterValues } = props;
8
10
  return (
9
11
  <S.TableHeader isScrolling={isScrolling}>
10
12
  <S.CheckHeader>
@@ -20,7 +22,10 @@ const TableHeader = (props: IProps) => {
20
22
  </S.CheckHeader>
21
23
  <S.NameHeader>Name</S.NameHeader>
22
24
  <S.CodeHeader>Code</S.CodeHeader>
23
- <S.TransHeader>Translations</S.TransHeader>
25
+ <S.SelectHeader>Selectable</S.SelectHeader>
26
+ <S.TransHeader>
27
+ <TranslationsFilter filterItems={filterItems} value={filterValues.translated} />
28
+ </S.TransHeader>
24
29
  <S.ActionsHeader>
25
30
  <TableCounter totalItems={totalItems} />
26
31
  </S.ActionsHeader>
@@ -32,6 +37,8 @@ interface IProps {
32
37
  totalItems: number;
33
38
  isScrolling: boolean;
34
39
  selectAllItems: () => void;
40
+ filterValues: Record<string, IQueryValue[]>;
41
+ filterItems: (filterPointer: string, filtersSelected: IQueryValue[]) => void;
35
42
  }
36
43
 
37
44
  export default TableHeader;