datastake-daf 0.6.827 → 0.6.828

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.
@@ -2292,7 +2292,7 @@ const useWidgetFetch = ({
2292
2292
  };
2293
2293
  React.useEffect(() => {
2294
2294
  fetchData();
2295
- }, [config]);
2295
+ }, [JSON.stringify(rest?.filters)]);
2296
2296
  return {
2297
2297
  data,
2298
2298
  loading,
@@ -2399,6 +2399,16 @@ const useGetQueryParams = ({
2399
2399
  product,
2400
2400
  ...rest
2401
2401
  } = queryParams;
2402
+ const parsedSearchParams = safeJsonParse(rawSearchParams);
2403
+ const otherParams = {
2404
+ ...rest,
2405
+ ...(product ? {
2406
+ "products.typeOfProduct": product
2407
+ } : {}),
2408
+ ...(status ? {
2409
+ published: status === "submitted"
2410
+ } : {})
2411
+ };
2402
2412
  return {
2403
2413
  paginationQuery: {
2404
2414
  skip: page,
@@ -2406,21 +2416,13 @@ const useGetQueryParams = ({
2406
2416
  },
2407
2417
  searchParams: {
2408
2418
  qs: search,
2409
- fields: safeJsonParse(rawSearchParams)
2410
- },
2411
- otherParams: {
2412
- ...rest,
2413
- ...(product && {
2414
- "products.typeOfProduct": product
2415
- }),
2416
- ...(status && {
2417
- published: status === "submitted" ? true : false
2418
- })
2419
+ fields: parsedSearchParams
2419
2420
  },
2421
+ otherParams,
2420
2422
  sortBy,
2421
2423
  sortDir
2422
2424
  };
2423
- }, [queryParams]);
2425
+ }, [JSON.stringify(queryParams)]);
2424
2426
  return params;
2425
2427
  };
2426
2428
 
@@ -7491,7 +7491,7 @@ const useWidgetFetch = ({
7491
7491
  };
7492
7492
  React.useEffect(() => {
7493
7493
  fetchData();
7494
- }, [config]);
7494
+ }, [JSON.stringify(rest?.filters)]);
7495
7495
  return {
7496
7496
  data,
7497
7497
  loading,
@@ -14419,6 +14419,9 @@ function MineSites({
14419
14419
  defaultData: [],
14420
14420
  stop: selectedPartners?.loading
14421
14421
  }), [activeTab, selectedPartners, filters]);
14422
+ console.log({
14423
+ dataFetchConfig
14424
+ });
14422
14425
  const {
14423
14426
  data,
14424
14427
  loading,
@@ -40577,6 +40580,16 @@ const useGetQueryParams = ({
40577
40580
  product,
40578
40581
  ...rest
40579
40582
  } = queryParams;
40583
+ const parsedSearchParams = safeJsonParse(rawSearchParams);
40584
+ const otherParams = {
40585
+ ...rest,
40586
+ ...(product ? {
40587
+ "products.typeOfProduct": product
40588
+ } : {}),
40589
+ ...(status ? {
40590
+ published: status === "submitted"
40591
+ } : {})
40592
+ };
40580
40593
  return {
40581
40594
  paginationQuery: {
40582
40595
  skip: page,
@@ -40584,21 +40597,13 @@ const useGetQueryParams = ({
40584
40597
  },
40585
40598
  searchParams: {
40586
40599
  qs: search,
40587
- fields: safeJsonParse(rawSearchParams)
40588
- },
40589
- otherParams: {
40590
- ...rest,
40591
- ...(product && {
40592
- "products.typeOfProduct": product
40593
- }),
40594
- ...(status && {
40595
- published: status === "submitted" ? true : false
40596
- })
40600
+ fields: parsedSearchParams
40597
40601
  },
40602
+ otherParams,
40598
40603
  sortBy,
40599
40604
  sortDir
40600
40605
  };
40601
- }, [queryParams]);
40606
+ }, [JSON.stringify(queryParams)]);
40602
40607
  return params;
40603
40608
  };
40604
40609
 
@@ -41564,7 +41569,7 @@ const getFilterOptions$c = (options, t) => {
41564
41569
  const formConfig$a = {
41565
41570
  namespace: 'OPERATOR',
41566
41571
  view: ['scoping', 'new'],
41567
- scope: 'global',
41572
+ scope: 'createOperator',
41568
41573
  formType: 'operator'
41569
41574
  };
41570
41575
  const viewConfig$a = {
@@ -41991,7 +41996,7 @@ const getFilterOptions$b = (options, t) => {
41991
41996
  const formConfig$9 = {
41992
41997
  namespace: 'WORKERS',
41993
41998
  view: ['scoping', 'new'],
41994
- scope: 'global',
41999
+ scope: 'createWorker',
41995
42000
  formType: 'worker'
41996
42001
  };
41997
42002
  const viewConfig$9 = {
@@ -44636,7 +44641,7 @@ const getFilterOptions$4 = (options, t) => {
44636
44641
  const formConfig$2 = {
44637
44642
  namespace: 'PRODUCTION SITES',
44638
44643
  view: ['scoping', 'new'],
44639
- scope: 'global',
44644
+ scope: 'create',
44640
44645
  formType: 'production-sites'
44641
44646
  };
44642
44647
  const viewConfig$2 = {
@@ -45491,6 +45496,9 @@ const useFetchData = ({
45491
45496
  } = useGetQueryParams({
45492
45497
  location
45493
45498
  });
45499
+ const tab = React.useMemo(() => {
45500
+ return activeTab;
45501
+ }, [activeTab]);
45494
45502
  React.useEffect(() => {
45495
45503
  const cleanSearchParams = Object.fromEntries(Object.entries(searchParams).filter(([_, value]) => value != null && value !== ''));
45496
45504
  const hasPagination = paginationQuery.skip != null || paginationQuery.take != null;
@@ -45506,12 +45514,12 @@ const useFetchData = ({
45506
45514
  ...(Object.keys(cleanSearchParams).length > 0 && {
45507
45515
  search: cleanSearchParams
45508
45516
  }),
45509
- tab: activeTab,
45517
+ tab: tab,
45510
45518
  sortBy: {
45511
45519
  [sortBy || extendingSortKey || "updatedAt"]: sortDir ? sortDir === "ascend" ? 1 : -1 : extendingSortDir || -1
45512
45520
  }
45513
45521
  }, subject);
45514
- }, [location.search, activeTab, JSON.stringify(extendingFilters)]);
45522
+ }, [location.search, JSON.stringify(extendingFilters)]);
45515
45523
  };
45516
45524
  const useTablePage = ({
45517
45525
  subject,
@@ -61765,14 +61773,18 @@ const getNamespace = namespace => {
61765
61773
  let _namespace = namespace;
61766
61774
  switch (namespace) {
61767
61775
  case "locations":
61776
+ case "location":
61768
61777
  _namespace = "location";
61769
61778
  break;
61770
61779
  case "stakeholders":
61780
+ case "stakeholder":
61771
61781
  _namespace = "stakeholder";
61772
61782
  break;
61773
61783
  case "documents":
61784
+ case "document":
61774
61785
  _namespace = "document";
61775
61786
  break;
61787
+ case "event":
61776
61788
  case "nashirikiEvent":
61777
61789
  case "events":
61778
61790
  _namespace = "event";
@@ -61815,7 +61827,7 @@ class LinkedSubjectsService extends BaseService {
61815
61827
  version
61816
61828
  }) {
61817
61829
  return this.apiGet({
61818
- url: `/${namespace === "nashirikiEvent" ? "event" : namespace}/${id}`,
61830
+ url: `/${getNamespace(namespace)}/${id}`,
61819
61831
  isApp: true,
61820
61832
  signal,
61821
61833
  params: {
@@ -62131,7 +62143,7 @@ const View = ({
62131
62143
  "management-location": "location",
62132
62144
  "management-stakeholder": "stakeholder",
62133
62145
  "management-event": "event",
62134
- "management-incident": "incident"
62146
+ "management-document": "document"
62135
62147
  };
62136
62148
  const handleDeleteSubject = React.useCallback(async () => {
62137
62149
  try {
@@ -1535,14 +1535,18 @@ const getNamespace = namespace => {
1535
1535
  let _namespace = namespace;
1536
1536
  switch (namespace) {
1537
1537
  case "locations":
1538
+ case "location":
1538
1539
  _namespace = "location";
1539
1540
  break;
1540
1541
  case "stakeholders":
1542
+ case "stakeholder":
1541
1543
  _namespace = "stakeholder";
1542
1544
  break;
1543
1545
  case "documents":
1546
+ case "document":
1544
1547
  _namespace = "document";
1545
1548
  break;
1549
+ case "event":
1546
1550
  case "nashirikiEvent":
1547
1551
  case "events":
1548
1552
  _namespace = "event";
@@ -1585,7 +1589,7 @@ class LinkedSubjectsService extends BaseService {
1585
1589
  version
1586
1590
  }) {
1587
1591
  return this.apiGet({
1588
- url: `/${namespace === "nashirikiEvent" ? "event" : namespace}/${id}`,
1592
+ url: `/${getNamespace(namespace)}/${id}`,
1589
1593
  isApp: true,
1590
1594
  signal,
1591
1595
  params: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datastake-daf",
3
- "version": "0.6.827",
3
+ "version": "0.6.828",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.2.5",
6
6
  "@antv/g2": "^5.1.1",
@@ -16,28 +16,10 @@ export const getTabs = ({ t }) => {
16
16
  };
17
17
 
18
18
  export const selectFiltersConfig = {
19
- category: {
19
+ eventsType: {
20
20
  type: "select",
21
- label: "Category",
22
- placeholder: (t) => t("Category"),
23
- style: { flex: 1 },
24
- labelStyle: { flex: 1 },
25
- getLabel: (option) => option.label,
26
- getValue: (option) => option.value,
27
- },
28
- country: {
29
- type: "select",
30
- label: "Country",
31
- placeholder: (t) => t("Country"),
32
- style: { flex: 1 },
33
- labelStyle: { flex: 1 },
34
- getLabel: (option) => option.label,
35
- getValue: (option) => option.value,
36
- },
37
- sources: {
38
- type: "select",
39
- label: "Sources",
40
- placeholder: (t) => t("Sources"),
21
+ label: "type",
22
+ placeholder: (t) => t("type"),
41
23
  style: { flex: 1 },
42
24
  labelStyle: { flex: 1 },
43
25
  getLabel: (option) => option.label,
@@ -45,6 +27,20 @@ export const selectFiltersConfig = {
45
27
  },
46
28
  };
47
29
 
30
+ export const getSelectFiltersConfig = ({t}) => {
31
+ return {
32
+ eventsType: {
33
+ type: "select",
34
+ label: "type",
35
+ placeholder: t("type"),
36
+ style: { flex: 1 },
37
+ labelStyle: { flex: 1 },
38
+ getLabel: (option) => option.label,
39
+ getValue: (option) => option.value,
40
+ },
41
+ }
42
+ };
43
+
48
44
  export const filtersConfig = {
49
45
  name: "",
50
46
  datastakeId: "",
@@ -5,10 +5,10 @@ import DAFTable from "../../../../Table/index.jsx";
5
5
  import { theme, Tag, message } from "antd";
6
6
  import CustomIcon from "../../../../Icon/CustomIcon.jsx";
7
7
  import {
8
- selectFiltersConfig,
9
8
  filtersConfig,
10
9
  defaultUrlParams,
11
10
  checkboxConfig,
11
+ getSelectFiltersConfig,
12
12
  } from "./helper.js";
13
13
  import { getColumns } from "./column.js";
14
14
  import { getTabs } from "../helper.js";
@@ -37,6 +37,10 @@ export default function EventsTable({
37
37
  const [selectedEvents, setSelectedEvents] = useState([]);
38
38
  const { token } = useToken();
39
39
 
40
+ const selectFiltersConfig = useMemo(() => {
41
+ return getSelectFiltersConfig({t});
42
+ }, [t]);
43
+
40
44
  const {
41
45
  filter,
42
46
  activeTab,
@@ -64,8 +68,6 @@ export default function EventsTable({
64
68
  return options;
65
69
  }, [options]);
66
70
 
67
-
68
-
69
71
  const columns = useMemo(() => {
70
72
  return getColumns({
71
73
  t,
@@ -67,7 +67,6 @@ export function useAdminTable({
67
67
  const params = filterParams({
68
68
  activeFilters: filter.activeFilters,
69
69
  });
70
- console.log(params, "params");
71
70
  const { data } = await getData({ params });
72
71
  setData(data.data || data);
73
72
  filter.setPagination((prev) => ({ ...prev, total: data?.meta?.total || data?.length || 0 }));
@@ -109,8 +108,6 @@ export const useGetParams = ({location}) => {
109
108
 
110
109
  const { activeTab, ...rest } = otherParams;
111
110
 
112
- console.log({hasPagination})
113
-
114
111
  const params = useMemo(() => {
115
112
  if (!hasPagination) {
116
113
  return {
@@ -153,7 +153,8 @@ function AdminView({
153
153
  };
154
154
 
155
155
  try {
156
- await updateAccount({ id: editData.id, data: newData });
156
+ const { data} = await updateAccount({ id: editData.id, data: newData });
157
+ console.log({data})
157
158
 
158
159
  console.log('Checking for pending users...', {
159
160
  hasPendingUsers: pendingUsers.length > 0,
@@ -1,30 +1,49 @@
1
1
  import { useMemo } from "react";
2
2
  import { safeJsonParse } from "../../helpers/StringHelper.js";
3
3
 
4
- export const useGetQueryParams = ({location}) => {
5
- const queryParams = useMemo(() => {
6
- const params = new URLSearchParams(location?.search);
7
- return Object.fromEntries(params.entries());
8
- }, [location.search]);
4
+ export const useGetQueryParams = ({ location }) => {
5
+ const queryParams = useMemo(() => {
6
+ const params = new URLSearchParams(location?.search);
7
+ return Object.fromEntries(params.entries());
8
+ }, [location.search]);
9
9
 
10
- const params = useMemo(() => {
11
- const { page, pageSize, search, searchParams: rawSearchParams, sortBy, sortDir, status, product, ...rest } = queryParams;
12
-
13
- return {
14
- paginationQuery: { skip: page, take: pageSize },
15
- searchParams: {
16
- qs: search,
17
- fields: safeJsonParse(rawSearchParams),
18
- },
19
- otherParams: {
20
- ...rest,
21
- ...(product && { "products.typeOfProduct": product }),
22
- ...(status && { published: status === "submitted" ? true : false }),
23
- },
24
- sortBy,
25
- sortDir,
26
- };
27
- }, [queryParams]);
10
+ const params = useMemo(() => {
11
+ const {
12
+ page,
13
+ pageSize,
14
+ search,
15
+ searchParams: rawSearchParams,
16
+ sortBy,
17
+ sortDir,
18
+ status,
19
+ product,
20
+ ...rest
21
+ } = queryParams;
28
22
 
29
- return params;
30
- }
23
+ const parsedSearchParams = safeJsonParse(rawSearchParams);
24
+
25
+ const otherParams = {
26
+ ...rest,
27
+ ...(product ? { "products.typeOfProduct": product } : {}),
28
+ ...(status ? { published: status === "submitted" } : {}),
29
+ };
30
+
31
+ return {
32
+ paginationQuery: {
33
+ skip: page,
34
+ take: pageSize,
35
+ },
36
+ searchParams: {
37
+ qs: search,
38
+ fields: parsedSearchParams,
39
+ },
40
+ otherParams,
41
+ sortBy,
42
+ sortDir,
43
+ };
44
+ }, [
45
+ JSON.stringify(queryParams),
46
+ ]);
47
+
48
+ return params;
49
+ };
@@ -35,7 +35,7 @@ export const useWidgetFetch = ({config, getData = DashboardService.getWidget, on
35
35
 
36
36
  useEffect(() => {
37
37
  fetchData();
38
- }, [config]);
38
+ }, [JSON.stringify(rest?.filters)]);
39
39
 
40
40
  return {
41
41
  data,
@@ -70,8 +70,10 @@ function MineSites({
70
70
  stop: selectedPartners?.loading,
71
71
  }),
72
72
  [activeTab, selectedPartners, filters],
73
+
73
74
  );
74
- const { data, loading, setData } = useWidgetFetch({config: dataFetchConfig});
75
+ console.log({dataFetchConfig})
76
+ const { data, loading, setData } = useWidgetFetch({config: dataFetchConfig});
75
77
 
76
78
  const tabs = useMemo(() => getTabs(t), [t]);
77
79
 
@@ -149,7 +149,7 @@ export const getFilterOptions = (options, t) => {
149
149
  export const formConfig = {
150
150
  namespace: 'PRODUCTION SITES',
151
151
  view: ['scoping', 'new'],
152
- scope: 'global',
152
+ scope: 'create',
153
153
  formType: 'production-sites',
154
154
  }
155
155
 
@@ -147,7 +147,7 @@ export const getFilterOptions = (options, t) => {
147
147
  export const formConfig = {
148
148
  namespace: 'OPERATOR',
149
149
  view: ['scoping', 'new'],
150
- scope: 'global',
150
+ scope: 'createOperator',
151
151
  formType: 'operator',
152
152
  }
153
153
 
@@ -137,7 +137,7 @@ export const getFilterOptions = (options, t) => {
137
137
  export const formConfig = {
138
138
  namespace: 'WORKERS',
139
139
  view: ['scoping', 'new'],
140
- scope: 'global',
140
+ scope: 'createWorker',
141
141
  formType: 'worker',
142
142
  }
143
143
 
@@ -18,6 +18,11 @@ export const useFetchData = ({
18
18
  subject,
19
19
  }) => {
20
20
  const { paginationQuery, searchParams, otherParams, sortBy, sortDir, } = useGetQueryParams({location});
21
+
22
+ const tab = useMemo(() => {
23
+ return activeTab;
24
+ }, [activeTab])
25
+
21
26
  useEffect(() => {
22
27
  const cleanSearchParams = Object.fromEntries(
23
28
  Object.entries(searchParams).filter(([_, value]) => value != null && value !== '')
@@ -37,12 +42,12 @@ export const useFetchData = ({
37
42
  pagination: paginationQuery,
38
43
  ...(Object.keys(otherParams).length > 0 && otherParams ),
39
44
  ...(Object.keys(cleanSearchParams).length > 0 && { search: cleanSearchParams }),
40
- tab: activeTab,
45
+ tab: tab,
41
46
  sortBy: {
42
47
  [sortBy || extendingSortKey || "updatedAt"]: sortDir ? (sortDir === "ascend" ? 1 : -1) : (extendingSortDir || -1),
43
48
  },
44
49
  }, subject)
45
- }, [location.search, activeTab, JSON.stringify(extendingFilters)]);
50
+ }, [location.search, JSON.stringify(extendingFilters)]);
46
51
  }
47
52
 
48
53
  export const useTablePage = ({
@@ -135,7 +135,7 @@ const View = ({
135
135
  "management-location": "location",
136
136
  "management-stakeholder": "stakeholder",
137
137
  "management-event": "event",
138
- "management-incident": "incident",
138
+ "management-document": "document",
139
139
  }
140
140
 
141
141
 
@@ -7,14 +7,18 @@ export const getNamespace = (namespace) => {
7
7
  let _namespace = namespace;
8
8
  switch (namespace) {
9
9
  case "locations":
10
+ case "location":
10
11
  _namespace = "location";
11
12
  break;
12
13
  case "stakeholders":
14
+ case "stakeholder":
13
15
  _namespace = "stakeholder";
14
16
  break;
15
17
  case "documents":
18
+ case "document":
16
19
  _namespace = "document";
17
20
  break;
21
+ case "event":
18
22
  case "nashirikiEvent":
19
23
  case "events":
20
24
  _namespace = "event";
@@ -50,7 +54,7 @@ class LinkedSubjectsService extends BaseService {
50
54
 
51
55
  getOne({ id, signal, namespace, sourceId, source, version }) {
52
56
  return this.apiGet({
53
- url: `/${namespace === "nashirikiEvent" ? "event" : namespace}/${id}`,
57
+ url: `/${getNamespace(namespace)}/${id}`,
54
58
  isApp: true,
55
59
  signal,
56
60
  params: { authorId: sourceId, source, version },