datastake-daf 0.6.737 → 0.6.738

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 (37) hide show
  1. package/dist/components/index.js +12 -5
  2. package/dist/hooks/index.js +4 -2
  3. package/dist/layouts/index.js +18 -5
  4. package/dist/pages/index.js +1410 -70
  5. package/dist/services/index.js +84 -0
  6. package/dist/utils/index.js +4 -4
  7. package/package.json +1 -1
  8. package/public/assets/favicons/datastake-black.svg +13 -0
  9. package/public/assets/favicons/datastake-white.svg +13 -0
  10. package/src/@daf/core/components/Sidenav/index.jsx +15 -3
  11. package/src/@daf/hooks/useGetQueryParams.js +2 -2
  12. package/src/@daf/layouts/AppLayout/components/Sidenav/index.js +2 -0
  13. package/src/@daf/layouts/AppLayout/index.jsx +6 -1
  14. package/src/@daf/pages/dashboards/AllInformation/Documents/columns.js +106 -0
  15. package/src/@daf/pages/dashboards/AllInformation/Documents/config.js +31 -0
  16. package/src/@daf/pages/dashboards/AllInformation/Documents/create.jsx +104 -0
  17. package/src/@daf/pages/dashboards/AllInformation/Documents/index.jsx +156 -0
  18. package/src/@daf/pages/dashboards/AllInformation/Events/columns.js +150 -0
  19. package/src/@daf/pages/dashboards/AllInformation/Events/config.js +31 -0
  20. package/src/@daf/pages/dashboards/AllInformation/Events/create.jsx +104 -0
  21. package/src/@daf/pages/dashboards/AllInformation/Events/index.jsx +156 -0
  22. package/src/@daf/pages/dashboards/AllInformation/Locations/index.jsx +1 -2
  23. package/src/@daf/pages/dashboards/Operations/Operators/columns.js +150 -0
  24. package/src/@daf/pages/dashboards/Operations/Operators/config.js +31 -0
  25. package/src/@daf/pages/dashboards/Operations/Operators/create.jsx +104 -0
  26. package/src/@daf/pages/dashboards/Operations/Operators/index.jsx +156 -0
  27. package/src/@daf/pages/pages/TablePageWithTabs/index.jsx +2 -2
  28. package/src/@daf/services/OperatorService.js +90 -0
  29. package/src/helpers/StringHelper.js +4 -4
  30. package/src/pages.js +5 -2
  31. package/src/services.js +2 -1
  32. package/build/favicon.ico +0 -0
  33. package/build/logo192.png +0 -0
  34. package/build/logo512.png +0 -0
  35. package/build/manifest.json +0 -25
  36. package/build/robots.txt +0 -3
  37. package/dist/style/datastake/mapbox-gl.css +0 -330
@@ -4662,12 +4662,12 @@ const camelCaseToTitle = string => string && typeof string === 'string' ? string
4662
4662
  const findOptions = (value, options) => {
4663
4663
  if (value instanceof Array) {
4664
4664
  return value.map(v => {
4665
- const op = options?.find(o => o.value === v);
4665
+ const op = Array.isArray(options) ? options.find(o => o.value === v) : null;
4666
4666
  return op ? op.label : v;
4667
4667
  });
4668
4668
  }
4669
4669
  if (typeof value === "string") {
4670
- const op = options?.find(o => o.value === value);
4670
+ const op = Array.isArray(options) ? options.find(o => o.value === value) : null;
4671
4671
  return op ? op.label : value;
4672
4672
  }
4673
4673
  return value;
@@ -13547,7 +13547,7 @@ const getTabs = t => {
13547
13547
  label: t("Events")
13548
13548
  }];
13549
13549
  };
13550
- const getFiltersConfig$2 = (t, filters, locationCategories) => {
13550
+ const getFiltersConfig$5 = (t, filters, locationCategories) => {
13551
13551
  const value = filters.type ? {
13552
13552
  value: filters.type
13553
13553
  } : {};
@@ -13756,7 +13756,7 @@ function MineSites({
13756
13756
  config: dataFetchConfig
13757
13757
  });
13758
13758
  const tabs = React.useMemo(() => getTabs(t), [t]);
13759
- const filtersConfig = React.useMemo(() => getFiltersConfig$2(t, filters, locationCategories), [activeTab, filters, t, locationCategories]);
13759
+ const filtersConfig = React.useMemo(() => getFiltersConfig$5(t, filters, locationCategories), [activeTab, filters, t, locationCategories]);
13760
13760
  const onFilterChange = filters => {
13761
13761
  setFilters(p => ({
13762
13762
  ...p,
@@ -15860,7 +15860,7 @@ const TablePageWithTabs = ({
15860
15860
  onCreateModalClose = () => {},
15861
15861
  children
15862
15862
  }) => {
15863
- const params = new URLSearchParams(location.search);
15863
+ const params = new URLSearchParams(location?.search);
15864
15864
  const [activeTab, setActiveTab] = React.useState(params.get("tab") || defaultActiveTab);
15865
15865
  const [openCreateModal, setOpenCreateModal] = React.useState(false);
15866
15866
  const getActiveTabRef = React.useRef(getActiveTab);
@@ -15901,7 +15901,7 @@ const TablePageWithTabs = ({
15901
15901
  return;
15902
15902
  }
15903
15903
  setActiveTab(val);
15904
- const newParams = new URLSearchParams(location.search);
15904
+ const newParams = new URLSearchParams(location?.search);
15905
15905
  newParams.set("tab", val);
15906
15906
  goTo(`${location.pathname}?${newParams.toString()}`);
15907
15907
  },
@@ -15992,7 +15992,13 @@ function AvatarGroup({
15992
15992
  });
15993
15993
  }
15994
15994
 
15995
- const getColumns$1 = ({
15995
+ const getLinkValue$2 = (value, linkingObject) => {
15996
+ if (linkingObject && linkingObject?.[value]) {
15997
+ return linkingObject?.[value]?.name;
15998
+ }
15999
+ return null;
16000
+ };
16001
+ const getColumns$4 = ({
15996
16002
  t,
15997
16003
  goTo,
15998
16004
  user,
@@ -16000,7 +16006,8 @@ const getColumns$1 = ({
16000
16006
  activeTab,
16001
16007
  getRedirectLink,
16002
16008
  theme,
16003
- subject
16009
+ subject,
16010
+ data
16004
16011
  }) => [{
16005
16012
  dataIndex: 'datastakeId',
16006
16013
  title: t('ID'),
@@ -16044,15 +16051,15 @@ const getColumns$1 = ({
16044
16051
  className: "daf-default-cell"
16045
16052
  });
16046
16053
  }
16047
- const category = findOptions(v, options?.categoriesOptions);
16054
+ const category = findOptions(v, data?.options?.locationCategories);
16048
16055
  return category ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
16049
16056
  title: category,
16050
16057
  children: category
16051
16058
  }) : '-';
16052
16059
  }
16053
16060
  }, {
16054
- dataIndex: 'subCategory',
16055
- title: t('Sub Category'),
16061
+ dataIndex: 'country',
16062
+ title: t('Country'),
16056
16063
  ellipsis: true,
16057
16064
  show: true,
16058
16065
  render: (v, all) => {
@@ -16061,15 +16068,15 @@ const getColumns$1 = ({
16061
16068
  className: "daf-default-cell"
16062
16069
  });
16063
16070
  }
16064
- const subCategory = findOptions(v, options?.subCategoriesOptions);
16065
- return subCategory ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
16066
- title: subCategory,
16067
- children: subCategory
16071
+ const country = findOptions(v, options?.countries);
16072
+ return country ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
16073
+ title: country,
16074
+ children: country
16068
16075
  }) : '-';
16069
16076
  }
16070
16077
  }, {
16071
- dataIndex: 'country',
16072
- title: t('Country'),
16078
+ dataIndex: 'administrativeLevel1',
16079
+ title: t('Region'),
16073
16080
  ellipsis: true,
16074
16081
  show: true,
16075
16082
  render: (v, all) => {
@@ -16078,10 +16085,27 @@ const getColumns$1 = ({
16078
16085
  className: "daf-default-cell"
16079
16086
  });
16080
16087
  }
16081
- const country = findOptions(v, options?.countries);
16082
- return country ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
16083
- title: country,
16084
- children: country
16088
+ const region = getLinkValue$2(v, all?.linking?.SCL);
16089
+ return region ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
16090
+ title: region,
16091
+ children: region
16092
+ }) : '-';
16093
+ }
16094
+ }, {
16095
+ dataIndex: 'administrativeLevel2',
16096
+ title: t('District'),
16097
+ ellipsis: true,
16098
+ show: true,
16099
+ render: (v, all) => {
16100
+ if (all.empty) {
16101
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
16102
+ className: "daf-default-cell"
16103
+ });
16104
+ }
16105
+ const district = getLinkValue$2(v, all?.linking?.SCL);
16106
+ return district ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
16107
+ title: district,
16108
+ children: district
16085
16109
  }) : '-';
16086
16110
  }
16087
16111
  }, {
@@ -16113,9 +16137,10 @@ const getColumns$1 = ({
16113
16137
  className: "daf-default-cell"
16114
16138
  });
16115
16139
  }
16116
- if (!val || val?.length === 0) {
16117
- return "--";
16118
- }
16140
+ console.log({
16141
+ val,
16142
+ all
16143
+ });
16119
16144
  return /*#__PURE__*/jsxRuntime.jsx(AvatarGroup, {
16120
16145
  items: val
16121
16146
  });
@@ -16148,11 +16173,11 @@ const getColumns$1 = ({
16148
16173
  }
16149
16174
  }].filter(column => column.show !== false);
16150
16175
 
16151
- const checkboxConfig$1 = {
16176
+ const checkboxConfig$4 = {
16152
16177
  name: 'Name',
16153
16178
  datastakeId: 'ID'
16154
16179
  };
16155
- const getFiltersConfig$1 = ({
16180
+ const getFiltersConfig$4 = ({
16156
16181
  t
16157
16182
  }) => {
16158
16183
  return {
@@ -16170,11 +16195,11 @@ const getFiltersConfig$1 = ({
16170
16195
  }
16171
16196
  };
16172
16197
  };
16173
- const filtersConfig$1 = {
16198
+ const filtersConfig$4 = {
16174
16199
  name: '',
16175
16200
  datastakeId: ''
16176
16201
  };
16177
- const getFilterOptions$1 = (options, t) => {
16202
+ const getFilterOptions$4 = (options, t) => {
16178
16203
  const {
16179
16204
  countries
16180
16205
  } = options || {};
@@ -16197,12 +16222,14 @@ const useGetQueryParams = ({
16197
16222
  pageSize,
16198
16223
  search,
16199
16224
  searchParams: rawSearchParams,
16225
+ sortBy,
16226
+ sortDir,
16200
16227
  ...rest
16201
16228
  } = queryParams;
16202
16229
  return {
16203
16230
  paginationQuery: {
16204
- page,
16205
- pageSize
16231
+ skip: page,
16232
+ take: pageSize
16206
16233
  },
16207
16234
  searchParams: {
16208
16235
  qs: search,
@@ -29883,9 +29910,9 @@ function DynamicForm({
29883
29910
  });
29884
29911
  }
29885
29912
 
29886
- const StakeholdersCreate$1 = ({
29887
- namespace = 'stakeholders',
29888
- view = 'scoping',
29913
+ const StakeholdersCreate$2 = ({
29914
+ namespace = "OPERATOR",
29915
+ view = ['scoping', 'new'],
29889
29916
  edit = false,
29890
29917
  formData = {},
29891
29918
  loading = false,
@@ -29960,7 +29987,7 @@ const StakeholdersCreate$1 = ({
29960
29987
  const newPayload = {
29961
29988
  ...defaultData,
29962
29989
  ...payloadData,
29963
- form: 'stakeholder'
29990
+ form: 'operator'
29964
29991
  };
29965
29992
  const callback = (type, m, data) => {
29966
29993
  if (setSelectedFormNext) {
@@ -29983,7 +30010,7 @@ const StakeholdersCreate$1 = ({
29983
30010
  });
29984
30011
  };
29985
30012
 
29986
- const StakeholdersTable = ({
30013
+ const OperatorsTable = ({
29987
30014
  t = () => {},
29988
30015
  goTo = () => {},
29989
30016
  user = {},
@@ -30008,11 +30035,12 @@ const StakeholdersTable = ({
30008
30035
  changeAjaxOptions = () => {},
30009
30036
  formData = {},
30010
30037
  formValue = {},
30011
- form = {}
30038
+ form = {},
30039
+ extendingFilters = {}
30012
30040
  }) => {
30013
30041
  const [selectOptions, setSelectOptions] = React.useState();
30014
30042
  const [activeTab, setActiveTab] = React.useState();
30015
- const columns = React.useMemo(() => getColumns$1({
30043
+ const columns = React.useMemo(() => getColumns$4({
30016
30044
  t,
30017
30045
  goTo,
30018
30046
  user,
@@ -30020,37 +30048,54 @@ const StakeholdersTable = ({
30020
30048
  activeTab,
30021
30049
  getRedirectLink,
30022
30050
  theme,
30023
- subject: 'stakeholders'
30024
- }), [t, goTo, user, options, activeTab, getRedirectLink, theme]);
30051
+ subject: 'operators',
30052
+ data
30053
+ }), [t, goTo, user, options, activeTab, getRedirectLink, theme, data]);
30025
30054
  const breadCrumbs = [];
30026
30055
  const {
30027
30056
  paginationQuery,
30028
30057
  searchParams,
30029
- otherParams
30058
+ otherParams,
30059
+ sortBy,
30060
+ sortDir
30030
30061
  } = useGetQueryParams({
30031
30062
  location
30032
30063
  });
30064
+ const filters = React.useMemo(() => {
30065
+ return {
30066
+ ...otherParams,
30067
+ ...extendingFilters
30068
+ };
30069
+ }, [otherParams, extendingFilters]);
30033
30070
  React.useEffect(() => {
30071
+ console.log("fetching data");
30034
30072
  getData({
30035
30073
  pagination: paginationQuery,
30036
- ...(Object.keys(otherParams).length > 0 && {
30037
- filters: otherParams
30074
+ ...(Object.keys(filters).length > 0 && {
30075
+ filters: filters
30038
30076
  }),
30039
30077
  ...(Object.keys(searchParams).length > 0 && {
30040
30078
  search: searchParams
30041
30079
  }),
30042
- tab: activeTab
30043
- }, 'stakeholders');
30044
- }, [paginationQuery, otherParams, searchParams, activeTab]);
30080
+ tab: activeTab,
30081
+ sortBy: {
30082
+ [sortBy || "updatedAt"]: sortDir ? sortDir === "ascend" ? 1 : -1 : -1
30083
+ }
30084
+ }, 'operators');
30085
+ console.log("data fetched");
30086
+ }, [location.search, activeTab, JSON.stringify(extendingFilters)]);
30087
+ console.log({
30088
+ data
30089
+ });
30045
30090
  const selectFiltersConfig = React.useMemo(() => {
30046
- return getFiltersConfig$1({
30091
+ return getFiltersConfig$4({
30047
30092
  t
30048
30093
  });
30049
30094
  }, [t]);
30050
30095
  React.useEffect(() => {
30051
30096
  setSelectOptions(prev => ({
30052
30097
  ...prev,
30053
- ...getFilterOptions$1(options)
30098
+ ...getFilterOptions$4(options)
30054
30099
  }));
30055
30100
  }, [options, t]);
30056
30101
  const handleActiveTabChange = React.useCallback(value => {
@@ -30058,7 +30103,7 @@ const StakeholdersTable = ({
30058
30103
  }, []);
30059
30104
  return /*#__PURE__*/jsxRuntime.jsx(TablePageWithTabs, {
30060
30105
  t: t,
30061
- title: t("Stakeholders"),
30106
+ title: t("Operators"),
30062
30107
  breadCrumbs: breadCrumbs,
30063
30108
  location: location,
30064
30109
  loading: loading,
@@ -30066,23 +30111,23 @@ const StakeholdersTable = ({
30066
30111
  defaultActiveTab: "all",
30067
30112
  columns: columns,
30068
30113
  data: data,
30069
- checkboxConfig: checkboxConfig$1,
30114
+ checkboxConfig: checkboxConfig$4,
30070
30115
  APP: APP,
30071
30116
  getApiBaseUrl: getApiBaseUrl,
30072
30117
  selectOptions: selectOptions,
30073
30118
  selectFiltersConfig: selectFiltersConfig,
30074
30119
  getRedirectLink: getRedirectLink,
30075
- filtersConfig: filtersConfig$1,
30120
+ filtersConfig: filtersConfig$4,
30076
30121
  isMobile: isMobile,
30077
- view: "stakeholders",
30122
+ view: "operators",
30078
30123
  getActiveTab: handleActiveTabChange,
30079
30124
  onDownload: () => {
30080
30125
  console.log("download");
30081
30126
  },
30082
- drawerTitle: t("Create Stakeholder"),
30127
+ drawerTitle: t("Create Operator"),
30083
30128
  children: ({
30084
30129
  onDrawerClose
30085
- }) => /*#__PURE__*/jsxRuntime.jsx(StakeholdersCreate$1, {
30130
+ }) => /*#__PURE__*/jsxRuntime.jsx(StakeholdersCreate$2, {
30086
30131
  t: t,
30087
30132
  goTo: goTo,
30088
30133
  user: user,
@@ -30095,7 +30140,8 @@ const StakeholdersTable = ({
30095
30140
  onSubmitted: (type, m, data) => {
30096
30141
  if (data.datastakeId) {
30097
30142
  displayMessage(type, t("affirmations::subject-created-successfully") || m);
30098
- goTo(`/app/stakeholders`);
30143
+ // goTo(`/app/edit/stakeholders/${data.datastakeId}`);
30144
+ goTo(`/app/edit/operators/${data.datastakeId}`);
30099
30145
  }
30100
30146
  },
30101
30147
  onCancel: onDrawerClose,
@@ -30111,13 +30157,13 @@ const StakeholdersTable = ({
30111
30157
  });
30112
30158
  };
30113
30159
 
30114
- const getLinkValue = (value, linkingObject) => {
30160
+ const getLinkValue$1 = (value, linkingObject) => {
30115
30161
  if (linkingObject && linkingObject?.[value]) {
30116
30162
  return linkingObject?.[value]?.name;
30117
30163
  }
30118
30164
  return null;
30119
30165
  };
30120
- const getColumns = ({
30166
+ const getColumns$3 = ({
30121
30167
  t,
30122
30168
  goTo,
30123
30169
  user,
@@ -30204,7 +30250,7 @@ const getColumns = ({
30204
30250
  className: "daf-default-cell"
30205
30251
  });
30206
30252
  }
30207
- const region = getLinkValue(v, all?.linking?.SCL);
30253
+ const region = getLinkValue$1(v, all?.linking?.SCL);
30208
30254
  return region ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
30209
30255
  title: region,
30210
30256
  children: region
@@ -30221,7 +30267,7 @@ const getColumns = ({
30221
30267
  className: "daf-default-cell"
30222
30268
  });
30223
30269
  }
30224
- const district = getLinkValue(v, all?.linking?.SCL);
30270
+ const district = getLinkValue$1(v, all?.linking?.SCL);
30225
30271
  return district ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
30226
30272
  title: district,
30227
30273
  children: district
@@ -30292,11 +30338,11 @@ const getColumns = ({
30292
30338
  }
30293
30339
  }].filter(column => column.show !== false);
30294
30340
 
30295
- const checkboxConfig = {
30341
+ const checkboxConfig$3 = {
30296
30342
  name: 'Name',
30297
30343
  datastakeId: 'ID'
30298
30344
  };
30299
- const getFiltersConfig = ({
30345
+ const getFiltersConfig$3 = ({
30300
30346
  t
30301
30347
  }) => {
30302
30348
  return {
@@ -30314,11 +30360,11 @@ const getFiltersConfig = ({
30314
30360
  }
30315
30361
  };
30316
30362
  };
30317
- const filtersConfig = {
30363
+ const filtersConfig$3 = {
30318
30364
  name: '',
30319
30365
  datastakeId: ''
30320
30366
  };
30321
- const getFilterOptions = (options, t) => {
30367
+ const getFilterOptions$3 = (options, t) => {
30322
30368
  const {
30323
30369
  countries
30324
30370
  } = options || {};
@@ -30328,7 +30374,7 @@ const getFilterOptions = (options, t) => {
30328
30374
  return _default;
30329
30375
  };
30330
30376
 
30331
- const StakeholdersCreate = ({
30377
+ const StakeholdersCreate$1 = ({
30332
30378
  namespace = 'locations',
30333
30379
  view = 'scoping',
30334
30380
  edit = false,
@@ -30457,7 +30503,7 @@ const LocationsTable = ({
30457
30503
  }) => {
30458
30504
  const [selectOptions, setSelectOptions] = React.useState();
30459
30505
  const [activeTab, setActiveTab] = React.useState();
30460
- const columns = React.useMemo(() => getColumns({
30506
+ const columns = React.useMemo(() => getColumns$3({
30461
30507
  t,
30462
30508
  goTo,
30463
30509
  user,
@@ -30492,14 +30538,14 @@ const LocationsTable = ({
30492
30538
  data
30493
30539
  });
30494
30540
  const selectFiltersConfig = React.useMemo(() => {
30495
- return getFiltersConfig({
30541
+ return getFiltersConfig$3({
30496
30542
  t
30497
30543
  });
30498
30544
  }, [t]);
30499
30545
  React.useEffect(() => {
30500
30546
  setSelectOptions(prev => ({
30501
30547
  ...prev,
30502
- ...getFilterOptions(options)
30548
+ ...getFilterOptions$3(options)
30503
30549
  }));
30504
30550
  }, [options, t]);
30505
30551
  const handleActiveTabChange = React.useCallback(value => {
@@ -30515,13 +30561,13 @@ const LocationsTable = ({
30515
30561
  defaultActiveTab: "all",
30516
30562
  columns: columns,
30517
30563
  data: data,
30518
- checkboxConfig: checkboxConfig,
30564
+ checkboxConfig: checkboxConfig$3,
30519
30565
  APP: APP,
30520
30566
  getApiBaseUrl: getApiBaseUrl,
30521
30567
  selectOptions: selectOptions,
30522
30568
  selectFiltersConfig: selectFiltersConfig,
30523
30569
  getRedirectLink: getRedirectLink,
30524
- filtersConfig: filtersConfig,
30570
+ filtersConfig: filtersConfig$3,
30525
30571
  isMobile: isMobile,
30526
30572
  view: "locations",
30527
30573
  getActiveTab: handleActiveTabChange,
@@ -30531,7 +30577,1298 @@ const LocationsTable = ({
30531
30577
  drawerTitle: t("Create Location"),
30532
30578
  children: ({
30533
30579
  onDrawerClose
30534
- }) => /*#__PURE__*/jsxRuntime.jsx(StakeholdersCreate, {
30580
+ }) => /*#__PURE__*/jsxRuntime.jsx(StakeholdersCreate$1, {
30581
+ t: t,
30582
+ goTo: goTo,
30583
+ user: user,
30584
+ APP: APP,
30585
+ getApiBaseUrl: getApiBaseUrl,
30586
+ getAppHeader: getAppHeader,
30587
+ getData: getFormData,
30588
+ saveData: saveFormData,
30589
+ loading: formLoading,
30590
+ onSubmitted: (type, m, data) => {
30591
+ if (data.datastakeId) {
30592
+ displayMessage(type, t("affirmations::subject-created-successfully") || m);
30593
+ goTo(`/app/edit/locations/${data.datastakeId}`);
30594
+ }
30595
+ },
30596
+ onCancel: onDrawerClose,
30597
+ query: query,
30598
+ ajaxForms: ajaxForms,
30599
+ changeAjaxForms: changeAjaxForms,
30600
+ ajaxOptions: ajaxOptions,
30601
+ changeAjaxOptions: changeAjaxOptions,
30602
+ formData: formData,
30603
+ formValue: formValue,
30604
+ form: form
30605
+ })
30606
+ });
30607
+ };
30608
+
30609
+ const getColumns$2 = ({
30610
+ t,
30611
+ goTo,
30612
+ user,
30613
+ options,
30614
+ activeTab,
30615
+ getRedirectLink,
30616
+ theme,
30617
+ subject
30618
+ }) => [{
30619
+ dataIndex: 'datastakeId',
30620
+ title: t('ID'),
30621
+ ellipsis: true,
30622
+ show: true,
30623
+ render: (v, all) => {
30624
+ if (all.empty) {
30625
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
30626
+ className: "daf-default-cell"
30627
+ });
30628
+ }
30629
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
30630
+ title: v,
30631
+ children: v
30632
+ });
30633
+ }
30634
+ }, {
30635
+ dataIndex: 'name',
30636
+ title: t('Name'),
30637
+ ellipsis: true,
30638
+ show: true,
30639
+ render: (v, all) => {
30640
+ if (all.empty) {
30641
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
30642
+ className: "daf-default-cell"
30643
+ });
30644
+ }
30645
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
30646
+ title: v,
30647
+ children: v
30648
+ });
30649
+ }
30650
+ }, {
30651
+ dataIndex: 'category',
30652
+ title: t('Category'),
30653
+ ellipsis: true,
30654
+ show: true,
30655
+ render: (v, all) => {
30656
+ if (all.empty) {
30657
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
30658
+ className: "daf-default-cell"
30659
+ });
30660
+ }
30661
+ const category = findOptions(v, options?.categoriesOptions);
30662
+ return category ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
30663
+ title: category,
30664
+ children: category
30665
+ }) : '-';
30666
+ }
30667
+ }, {
30668
+ dataIndex: 'subCategory',
30669
+ title: t('Sub Category'),
30670
+ ellipsis: true,
30671
+ show: true,
30672
+ render: (v, all) => {
30673
+ if (all.empty) {
30674
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
30675
+ className: "daf-default-cell"
30676
+ });
30677
+ }
30678
+ const subCategory = findOptions(v, options?.subCategoriesOptions);
30679
+ return subCategory ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
30680
+ title: subCategory,
30681
+ children: subCategory
30682
+ }) : '-';
30683
+ }
30684
+ }, {
30685
+ dataIndex: 'country',
30686
+ title: t('Country'),
30687
+ ellipsis: true,
30688
+ show: true,
30689
+ render: (v, all) => {
30690
+ if (all.empty) {
30691
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
30692
+ className: "daf-default-cell"
30693
+ });
30694
+ }
30695
+ const country = findOptions(v, options?.countries);
30696
+ return country ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
30697
+ title: country,
30698
+ children: country
30699
+ }) : '-';
30700
+ }
30701
+ }, {
30702
+ title: t("Last Update"),
30703
+ dataIndex: "updatedAt",
30704
+ key: "updatedAt",
30705
+ width: 125,
30706
+ render: (date, all) => {
30707
+ if (all.empty) {
30708
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
30709
+ className: "daf-default-cell"
30710
+ });
30711
+ }
30712
+ const _date = date ? renderDateFormatted(date, "DD MMM YYYY", user?.language || 'en') : "-";
30713
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
30714
+ title: _date,
30715
+ children: _date
30716
+ });
30717
+ },
30718
+ ellipsis: true
30719
+ }, {
30720
+ title: t("Sources"),
30721
+ dataIndex: "sources",
30722
+ key: "sources",
30723
+ show: activeTab !== "own",
30724
+ render: (val, all) => {
30725
+ if (all.empty) {
30726
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
30727
+ className: "daf-default-cell"
30728
+ });
30729
+ }
30730
+ if (!val || val?.length === 0) {
30731
+ return "--";
30732
+ }
30733
+ return /*#__PURE__*/jsxRuntime.jsx(AvatarGroup, {
30734
+ items: val
30735
+ });
30736
+ }
30737
+ }, {
30738
+ id: 'actions',
30739
+ title: "",
30740
+ width: 60,
30741
+ render: (_, all) => {
30742
+ if (all.empty) {
30743
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
30744
+ className: "daf-default-cell"
30745
+ });
30746
+ }
30747
+ const link = `/app/view/${subject}/${all.datastakeId}`;
30748
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
30749
+ style: {
30750
+ display: "flex",
30751
+ justifyContent: "center"
30752
+ },
30753
+ children: /*#__PURE__*/jsxRuntime.jsx("a", {
30754
+ href: getRedirectLink(link),
30755
+ children: /*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
30756
+ name: "Link",
30757
+ size: 15,
30758
+ color: theme.baseGray70
30759
+ })
30760
+ })
30761
+ });
30762
+ }
30763
+ }].filter(column => column.show !== false);
30764
+
30765
+ const checkboxConfig$2 = {
30766
+ name: 'Name',
30767
+ datastakeId: 'ID'
30768
+ };
30769
+ const getFiltersConfig$2 = ({
30770
+ t
30771
+ }) => {
30772
+ return {
30773
+ country: {
30774
+ type: 'select',
30775
+ placeholder: t('Country'),
30776
+ style: {
30777
+ flex: 1
30778
+ },
30779
+ labelStyle: {
30780
+ flex: 1
30781
+ },
30782
+ getLabel: option => option.label,
30783
+ getValue: option => option.value
30784
+ }
30785
+ };
30786
+ };
30787
+ const filtersConfig$2 = {
30788
+ name: '',
30789
+ datastakeId: ''
30790
+ };
30791
+ const getFilterOptions$2 = (options, t) => {
30792
+ const {
30793
+ countries
30794
+ } = options || {};
30795
+ const _default = {
30796
+ country: countries
30797
+ };
30798
+ return _default;
30799
+ };
30800
+
30801
+ const StakeholdersCreate = ({
30802
+ namespace = 'stakeholders',
30803
+ view = 'scoping',
30804
+ edit = false,
30805
+ formData = {},
30806
+ loading = false,
30807
+ onSubmitted = () => {},
30808
+ onCancel = () => {},
30809
+ getData = () => {},
30810
+ saveData = () => {},
30811
+ form: formConfig = {},
30812
+ formValue = {},
30813
+ defaultData = {},
30814
+ user = {},
30815
+ APP,
30816
+ query,
30817
+ goTo = () => {},
30818
+ t = () => {},
30819
+ ajaxForms = {},
30820
+ changeAjaxForms = () => {},
30821
+ ajaxOptions = {},
30822
+ changeAjaxOptions = () => {},
30823
+ getAppHeader = () => {},
30824
+ getApiBaseUrl = () => {}
30825
+ }) => {
30826
+ let {
30827
+ form = {},
30828
+ data = defaultData || {}
30829
+ } = !edit ? formData[`${APP}-${view}`] || {} : {
30830
+ form: formConfig,
30831
+ data: formValue
30832
+ };
30833
+ React.useEffect(() => {
30834
+ if (Object.keys(form).length === 0 && !formData[`${APP}-${view}`]) {
30835
+ if (!edit) {
30836
+ getData({
30837
+ namespace,
30838
+ module: APP,
30839
+ view,
30840
+ scope: 'global'
30841
+ });
30842
+ } else {
30843
+ form = formConfig;
30844
+ data = formValue;
30845
+ }
30846
+ }
30847
+ }, [edit, user?.language]);
30848
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
30849
+ className: "daf-create-form",
30850
+ children: /*#__PURE__*/jsxRuntime.jsx(DynamicForm, {
30851
+ form: form,
30852
+ data: data,
30853
+ showSaveAndNext: false,
30854
+ module: APP,
30855
+ onCancel: onCancel,
30856
+ isCreate: true,
30857
+ t: t,
30858
+ excludedKeys: ["title"],
30859
+ user: user,
30860
+ ajaxForms: ajaxForms,
30861
+ ajaxOptions: ajaxOptions,
30862
+ getAppHeader: getAppHeader,
30863
+ getApiBaseUrl: getApiBaseUrl,
30864
+ changeAjaxOptions: changeAjaxOptions,
30865
+ app: APP,
30866
+ query: query,
30867
+ goTo: goTo,
30868
+ changeAjaxForms: changeAjaxForms,
30869
+ submit: (payload, setSelectedFormNext) => {
30870
+ const payloadData = {
30871
+ ...payload,
30872
+ module: APP,
30873
+ namespace
30874
+ };
30875
+ const newPayload = {
30876
+ ...defaultData,
30877
+ ...payloadData,
30878
+ form: 'stakeholder'
30879
+ };
30880
+ const callback = (type, m, data) => {
30881
+ if (setSelectedFormNext) {
30882
+ setSelectedFormNext();
30883
+ }
30884
+ if (type === MessageTypes.SUCCESS) {
30885
+ if (onSubmitted) onSubmitted(type, m, data);
30886
+ } else {
30887
+ antd.message.error(m);
30888
+ }
30889
+ };
30890
+ saveData(!data && !data.id ? newPayload : Object.assign(newPayload, {
30891
+ id: data.id
30892
+ }), callback);
30893
+ },
30894
+ isFormDisabled: () => {
30895
+ return !data || !data.typeOfEvent;
30896
+ }
30897
+ })
30898
+ });
30899
+ };
30900
+
30901
+ const StakeholdersTable = ({
30902
+ t = () => {},
30903
+ goTo = () => {},
30904
+ user = {},
30905
+ options = {},
30906
+ getRedirectLink = () => {},
30907
+ theme = {},
30908
+ loading = false,
30909
+ data = {},
30910
+ isMobile,
30911
+ APP,
30912
+ location,
30913
+ getData = () => {},
30914
+ getApiBaseUrl = () => {},
30915
+ getAppHeader = () => {},
30916
+ getFormData = () => {},
30917
+ saveFormData = () => {},
30918
+ formLoading = false,
30919
+ query = {},
30920
+ ajaxForms = {},
30921
+ changeAjaxForms = () => {},
30922
+ ajaxOptions = {},
30923
+ changeAjaxOptions = () => {},
30924
+ formData = {},
30925
+ formValue = {},
30926
+ form = {}
30927
+ }) => {
30928
+ const [selectOptions, setSelectOptions] = React.useState();
30929
+ const [activeTab, setActiveTab] = React.useState();
30930
+ const columns = React.useMemo(() => getColumns$2({
30931
+ t,
30932
+ goTo,
30933
+ user,
30934
+ options,
30935
+ activeTab,
30936
+ getRedirectLink,
30937
+ theme,
30938
+ subject: 'stakeholders'
30939
+ }), [t, goTo, user, options, activeTab, getRedirectLink, theme]);
30940
+ const breadCrumbs = [];
30941
+ const {
30942
+ paginationQuery,
30943
+ searchParams,
30944
+ otherParams
30945
+ } = useGetQueryParams({
30946
+ location
30947
+ });
30948
+ React.useEffect(() => {
30949
+ getData({
30950
+ pagination: paginationQuery,
30951
+ ...(Object.keys(otherParams).length > 0 && {
30952
+ filters: otherParams
30953
+ }),
30954
+ ...(Object.keys(searchParams).length > 0 && {
30955
+ search: searchParams
30956
+ }),
30957
+ tab: activeTab
30958
+ }, 'stakeholders');
30959
+ }, [paginationQuery, otherParams, searchParams, activeTab]);
30960
+ const selectFiltersConfig = React.useMemo(() => {
30961
+ return getFiltersConfig$2({
30962
+ t
30963
+ });
30964
+ }, [t]);
30965
+ React.useEffect(() => {
30966
+ setSelectOptions(prev => ({
30967
+ ...prev,
30968
+ ...getFilterOptions$2(options)
30969
+ }));
30970
+ }, [options, t]);
30971
+ const handleActiveTabChange = React.useCallback(value => {
30972
+ setActiveTab(value);
30973
+ }, []);
30974
+ return /*#__PURE__*/jsxRuntime.jsx(TablePageWithTabs, {
30975
+ t: t,
30976
+ title: t("Stakeholders"),
30977
+ breadCrumbs: breadCrumbs,
30978
+ location: location,
30979
+ loading: loading,
30980
+ goTo: goTo,
30981
+ defaultActiveTab: "all",
30982
+ columns: columns,
30983
+ data: data,
30984
+ checkboxConfig: checkboxConfig$2,
30985
+ APP: APP,
30986
+ getApiBaseUrl: getApiBaseUrl,
30987
+ selectOptions: selectOptions,
30988
+ selectFiltersConfig: selectFiltersConfig,
30989
+ getRedirectLink: getRedirectLink,
30990
+ filtersConfig: filtersConfig$2,
30991
+ isMobile: isMobile,
30992
+ view: "stakeholders",
30993
+ getActiveTab: handleActiveTabChange,
30994
+ onDownload: () => {
30995
+ console.log("download");
30996
+ },
30997
+ drawerTitle: t("Create Stakeholder"),
30998
+ children: ({
30999
+ onDrawerClose
31000
+ }) => /*#__PURE__*/jsxRuntime.jsx(StakeholdersCreate, {
31001
+ t: t,
31002
+ goTo: goTo,
31003
+ user: user,
31004
+ APP: APP,
31005
+ getApiBaseUrl: getApiBaseUrl,
31006
+ getAppHeader: getAppHeader,
31007
+ getData: getFormData,
31008
+ saveData: saveFormData,
31009
+ loading: formLoading,
31010
+ onSubmitted: (type, m, data) => {
31011
+ if (data.datastakeId) {
31012
+ displayMessage(type, t("affirmations::subject-created-successfully") || m);
31013
+ goTo(`/app/stakeholders`);
31014
+ }
31015
+ },
31016
+ onCancel: onDrawerClose,
31017
+ query: query,
31018
+ ajaxForms: ajaxForms,
31019
+ changeAjaxForms: changeAjaxForms,
31020
+ ajaxOptions: ajaxOptions,
31021
+ changeAjaxOptions: changeAjaxOptions,
31022
+ formData: formData,
31023
+ formValue: formValue,
31024
+ form: form
31025
+ })
31026
+ });
31027
+ };
31028
+
31029
+ const getLinkValue = (value, linkingObject) => {
31030
+ if (linkingObject && linkingObject?.[value]) {
31031
+ return linkingObject?.[value]?.name;
31032
+ }
31033
+ return null;
31034
+ };
31035
+ const getColumns$1 = ({
31036
+ t,
31037
+ goTo,
31038
+ user,
31039
+ options,
31040
+ activeTab,
31041
+ getRedirectLink,
31042
+ theme,
31043
+ subject,
31044
+ data
31045
+ }) => [{
31046
+ dataIndex: 'datastakeId',
31047
+ title: t('ID'),
31048
+ ellipsis: true,
31049
+ show: true,
31050
+ render: (v, all) => {
31051
+ if (all.empty) {
31052
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
31053
+ className: "daf-default-cell"
31054
+ });
31055
+ }
31056
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
31057
+ title: v,
31058
+ children: v
31059
+ });
31060
+ }
31061
+ }, {
31062
+ dataIndex: 'name',
31063
+ title: t('Name'),
31064
+ ellipsis: true,
31065
+ show: true,
31066
+ render: (v, all) => {
31067
+ if (all.empty) {
31068
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
31069
+ className: "daf-default-cell"
31070
+ });
31071
+ }
31072
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
31073
+ title: v,
31074
+ children: v
31075
+ });
31076
+ }
31077
+ }, {
31078
+ dataIndex: 'type',
31079
+ title: t('Type'),
31080
+ ellipsis: true,
31081
+ show: true,
31082
+ render: (v, all) => {
31083
+ if (all.empty) {
31084
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
31085
+ className: "daf-default-cell"
31086
+ });
31087
+ }
31088
+ const type = findOptions(v, data?.options?.locationCategories);
31089
+ return type ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
31090
+ title: type,
31091
+ children: type
31092
+ }) : '-';
31093
+ }
31094
+ }, {
31095
+ dataIndex: 'keyStakeholder',
31096
+ title: t('Key Stakeholder'),
31097
+ ellipsis: true,
31098
+ show: true,
31099
+ render: (v, all) => {
31100
+ if (all.empty) {
31101
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
31102
+ className: "daf-default-cell"
31103
+ });
31104
+ }
31105
+ const country = findOptions(v, options?.countries);
31106
+ return country ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
31107
+ title: country,
31108
+ children: country
31109
+ }) : '-';
31110
+ }
31111
+ }, {
31112
+ dataIndex: 'scope',
31113
+ title: t('Scope'),
31114
+ ellipsis: true,
31115
+ show: true,
31116
+ render: (v, all) => {
31117
+ if (all.empty) {
31118
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
31119
+ className: "daf-default-cell"
31120
+ });
31121
+ }
31122
+ const scope = getLinkValue(v, all?.linking?.SCL);
31123
+ return scope ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
31124
+ title: scope,
31125
+ children: scope
31126
+ }) : '-';
31127
+ }
31128
+ }, {
31129
+ title: t("Start Date"),
31130
+ dataIndex: "startDate",
31131
+ key: "startDate",
31132
+ width: 125,
31133
+ render: (date, all) => {
31134
+ if (all.empty) {
31135
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
31136
+ className: "daf-default-cell"
31137
+ });
31138
+ }
31139
+ const _date = date ? renderDateFormatted(date, "DD MMM YYYY", user?.language || 'en') : "-";
31140
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
31141
+ title: _date,
31142
+ children: _date
31143
+ });
31144
+ },
31145
+ ellipsis: true
31146
+ }, {
31147
+ title: t("End Date"),
31148
+ dataIndex: "endDate",
31149
+ key: "endDate",
31150
+ width: 125,
31151
+ render: (date, all) => {
31152
+ if (all.empty) {
31153
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
31154
+ className: "daf-default-cell"
31155
+ });
31156
+ }
31157
+ const _date = date ? renderDateFormatted(date, "DD MMM YYYY", user?.language || 'en') : "-";
31158
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
31159
+ title: _date,
31160
+ children: _date
31161
+ });
31162
+ },
31163
+ ellipsis: true
31164
+ }, {
31165
+ title: t("Sources"),
31166
+ dataIndex: "sources",
31167
+ key: "sources",
31168
+ show: activeTab !== "own",
31169
+ render: (val, all) => {
31170
+ if (all.empty) {
31171
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
31172
+ className: "daf-default-cell"
31173
+ });
31174
+ }
31175
+ console.log({
31176
+ val,
31177
+ all
31178
+ });
31179
+ return /*#__PURE__*/jsxRuntime.jsx(AvatarGroup, {
31180
+ items: val
31181
+ });
31182
+ }
31183
+ }, {
31184
+ id: 'actions',
31185
+ title: "",
31186
+ width: 60,
31187
+ render: (_, all) => {
31188
+ if (all.empty) {
31189
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
31190
+ className: "daf-default-cell"
31191
+ });
31192
+ }
31193
+ const link = `/app/view/${subject}/${all.datastakeId}`;
31194
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
31195
+ style: {
31196
+ display: "flex",
31197
+ justifyContent: "center"
31198
+ },
31199
+ children: /*#__PURE__*/jsxRuntime.jsx("a", {
31200
+ href: getRedirectLink(link),
31201
+ children: /*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
31202
+ name: "Link",
31203
+ size: 15,
31204
+ color: theme.baseGray70
31205
+ })
31206
+ })
31207
+ });
31208
+ }
31209
+ }].filter(column => column.show !== false);
31210
+
31211
+ const checkboxConfig$1 = {
31212
+ name: 'Name',
31213
+ datastakeId: 'ID'
31214
+ };
31215
+ const getFiltersConfig$1 = ({
31216
+ t
31217
+ }) => {
31218
+ return {
31219
+ country: {
31220
+ type: 'select',
31221
+ placeholder: t('Country'),
31222
+ style: {
31223
+ flex: 1
31224
+ },
31225
+ labelStyle: {
31226
+ flex: 1
31227
+ },
31228
+ getLabel: option => option.label,
31229
+ getValue: option => option.value
31230
+ }
31231
+ };
31232
+ };
31233
+ const filtersConfig$1 = {
31234
+ name: '',
31235
+ datastakeId: ''
31236
+ };
31237
+ const getFilterOptions$1 = (options, t) => {
31238
+ const {
31239
+ countries
31240
+ } = options || {};
31241
+ const _default = {
31242
+ country: countries
31243
+ };
31244
+ return _default;
31245
+ };
31246
+
31247
+ const EventsCreate = ({
31248
+ namespace = 'events',
31249
+ view = 'scoping',
31250
+ edit = false,
31251
+ formData = {},
31252
+ loading = false,
31253
+ onSubmitted = () => {},
31254
+ onCancel = () => {},
31255
+ getData = () => {},
31256
+ saveData = () => {},
31257
+ form: formConfig = {},
31258
+ formValue = {},
31259
+ defaultData = {},
31260
+ user = {},
31261
+ APP,
31262
+ query,
31263
+ goTo = () => {},
31264
+ t = () => {},
31265
+ ajaxForms = {},
31266
+ changeAjaxForms = () => {},
31267
+ ajaxOptions = {},
31268
+ changeAjaxOptions = () => {},
31269
+ getAppHeader = () => {},
31270
+ getApiBaseUrl = () => {}
31271
+ }) => {
31272
+ let {
31273
+ form = {},
31274
+ data = defaultData || {}
31275
+ } = !edit ? formData[`${APP}-${view}`] || {} : {
31276
+ form: formConfig,
31277
+ data: formValue
31278
+ };
31279
+ React.useEffect(() => {
31280
+ if (Object.keys(form).length === 0 && !formData[`${APP}-${view}`]) {
31281
+ if (!edit) {
31282
+ getData({
31283
+ namespace,
31284
+ module: APP,
31285
+ view,
31286
+ scope: 'global'
31287
+ });
31288
+ } else {
31289
+ form = formConfig;
31290
+ data = formValue;
31291
+ }
31292
+ }
31293
+ }, [edit, user?.language]);
31294
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
31295
+ className: "daf-create-form",
31296
+ children: /*#__PURE__*/jsxRuntime.jsx(DynamicForm, {
31297
+ form: form,
31298
+ data: data,
31299
+ showSaveAndNext: false,
31300
+ module: APP,
31301
+ onCancel: onCancel,
31302
+ isCreate: true,
31303
+ t: t,
31304
+ excludedKeys: ["title"],
31305
+ user: user,
31306
+ ajaxForms: ajaxForms,
31307
+ ajaxOptions: ajaxOptions,
31308
+ getAppHeader: getAppHeader,
31309
+ getApiBaseUrl: getApiBaseUrl,
31310
+ changeAjaxOptions: changeAjaxOptions,
31311
+ app: APP,
31312
+ query: query,
31313
+ goTo: goTo,
31314
+ changeAjaxForms: changeAjaxForms,
31315
+ submit: (payload, setSelectedFormNext) => {
31316
+ const payloadData = {
31317
+ ...payload,
31318
+ module: APP,
31319
+ namespace
31320
+ };
31321
+ const newPayload = {
31322
+ ...defaultData,
31323
+ ...payloadData,
31324
+ form: 'location'
31325
+ };
31326
+ const callback = (type, m, data) => {
31327
+ if (setSelectedFormNext) {
31328
+ setSelectedFormNext();
31329
+ }
31330
+ if (type === MessageTypes.SUCCESS) {
31331
+ if (onSubmitted) onSubmitted(type, m, data);
31332
+ } else {
31333
+ antd.message.error(m);
31334
+ }
31335
+ };
31336
+ saveData(!data && !data.id ? newPayload : Object.assign(newPayload, {
31337
+ id: data.id
31338
+ }), callback);
31339
+ },
31340
+ isFormDisabled: () => {
31341
+ return !data || !data.typeOfEvent;
31342
+ }
31343
+ })
31344
+ });
31345
+ };
31346
+
31347
+ const EventsTable = ({
31348
+ t = () => {},
31349
+ goTo = () => {},
31350
+ user = {},
31351
+ options = {},
31352
+ getRedirectLink = () => {},
31353
+ theme = {},
31354
+ loading = false,
31355
+ data = {},
31356
+ isMobile,
31357
+ APP,
31358
+ location,
31359
+ getData = () => {},
31360
+ getApiBaseUrl = () => {},
31361
+ getAppHeader = () => {},
31362
+ getFormData = () => {},
31363
+ saveFormData = () => {},
31364
+ formLoading = false,
31365
+ query = {},
31366
+ ajaxForms = {},
31367
+ changeAjaxForms = () => {},
31368
+ ajaxOptions = {},
31369
+ changeAjaxOptions = () => {},
31370
+ formData = {},
31371
+ formValue = {},
31372
+ form = {},
31373
+ extendingFilters = {}
31374
+ }) => {
31375
+ const [selectOptions, setSelectOptions] = React.useState();
31376
+ const [activeTab, setActiveTab] = React.useState();
31377
+ const columns = React.useMemo(() => getColumns$1({
31378
+ t,
31379
+ goTo,
31380
+ user,
31381
+ options,
31382
+ activeTab,
31383
+ getRedirectLink,
31384
+ theme,
31385
+ subject: 'events',
31386
+ data
31387
+ }), [t, goTo, user, options, activeTab, getRedirectLink, theme, data]);
31388
+ const breadCrumbs = [];
31389
+ const {
31390
+ paginationQuery,
31391
+ searchParams,
31392
+ otherParams,
31393
+ sortBy,
31394
+ sortDir
31395
+ } = useGetQueryParams({
31396
+ location
31397
+ });
31398
+ const filters = React.useMemo(() => {
31399
+ return {
31400
+ ...otherParams,
31401
+ ...extendingFilters
31402
+ };
31403
+ }, [otherParams, extendingFilters]);
31404
+ React.useEffect(() => {
31405
+ console.log("fetching data");
31406
+ getData({
31407
+ pagination: paginationQuery,
31408
+ ...(Object.keys(filters).length > 0 && {
31409
+ filters: filters
31410
+ }),
31411
+ ...(Object.keys(searchParams).length > 0 && {
31412
+ search: searchParams
31413
+ }),
31414
+ tab: activeTab,
31415
+ sortBy: {
31416
+ [sortBy || "updatedAt"]: sortDir ? sortDir === "ascend" ? 1 : -1 : -1
31417
+ }
31418
+ }, 'events');
31419
+ console.log("data fetched");
31420
+ }, [location.search, activeTab, JSON.stringify(extendingFilters)]);
31421
+ console.log({
31422
+ data
31423
+ });
31424
+ const selectFiltersConfig = React.useMemo(() => {
31425
+ return getFiltersConfig$1({
31426
+ t
31427
+ });
31428
+ }, [t]);
31429
+ React.useEffect(() => {
31430
+ setSelectOptions(prev => ({
31431
+ ...prev,
31432
+ ...getFilterOptions$1(options)
31433
+ }));
31434
+ }, [options, t]);
31435
+ const handleActiveTabChange = React.useCallback(value => {
31436
+ setActiveTab(value);
31437
+ }, []);
31438
+ return /*#__PURE__*/jsxRuntime.jsx(TablePageWithTabs, {
31439
+ t: t,
31440
+ title: t("events"),
31441
+ breadCrumbs: breadCrumbs,
31442
+ location: location,
31443
+ loading: loading,
31444
+ goTo: goTo,
31445
+ defaultActiveTab: "all",
31446
+ columns: columns,
31447
+ data: data,
31448
+ checkboxConfig: checkboxConfig$1,
31449
+ APP: APP,
31450
+ getApiBaseUrl: getApiBaseUrl,
31451
+ selectOptions: selectOptions,
31452
+ selectFiltersConfig: selectFiltersConfig,
31453
+ getRedirectLink: getRedirectLink,
31454
+ filtersConfig: filtersConfig$1,
31455
+ isMobile: isMobile,
31456
+ view: "events",
31457
+ getActiveTab: handleActiveTabChange,
31458
+ onDownload: () => {
31459
+ console.log("download");
31460
+ },
31461
+ drawerTitle: t("Create Events"),
31462
+ children: ({
31463
+ onDrawerClose
31464
+ }) => /*#__PURE__*/jsxRuntime.jsx(EventsCreate, {
31465
+ t: t,
31466
+ goTo: goTo,
31467
+ user: user,
31468
+ APP: APP,
31469
+ getApiBaseUrl: getApiBaseUrl,
31470
+ getAppHeader: getAppHeader,
31471
+ getData: getFormData,
31472
+ saveData: saveFormData,
31473
+ loading: formLoading,
31474
+ onSubmitted: (type, m, data) => {
31475
+ if (data.datastakeId) {
31476
+ displayMessage(type, t("affirmations::subject-created-successfully") || m);
31477
+ // goTo(`/app/edit/stakeholders/${data.datastakeId}`);
31478
+ goTo(`/app/edit/events/${data.datastakeId}`);
31479
+ }
31480
+ },
31481
+ onCancel: onDrawerClose,
31482
+ query: query,
31483
+ ajaxForms: ajaxForms,
31484
+ changeAjaxForms: changeAjaxForms,
31485
+ ajaxOptions: ajaxOptions,
31486
+ changeAjaxOptions: changeAjaxOptions,
31487
+ formData: formData,
31488
+ formValue: formValue,
31489
+ form: form
31490
+ })
31491
+ });
31492
+ };
31493
+
31494
+ const getColumns = ({
31495
+ t,
31496
+ goTo,
31497
+ user,
31498
+ options,
31499
+ activeTab,
31500
+ getRedirectLink,
31501
+ theme,
31502
+ subject,
31503
+ data
31504
+ }) => [{
31505
+ dataIndex: 'datastakeId',
31506
+ title: t('ID'),
31507
+ ellipsis: true,
31508
+ show: true,
31509
+ render: (v, all) => {
31510
+ if (all.empty) {
31511
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
31512
+ className: "daf-default-cell"
31513
+ });
31514
+ }
31515
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
31516
+ title: v,
31517
+ children: v
31518
+ });
31519
+ }
31520
+ }, {
31521
+ dataIndex: 'title',
31522
+ title: t('Title'),
31523
+ ellipsis: true,
31524
+ show: true,
31525
+ render: (v, all) => {
31526
+ if (all.empty) {
31527
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
31528
+ className: "daf-default-cell"
31529
+ });
31530
+ }
31531
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
31532
+ title: v,
31533
+ children: v
31534
+ });
31535
+ }
31536
+ }, {
31537
+ dataIndex: 'type',
31538
+ title: t('Type'),
31539
+ ellipsis: true,
31540
+ show: true,
31541
+ render: (v, all) => {
31542
+ if (all.empty) {
31543
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
31544
+ className: "daf-default-cell"
31545
+ });
31546
+ }
31547
+ const type = findOptions(v, data?.options?.locationCategories);
31548
+ return type ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
31549
+ title: type,
31550
+ children: type
31551
+ }) : '-';
31552
+ }
31553
+ }, {
31554
+ title: t("Last Update"),
31555
+ dataIndex: "updatedAt",
31556
+ key: "updatedAt",
31557
+ width: 125,
31558
+ render: (date, all) => {
31559
+ if (all.empty) {
31560
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
31561
+ className: "daf-default-cell"
31562
+ });
31563
+ }
31564
+ const _date = date ? renderDateFormatted(date, "DD MMM YYYY", user?.language || 'en') : "-";
31565
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
31566
+ title: _date,
31567
+ children: _date
31568
+ });
31569
+ },
31570
+ ellipsis: true
31571
+ }, {
31572
+ title: t("Sources"),
31573
+ dataIndex: "sources",
31574
+ key: "sources",
31575
+ show: activeTab !== "own",
31576
+ render: (val, all) => {
31577
+ if (all.empty) {
31578
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
31579
+ className: "daf-default-cell"
31580
+ });
31581
+ }
31582
+ console.log({
31583
+ val,
31584
+ all
31585
+ });
31586
+ return /*#__PURE__*/jsxRuntime.jsx(AvatarGroup, {
31587
+ items: val
31588
+ });
31589
+ }
31590
+ }, {
31591
+ id: 'actions',
31592
+ title: "",
31593
+ width: 60,
31594
+ render: (_, all) => {
31595
+ if (all.empty) {
31596
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
31597
+ className: "daf-default-cell"
31598
+ });
31599
+ }
31600
+ const link = `/app/view/${subject}/${all.datastakeId}`;
31601
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
31602
+ style: {
31603
+ display: "flex",
31604
+ justifyContent: "center"
31605
+ },
31606
+ children: /*#__PURE__*/jsxRuntime.jsx("a", {
31607
+ href: getRedirectLink(link),
31608
+ children: /*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
31609
+ name: "Link",
31610
+ size: 15,
31611
+ color: theme.baseGray70
31612
+ })
31613
+ })
31614
+ });
31615
+ }
31616
+ }].filter(column => column.show !== false);
31617
+
31618
+ const checkboxConfig = {
31619
+ name: 'Name',
31620
+ datastakeId: 'ID'
31621
+ };
31622
+ const getFiltersConfig = ({
31623
+ t
31624
+ }) => {
31625
+ return {
31626
+ country: {
31627
+ type: 'select',
31628
+ placeholder: t('Country'),
31629
+ style: {
31630
+ flex: 1
31631
+ },
31632
+ labelStyle: {
31633
+ flex: 1
31634
+ },
31635
+ getLabel: option => option.label,
31636
+ getValue: option => option.value
31637
+ }
31638
+ };
31639
+ };
31640
+ const filtersConfig = {
31641
+ name: '',
31642
+ datastakeId: ''
31643
+ };
31644
+ const getFilterOptions = (options, t) => {
31645
+ const {
31646
+ countries
31647
+ } = options || {};
31648
+ const _default = {
31649
+ country: countries
31650
+ };
31651
+ return _default;
31652
+ };
31653
+
31654
+ const DocumentsCreate = ({
31655
+ namespace = 'documents',
31656
+ view = 'scoping',
31657
+ edit = false,
31658
+ formData = {},
31659
+ loading = false,
31660
+ onSubmitted = () => {},
31661
+ onCancel = () => {},
31662
+ getData = () => {},
31663
+ saveData = () => {},
31664
+ form: formConfig = {},
31665
+ formValue = {},
31666
+ defaultData = {},
31667
+ user = {},
31668
+ APP,
31669
+ query,
31670
+ goTo = () => {},
31671
+ t = () => {},
31672
+ ajaxForms = {},
31673
+ changeAjaxForms = () => {},
31674
+ ajaxOptions = {},
31675
+ changeAjaxOptions = () => {},
31676
+ getAppHeader = () => {},
31677
+ getApiBaseUrl = () => {}
31678
+ }) => {
31679
+ let {
31680
+ form = {},
31681
+ data = defaultData || {}
31682
+ } = !edit ? formData[`${APP}-${view}`] || {} : {
31683
+ form: formConfig,
31684
+ data: formValue
31685
+ };
31686
+ React.useEffect(() => {
31687
+ if (Object.keys(form).length === 0 && !formData[`${APP}-${view}`]) {
31688
+ if (!edit) {
31689
+ getData({
31690
+ namespace,
31691
+ module: APP,
31692
+ view,
31693
+ scope: 'global'
31694
+ });
31695
+ } else {
31696
+ form = formConfig;
31697
+ data = formValue;
31698
+ }
31699
+ }
31700
+ }, [edit, user?.language]);
31701
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
31702
+ className: "daf-create-form",
31703
+ children: /*#__PURE__*/jsxRuntime.jsx(DynamicForm, {
31704
+ form: form,
31705
+ data: data,
31706
+ showSaveAndNext: false,
31707
+ module: APP,
31708
+ onCancel: onCancel,
31709
+ isCreate: true,
31710
+ t: t,
31711
+ excludedKeys: ["title"],
31712
+ user: user,
31713
+ ajaxForms: ajaxForms,
31714
+ ajaxOptions: ajaxOptions,
31715
+ getAppHeader: getAppHeader,
31716
+ getApiBaseUrl: getApiBaseUrl,
31717
+ changeAjaxOptions: changeAjaxOptions,
31718
+ app: APP,
31719
+ query: query,
31720
+ goTo: goTo,
31721
+ changeAjaxForms: changeAjaxForms,
31722
+ submit: (payload, setSelectedFormNext) => {
31723
+ const payloadData = {
31724
+ ...payload,
31725
+ module: APP,
31726
+ namespace
31727
+ };
31728
+ const newPayload = {
31729
+ ...defaultData,
31730
+ ...payloadData,
31731
+ form: 'document'
31732
+ };
31733
+ const callback = (type, m, data) => {
31734
+ if (setSelectedFormNext) {
31735
+ setSelectedFormNext();
31736
+ }
31737
+ if (type === MessageTypes.SUCCESS) {
31738
+ if (onSubmitted) onSubmitted(type, m, data);
31739
+ } else {
31740
+ antd.message.error(m);
31741
+ }
31742
+ };
31743
+ saveData(!data && !data.id ? newPayload : Object.assign(newPayload, {
31744
+ id: data.id
31745
+ }), callback);
31746
+ },
31747
+ isFormDisabled: () => {
31748
+ return !data || !data.typeOfEvent;
31749
+ }
31750
+ })
31751
+ });
31752
+ };
31753
+
31754
+ const DocumentsTable = ({
31755
+ t = () => {},
31756
+ goTo = () => {},
31757
+ user = {},
31758
+ options = {},
31759
+ getRedirectLink = () => {},
31760
+ theme = {},
31761
+ loading = false,
31762
+ data = {},
31763
+ isMobile,
31764
+ APP,
31765
+ location,
31766
+ getData = () => {},
31767
+ getApiBaseUrl = () => {},
31768
+ getAppHeader = () => {},
31769
+ getFormData = () => {},
31770
+ saveFormData = () => {},
31771
+ formLoading = false,
31772
+ query = {},
31773
+ ajaxForms = {},
31774
+ changeAjaxForms = () => {},
31775
+ ajaxOptions = {},
31776
+ changeAjaxOptions = () => {},
31777
+ formData = {},
31778
+ formValue = {},
31779
+ form = {},
31780
+ extendingFilters = {}
31781
+ }) => {
31782
+ const [selectOptions, setSelectOptions] = React.useState();
31783
+ const [activeTab, setActiveTab] = React.useState();
31784
+ const columns = React.useMemo(() => getColumns({
31785
+ t,
31786
+ goTo,
31787
+ user,
31788
+ options,
31789
+ activeTab,
31790
+ getRedirectLink,
31791
+ theme,
31792
+ subject: 'documents',
31793
+ data
31794
+ }), [t, goTo, user, options, activeTab, getRedirectLink, theme, data]);
31795
+ const breadCrumbs = [];
31796
+ const {
31797
+ paginationQuery,
31798
+ searchParams,
31799
+ otherParams,
31800
+ sortBy,
31801
+ sortDir
31802
+ } = useGetQueryParams({
31803
+ location
31804
+ });
31805
+ const filters = React.useMemo(() => {
31806
+ return {
31807
+ ...otherParams,
31808
+ ...extendingFilters
31809
+ };
31810
+ }, [otherParams, extendingFilters]);
31811
+ React.useEffect(() => {
31812
+ console.log("fetching data");
31813
+ getData({
31814
+ pagination: paginationQuery,
31815
+ ...(Object.keys(filters).length > 0 && {
31816
+ filters: filters
31817
+ }),
31818
+ ...(Object.keys(searchParams).length > 0 && {
31819
+ search: searchParams
31820
+ }),
31821
+ tab: activeTab,
31822
+ sortBy: {
31823
+ [sortBy || "updatedAt"]: sortDir ? sortDir === "ascend" ? 1 : -1 : -1
31824
+ }
31825
+ }, 'documents');
31826
+ console.log("data fetched");
31827
+ }, [location.search, activeTab, JSON.stringify(extendingFilters)]);
31828
+ console.log({
31829
+ data
31830
+ });
31831
+ const selectFiltersConfig = React.useMemo(() => {
31832
+ return getFiltersConfig({
31833
+ t
31834
+ });
31835
+ }, [t]);
31836
+ React.useEffect(() => {
31837
+ setSelectOptions(prev => ({
31838
+ ...prev,
31839
+ ...getFilterOptions(options)
31840
+ }));
31841
+ }, [options, t]);
31842
+ const handleActiveTabChange = React.useCallback(value => {
31843
+ setActiveTab(value);
31844
+ }, []);
31845
+ return /*#__PURE__*/jsxRuntime.jsx(TablePageWithTabs, {
31846
+ t: t,
31847
+ title: t("documents"),
31848
+ breadCrumbs: breadCrumbs,
31849
+ location: location,
31850
+ loading: loading,
31851
+ goTo: goTo,
31852
+ defaultActiveTab: "all",
31853
+ columns: columns,
31854
+ data: data,
31855
+ checkboxConfig: checkboxConfig,
31856
+ APP: APP,
31857
+ getApiBaseUrl: getApiBaseUrl,
31858
+ selectOptions: selectOptions,
31859
+ selectFiltersConfig: selectFiltersConfig,
31860
+ getRedirectLink: getRedirectLink,
31861
+ filtersConfig: filtersConfig,
31862
+ isMobile: isMobile,
31863
+ view: "documents",
31864
+ getActiveTab: handleActiveTabChange,
31865
+ onDownload: () => {
31866
+ console.log("download");
31867
+ },
31868
+ drawerTitle: t("Create Document"),
31869
+ children: ({
31870
+ onDrawerClose
31871
+ }) => /*#__PURE__*/jsxRuntime.jsx(DocumentsCreate, {
30535
31872
  t: t,
30536
31873
  goTo: goTo,
30537
31874
  user: user,
@@ -30545,7 +31882,7 @@ const LocationsTable = ({
30545
31882
  if (data.datastakeId) {
30546
31883
  displayMessage(type, t("affirmations::subject-created-successfully") || m);
30547
31884
  // goTo(`/app/edit/stakeholders/${data.datastakeId}`);
30548
- goTo('/app/locations');
31885
+ goTo(`/app/edit/documents/${data.datastakeId}`);
30549
31886
  }
30550
31887
  },
30551
31888
  onCancel: onDrawerClose,
@@ -30561,7 +31898,10 @@ const LocationsTable = ({
30561
31898
  });
30562
31899
  };
30563
31900
 
31901
+ exports.DocumentsTable = DocumentsTable;
31902
+ exports.EventsTable = EventsTable;
30564
31903
  exports.LocationsTable = LocationsTable;
31904
+ exports.OperatorsTable = OperatorsTable;
30565
31905
  exports.StakeholdersTable = StakeholdersTable;
30566
31906
  exports.SupplyChainDashboard = SupplyChain;
30567
31907
  exports.TablePageWithTabs = TablePageWithTabs;