datastake-daf 0.6.742 → 0.6.744

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 (48) hide show
  1. package/build/favicon.ico +0 -0
  2. package/build/logo192.png +0 -0
  3. package/build/logo512.png +0 -0
  4. package/build/manifest.json +25 -0
  5. package/build/robots.txt +3 -0
  6. package/dist/hooks/index.js +4658 -19
  7. package/dist/pages/index.js +3278 -280
  8. package/dist/services/index.js +2 -2
  9. package/package.json +1 -1
  10. package/src/@daf/pages/dashboards/AllInformation/Documents/columns.js +42 -16
  11. package/src/@daf/pages/dashboards/AllInformation/Documents/create.jsx +5 -4
  12. package/src/@daf/pages/dashboards/AllInformation/Documents/index.jsx +18 -26
  13. package/src/@daf/pages/dashboards/AllInformation/Events/columns.js +4 -3
  14. package/src/@daf/pages/dashboards/AllInformation/Events/config.js +158 -6
  15. package/src/@daf/pages/dashboards/AllInformation/Events/create.jsx +2 -2
  16. package/src/@daf/pages/dashboards/AllInformation/Events/index.jsx +11 -1
  17. package/src/@daf/pages/dashboards/AllInformation/Locations/columns.js +4 -3
  18. package/src/@daf/pages/dashboards/AllInformation/Locations/create.jsx +1 -1
  19. package/src/@daf/pages/dashboards/AllInformation/Locations/index.jsx +11 -1
  20. package/src/@daf/pages/dashboards/AllInformation/Stakeholders/columns.js +5 -2
  21. package/src/@daf/pages/dashboards/AllInformation/Stakeholders/create.jsx +1 -1
  22. package/src/@daf/pages/dashboards/AllInformation/Stakeholders/index.jsx +13 -3
  23. package/src/@daf/pages/dashboards/DueDilligence/Activities/columns.js +221 -0
  24. package/src/@daf/pages/dashboards/DueDilligence/Activities/config.js +166 -0
  25. package/src/@daf/pages/dashboards/DueDilligence/Activities/create.jsx +104 -0
  26. package/src/@daf/pages/dashboards/DueDilligence/Activities/index.jsx +157 -0
  27. package/src/@daf/pages/dashboards/DueDilligence/Incidents/columns.js +221 -0
  28. package/src/@daf/pages/dashboards/DueDilligence/Incidents/config.js +166 -0
  29. package/src/@daf/pages/dashboards/DueDilligence/Incidents/create.jsx +104 -0
  30. package/src/@daf/pages/dashboards/DueDilligence/Incidents/index.jsx +157 -0
  31. package/src/@daf/pages/dashboards/DueDilligence/Incidents2/columns.js +176 -0
  32. package/src/@daf/pages/dashboards/DueDilligence/Incidents2/config.js +171 -0
  33. package/src/@daf/pages/dashboards/DueDilligence/Incidents2/create.jsx +104 -0
  34. package/src/@daf/pages/dashboards/DueDilligence/Incidents2/index.jsx +156 -0
  35. package/src/@daf/pages/dashboards/Operations/Operators/columns.js +4 -3
  36. package/src/@daf/pages/dashboards/Operations/Operators/config.js +0 -1
  37. package/src/@daf/pages/dashboards/Operations/Operators/index.jsx +3 -1
  38. package/src/@daf/pages/dashboards/Operations/ProductionSites/columns.js +150 -0
  39. package/src/@daf/pages/dashboards/Operations/ProductionSites/config.js +165 -0
  40. package/src/@daf/pages/dashboards/Operations/ProductionSites/create.jsx +104 -0
  41. package/src/@daf/pages/dashboards/Operations/ProductionSites/index.jsx +155 -0
  42. package/src/@daf/pages/dashboards/Operations/Workers/columns.js +176 -0
  43. package/src/@daf/pages/dashboards/Operations/Workers/config.js +166 -0
  44. package/src/@daf/pages/dashboards/Operations/Workers/create.jsx +104 -0
  45. package/src/@daf/pages/dashboards/Operations/Workers/index.jsx +157 -0
  46. package/src/@daf/services/LinkedSubjects.js +2 -2
  47. package/src/helpers/sourceAvatarConfig.js +37 -0
  48. package/src/pages.js +6 -0
@@ -13547,7 +13547,7 @@ const getTabs = t => {
13547
13547
  label: t("Events")
13548
13548
  }];
13549
13549
  };
13550
- const getFiltersConfig$5 = (t, filters, locationCategories) => {
13550
+ const getFiltersConfig$9 = (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$5(t, filters, locationCategories), [activeTab, filters, t, locationCategories]);
13759
+ const filtersConfig = React.useMemo(() => getFiltersConfig$9(t, filters, locationCategories), [activeTab, filters, t, locationCategories]);
13760
13760
  const onFilterChange = filters => {
13761
13761
  setFilters(p => ({
13762
13762
  ...p,
@@ -15992,13 +15992,46 @@ function AvatarGroup({
15992
15992
  });
15993
15993
  }
15994
15994
 
15995
- const getLinkValue$2 = (value, linkingObject) => {
15995
+ function sourceAvatarConfig(items, user, applications) {
15996
+ const userInterface = user?.company?.apps?.[0]?.interface;
15997
+ const icon = applications[0]?.interfaces?.find(i => i.value === userInterface)?.iconName;
15998
+ const sources = [];
15999
+ items?.length > 0 && items?.forEach(author => {
16000
+ if (author?.id) {
16001
+ if (author.id === user?.company?.id) {
16002
+ // it's own data
16003
+ sources.push({
16004
+ name: author.name,
16005
+ icon: 'OwnData',
16006
+ isOwn: true,
16007
+ sourceId: author.id
16008
+ });
16009
+ } else {
16010
+ sources.push({
16011
+ name: author.name,
16012
+ icon: icon,
16013
+ isOwn: false,
16014
+ sourceId: author.id
16015
+ });
16016
+ }
16017
+ }
16018
+ });
16019
+
16020
+ // sort to have own data first
16021
+ return sources.sort((a, b) => {
16022
+ if (a.isOwn && !b.isOwn) return -1;
16023
+ if (!a.isOwn && b.isOwn) return 1;
16024
+ return 0;
16025
+ });
16026
+ }
16027
+
16028
+ const getLinkValue$5 = (value, linkingObject) => {
15996
16029
  if (linkingObject && linkingObject?.[value]) {
15997
16030
  return linkingObject?.[value]?.name;
15998
16031
  }
15999
16032
  return null;
16000
16033
  };
16001
- const getColumns$4 = ({
16034
+ const getColumns$8 = ({
16002
16035
  t,
16003
16036
  goTo,
16004
16037
  user,
@@ -16007,7 +16040,8 @@ const getColumns$4 = ({
16007
16040
  getRedirectLink,
16008
16041
  theme,
16009
16042
  subject,
16010
- data
16043
+ data,
16044
+ applications
16011
16045
  }) => [{
16012
16046
  dataIndex: 'datastakeId',
16013
16047
  title: t('ID'),
@@ -16085,7 +16119,7 @@ const getColumns$4 = ({
16085
16119
  className: "daf-default-cell"
16086
16120
  });
16087
16121
  }
16088
- const region = getLinkValue$2(all?.location?.administrativeLevel1, all?.location?.linking?.SCL);
16122
+ const region = getLinkValue$5(all?.location?.administrativeLevel1, all?.location?.linking?.SCL);
16089
16123
  return region ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
16090
16124
  title: region,
16091
16125
  children: region
@@ -16102,7 +16136,7 @@ const getColumns$4 = ({
16102
16136
  className: "daf-default-cell"
16103
16137
  });
16104
16138
  }
16105
- const district = getLinkValue$2(all?.location?.administrativeLevel2, all?.location?.linking?.SCL);
16139
+ const district = getLinkValue$5(all?.location?.administrativeLevel2, all?.location?.linking?.SCL);
16106
16140
  return district ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
16107
16141
  title: district,
16108
16142
  children: district
@@ -16119,12 +16153,9 @@ const getColumns$4 = ({
16119
16153
  className: "daf-default-cell"
16120
16154
  });
16121
16155
  }
16122
- console.log({
16123
- val,
16124
- all
16125
- });
16156
+ const sources = sourceAvatarConfig(val, user, applications);
16126
16157
  return /*#__PURE__*/jsxRuntime.jsx(AvatarGroup, {
16127
- items: val
16158
+ items: sources
16128
16159
  });
16129
16160
  }
16130
16161
  }, {
@@ -16173,11 +16204,11 @@ const getColumns$4 = ({
16173
16204
  }
16174
16205
  }].filter(column => column.show !== false);
16175
16206
 
16176
- const checkboxConfig$4 = {
16207
+ const checkboxConfig$8 = {
16177
16208
  name: 'Name',
16178
16209
  datastakeId: 'ID'
16179
16210
  };
16180
- const getFiltersConfig$4 = ({
16211
+ const getFiltersConfig$8 = ({
16181
16212
  t
16182
16213
  }) => {
16183
16214
  return {
@@ -16345,11 +16376,11 @@ const getFiltersConfig$4 = ({
16345
16376
  }
16346
16377
  };
16347
16378
  };
16348
- const filtersConfig$4 = {
16379
+ const filtersConfig$8 = {
16349
16380
  name: '',
16350
16381
  datastakeId: ''
16351
16382
  };
16352
- const getFilterOptions$4 = (options, t) => {
16383
+ const getFilterOptions$8 = (options, t) => {
16353
16384
  const {
16354
16385
  statusOptions = [],
16355
16386
  categoryOptions = [],
@@ -16361,9 +16392,6 @@ const getFilterOptions$4 = (options, t) => {
16361
16392
  administrativeLevel1,
16362
16393
  administrativeLevel2
16363
16394
  } = options || {};
16364
- console.log({
16365
- options
16366
- });
16367
16395
  const _default = {
16368
16396
  category: stakeholderCategoryOptions || categoryOptions,
16369
16397
  country: countries,
@@ -30082,7 +30110,7 @@ function DynamicForm({
30082
30110
  });
30083
30111
  }
30084
30112
 
30085
- const StakeholdersCreate$2 = ({
30113
+ const StakeholdersCreate$6 = ({
30086
30114
  namespace = "OPERATOR",
30087
30115
  view = ['scoping', 'new'],
30088
30116
  edit = false,
@@ -30212,11 +30240,12 @@ const OperatorsTable = ({
30212
30240
  formValue = {},
30213
30241
  form = {},
30214
30242
  extendingFilters = {},
30215
- createDefaultValues = {}
30243
+ createDefaultValues = {},
30244
+ applications = []
30216
30245
  }) => {
30217
30246
  const [selectOptions, setSelectOptions] = React.useState();
30218
30247
  const [activeTab, setActiveTab] = React.useState();
30219
- const columns = React.useMemo(() => getColumns$4({
30248
+ const columns = React.useMemo(() => getColumns$8({
30220
30249
  t,
30221
30250
  goTo,
30222
30251
  user,
@@ -30225,8 +30254,9 @@ const OperatorsTable = ({
30225
30254
  getRedirectLink,
30226
30255
  theme,
30227
30256
  subject: 'operators',
30228
- data
30229
- }), [t, goTo, user, options, activeTab, getRedirectLink, theme, data]);
30257
+ data,
30258
+ applications
30259
+ }), [t, goTo, user, options, activeTab, getRedirectLink, theme, data, applications]);
30230
30260
  const breadCrumbs = [];
30231
30261
  const {
30232
30262
  paginationQuery,
@@ -30258,14 +30288,14 @@ const OperatorsTable = ({
30258
30288
  }, 'operators');
30259
30289
  }, [location.search, activeTab, JSON.stringify(extendingFilters)]);
30260
30290
  const selectFiltersConfig = React.useMemo(() => {
30261
- return getFiltersConfig$4({
30291
+ return getFiltersConfig$8({
30262
30292
  t
30263
30293
  });
30264
30294
  }, [t]);
30265
30295
  React.useEffect(() => {
30266
30296
  setSelectOptions(prev => ({
30267
30297
  ...prev,
30268
- ...getFilterOptions$4(options)
30298
+ ...getFilterOptions$8(options)
30269
30299
  }));
30270
30300
  }, [options, t]);
30271
30301
  const handleActiveTabChange = React.useCallback(value => {
@@ -30281,13 +30311,13 @@ const OperatorsTable = ({
30281
30311
  defaultActiveTab: "all",
30282
30312
  columns: columns,
30283
30313
  data: data,
30284
- checkboxConfig: checkboxConfig$4,
30314
+ checkboxConfig: checkboxConfig$8,
30285
30315
  APP: APP,
30286
30316
  getApiBaseUrl: getApiBaseUrl,
30287
30317
  selectOptions: selectOptions,
30288
30318
  selectFiltersConfig: selectFiltersConfig,
30289
30319
  getRedirectLink: getRedirectLink,
30290
- filtersConfig: filtersConfig$4,
30320
+ filtersConfig: filtersConfig$8,
30291
30321
  isMobile: isMobile,
30292
30322
  view: "operators",
30293
30323
  getActiveTab: handleActiveTabChange,
@@ -30297,7 +30327,7 @@ const OperatorsTable = ({
30297
30327
  drawerTitle: t("Create Operator"),
30298
30328
  children: ({
30299
30329
  onDrawerClose
30300
- }) => /*#__PURE__*/jsxRuntime.jsx(StakeholdersCreate$2, {
30330
+ }) => /*#__PURE__*/jsxRuntime.jsx(StakeholdersCreate$6, {
30301
30331
  defaultData: createDefaultValues,
30302
30332
  t: t,
30303
30333
  goTo: goTo,
@@ -30328,13 +30358,13 @@ const OperatorsTable = ({
30328
30358
  });
30329
30359
  };
30330
30360
 
30331
- const getLinkValue$1 = (value, linkingObject) => {
30361
+ const getLinkValue$4 = (value, linkingObject) => {
30332
30362
  if (linkingObject && linkingObject?.[value]) {
30333
30363
  return linkingObject?.[value]?.name;
30334
30364
  }
30335
30365
  return null;
30336
30366
  };
30337
- const getColumns$3 = ({
30367
+ const getColumns$7 = ({
30338
30368
  t,
30339
30369
  goTo,
30340
30370
  user,
@@ -30343,7 +30373,8 @@ const getColumns$3 = ({
30343
30373
  getRedirectLink,
30344
30374
  theme,
30345
30375
  subject,
30346
- data
30376
+ data,
30377
+ applications
30347
30378
  }) => [{
30348
30379
  dataIndex: 'datastakeId',
30349
30380
  title: t('ID'),
@@ -30421,7 +30452,7 @@ const getColumns$3 = ({
30421
30452
  className: "daf-default-cell"
30422
30453
  });
30423
30454
  }
30424
- const region = getLinkValue$1(v, all?.linking?.SCL);
30455
+ const region = getLinkValue$4(v, all?.linking?.SCL);
30425
30456
  return region ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
30426
30457
  title: region,
30427
30458
  children: region
@@ -30438,7 +30469,7 @@ const getColumns$3 = ({
30438
30469
  className: "daf-default-cell"
30439
30470
  });
30440
30471
  }
30441
- const district = getLinkValue$1(v, all?.linking?.SCL);
30472
+ const district = getLinkValue$4(v, all?.linking?.SCL);
30442
30473
  return district ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
30443
30474
  title: district,
30444
30475
  children: district
@@ -30473,12 +30504,9 @@ const getColumns$3 = ({
30473
30504
  className: "daf-default-cell"
30474
30505
  });
30475
30506
  }
30476
- console.log({
30477
- val,
30478
- all
30479
- });
30507
+ const sources = sourceAvatarConfig(val, user, applications);
30480
30508
  return /*#__PURE__*/jsxRuntime.jsx(AvatarGroup, {
30481
- items: val
30509
+ items: sources
30482
30510
  });
30483
30511
  }
30484
30512
  }, {
@@ -30509,11 +30537,11 @@ const getColumns$3 = ({
30509
30537
  }
30510
30538
  }].filter(column => column.show !== false);
30511
30539
 
30512
- const checkboxConfig$3 = {
30540
+ const checkboxConfig$7 = {
30513
30541
  name: 'Name',
30514
30542
  datastakeId: 'ID'
30515
30543
  };
30516
- const getFiltersConfig$3 = ({
30544
+ const getFiltersConfig$7 = ({
30517
30545
  t
30518
30546
  }) => {
30519
30547
  return {
@@ -30531,11 +30559,11 @@ const getFiltersConfig$3 = ({
30531
30559
  }
30532
30560
  };
30533
30561
  };
30534
- const filtersConfig$3 = {
30562
+ const filtersConfig$7 = {
30535
30563
  name: '',
30536
30564
  datastakeId: ''
30537
30565
  };
30538
- const getFilterOptions$3 = (options, t) => {
30566
+ const getFilterOptions$7 = (options, t) => {
30539
30567
  const {
30540
30568
  countries
30541
30569
  } = options || {};
@@ -30545,7 +30573,7 @@ const getFilterOptions$3 = (options, t) => {
30545
30573
  return _default;
30546
30574
  };
30547
30575
 
30548
- const StakeholdersCreate$1 = ({
30576
+ const StakeholdersCreate$5 = ({
30549
30577
  namespace = 'locations',
30550
30578
  view = 'scoping',
30551
30579
  edit = false,
@@ -30584,7 +30612,7 @@ const StakeholdersCreate$1 = ({
30584
30612
  namespace,
30585
30613
  module: APP,
30586
30614
  view,
30587
- scope: 'global'
30615
+ scope: 'create'
30588
30616
  });
30589
30617
  } else {
30590
30618
  form = formConfig;
@@ -30670,11 +30698,13 @@ const LocationsTable = ({
30670
30698
  changeAjaxOptions = () => {},
30671
30699
  formData = {},
30672
30700
  formValue = {},
30673
- form = {}
30701
+ form = {},
30702
+ applications = [],
30703
+ subjectClear = () => {}
30674
30704
  }) => {
30675
30705
  const [selectOptions, setSelectOptions] = React.useState();
30676
30706
  const [activeTab, setActiveTab] = React.useState();
30677
- const columns = React.useMemo(() => getColumns$3({
30707
+ const columns = React.useMemo(() => getColumns$7({
30678
30708
  t,
30679
30709
  goTo,
30680
30710
  user,
@@ -30683,8 +30713,9 @@ const LocationsTable = ({
30683
30713
  getRedirectLink,
30684
30714
  theme,
30685
30715
  subject: 'locations',
30686
- data
30687
- }), [t, goTo, user, options, activeTab, getRedirectLink, theme, data]);
30716
+ data,
30717
+ applications
30718
+ }), [t, goTo, user, options, activeTab, getRedirectLink, theme, data, applications]);
30688
30719
  const breadCrumbs = [];
30689
30720
  const {
30690
30721
  paginationQuery,
@@ -30709,19 +30740,22 @@ const LocationsTable = ({
30709
30740
  data
30710
30741
  });
30711
30742
  const selectFiltersConfig = React.useMemo(() => {
30712
- return getFiltersConfig$3({
30743
+ return getFiltersConfig$7({
30713
30744
  t
30714
30745
  });
30715
30746
  }, [t]);
30716
30747
  React.useEffect(() => {
30717
30748
  setSelectOptions(prev => ({
30718
30749
  ...prev,
30719
- ...getFilterOptions$3(options)
30750
+ ...getFilterOptions$7(options)
30720
30751
  }));
30721
30752
  }, [options, t]);
30722
30753
  const handleActiveTabChange = React.useCallback(value => {
30723
30754
  setActiveTab(value);
30724
30755
  }, []);
30756
+ React.useEffect(() => () => {
30757
+ subjectClear();
30758
+ }, []);
30725
30759
  return /*#__PURE__*/jsxRuntime.jsx(TablePageWithTabs, {
30726
30760
  t: t,
30727
30761
  title: t("Locations"),
@@ -30732,13 +30766,13 @@ const LocationsTable = ({
30732
30766
  defaultActiveTab: "all",
30733
30767
  columns: columns,
30734
30768
  data: data,
30735
- checkboxConfig: checkboxConfig$3,
30769
+ checkboxConfig: checkboxConfig$7,
30736
30770
  APP: APP,
30737
30771
  getApiBaseUrl: getApiBaseUrl,
30738
30772
  selectOptions: selectOptions,
30739
30773
  selectFiltersConfig: selectFiltersConfig,
30740
30774
  getRedirectLink: getRedirectLink,
30741
- filtersConfig: filtersConfig$3,
30775
+ filtersConfig: filtersConfig$7,
30742
30776
  isMobile: isMobile,
30743
30777
  view: "locations",
30744
30778
  getActiveTab: handleActiveTabChange,
@@ -30748,7 +30782,7 @@ const LocationsTable = ({
30748
30782
  drawerTitle: t("Create Location"),
30749
30783
  children: ({
30750
30784
  onDrawerClose
30751
- }) => /*#__PURE__*/jsxRuntime.jsx(StakeholdersCreate$1, {
30785
+ }) => /*#__PURE__*/jsxRuntime.jsx(StakeholdersCreate$5, {
30752
30786
  t: t,
30753
30787
  goTo: goTo,
30754
30788
  user: user,
@@ -30777,7 +30811,7 @@ const LocationsTable = ({
30777
30811
  });
30778
30812
  };
30779
30813
 
30780
- const getColumns$2 = ({
30814
+ const getColumns$6 = ({
30781
30815
  t,
30782
30816
  goTo,
30783
30817
  user,
@@ -30785,7 +30819,8 @@ const getColumns$2 = ({
30785
30819
  activeTab,
30786
30820
  getRedirectLink,
30787
30821
  theme,
30788
- subject
30822
+ subject,
30823
+ applications
30789
30824
  }) => [{
30790
30825
  dataIndex: 'datastakeId',
30791
30826
  title: t('ID'),
@@ -30901,8 +30936,9 @@ const getColumns$2 = ({
30901
30936
  if (!val || val?.length === 0) {
30902
30937
  return "--";
30903
30938
  }
30939
+ const sources = sourceAvatarConfig(val, user, applications);
30904
30940
  return /*#__PURE__*/jsxRuntime.jsx(AvatarGroup, {
30905
- items: val
30941
+ items: sources
30906
30942
  });
30907
30943
  }
30908
30944
  }, {
@@ -30933,11 +30969,11 @@ const getColumns$2 = ({
30933
30969
  }
30934
30970
  }].filter(column => column.show !== false);
30935
30971
 
30936
- const checkboxConfig$2 = {
30972
+ const checkboxConfig$6 = {
30937
30973
  name: 'Name',
30938
30974
  datastakeId: 'ID'
30939
30975
  };
30940
- const getFiltersConfig$2 = ({
30976
+ const getFiltersConfig$6 = ({
30941
30977
  t
30942
30978
  }) => {
30943
30979
  return {
@@ -30955,11 +30991,11 @@ const getFiltersConfig$2 = ({
30955
30991
  }
30956
30992
  };
30957
30993
  };
30958
- const filtersConfig$2 = {
30994
+ const filtersConfig$6 = {
30959
30995
  name: '',
30960
30996
  datastakeId: ''
30961
30997
  };
30962
- const getFilterOptions$2 = (options, t) => {
30998
+ const getFilterOptions$6 = (options, t) => {
30963
30999
  const {
30964
31000
  countries
30965
31001
  } = options || {};
@@ -30969,7 +31005,7 @@ const getFilterOptions$2 = (options, t) => {
30969
31005
  return _default;
30970
31006
  };
30971
31007
 
30972
- const StakeholdersCreate = ({
31008
+ const StakeholdersCreate$4 = ({
30973
31009
  namespace = 'stakeholders',
30974
31010
  view = 'scoping',
30975
31011
  edit = false,
@@ -31008,7 +31044,7 @@ const StakeholdersCreate = ({
31008
31044
  namespace,
31009
31045
  module: APP,
31010
31046
  view,
31011
- scope: 'global'
31047
+ scope: 'create'
31012
31048
  });
31013
31049
  } else {
31014
31050
  form = formConfig;
@@ -31094,11 +31130,13 @@ const StakeholdersTable = ({
31094
31130
  changeAjaxOptions = () => {},
31095
31131
  formData = {},
31096
31132
  formValue = {},
31097
- form = {}
31133
+ form = {},
31134
+ applications = [],
31135
+ subjectClear = () => {}
31098
31136
  }) => {
31099
31137
  const [selectOptions, setSelectOptions] = React.useState();
31100
31138
  const [activeTab, setActiveTab] = React.useState();
31101
- const columns = React.useMemo(() => getColumns$2({
31139
+ const columns = React.useMemo(() => getColumns$6({
31102
31140
  t,
31103
31141
  goTo,
31104
31142
  user,
@@ -31106,8 +31144,9 @@ const StakeholdersTable = ({
31106
31144
  activeTab,
31107
31145
  getRedirectLink,
31108
31146
  theme,
31109
- subject: 'stakeholders'
31110
- }), [t, goTo, user, options, activeTab, getRedirectLink, theme]);
31147
+ subject: 'stakeholders',
31148
+ applications
31149
+ }), [t, goTo, user, options, activeTab, getRedirectLink, theme, applications]);
31111
31150
  const breadCrumbs = [];
31112
31151
  const {
31113
31152
  paginationQuery,
@@ -31129,19 +31168,22 @@ const StakeholdersTable = ({
31129
31168
  }, 'stakeholders');
31130
31169
  }, [paginationQuery, otherParams, searchParams, activeTab]);
31131
31170
  const selectFiltersConfig = React.useMemo(() => {
31132
- return getFiltersConfig$2({
31171
+ return getFiltersConfig$6({
31133
31172
  t
31134
31173
  });
31135
31174
  }, [t]);
31136
31175
  React.useEffect(() => {
31137
31176
  setSelectOptions(prev => ({
31138
31177
  ...prev,
31139
- ...getFilterOptions$2(options)
31178
+ ...getFilterOptions$6(options)
31140
31179
  }));
31141
31180
  }, [options, t]);
31142
31181
  const handleActiveTabChange = React.useCallback(value => {
31143
31182
  setActiveTab(value);
31144
31183
  }, []);
31184
+ React.useEffect(() => () => {
31185
+ subjectClear();
31186
+ }, []);
31145
31187
  return /*#__PURE__*/jsxRuntime.jsx(TablePageWithTabs, {
31146
31188
  t: t,
31147
31189
  title: t("Stakeholders"),
@@ -31152,13 +31194,13 @@ const StakeholdersTable = ({
31152
31194
  defaultActiveTab: "all",
31153
31195
  columns: columns,
31154
31196
  data: data,
31155
- checkboxConfig: checkboxConfig$2,
31197
+ checkboxConfig: checkboxConfig$6,
31156
31198
  APP: APP,
31157
31199
  getApiBaseUrl: getApiBaseUrl,
31158
31200
  selectOptions: selectOptions,
31159
31201
  selectFiltersConfig: selectFiltersConfig,
31160
31202
  getRedirectLink: getRedirectLink,
31161
- filtersConfig: filtersConfig$2,
31203
+ filtersConfig: filtersConfig$6,
31162
31204
  isMobile: isMobile,
31163
31205
  view: "stakeholders",
31164
31206
  getActiveTab: handleActiveTabChange,
@@ -31168,7 +31210,7 @@ const StakeholdersTable = ({
31168
31210
  drawerTitle: t("Create Stakeholder"),
31169
31211
  children: ({
31170
31212
  onDrawerClose
31171
- }) => /*#__PURE__*/jsxRuntime.jsx(StakeholdersCreate, {
31213
+ }) => /*#__PURE__*/jsxRuntime.jsx(StakeholdersCreate$4, {
31172
31214
  t: t,
31173
31215
  goTo: goTo,
31174
31216
  user: user,
@@ -31181,7 +31223,7 @@ const StakeholdersTable = ({
31181
31223
  onSubmitted: (type, m, data) => {
31182
31224
  if (data.datastakeId) {
31183
31225
  displayMessage(type, t("affirmations::subject-created-successfully") || m);
31184
- goTo(`/app/stakeholders`);
31226
+ goTo(`/app/edit/stakeholders/${data.datastakeId}`);
31185
31227
  }
31186
31228
  },
31187
31229
  onCancel: onDrawerClose,
@@ -31197,13 +31239,13 @@ const StakeholdersTable = ({
31197
31239
  });
31198
31240
  };
31199
31241
 
31200
- const getLinkValue = (value, linkingObject) => {
31242
+ const getLinkValue$3 = (value, linkingObject) => {
31201
31243
  if (linkingObject && linkingObject?.[value]) {
31202
31244
  return linkingObject?.[value]?.name;
31203
31245
  }
31204
31246
  return null;
31205
31247
  };
31206
- const getColumns$1 = ({
31248
+ const getColumns$5 = ({
31207
31249
  t,
31208
31250
  goTo,
31209
31251
  user,
@@ -31212,7 +31254,8 @@ const getColumns$1 = ({
31212
31254
  getRedirectLink,
31213
31255
  theme,
31214
31256
  subject,
31215
- data
31257
+ data,
31258
+ applications
31216
31259
  }) => [{
31217
31260
  dataIndex: 'datastakeId',
31218
31261
  title: t('ID'),
@@ -31290,7 +31333,7 @@ const getColumns$1 = ({
31290
31333
  className: "daf-default-cell"
31291
31334
  });
31292
31335
  }
31293
- const scope = getLinkValue(v, all?.linking?.SCL);
31336
+ const scope = getLinkValue$3(v, all?.linking?.SCL);
31294
31337
  return scope ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
31295
31338
  title: scope,
31296
31339
  children: scope
@@ -31343,12 +31386,9 @@ const getColumns$1 = ({
31343
31386
  className: "daf-default-cell"
31344
31387
  });
31345
31388
  }
31346
- console.log({
31347
- val,
31348
- all
31349
- });
31389
+ const sources = sourceAvatarConfig(val, user, applications);
31350
31390
  return /*#__PURE__*/jsxRuntime.jsx(AvatarGroup, {
31351
- items: val
31391
+ items: sources
31352
31392
  });
31353
31393
  }
31354
31394
  }, {
@@ -31379,17 +31419,25 @@ const getColumns$1 = ({
31379
31419
  }
31380
31420
  }].filter(column => column.show !== false);
31381
31421
 
31382
- const checkboxConfig$1 = {
31422
+ const checkboxConfig$5 = {
31383
31423
  name: 'Name',
31384
31424
  datastakeId: 'ID'
31385
31425
  };
31386
- const getFiltersConfig$1 = ({
31426
+ const getFiltersConfig$5 = ({
31387
31427
  t
31388
31428
  }) => {
31389
31429
  return {
31430
+ timeframe: {
31431
+ type: "timeframe",
31432
+ label: "Timeframe",
31433
+ style: {
31434
+ flex: 1
31435
+ }
31436
+ },
31390
31437
  country: {
31391
31438
  type: 'select',
31392
- placeholder: t('Country'),
31439
+ label: 'Country',
31440
+ placeholder: t => `${t('Filter by')} ${t('Country').toLowerCase()}`,
31393
31441
  style: {
31394
31442
  flex: 1
31395
31443
  },
@@ -31398,126 +31446,2844 @@ const getFiltersConfig$1 = ({
31398
31446
  },
31399
31447
  getLabel: option => option.label,
31400
31448
  getValue: option => option.value
31401
- }
31402
- };
31403
- };
31404
- const filtersConfig$1 = {
31405
- name: '',
31406
- datastakeId: ''
31407
- };
31408
- const getFilterOptions$1 = (options, t) => {
31409
- const {
31410
- countries
31411
- } = options || {};
31412
- const _default = {
31413
- country: countries
31414
- };
31415
- return _default;
31416
- };
31417
-
31418
- const EventsCreate = ({
31419
- namespace = 'events',
31420
- view = 'scoping',
31421
- edit = false,
31422
- formData = {},
31423
- loading = false,
31424
- onSubmitted = () => {},
31425
- onCancel = () => {},
31426
- getData = () => {},
31427
- saveData = () => {},
31428
- form: formConfig = {},
31429
- formValue = {},
31430
- defaultData = {},
31431
- user = {},
31432
- APP,
31433
- query,
31434
- goTo = () => {},
31435
- t = () => {},
31436
- ajaxForms = {},
31437
- changeAjaxForms = () => {},
31438
- ajaxOptions = {},
31439
- changeAjaxOptions = () => {},
31440
- getAppHeader = () => {},
31441
- getApiBaseUrl = () => {}
31442
- }) => {
31443
- let {
31444
- form = {},
31445
- data = defaultData || {}
31446
- } = !edit ? formData[`${APP}-${view}`] || {} : {
31447
- form: formConfig,
31448
- data: formValue
31449
- };
31450
- React.useEffect(() => {
31451
- if (Object.keys(form).length === 0 && !formData[`${APP}-${view}`]) {
31452
- if (!edit) {
31453
- getData({
31454
- namespace,
31455
- module: APP,
31456
- view,
31457
- scope: 'global'
31458
- });
31459
- } else {
31460
- form = formConfig;
31461
- data = formValue;
31462
- }
31463
- }
31464
- }, [edit, user?.language]);
31465
- return /*#__PURE__*/jsxRuntime.jsx("div", {
31466
- className: "daf-create-form",
31467
- children: /*#__PURE__*/jsxRuntime.jsx(DynamicForm, {
31468
- form: form,
31469
- data: data,
31470
- showSaveAndNext: false,
31471
- module: APP,
31472
- onCancel: onCancel,
31473
- isCreate: true,
31474
- t: t,
31475
- excludedKeys: ["title"],
31476
- user: user,
31477
- ajaxForms: ajaxForms,
31478
- ajaxOptions: ajaxOptions,
31479
- getAppHeader: getAppHeader,
31480
- getApiBaseUrl: getApiBaseUrl,
31481
- changeAjaxOptions: changeAjaxOptions,
31482
- app: APP,
31483
- query: query,
31484
- goTo: goTo,
31485
- changeAjaxForms: changeAjaxForms,
31486
- submit: (payload, setSelectedFormNext) => {
31487
- const payloadData = {
31488
- ...payload,
31489
- module: APP,
31490
- namespace
31491
- };
31492
- const newPayload = {
31493
- ...defaultData,
31494
- ...payloadData,
31495
- form: 'location'
31496
- };
31497
- const callback = (type, m, data) => {
31498
- if (setSelectedFormNext) {
31499
- setSelectedFormNext();
31500
- }
31501
- if (type === MessageTypes.SUCCESS) {
31502
- if (onSubmitted) onSubmitted(type, m, data);
31503
- } else {
31504
- antd.message.error(m);
31449
+ },
31450
+ administrativeLevel1: {
31451
+ type: 'ajaxSelect',
31452
+ label: ({
31453
+ t = s => s,
31454
+ options = {},
31455
+ filters = {},
31456
+ language = 'en'
31457
+ }) => {
31458
+ const {
31459
+ administrativeLevel1
31460
+ } = options;
31461
+ if (administrativeLevel1) {
31462
+ if (options.country) {
31463
+ const _item = administrativeLevel1[filters.country];
31464
+ if (_item) {
31465
+ if (_item[language]) {
31466
+ return _item[language];
31467
+ }
31468
+ }
31505
31469
  }
31506
- };
31507
- saveData(!data && !data.id ? newPayload : Object.assign(newPayload, {
31508
- id: data.id
31509
- }), callback);
31470
+ }
31471
+ return t('Province');
31510
31472
  },
31511
- isFormDisabled: () => {
31512
- return !data || !data.typeOfEvent;
31473
+ placeholder: t => `${t('Filter by')} ${t('Province').toLowerCase()}`,
31474
+ filters: data => ({
31475
+ country: data.country,
31476
+ level: 'level_1'
31477
+ }),
31478
+ show: data => !data.country,
31479
+ disabled: data => !data.country,
31480
+ mapper: {
31481
+ label: "name",
31482
+ value: "id"
31483
+ },
31484
+ method: 'getOptions',
31485
+ entity: 'AdministrativeLevel',
31486
+ style: {
31487
+ flex: 1
31488
+ },
31489
+ labelStyle: {
31490
+ flex: 1
31513
31491
  }
31514
- })
31515
- });
31516
- };
31517
-
31518
- const EventsTable = ({
31519
- t = () => {},
31520
- goTo = () => {},
31492
+ },
31493
+ administrativeLevel2: {
31494
+ type: 'ajaxSelect',
31495
+ label: ({
31496
+ t = s => s,
31497
+ options = {},
31498
+ filters = {},
31499
+ language = 'en'
31500
+ }) => {
31501
+ const {
31502
+ administrativeLevel2
31503
+ } = options;
31504
+ if (administrativeLevel2) {
31505
+ if (options.country) {
31506
+ const _item = administrativeLevel2[filters.country];
31507
+ if (_item) {
31508
+ if (_item[language]) {
31509
+ return _item[language];
31510
+ }
31511
+ }
31512
+ }
31513
+ }
31514
+ return t('Province');
31515
+ },
31516
+ show: data => !(data.country && data.administrativeLevel1),
31517
+ placeholder: t => `${t('Filter by')} ${t('Territory').toLowerCase()}`,
31518
+ filters: data => ({
31519
+ country: data.country,
31520
+ level: 'level_2',
31521
+ administrativeLevel1: data.administrativeLevel1
31522
+ }),
31523
+ disabled: data => !(data.country && data.administrativeLevel1),
31524
+ mapper: {
31525
+ label: "name",
31526
+ value: "id"
31527
+ },
31528
+ method: 'getOptions',
31529
+ entity: 'AdministrativeLevel',
31530
+ style: {
31531
+ flex: 1
31532
+ },
31533
+ labelStyle: {
31534
+ flex: 1
31535
+ }
31536
+ },
31537
+ subCategory: {
31538
+ type: 'select',
31539
+ label: 'Category',
31540
+ placeholder: t => `${t('Filter by')} ${t('Category').toLowerCase()}`,
31541
+ style: {
31542
+ flex: 1
31543
+ },
31544
+ labelStyle: {
31545
+ flex: 1
31546
+ },
31547
+ getLabel: option => option.label,
31548
+ getValue: option => option.value,
31549
+ filterOptions: val => {
31550
+ if (val) {
31551
+ const {
31552
+ option,
31553
+ filters
31554
+ } = val;
31555
+ if (filters && option) {
31556
+ const {
31557
+ filters: optionFilters
31558
+ } = option;
31559
+ if (Array.isArray(optionFilters) && optionFilters.length) {
31560
+ const {
31561
+ value,
31562
+ condition
31563
+ } = optionFilters[0];
31564
+ if (condition === 'includes') {
31565
+ return value.includes('corporation');
31566
+ }
31567
+ }
31568
+ }
31569
+ }
31570
+ return true;
31571
+ }
31572
+ },
31573
+ positionInTheMineralSupplyChain: {
31574
+ type: 'select',
31575
+ label: 'Position',
31576
+ placeholder: t => `${t('Filter by')} ${t('Position').toLowerCase()}`,
31577
+ style: {
31578
+ flex: 1
31579
+ },
31580
+ labelStyle: {
31581
+ flex: 1
31582
+ },
31583
+ getLabel: option => option.label,
31584
+ getValue: option => option.value
31585
+ },
31586
+ status: {
31587
+ type: "select",
31588
+ label: "Status",
31589
+ placeholder: t => `${t("Filter by")} ${t("Status").toLowerCase()}`,
31590
+ style: {
31591
+ flex: 1
31592
+ },
31593
+ labelStyle: {
31594
+ fley: 1
31595
+ },
31596
+ getLabel: option => option.label,
31597
+ getValue: option => option.value
31598
+ },
31599
+ category: {
31600
+ type: 'select',
31601
+ label: 'Category',
31602
+ placeholder: t => `${t('Filter by')} ${t('Category').toLowerCase()}`,
31603
+ style: {
31604
+ flex: 1
31605
+ },
31606
+ labelStyle: {
31607
+ flex: 1
31608
+ },
31609
+ getLabel: option => option.label,
31610
+ getValue: option => option.value
31611
+ }
31612
+ };
31613
+ };
31614
+ const filtersConfig$5 = {
31615
+ name: '',
31616
+ datastakeId: ''
31617
+ };
31618
+ const getFilterOptions$5 = (options, t) => {
31619
+ const {
31620
+ timeframe = [],
31621
+ statusOptions = [],
31622
+ categoryOptions = [],
31623
+ countries = [],
31624
+ subCategory = [],
31625
+ subCategoriesOptions,
31626
+ stakeholderCategoryOptions,
31627
+ stakeholderSubCategoriesOptions,
31628
+ administrativeLevel1,
31629
+ administrativeLevel2,
31630
+ category = []
31631
+ } = options || {};
31632
+ console.log({
31633
+ options
31634
+ });
31635
+ const _default = {
31636
+ timeframe: timeframe,
31637
+ country: countries,
31638
+ category: stakeholderCategoryOptions || categoryOptions,
31639
+ administrativeLevel1,
31640
+ administrativeLevel2,
31641
+ // subCategory: subCategoriesOptions,
31642
+ category: category,
31643
+ status: [{
31644
+ value: "submitted",
31645
+ label: "Submitted"
31646
+ }, {
31647
+ value: "private",
31648
+ label: "Private"
31649
+ }]
31650
+ };
31651
+ return _default;
31652
+ };
31653
+
31654
+ const EventsCreate = ({
31655
+ namespace = 'event',
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: 'create'
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: 'location'
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 EventsTable = ({
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
+ applications = [],
31782
+ subjectClear = () => {}
31783
+ }) => {
31784
+ const [selectOptions, setSelectOptions] = React.useState();
31785
+ const [activeTab, setActiveTab] = React.useState();
31786
+ const columns = React.useMemo(() => getColumns$5({
31787
+ t,
31788
+ goTo,
31789
+ user,
31790
+ options,
31791
+ activeTab,
31792
+ getRedirectLink,
31793
+ theme,
31794
+ subject: 'events',
31795
+ data,
31796
+ applications
31797
+ }), [t, goTo, user, options, activeTab, getRedirectLink, theme, data, applications]);
31798
+ const breadCrumbs = [];
31799
+ const {
31800
+ paginationQuery,
31801
+ searchParams,
31802
+ otherParams,
31803
+ sortBy,
31804
+ sortDir
31805
+ } = useGetQueryParams({
31806
+ location
31807
+ });
31808
+ const filters = React.useMemo(() => {
31809
+ return {
31810
+ ...otherParams,
31811
+ ...extendingFilters
31812
+ };
31813
+ }, [otherParams, extendingFilters]);
31814
+ React.useEffect(() => {
31815
+ console.log("fetching data");
31816
+ getData({
31817
+ pagination: paginationQuery,
31818
+ ...(Object.keys(filters).length > 0 && {
31819
+ filters: filters
31820
+ }),
31821
+ ...(Object.keys(searchParams).length > 0 && {
31822
+ search: searchParams
31823
+ }),
31824
+ tab: activeTab,
31825
+ sortBy: {
31826
+ [sortBy || "updatedAt"]: sortDir ? sortDir === "ascend" ? 1 : -1 : -1
31827
+ }
31828
+ }, 'events');
31829
+ console.log("data fetched");
31830
+ }, [location.search, activeTab, JSON.stringify(extendingFilters)]);
31831
+ console.log({
31832
+ data
31833
+ });
31834
+ const selectFiltersConfig = React.useMemo(() => {
31835
+ return getFiltersConfig$5({
31836
+ t
31837
+ });
31838
+ }, [t]);
31839
+ React.useEffect(() => {
31840
+ setSelectOptions(prev => ({
31841
+ ...prev,
31842
+ ...getFilterOptions$5(options)
31843
+ }));
31844
+ }, [options, t]);
31845
+ const handleActiveTabChange = React.useCallback(value => {
31846
+ setActiveTab(value);
31847
+ }, []);
31848
+ React.useEffect(() => () => {
31849
+ subjectClear();
31850
+ }, []);
31851
+ return /*#__PURE__*/jsxRuntime.jsx(TablePageWithTabs, {
31852
+ t: t,
31853
+ title: t("events"),
31854
+ breadCrumbs: breadCrumbs,
31855
+ location: location,
31856
+ loading: loading,
31857
+ goTo: goTo,
31858
+ defaultActiveTab: "all",
31859
+ columns: columns,
31860
+ data: data,
31861
+ checkboxConfig: checkboxConfig$5,
31862
+ APP: APP,
31863
+ getApiBaseUrl: getApiBaseUrl,
31864
+ selectOptions: selectOptions,
31865
+ selectFiltersConfig: selectFiltersConfig,
31866
+ getRedirectLink: getRedirectLink,
31867
+ filtersConfig: filtersConfig$5,
31868
+ isMobile: isMobile,
31869
+ view: "events",
31870
+ getActiveTab: handleActiveTabChange,
31871
+ onDownload: () => {
31872
+ console.log("download");
31873
+ },
31874
+ drawerTitle: t("Create Events"),
31875
+ children: ({
31876
+ onDrawerClose
31877
+ }) => /*#__PURE__*/jsxRuntime.jsx(EventsCreate, {
31878
+ t: t,
31879
+ goTo: goTo,
31880
+ user: user,
31881
+ APP: APP,
31882
+ getApiBaseUrl: getApiBaseUrl,
31883
+ getAppHeader: getAppHeader,
31884
+ getData: getFormData,
31885
+ saveData: saveFormData,
31886
+ loading: formLoading,
31887
+ onSubmitted: (type, m, data) => {
31888
+ if (data.datastakeId) {
31889
+ displayMessage(type, t("affirmations::subject-created-successfully") || m);
31890
+ // goTo(`/app/edit/stakeholders/${data.datastakeId}`);
31891
+ goTo(`/app/edit/events/${data.datastakeId}`);
31892
+ }
31893
+ },
31894
+ onCancel: onDrawerClose,
31895
+ query: query,
31896
+ ajaxForms: ajaxForms,
31897
+ changeAjaxForms: changeAjaxForms,
31898
+ ajaxOptions: ajaxOptions,
31899
+ changeAjaxOptions: changeAjaxOptions,
31900
+ formData: formData,
31901
+ formValue: formValue,
31902
+ form: form
31903
+ })
31904
+ });
31905
+ };
31906
+
31907
+ const getColumns$4 = ({
31908
+ t,
31909
+ goTo,
31910
+ user,
31911
+ options,
31912
+ activeTab,
31913
+ getRedirectLink,
31914
+ theme,
31915
+ subject,
31916
+ applications
31917
+ }) => [{
31918
+ dataIndex: 'datastakeId',
31919
+ title: t('ID'),
31920
+ ellipsis: true,
31921
+ show: true,
31922
+ render: (v, all) => {
31923
+ if (all.empty) {
31924
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
31925
+ className: "daf-default-cell"
31926
+ });
31927
+ }
31928
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
31929
+ title: v,
31930
+ children: v
31931
+ });
31932
+ }
31933
+ }, {
31934
+ dataIndex: 'name',
31935
+ title: t('Name'),
31936
+ ellipsis: true,
31937
+ show: true,
31938
+ render: (v, all) => {
31939
+ if (all.empty) {
31940
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
31941
+ className: "daf-default-cell"
31942
+ });
31943
+ }
31944
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
31945
+ title: v,
31946
+ children: v
31947
+ });
31948
+ }
31949
+ }, {
31950
+ dataIndex: 'category',
31951
+ title: t('Category'),
31952
+ ellipsis: true,
31953
+ show: true,
31954
+ render: (v, all) => {
31955
+ if (all.empty) {
31956
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
31957
+ className: "daf-default-cell"
31958
+ });
31959
+ }
31960
+ const category = findOptions(v, options?.categoriesOptions);
31961
+ return category ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
31962
+ title: category,
31963
+ children: category
31964
+ }) : '-';
31965
+ }
31966
+ }, {
31967
+ dataIndex: 'subCategory',
31968
+ title: t('Sub Category'),
31969
+ ellipsis: true,
31970
+ show: true,
31971
+ render: (v, all) => {
31972
+ if (all.empty) {
31973
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
31974
+ className: "daf-default-cell"
31975
+ });
31976
+ }
31977
+ const subCategory = findOptions(v, options?.subCategoriesOptions);
31978
+ return subCategory ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
31979
+ title: subCategory,
31980
+ children: subCategory
31981
+ }) : '-';
31982
+ }
31983
+ }, {
31984
+ dataIndex: 'country',
31985
+ title: t('Country'),
31986
+ ellipsis: true,
31987
+ show: true,
31988
+ render: (v, all) => {
31989
+ if (all.empty) {
31990
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
31991
+ className: "daf-default-cell"
31992
+ });
31993
+ }
31994
+ const country = findOptions(v, options?.countries);
31995
+ return country ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
31996
+ title: country,
31997
+ children: country
31998
+ }) : '-';
31999
+ }
32000
+ }, {
32001
+ title: t("Last Update"),
32002
+ dataIndex: "updatedAt",
32003
+ key: "updatedAt",
32004
+ width: 125,
32005
+ render: (date, all) => {
32006
+ if (all.empty) {
32007
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32008
+ className: "daf-default-cell"
32009
+ });
32010
+ }
32011
+ const _date = date ? renderDateFormatted(date, "DD MMM YYYY", user?.language || 'en') : "-";
32012
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
32013
+ title: _date,
32014
+ children: _date
32015
+ });
32016
+ },
32017
+ ellipsis: true
32018
+ }, {
32019
+ title: t("Sources"),
32020
+ dataIndex: "sources",
32021
+ key: "sources",
32022
+ show: activeTab !== "own",
32023
+ render: (val, all) => {
32024
+ if (all.empty) {
32025
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32026
+ className: "daf-default-cell"
32027
+ });
32028
+ }
32029
+ if (!val || val?.length === 0) {
32030
+ return "--";
32031
+ }
32032
+ const sources = sourceAvatarConfig(val, user, applications);
32033
+ return /*#__PURE__*/jsxRuntime.jsx(AvatarGroup, {
32034
+ items: sources
32035
+ });
32036
+ }
32037
+ }, {
32038
+ id: 'actions',
32039
+ title: "",
32040
+ width: 60,
32041
+ render: (_, all) => {
32042
+ if (all.empty) {
32043
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32044
+ className: "daf-default-cell"
32045
+ });
32046
+ }
32047
+ const link = `/app/view/${subject}/${all.datastakeId}`;
32048
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32049
+ style: {
32050
+ display: "flex",
32051
+ justifyContent: "center"
32052
+ },
32053
+ children: /*#__PURE__*/jsxRuntime.jsx("a", {
32054
+ href: getRedirectLink(link),
32055
+ children: /*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
32056
+ name: "Link",
32057
+ size: 15,
32058
+ color: theme.baseGray70
32059
+ })
32060
+ })
32061
+ });
32062
+ }
32063
+ }].filter(column => column.show !== false);
32064
+
32065
+ const checkboxConfig$4 = {
32066
+ name: 'Name',
32067
+ datastakeId: 'ID'
32068
+ };
32069
+ const getFiltersConfig$4 = ({
32070
+ t
32071
+ }) => {
32072
+ return {
32073
+ country: {
32074
+ type: 'select',
32075
+ placeholder: t('Country'),
32076
+ style: {
32077
+ flex: 1
32078
+ },
32079
+ labelStyle: {
32080
+ flex: 1
32081
+ },
32082
+ getLabel: option => option.label,
32083
+ getValue: option => option.value
32084
+ }
32085
+ };
32086
+ };
32087
+ const filtersConfig$4 = {
32088
+ name: '',
32089
+ datastakeId: ''
32090
+ };
32091
+ const getFilterOptions$4 = (options, t) => {
32092
+ const {
32093
+ countries
32094
+ } = options || {};
32095
+ const _default = {
32096
+ country: countries
32097
+ };
32098
+ return _default;
32099
+ };
32100
+
32101
+ const StakeholdersCreate$3 = ({
32102
+ namespace = 'stakeholders',
32103
+ view = 'scoping',
32104
+ edit = false,
32105
+ formData = {},
32106
+ loading = false,
32107
+ onSubmitted = () => {},
32108
+ onCancel = () => {},
32109
+ getData = () => {},
32110
+ saveData = () => {},
32111
+ form: formConfig = {},
32112
+ formValue = {},
32113
+ defaultData = {},
32114
+ user = {},
32115
+ APP,
32116
+ query,
32117
+ goTo = () => {},
32118
+ t = () => {},
32119
+ ajaxForms = {},
32120
+ changeAjaxForms = () => {},
32121
+ ajaxOptions = {},
32122
+ changeAjaxOptions = () => {},
32123
+ getAppHeader = () => {},
32124
+ getApiBaseUrl = () => {}
32125
+ }) => {
32126
+ let {
32127
+ form = {},
32128
+ data = defaultData || {}
32129
+ } = !edit ? formData[`${APP}-${view}`] || {} : {
32130
+ form: formConfig,
32131
+ data: formValue
32132
+ };
32133
+ React.useEffect(() => {
32134
+ if (Object.keys(form).length === 0 && !formData[`${APP}-${view}`]) {
32135
+ if (!edit) {
32136
+ getData({
32137
+ namespace,
32138
+ module: APP,
32139
+ view,
32140
+ scope: 'create'
32141
+ });
32142
+ } else {
32143
+ form = formConfig;
32144
+ data = formValue;
32145
+ }
32146
+ }
32147
+ }, [edit, user?.language]);
32148
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32149
+ className: "daf-create-form",
32150
+ children: /*#__PURE__*/jsxRuntime.jsx(DynamicForm, {
32151
+ form: form,
32152
+ data: data,
32153
+ showSaveAndNext: false,
32154
+ module: APP,
32155
+ onCancel: onCancel,
32156
+ isCreate: true,
32157
+ t: t,
32158
+ excludedKeys: ["title"],
32159
+ user: user,
32160
+ ajaxForms: ajaxForms,
32161
+ ajaxOptions: ajaxOptions,
32162
+ getAppHeader: getAppHeader,
32163
+ getApiBaseUrl: getApiBaseUrl,
32164
+ changeAjaxOptions: changeAjaxOptions,
32165
+ app: APP,
32166
+ query: query,
32167
+ goTo: goTo,
32168
+ changeAjaxForms: changeAjaxForms,
32169
+ submit: (payload, setSelectedFormNext) => {
32170
+ const payloadData = {
32171
+ ...payload,
32172
+ module: APP,
32173
+ namespace
32174
+ };
32175
+ const newPayload = {
32176
+ ...defaultData,
32177
+ ...payloadData,
32178
+ form: 'document'
32179
+ };
32180
+ const callback = (type, m, data) => {
32181
+ if (setSelectedFormNext) {
32182
+ setSelectedFormNext();
32183
+ }
32184
+ if (type === MessageTypes.SUCCESS) {
32185
+ if (onSubmitted) onSubmitted(type, m, data);
32186
+ } else {
32187
+ antd.message.error(m);
32188
+ }
32189
+ };
32190
+ saveData(!data && !data.id ? newPayload : Object.assign(newPayload, {
32191
+ id: data.id
32192
+ }), callback);
32193
+ },
32194
+ isFormDisabled: () => {
32195
+ return !data || !data.typeOfEvent;
32196
+ }
32197
+ })
32198
+ });
32199
+ };
32200
+
32201
+ const DocumentsTable = ({
32202
+ t = () => {},
32203
+ goTo = () => {},
32204
+ user = {},
32205
+ options = {},
32206
+ getRedirectLink = () => {},
32207
+ theme = {},
32208
+ loading = false,
32209
+ data = {},
32210
+ isMobile,
32211
+ APP,
32212
+ location,
32213
+ getData = () => {},
32214
+ getApiBaseUrl = () => {},
32215
+ getAppHeader = () => {},
32216
+ getFormData = () => {},
32217
+ saveFormData = () => {},
32218
+ formLoading = false,
32219
+ query = {},
32220
+ ajaxForms = {},
32221
+ changeAjaxForms = () => {},
32222
+ ajaxOptions = {},
32223
+ changeAjaxOptions = () => {},
32224
+ formData = {},
32225
+ formValue = {},
32226
+ form = {},
32227
+ applications = [],
32228
+ subjectClear = () => {}
32229
+ }) => {
32230
+ const [selectOptions, setSelectOptions] = React.useState();
32231
+ const [activeTab, setActiveTab] = React.useState();
32232
+ const columns = React.useMemo(() => getColumns$4({
32233
+ t,
32234
+ goTo,
32235
+ user,
32236
+ options,
32237
+ activeTab,
32238
+ getRedirectLink,
32239
+ theme,
32240
+ subject: 'documents',
32241
+ applications
32242
+ }), [t, goTo, user, options, activeTab, getRedirectLink, theme, applications]);
32243
+ const breadCrumbs = [];
32244
+ const {
32245
+ paginationQuery,
32246
+ searchParams,
32247
+ otherParams
32248
+ } = useGetQueryParams({
32249
+ location
32250
+ });
32251
+ React.useEffect(() => {
32252
+ getData({
32253
+ pagination: paginationQuery,
32254
+ ...(Object.keys(otherParams).length > 0 && {
32255
+ filters: otherParams
32256
+ }),
32257
+ ...(Object.keys(searchParams).length > 0 && {
32258
+ search: searchParams
32259
+ }),
32260
+ tab: activeTab
32261
+ }, 'documents');
32262
+ }, [paginationQuery, otherParams, searchParams, activeTab]);
32263
+ const selectFiltersConfig = React.useMemo(() => {
32264
+ return getFiltersConfig$4({
32265
+ t
32266
+ });
32267
+ }, [t]);
32268
+ React.useEffect(() => {
32269
+ setSelectOptions(prev => ({
32270
+ ...prev,
32271
+ ...getFilterOptions$4(options)
32272
+ }));
32273
+ }, [options, t]);
32274
+ const handleActiveTabChange = React.useCallback(value => {
32275
+ setActiveTab(value);
32276
+ }, []);
32277
+ React.useEffect(() => () => {
32278
+ subjectClear();
32279
+ }, []);
32280
+ return /*#__PURE__*/jsxRuntime.jsx(TablePageWithTabs, {
32281
+ t: t,
32282
+ title: t("Documents"),
32283
+ breadCrumbs: breadCrumbs,
32284
+ location: location,
32285
+ loading: loading,
32286
+ goTo: goTo,
32287
+ defaultActiveTab: "all",
32288
+ columns: columns,
32289
+ data: data,
32290
+ checkboxConfig: checkboxConfig$4,
32291
+ APP: APP,
32292
+ getApiBaseUrl: getApiBaseUrl,
32293
+ selectOptions: selectOptions,
32294
+ selectFiltersConfig: selectFiltersConfig,
32295
+ getRedirectLink: getRedirectLink,
32296
+ filtersConfig: filtersConfig$4,
32297
+ isMobile: isMobile,
32298
+ view: "documents",
32299
+ getActiveTab: handleActiveTabChange,
32300
+ onDownload: () => {
32301
+ console.log("download");
32302
+ },
32303
+ drawerTitle: t("Create Document"),
32304
+ children: ({
32305
+ onDrawerClose
32306
+ }) => /*#__PURE__*/jsxRuntime.jsx(StakeholdersCreate$3, {
32307
+ t: t,
32308
+ goTo: goTo,
32309
+ user: user,
32310
+ APP: APP,
32311
+ getApiBaseUrl: getApiBaseUrl,
32312
+ getAppHeader: getAppHeader,
32313
+ getData: getFormData,
32314
+ saveData: saveFormData,
32315
+ loading: formLoading,
32316
+ onSubmitted: (type, m, data) => {
32317
+ if (data.datastakeId) {
32318
+ displayMessage(type, t("affirmations::subject-created-successfully") || m);
32319
+ goTo(`/app/edit/documents/${data.datastakeId}`);
32320
+ }
32321
+ },
32322
+ onCancel: onDrawerClose,
32323
+ query: query,
32324
+ ajaxForms: ajaxForms,
32325
+ changeAjaxForms: changeAjaxForms,
32326
+ ajaxOptions: ajaxOptions,
32327
+ changeAjaxOptions: changeAjaxOptions,
32328
+ formData: formData,
32329
+ formValue: formValue,
32330
+ form: form
32331
+ })
32332
+ });
32333
+ };
32334
+
32335
+ const renderStatusTag$2 = ({
32336
+ value,
32337
+ t = s => s
32338
+ }) => {
32339
+ const width = 87;
32340
+ switch (value) {
32341
+ case "edited":
32342
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
32343
+ color: "yellow",
32344
+ style: {
32345
+ width
32346
+ },
32347
+ className: "text-center",
32348
+ children: t("Edited")
32349
+ });
32350
+ case "submitted":
32351
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
32352
+ color: "green",
32353
+ style: {
32354
+ width
32355
+ },
32356
+ className: "text-center",
32357
+ children: t("Submitted")
32358
+ });
32359
+ default:
32360
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
32361
+ color: "blue",
32362
+ style: {
32363
+ width
32364
+ },
32365
+ className: "text-center",
32366
+ children: t("Private")
32367
+ });
32368
+ }
32369
+ };
32370
+ const getColumns$3 = ({
32371
+ t,
32372
+ goTo,
32373
+ user,
32374
+ options,
32375
+ activeTab,
32376
+ getRedirectLink,
32377
+ theme,
32378
+ subject,
32379
+ data,
32380
+ applications
32381
+ }) => [
32382
+ // {
32383
+ // dataIndex: 'datastakeId',
32384
+ // title: t('ID'),
32385
+ // ellipsis: true,
32386
+ // show: true,
32387
+ // render: (v, all) => {
32388
+ // if (all.empty) {
32389
+ // return <div className="daf-default-cell" />
32390
+ // }
32391
+
32392
+ // return <Tooltip title={v}>{v}</Tooltip>;
32393
+ // },
32394
+ // },
32395
+ {
32396
+ dataIndex: 'name',
32397
+ title: t('Name'),
32398
+ ellipsis: true,
32399
+ show: true,
32400
+ render: (v, all) => {
32401
+ if (all.empty) {
32402
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32403
+ className: "daf-default-cell"
32404
+ });
32405
+ }
32406
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
32407
+ title: v,
32408
+ children: v
32409
+ });
32410
+ }
32411
+ }, {
32412
+ dataIndex: 'mineSite',
32413
+ title: t('Position'),
32414
+ ellipsis: true,
32415
+ show: true,
32416
+ render: (v, all) => {
32417
+ if (all.empty) {
32418
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32419
+ className: "daf-default-cell"
32420
+ });
32421
+ }
32422
+
32423
+ // const country = findOptions(v, data?.options?.positionSupplyChainOptions);
32424
+ const mineSite = all?.location?.name;
32425
+ return mineSite ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
32426
+ title: mineSite,
32427
+ children: mineSite
32428
+ }) : '-';
32429
+ }
32430
+ }, {
32431
+ dataIndex: 'activity',
32432
+ title: t('Activity'),
32433
+ ellipsis: true,
32434
+ show: true,
32435
+ render: (v, all) => {
32436
+ if (all.empty) {
32437
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32438
+ className: "daf-default-cell"
32439
+ });
32440
+ }
32441
+ const activity = findOptions(v, data?.options?.activityAtSiteOptions);
32442
+ return activity ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
32443
+ title: activity,
32444
+ children: activity
32445
+ }) : '-';
32446
+ }
32447
+ }, {
32448
+ dataIndex: 'origin',
32449
+ title: t('Origin'),
32450
+ ellipsis: true,
32451
+ show: true,
32452
+ render: (v, all) => {
32453
+ if (all.empty) {
32454
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32455
+ className: "daf-default-cell"
32456
+ });
32457
+ }
32458
+ const origin = all?.placeOfBirth?.name;
32459
+ return origin ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
32460
+ title: origin,
32461
+ children: origin
32462
+ }) : '-';
32463
+ }
32464
+ }, {
32465
+ title: t("Census Update"),
32466
+ dataIndex: "createdAt",
32467
+ key: "createdAt",
32468
+ render: (date, all) => {
32469
+ if (all.empty) {
32470
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32471
+ className: "daf-default-cell"
32472
+ });
32473
+ }
32474
+ const _date = date ? renderDateFormatted(date, "DD MMM YYYY", user?.language || 'en') : "-";
32475
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
32476
+ title: _date,
32477
+ children: _date
32478
+ });
32479
+ },
32480
+ ellipsis: true
32481
+ }, {
32482
+ title: t("Sources"),
32483
+ dataIndex: "sources",
32484
+ key: "sources",
32485
+ show: activeTab !== "own",
32486
+ render: (val, all) => {
32487
+ if (all.empty) {
32488
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32489
+ className: "daf-default-cell"
32490
+ });
32491
+ }
32492
+ sourceAvatarConfig(val, user, applications);
32493
+ return /*#__PURE__*/jsxRuntime.jsx(AvatarGroup, {
32494
+ items: val
32495
+ });
32496
+ }
32497
+ }, {
32498
+ title: t("Status"),
32499
+ dataIndex: "status",
32500
+ key: "status",
32501
+ show: activeTab === "own",
32502
+ render: (val, all) => {
32503
+ if (all.empty) {
32504
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32505
+ className: "daf-default-cell"
32506
+ });
32507
+ }
32508
+ const _val = all?.published || all?.status === "submitted" ? "submitted" : val;
32509
+ return renderStatusTag$2({
32510
+ value: _val,
32511
+ t
32512
+ });
32513
+ }
32514
+ }, {
32515
+ id: 'actions',
32516
+ title: "",
32517
+ width: 60,
32518
+ render: (_, all) => {
32519
+ if (all.empty) {
32520
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32521
+ className: "daf-default-cell"
32522
+ });
32523
+ }
32524
+ const link = `/app/view/${subject}/${all.datastakeId}`;
32525
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32526
+ style: {
32527
+ display: "flex",
32528
+ justifyContent: "center"
32529
+ },
32530
+ children: /*#__PURE__*/jsxRuntime.jsx("a", {
32531
+ href: getRedirectLink(link),
32532
+ children: /*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
32533
+ name: "Link",
32534
+ size: 15,
32535
+ color: theme.baseGray70
32536
+ })
32537
+ })
32538
+ });
32539
+ }
32540
+ }].filter(column => column.show !== false);
32541
+
32542
+ const checkboxConfig$3 = {
32543
+ name: 'Name',
32544
+ datastakeId: 'ID'
32545
+ };
32546
+ const getFiltersConfig$3 = ({
32547
+ t
32548
+ }) => {
32549
+ return {
32550
+ country: {
32551
+ type: 'select',
32552
+ label: 'Country',
32553
+ placeholder: t => `${t('Filter by')} ${t('Country').toLowerCase()}`,
32554
+ style: {
32555
+ flex: 1
32556
+ },
32557
+ labelStyle: {
32558
+ flex: 1
32559
+ },
32560
+ getLabel: option => option.label,
32561
+ getValue: option => option.value
32562
+ },
32563
+ administrativeLevel1: {
32564
+ type: 'ajaxSelect',
32565
+ label: ({
32566
+ t = s => s,
32567
+ options = {},
32568
+ filters = {},
32569
+ language = 'en'
32570
+ }) => {
32571
+ const {
32572
+ administrativeLevel1
32573
+ } = options;
32574
+ if (administrativeLevel1) {
32575
+ if (options.country) {
32576
+ const _item = administrativeLevel1[filters.country];
32577
+ if (_item) {
32578
+ if (_item[language]) {
32579
+ return _item[language];
32580
+ }
32581
+ }
32582
+ }
32583
+ }
32584
+ return t('Province');
32585
+ },
32586
+ placeholder: t => `${t('Filter by')} ${t('Province').toLowerCase()}`,
32587
+ filters: data => ({
32588
+ country: data.country,
32589
+ level: 'level_1'
32590
+ }),
32591
+ show: data => !data.country,
32592
+ disabled: data => !data.country,
32593
+ mapper: {
32594
+ label: "name",
32595
+ value: "id"
32596
+ },
32597
+ method: 'getOptions',
32598
+ entity: 'AdministrativeLevel',
32599
+ style: {
32600
+ flex: 1
32601
+ },
32602
+ labelStyle: {
32603
+ flex: 1
32604
+ }
32605
+ },
32606
+ administrativeLevel2: {
32607
+ type: 'ajaxSelect',
32608
+ label: ({
32609
+ t = s => s,
32610
+ options = {},
32611
+ filters = {},
32612
+ language = 'en'
32613
+ }) => {
32614
+ const {
32615
+ administrativeLevel2
32616
+ } = options;
32617
+ if (administrativeLevel2) {
32618
+ if (options.country) {
32619
+ const _item = administrativeLevel2[filters.country];
32620
+ if (_item) {
32621
+ if (_item[language]) {
32622
+ return _item[language];
32623
+ }
32624
+ }
32625
+ }
32626
+ }
32627
+ return t('Province');
32628
+ },
32629
+ show: data => !(data.country && data.administrativeLevel1),
32630
+ placeholder: t => `${t('Filter by')} ${t('Territory').toLowerCase()}`,
32631
+ filters: data => ({
32632
+ country: data.country,
32633
+ level: 'level_2',
32634
+ administrativeLevel1: data.administrativeLevel1
32635
+ }),
32636
+ disabled: data => !(data.country && data.administrativeLevel1),
32637
+ mapper: {
32638
+ label: "name",
32639
+ value: "id"
32640
+ },
32641
+ method: 'getOptions',
32642
+ entity: 'AdministrativeLevel',
32643
+ style: {
32644
+ flex: 1
32645
+ },
32646
+ labelStyle: {
32647
+ flex: 1
32648
+ }
32649
+ },
32650
+ activity: {
32651
+ type: 'select',
32652
+ label: 'Activity',
32653
+ placeholder: t => `${t('Filter by')} ${t('Activity').toLowerCase()}`,
32654
+ style: {
32655
+ flex: 1
32656
+ },
32657
+ labelStyle: {
32658
+ flex: 1
32659
+ },
32660
+ getLabel: option => option.label,
32661
+ getValue: option => option.value,
32662
+ filterOptions: val => {
32663
+ if (val) {
32664
+ const {
32665
+ option,
32666
+ filters
32667
+ } = val;
32668
+ if (filters && option) {
32669
+ const {
32670
+ filters: optionFilters
32671
+ } = option;
32672
+ if (Array.isArray(optionFilters) && optionFilters.length) {
32673
+ const {
32674
+ value,
32675
+ condition
32676
+ } = optionFilters[0];
32677
+ if (condition === 'includes') {
32678
+ return value.includes('corporation');
32679
+ }
32680
+ }
32681
+ }
32682
+ }
32683
+ return true;
32684
+ }
32685
+ },
32686
+ positionInTheMineralSupplyChain: {
32687
+ type: 'select',
32688
+ label: 'Position',
32689
+ placeholder: t => `${t('Filter by')} ${t('Position').toLowerCase()}`,
32690
+ style: {
32691
+ flex: 1
32692
+ },
32693
+ labelStyle: {
32694
+ flex: 1
32695
+ },
32696
+ getLabel: option => option.label,
32697
+ getValue: option => option.value
32698
+ },
32699
+ status: {
32700
+ type: "select",
32701
+ label: "Status",
32702
+ placeholder: t => `${t("Filter by")} ${t("Status").toLowerCase()}`,
32703
+ style: {
32704
+ flex: 1
32705
+ },
32706
+ labelStyle: {
32707
+ fley: 1
32708
+ },
32709
+ getLabel: option => option.label,
32710
+ getValue: option => option.value
32711
+ }
32712
+ };
32713
+ };
32714
+ const filtersConfig$3 = {
32715
+ name: '',
32716
+ datastakeId: ''
32717
+ };
32718
+ const getFilterOptions$3 = (options, t) => {
32719
+ const {
32720
+ statusOptions = [],
32721
+ categoryOptions = [],
32722
+ countries = [],
32723
+ subCategory = [],
32724
+ activityAtSiteOptions = [],
32725
+ stakeholderCategoryOptions,
32726
+ stakeholderSubCategoriesOptions,
32727
+ administrativeLevel1,
32728
+ administrativeLevel2,
32729
+ positionInMineralSupplyChainOptions,
32730
+ subCategoriesOptions
32731
+ } = options || {};
32732
+ const _default = {
32733
+ status: [{
32734
+ value: "submitted",
32735
+ label: "Submitted"
32736
+ }, {
32737
+ value: "private",
32738
+ label: "Private"
32739
+ }],
32740
+ category: stakeholderCategoryOptions || categoryOptions,
32741
+ country: countries,
32742
+ subCategory: subCategoriesOptions,
32743
+ activity: activityAtSiteOptions,
32744
+ administrativeLevel1,
32745
+ administrativeLevel2,
32746
+ positionInTheMineralSupplyChain: positionInMineralSupplyChainOptions
32747
+ };
32748
+ return _default;
32749
+ };
32750
+
32751
+ const StakeholdersCreate$2 = ({
32752
+ namespace = "WORKERS",
32753
+ view = ['scoping', 'new'],
32754
+ edit = false,
32755
+ formData = {},
32756
+ loading = false,
32757
+ onSubmitted = () => {},
32758
+ onCancel = () => {},
32759
+ getData = () => {},
32760
+ saveData = () => {},
32761
+ form: formConfig = {},
32762
+ formValue = {},
32763
+ defaultData = {},
32764
+ user = {},
32765
+ APP,
32766
+ query,
32767
+ goTo = () => {},
32768
+ t = () => {},
32769
+ ajaxForms = {},
32770
+ changeAjaxForms = () => {},
32771
+ ajaxOptions = {},
32772
+ changeAjaxOptions = () => {},
32773
+ getAppHeader = () => {},
32774
+ getApiBaseUrl = () => {}
32775
+ }) => {
32776
+ let {
32777
+ form = {},
32778
+ data = defaultData || {}
32779
+ } = !edit ? formData[`${APP}-${view}`] || {} : {
32780
+ form: formConfig,
32781
+ data: formValue
32782
+ };
32783
+ React.useEffect(() => {
32784
+ if (Object.keys(form).length === 0 && !formData[`${APP}-${view}`]) {
32785
+ if (!edit) {
32786
+ getData({
32787
+ namespace,
32788
+ module: APP,
32789
+ view,
32790
+ scope: 'global'
32791
+ });
32792
+ } else {
32793
+ form = formConfig;
32794
+ data = formValue;
32795
+ }
32796
+ }
32797
+ }, [edit, user?.language]);
32798
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32799
+ className: "daf-create-form",
32800
+ children: /*#__PURE__*/jsxRuntime.jsx(DynamicForm, {
32801
+ form: form,
32802
+ data: {
32803
+ ...defaultData,
32804
+ ...data
32805
+ },
32806
+ showSaveAndNext: false,
32807
+ module: APP,
32808
+ onCancel: onCancel,
32809
+ isCreate: true,
32810
+ t: t,
32811
+ excludedKeys: ["title"],
32812
+ user: user,
32813
+ ajaxForms: ajaxForms,
32814
+ ajaxOptions: ajaxOptions,
32815
+ getAppHeader: getAppHeader,
32816
+ getApiBaseUrl: getApiBaseUrl,
32817
+ changeAjaxOptions: changeAjaxOptions,
32818
+ app: APP,
32819
+ query: query,
32820
+ goTo: goTo,
32821
+ changeAjaxForms: changeAjaxForms,
32822
+ submit: (payload, setSelectedFormNext) => {
32823
+ const payloadData = {
32824
+ ...payload,
32825
+ module: APP,
32826
+ namespace
32827
+ };
32828
+ const newPayload = {
32829
+ ...defaultData,
32830
+ ...payloadData,
32831
+ form: 'worker'
32832
+ };
32833
+ const callback = (type, m, data) => {
32834
+ if (setSelectedFormNext) {
32835
+ setSelectedFormNext();
32836
+ }
32837
+ if (type === MessageTypes.SUCCESS) {
32838
+ if (onSubmitted) onSubmitted(type, m, data);
32839
+ } else {
32840
+ antd.message.error(m);
32841
+ }
32842
+ };
32843
+ saveData(!data && !data.id ? newPayload : Object.assign(newPayload, {
32844
+ id: data.id
32845
+ }), callback);
32846
+ },
32847
+ isFormDisabled: () => {
32848
+ return !data || !data.typeOfEvent;
32849
+ }
32850
+ })
32851
+ });
32852
+ };
32853
+
32854
+ const WorkersTable = ({
32855
+ t = () => {},
32856
+ goTo = () => {},
32857
+ user = {},
32858
+ options = {},
32859
+ getRedirectLink = () => {},
32860
+ theme = {},
32861
+ loading = false,
32862
+ data = {},
32863
+ isMobile,
32864
+ APP,
32865
+ location,
32866
+ getData = () => {},
32867
+ getApiBaseUrl = () => {},
32868
+ getAppHeader = () => {},
32869
+ getFormData = () => {},
32870
+ saveFormData = () => {},
32871
+ formLoading = false,
32872
+ query = {},
32873
+ ajaxForms = {},
32874
+ changeAjaxForms = () => {},
32875
+ ajaxOptions = {},
32876
+ changeAjaxOptions = () => {},
32877
+ formData = {},
32878
+ formValue = {},
32879
+ form = {},
32880
+ extendingFilters = {},
32881
+ createDefaultValues = {},
32882
+ applications = []
32883
+ }) => {
32884
+ const [selectOptions, setSelectOptions] = React.useState();
32885
+ const [activeTab, setActiveTab] = React.useState();
32886
+ const columns = React.useMemo(() => getColumns$3({
32887
+ t,
32888
+ goTo,
32889
+ user,
32890
+ options,
32891
+ activeTab,
32892
+ getRedirectLink,
32893
+ theme,
32894
+ subject: 'workers',
32895
+ data,
32896
+ applications
32897
+ }), [t, goTo, user, options, activeTab, getRedirectLink, theme, data, applications]);
32898
+ const breadCrumbs = [];
32899
+ const {
32900
+ paginationQuery,
32901
+ searchParams,
32902
+ otherParams,
32903
+ sortBy,
32904
+ sortDir
32905
+ } = useGetQueryParams({
32906
+ location
32907
+ });
32908
+ React.useMemo(() => {
32909
+ return {
32910
+ ...otherParams,
32911
+ ...extendingFilters
32912
+ };
32913
+ }, [otherParams, extendingFilters]);
32914
+ React.useEffect(() => {
32915
+ getData({
32916
+ pagination: paginationQuery,
32917
+ ...(Object.keys(searchParams).length > 0 && {
32918
+ search: searchParams
32919
+ }),
32920
+ ...otherParams,
32921
+ tab: activeTab,
32922
+ sortBy: {
32923
+ [sortBy || "updatedAt"]: sortDir ? sortDir === "ascend" ? 1 : -1 : -1
32924
+ },
32925
+ ...extendingFilters
32926
+ }, 'workers');
32927
+ }, [location.search, activeTab, JSON.stringify(extendingFilters)]);
32928
+ const selectFiltersConfig = React.useMemo(() => {
32929
+ return getFiltersConfig$3({
32930
+ t
32931
+ });
32932
+ }, [t]);
32933
+ React.useEffect(() => {
32934
+ setSelectOptions(prev => ({
32935
+ ...prev,
32936
+ ...getFilterOptions$3(options)
32937
+ }));
32938
+ }, [options, t]);
32939
+ const handleActiveTabChange = React.useCallback(value => {
32940
+ setActiveTab(value);
32941
+ }, []);
32942
+ return /*#__PURE__*/jsxRuntime.jsx(TablePageWithTabs, {
32943
+ t: t,
32944
+ title: t("Workers"),
32945
+ breadCrumbs: breadCrumbs,
32946
+ location: location,
32947
+ loading: loading,
32948
+ goTo: goTo,
32949
+ defaultActiveTab: "all",
32950
+ columns: columns,
32951
+ data: data,
32952
+ checkboxConfig: checkboxConfig$3,
32953
+ APP: APP,
32954
+ getApiBaseUrl: getApiBaseUrl,
32955
+ selectOptions: selectOptions,
32956
+ selectFiltersConfig: selectFiltersConfig,
32957
+ getRedirectLink: getRedirectLink,
32958
+ filtersConfig: filtersConfig$3,
32959
+ isMobile: isMobile,
32960
+ view: "workers",
32961
+ getActiveTab: handleActiveTabChange,
32962
+ onDownload: () => {
32963
+ console.log("download");
32964
+ },
32965
+ drawerTitle: t("Create Worker"),
32966
+ children: ({
32967
+ onDrawerClose
32968
+ }) => /*#__PURE__*/jsxRuntime.jsx(StakeholdersCreate$2, {
32969
+ defaultData: createDefaultValues,
32970
+ t: t,
32971
+ goTo: goTo,
32972
+ user: user,
32973
+ APP: APP,
32974
+ getApiBaseUrl: getApiBaseUrl,
32975
+ getAppHeader: getAppHeader,
32976
+ getData: getFormData,
32977
+ saveData: saveFormData,
32978
+ loading: formLoading,
32979
+ onSubmitted: (type, m, data) => {
32980
+ if (data.datastakeId) {
32981
+ displayMessage(type, t("affirmations::subject-created-successfully") || m);
32982
+ // goTo(`/app/edit/stakeholders/${data.datastakeId}`);
32983
+ goTo(`/app/edit/workers/${data.datastakeId}`);
32984
+ }
32985
+ },
32986
+ onCancel: onDrawerClose,
32987
+ query: query,
32988
+ ajaxForms: ajaxForms,
32989
+ changeAjaxForms: changeAjaxForms,
32990
+ ajaxOptions: ajaxOptions,
32991
+ changeAjaxOptions: changeAjaxOptions,
32992
+ formData: formData,
32993
+ formValue: formValue,
32994
+ form: form
32995
+ })
32996
+ });
32997
+ };
32998
+
32999
+ const getLinkValue$2 = (value, linkingObject) => {
33000
+ if (linkingObject && linkingObject?.[value]) {
33001
+ return linkingObject?.[value]?.name;
33002
+ }
33003
+ return null;
33004
+ };
33005
+ const getEventCategoryBySubject$1 = (eventCategoryObject, subject) => {
33006
+ if (!eventCategoryObject || typeof eventCategoryObject !== 'object') {
33007
+ return null;
33008
+ }
33009
+ const subjectSingular = subject.endsWith('ies') ? subject.slice(0, -3) + 'y' : subject.endsWith('s') ? subject.slice(0, -1) : subject;
33010
+ const key = `typeOfEvent is ${subjectSingular}`;
33011
+ return eventCategoryObject[key] || null;
33012
+ };
33013
+ const renderStatusTag$1 = ({
33014
+ value,
33015
+ t = s => s
33016
+ }) => {
33017
+ const width = 87;
33018
+ switch (value) {
33019
+ case "edited":
33020
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
33021
+ color: "yellow",
33022
+ style: {
33023
+ width
33024
+ },
33025
+ className: "text-center",
33026
+ children: t("Edited")
33027
+ });
33028
+ case "submitted":
33029
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
33030
+ color: "green",
33031
+ style: {
33032
+ width
33033
+ },
33034
+ className: "text-center",
33035
+ children: t("Submitted")
33036
+ });
33037
+ default:
33038
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
33039
+ color: "blue",
33040
+ style: {
33041
+ width
33042
+ },
33043
+ className: "text-center",
33044
+ children: t("Private")
33045
+ });
33046
+ }
33047
+ };
33048
+ const getColumns$2 = ({
33049
+ t,
33050
+ goTo,
33051
+ user,
33052
+ options,
33053
+ activeTab,
33054
+ getRedirectLink,
33055
+ theme,
33056
+ subject,
33057
+ data,
33058
+ applications
33059
+ }) => [{
33060
+ dataIndex: 'datastakeId',
33061
+ title: t('ID'),
33062
+ ellipsis: true,
33063
+ show: true,
33064
+ render: (v, all) => {
33065
+ if (all.empty) {
33066
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
33067
+ className: "daf-default-cell"
33068
+ });
33069
+ }
33070
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
33071
+ title: v,
33072
+ children: v
33073
+ });
33074
+ }
33075
+ }, {
33076
+ dataIndex: 'name',
33077
+ title: t('Title'),
33078
+ ellipsis: true,
33079
+ show: true,
33080
+ render: (v, all) => {
33081
+ if (all.empty) {
33082
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
33083
+ className: "daf-default-cell"
33084
+ });
33085
+ }
33086
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
33087
+ title: v,
33088
+ children: v
33089
+ });
33090
+ }
33091
+ }, {
33092
+ title: t("Date"),
33093
+ dataIndex: "date",
33094
+ key: "date",
33095
+ render: (date, all) => {
33096
+ if (all.empty) {
33097
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
33098
+ className: "daf-default-cell"
33099
+ });
33100
+ }
33101
+ const _date = date ? renderDateFormatted(date, "DD MMM YYYY", user?.language || 'en') : "-";
33102
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
33103
+ title: _date,
33104
+ children: _date
33105
+ });
33106
+ },
33107
+ ellipsis: true
33108
+ }, {
33109
+ dataIndex: 'mineSite',
33110
+ title: t('Location'),
33111
+ ellipsis: true,
33112
+ show: true,
33113
+ render: (v, all) => {
33114
+ if (all.empty) {
33115
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
33116
+ className: "daf-default-cell"
33117
+ });
33118
+ }
33119
+
33120
+ // const country = findOptions(v, data?.options?.positionSupplyChainOptions);
33121
+ const mineSite = all?.location?.name;
33122
+ return mineSite ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
33123
+ title: mineSite,
33124
+ children: mineSite
33125
+ }) : '-';
33126
+ }
33127
+ }, {
33128
+ dataIndex: 'province',
33129
+ title: t('Province'),
33130
+ ellipsis: true,
33131
+ show: true,
33132
+ render: (v, all) => {
33133
+ if (all.empty) {
33134
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
33135
+ className: "daf-default-cell"
33136
+ });
33137
+ }
33138
+ const region = getLinkValue$2(all?.location?.administrativeLevel1, all?.location?.linking?.SCL);
33139
+ return region ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
33140
+ title: region,
33141
+ children: region
33142
+ }) : '-';
33143
+ }
33144
+ }, {
33145
+ dataIndex: 'territory',
33146
+ title: t('Territory'),
33147
+ ellipsis: true,
33148
+ show: true,
33149
+ render: (v, all) => {
33150
+ if (all.empty) {
33151
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
33152
+ className: "daf-default-cell"
33153
+ });
33154
+ }
33155
+ const district = getLinkValue$2(all?.location?.administrativeLevel2, all?.location?.linking?.SCL);
33156
+ return district ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
33157
+ title: district,
33158
+ children: district
33159
+ }) : '-';
33160
+ }
33161
+ }, {
33162
+ dataIndex: 'eventCategory',
33163
+ title: t('Category'),
33164
+ ellipsis: true,
33165
+ show: true,
33166
+ render: (v, all) => {
33167
+ if (all.empty) {
33168
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
33169
+ className: "daf-default-cell"
33170
+ });
33171
+ }
33172
+ const eventCategory = findOptions(v, data?.options?.eventCategoryOptions);
33173
+ const categoryValue = getEventCategoryBySubject$1(eventCategory, subject);
33174
+ return categoryValue ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
33175
+ title: categoryValue,
33176
+ children: categoryValue
33177
+ }) : '-';
33178
+ }
33179
+ }, {
33180
+ title: t("Sources"),
33181
+ dataIndex: "sources",
33182
+ key: "sources",
33183
+ show: activeTab !== "own",
33184
+ render: (val, all) => {
33185
+ if (all.empty) {
33186
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
33187
+ className: "daf-default-cell"
33188
+ });
33189
+ }
33190
+ const sources = sourceAvatarConfig(val, user, applications);
33191
+ return /*#__PURE__*/jsxRuntime.jsx(AvatarGroup, {
33192
+ items: sources
33193
+ });
33194
+ }
33195
+ }, {
33196
+ title: t("Status"),
33197
+ dataIndex: "status",
33198
+ key: "status",
33199
+ show: activeTab === "own",
33200
+ render: (val, all) => {
33201
+ if (all.empty) {
33202
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
33203
+ className: "daf-default-cell"
33204
+ });
33205
+ }
33206
+ const _val = all?.published || all?.status === "submitted" ? "submitted" : val;
33207
+ return renderStatusTag$1({
33208
+ value: _val,
33209
+ t
33210
+ });
33211
+ }
33212
+ }, {
33213
+ title: t("Last Update"),
33214
+ dataIndex: "updatedAt",
33215
+ key: "updatedAt",
33216
+ render: (date, all) => {
33217
+ if (all.empty) {
33218
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
33219
+ className: "daf-default-cell"
33220
+ });
33221
+ }
33222
+ const _date = date ? renderDateFormatted(date, "DD MMM YYYY", user?.language || 'en') : "-";
33223
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
33224
+ title: _date,
33225
+ children: _date
33226
+ });
33227
+ },
33228
+ ellipsis: true
33229
+ }, {
33230
+ id: 'actions',
33231
+ title: "",
33232
+ width: 60,
33233
+ render: (_, all) => {
33234
+ if (all.empty) {
33235
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
33236
+ className: "daf-default-cell"
33237
+ });
33238
+ }
33239
+ const link = `/app/view/${subject}/${all.datastakeId}`;
33240
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
33241
+ style: {
33242
+ display: "flex",
33243
+ justifyContent: "center"
33244
+ },
33245
+ children: /*#__PURE__*/jsxRuntime.jsx("a", {
33246
+ href: getRedirectLink(link),
33247
+ children: /*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
33248
+ name: "Link",
33249
+ size: 15,
33250
+ color: theme.baseGray70
33251
+ })
33252
+ })
33253
+ });
33254
+ }
33255
+ }].filter(column => column.show !== false);
33256
+
33257
+ const checkboxConfig$2 = {
33258
+ name: 'Name',
33259
+ datastakeId: 'ID'
33260
+ };
33261
+ const getFiltersConfig$2 = ({
33262
+ t
33263
+ }) => {
33264
+ return {
33265
+ country: {
33266
+ type: 'select',
33267
+ label: 'Country',
33268
+ placeholder: t => `${t('Filter by')} ${t('Country').toLowerCase()}`,
33269
+ style: {
33270
+ flex: 1
33271
+ },
33272
+ labelStyle: {
33273
+ flex: 1
33274
+ },
33275
+ getLabel: option => option.label,
33276
+ getValue: option => option.value
33277
+ },
33278
+ administrativeLevel1: {
33279
+ type: 'ajaxSelect',
33280
+ label: ({
33281
+ t = s => s,
33282
+ options = {},
33283
+ filters = {},
33284
+ language = 'en'
33285
+ }) => {
33286
+ const {
33287
+ administrativeLevel1
33288
+ } = options;
33289
+ if (administrativeLevel1) {
33290
+ if (options.country) {
33291
+ const _item = administrativeLevel1[filters.country];
33292
+ if (_item) {
33293
+ if (_item[language]) {
33294
+ return _item[language];
33295
+ }
33296
+ }
33297
+ }
33298
+ }
33299
+ return t('Province');
33300
+ },
33301
+ placeholder: t => `${t('Filter by')} ${t('Province').toLowerCase()}`,
33302
+ filters: data => ({
33303
+ country: data.country,
33304
+ level: 'level_1'
33305
+ }),
33306
+ show: data => !data.country,
33307
+ disabled: data => !data.country,
33308
+ mapper: {
33309
+ label: "name",
33310
+ value: "id"
33311
+ },
33312
+ method: 'getOptions',
33313
+ entity: 'AdministrativeLevel',
33314
+ style: {
33315
+ flex: 1
33316
+ },
33317
+ labelStyle: {
33318
+ flex: 1
33319
+ }
33320
+ },
33321
+ administrativeLevel2: {
33322
+ type: 'ajaxSelect',
33323
+ label: ({
33324
+ t = s => s,
33325
+ options = {},
33326
+ filters = {},
33327
+ language = 'en'
33328
+ }) => {
33329
+ const {
33330
+ administrativeLevel2
33331
+ } = options;
33332
+ if (administrativeLevel2) {
33333
+ if (options.country) {
33334
+ const _item = administrativeLevel2[filters.country];
33335
+ if (_item) {
33336
+ if (_item[language]) {
33337
+ return _item[language];
33338
+ }
33339
+ }
33340
+ }
33341
+ }
33342
+ return t('Province');
33343
+ },
33344
+ show: data => !(data.country && data.administrativeLevel1),
33345
+ placeholder: t => `${t('Filter by')} ${t('Territory').toLowerCase()}`,
33346
+ filters: data => ({
33347
+ country: data.country,
33348
+ level: 'level_2',
33349
+ administrativeLevel1: data.administrativeLevel1
33350
+ }),
33351
+ disabled: data => !(data.country && data.administrativeLevel1),
33352
+ mapper: {
33353
+ label: "name",
33354
+ value: "id"
33355
+ },
33356
+ method: 'getOptions',
33357
+ entity: 'AdministrativeLevel',
33358
+ style: {
33359
+ flex: 1
33360
+ },
33361
+ labelStyle: {
33362
+ flex: 1
33363
+ }
33364
+ },
33365
+ activity: {
33366
+ type: 'select',
33367
+ label: 'Activity',
33368
+ placeholder: t => `${t('Filter by')} ${t('Activity').toLowerCase()}`,
33369
+ style: {
33370
+ flex: 1
33371
+ },
33372
+ labelStyle: {
33373
+ flex: 1
33374
+ },
33375
+ getLabel: option => option.label,
33376
+ getValue: option => option.value,
33377
+ filterOptions: val => {
33378
+ if (val) {
33379
+ const {
33380
+ option,
33381
+ filters
33382
+ } = val;
33383
+ if (filters && option) {
33384
+ const {
33385
+ filters: optionFilters
33386
+ } = option;
33387
+ if (Array.isArray(optionFilters) && optionFilters.length) {
33388
+ const {
33389
+ value,
33390
+ condition
33391
+ } = optionFilters[0];
33392
+ if (condition === 'includes') {
33393
+ return value.includes('corporation');
33394
+ }
33395
+ }
33396
+ }
33397
+ }
33398
+ return true;
33399
+ }
33400
+ },
33401
+ positionInTheMineralSupplyChain: {
33402
+ type: 'select',
33403
+ label: 'Position',
33404
+ placeholder: t => `${t('Filter by')} ${t('Position').toLowerCase()}`,
33405
+ style: {
33406
+ flex: 1
33407
+ },
33408
+ labelStyle: {
33409
+ flex: 1
33410
+ },
33411
+ getLabel: option => option.label,
33412
+ getValue: option => option.value
33413
+ },
33414
+ status: {
33415
+ type: "select",
33416
+ label: "Status",
33417
+ placeholder: t => `${t("Filter by")} ${t("Status").toLowerCase()}`,
33418
+ style: {
33419
+ flex: 1
33420
+ },
33421
+ labelStyle: {
33422
+ fley: 1
33423
+ },
33424
+ getLabel: option => option.label,
33425
+ getValue: option => option.value
33426
+ }
33427
+ };
33428
+ };
33429
+ const filtersConfig$2 = {
33430
+ name: '',
33431
+ datastakeId: ''
33432
+ };
33433
+ const getFilterOptions$2 = (options, t) => {
33434
+ const {
33435
+ statusOptions = [],
33436
+ categoryOptions = [],
33437
+ countries = [],
33438
+ subCategory = [],
33439
+ activityAtSiteOptions = [],
33440
+ stakeholderCategoryOptions,
33441
+ stakeholderSubCategoriesOptions,
33442
+ administrativeLevel1,
33443
+ administrativeLevel2,
33444
+ positionInMineralSupplyChainOptions,
33445
+ subCategoriesOptions
33446
+ } = options || {};
33447
+ const _default = {
33448
+ status: [{
33449
+ value: "submitted",
33450
+ label: "Submitted"
33451
+ }, {
33452
+ value: "private",
33453
+ label: "Private"
33454
+ }],
33455
+ category: stakeholderCategoryOptions || categoryOptions,
33456
+ country: countries,
33457
+ subCategory: subCategoriesOptions,
33458
+ activity: activityAtSiteOptions,
33459
+ administrativeLevel1,
33460
+ administrativeLevel2,
33461
+ positionInTheMineralSupplyChain: positionInMineralSupplyChainOptions
33462
+ };
33463
+ return _default;
33464
+ };
33465
+
33466
+ const StakeholdersCreate$1 = ({
33467
+ namespace = "corrective-actions",
33468
+ view = "corrective-actions",
33469
+ edit = false,
33470
+ formData = {},
33471
+ loading = false,
33472
+ onSubmitted = () => {},
33473
+ onCancel = () => {},
33474
+ getData = () => {},
33475
+ saveData = () => {},
33476
+ form: formConfig = {},
33477
+ formValue = {},
33478
+ defaultData = {},
33479
+ user = {},
33480
+ APP,
33481
+ query,
33482
+ goTo = () => {},
33483
+ t = () => {},
33484
+ ajaxForms = {},
33485
+ changeAjaxForms = () => {},
33486
+ ajaxOptions = {},
33487
+ changeAjaxOptions = () => {},
33488
+ getAppHeader = () => {},
33489
+ getApiBaseUrl = () => {}
33490
+ }) => {
33491
+ let {
33492
+ form = {},
33493
+ data = defaultData || {}
33494
+ } = !edit ? formData[`${APP}-${view}`] || {} : {
33495
+ form: formConfig,
33496
+ data: formValue
33497
+ };
33498
+ React.useEffect(() => {
33499
+ if (Object.keys(form).length === 0 && !formData[`${APP}-${view}`]) {
33500
+ if (!edit) {
33501
+ getData({
33502
+ namespace,
33503
+ module: APP,
33504
+ view,
33505
+ scope: 'createActivity'
33506
+ });
33507
+ } else {
33508
+ form = formConfig;
33509
+ data = formValue;
33510
+ }
33511
+ }
33512
+ }, [edit, user?.language]);
33513
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
33514
+ className: "daf-create-form",
33515
+ children: /*#__PURE__*/jsxRuntime.jsx(DynamicForm, {
33516
+ form: form,
33517
+ data: {
33518
+ ...defaultData,
33519
+ ...data
33520
+ },
33521
+ showSaveAndNext: false,
33522
+ module: APP,
33523
+ onCancel: onCancel,
33524
+ isCreate: true,
33525
+ t: t,
33526
+ excludedKeys: ["title"],
33527
+ user: user,
33528
+ ajaxForms: ajaxForms,
33529
+ ajaxOptions: ajaxOptions,
33530
+ getAppHeader: getAppHeader,
33531
+ getApiBaseUrl: getApiBaseUrl,
33532
+ changeAjaxOptions: changeAjaxOptions,
33533
+ app: APP,
33534
+ query: query,
33535
+ goTo: goTo,
33536
+ changeAjaxForms: changeAjaxForms,
33537
+ submit: (payload, setSelectedFormNext) => {
33538
+ const payloadData = {
33539
+ ...payload,
33540
+ module: APP,
33541
+ namespace
33542
+ };
33543
+ const newPayload = {
33544
+ ...defaultData,
33545
+ ...payloadData,
33546
+ form: 'worker'
33547
+ };
33548
+ const callback = (type, m, data) => {
33549
+ if (setSelectedFormNext) {
33550
+ setSelectedFormNext();
33551
+ }
33552
+ if (type === MessageTypes.SUCCESS) {
33553
+ if (onSubmitted) onSubmitted(type, m, data);
33554
+ } else {
33555
+ antd.message.error(m);
33556
+ }
33557
+ };
33558
+ saveData(!data && !data.id ? newPayload : Object.assign(newPayload, {
33559
+ id: data.id
33560
+ }), callback);
33561
+ },
33562
+ isFormDisabled: () => {
33563
+ return !data || !data.typeOfEvent;
33564
+ }
33565
+ })
33566
+ });
33567
+ };
33568
+
33569
+ const ActivitiesTable = ({
33570
+ t = () => {},
33571
+ goTo = () => {},
33572
+ user = {},
33573
+ options = {},
33574
+ getRedirectLink = () => {},
33575
+ theme = {},
33576
+ loading = false,
33577
+ data = {},
33578
+ isMobile,
33579
+ APP,
33580
+ location,
33581
+ getData = () => {},
33582
+ getApiBaseUrl = () => {},
33583
+ getAppHeader = () => {},
33584
+ getFormData = () => {},
33585
+ saveFormData = () => {},
33586
+ formLoading = false,
33587
+ query = {},
33588
+ ajaxForms = {},
33589
+ changeAjaxForms = () => {},
33590
+ ajaxOptions = {},
33591
+ changeAjaxOptions = () => {},
33592
+ formData = {},
33593
+ formValue = {},
33594
+ form = {},
33595
+ extendingFilters = {},
33596
+ createDefaultValues = {},
33597
+ applications = []
33598
+ }) => {
33599
+ const [selectOptions, setSelectOptions] = React.useState();
33600
+ const [activeTab, setActiveTab] = React.useState();
33601
+ const columns = React.useMemo(() => getColumns$2({
33602
+ t,
33603
+ goTo,
33604
+ user,
33605
+ options,
33606
+ activeTab,
33607
+ getRedirectLink,
33608
+ theme,
33609
+ subject: 'activities',
33610
+ data,
33611
+ applications
33612
+ }), [t, goTo, user, options, activeTab, getRedirectLink, theme, data, applications]);
33613
+ const breadCrumbs = [];
33614
+ const {
33615
+ paginationQuery,
33616
+ searchParams,
33617
+ otherParams,
33618
+ sortBy,
33619
+ sortDir
33620
+ } = useGetQueryParams({
33621
+ location
33622
+ });
33623
+ React.useMemo(() => {
33624
+ return {
33625
+ ...otherParams,
33626
+ ...extendingFilters
33627
+ };
33628
+ }, [otherParams, extendingFilters]);
33629
+ React.useEffect(() => {
33630
+ getData({
33631
+ pagination: paginationQuery,
33632
+ ...(Object.keys(searchParams).length > 0 && {
33633
+ search: searchParams
33634
+ }),
33635
+ ...otherParams,
33636
+ tab: activeTab,
33637
+ sortBy: {
33638
+ [sortBy || "updatedAt"]: sortDir ? sortDir === "ascend" ? 1 : -1 : -1
33639
+ },
33640
+ ...extendingFilters
33641
+ }, 'activities');
33642
+ }, [location.search, activeTab, JSON.stringify(extendingFilters)]);
33643
+ const selectFiltersConfig = React.useMemo(() => {
33644
+ return getFiltersConfig$2({
33645
+ t
33646
+ });
33647
+ }, [t]);
33648
+ React.useEffect(() => {
33649
+ setSelectOptions(prev => ({
33650
+ ...prev,
33651
+ ...getFilterOptions$2(options)
33652
+ }));
33653
+ }, [options, t]);
33654
+ const handleActiveTabChange = React.useCallback(value => {
33655
+ setActiveTab(value);
33656
+ }, []);
33657
+ return /*#__PURE__*/jsxRuntime.jsx(TablePageWithTabs, {
33658
+ t: t,
33659
+ title: t("Activities"),
33660
+ breadCrumbs: breadCrumbs,
33661
+ location: location,
33662
+ loading: loading,
33663
+ goTo: goTo,
33664
+ defaultActiveTab: "all",
33665
+ columns: columns,
33666
+ data: data,
33667
+ checkboxConfig: checkboxConfig$2,
33668
+ APP: APP,
33669
+ getApiBaseUrl: getApiBaseUrl,
33670
+ selectOptions: selectOptions,
33671
+ selectFiltersConfig: selectFiltersConfig,
33672
+ getRedirectLink: getRedirectLink,
33673
+ filtersConfig: filtersConfig$2,
33674
+ isMobile: isMobile,
33675
+ view: "activities",
33676
+ getActiveTab: handleActiveTabChange,
33677
+ onDownload: () => {
33678
+ console.log("download");
33679
+ },
33680
+ drawerTitle: t("Create Activity"),
33681
+ children: ({
33682
+ onDrawerClose
33683
+ }) => /*#__PURE__*/jsxRuntime.jsx(StakeholdersCreate$1, {
33684
+ defaultData: createDefaultValues,
33685
+ t: t,
33686
+ goTo: goTo,
33687
+ user: user,
33688
+ APP: APP,
33689
+ getApiBaseUrl: getApiBaseUrl,
33690
+ getAppHeader: getAppHeader,
33691
+ getData: getFormData,
33692
+ saveData: saveFormData,
33693
+ loading: formLoading,
33694
+ onSubmitted: (type, m, data) => {
33695
+ if (data.datastakeId) {
33696
+ displayMessage(type, t("affirmations::subject-created-successfully") || m);
33697
+ // goTo(`/app/edit/stakeholders/${data.datastakeId}`);
33698
+ goTo(`/app/edit/activities/${data.datastakeId}`);
33699
+ }
33700
+ },
33701
+ onCancel: onDrawerClose,
33702
+ query: query,
33703
+ ajaxForms: ajaxForms,
33704
+ changeAjaxForms: changeAjaxForms,
33705
+ ajaxOptions: ajaxOptions,
33706
+ changeAjaxOptions: changeAjaxOptions,
33707
+ formData: formData,
33708
+ formValue: formValue,
33709
+ form: form
33710
+ })
33711
+ });
33712
+ };
33713
+
33714
+ const getLinkValue$1 = (value, linkingObject) => {
33715
+ if (linkingObject && linkingObject?.[value]) {
33716
+ return linkingObject?.[value]?.name;
33717
+ }
33718
+ return null;
33719
+ };
33720
+ const getEventCategoryBySubject = (eventCategoryObject, subject) => {
33721
+ if (!eventCategoryObject || typeof eventCategoryObject !== 'object') {
33722
+ return null;
33723
+ }
33724
+ const subjectSingular = subject.endsWith('ies') ? subject.slice(0, -3) + 'y' : subject.endsWith('s') ? subject.slice(0, -1) : subject;
33725
+ const key = `typeOfEvent is ${subjectSingular}`;
33726
+ return eventCategoryObject[key] || null;
33727
+ };
33728
+ const renderStatusTag = ({
33729
+ value,
33730
+ t = s => s
33731
+ }) => {
33732
+ const width = 87;
33733
+ switch (value) {
33734
+ case "edited":
33735
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
33736
+ color: "yellow",
33737
+ style: {
33738
+ width
33739
+ },
33740
+ className: "text-center",
33741
+ children: t("Edited")
33742
+ });
33743
+ case "submitted":
33744
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
33745
+ color: "green",
33746
+ style: {
33747
+ width
33748
+ },
33749
+ className: "text-center",
33750
+ children: t("Submitted")
33751
+ });
33752
+ default:
33753
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
33754
+ color: "blue",
33755
+ style: {
33756
+ width
33757
+ },
33758
+ className: "text-center",
33759
+ children: t("Private")
33760
+ });
33761
+ }
33762
+ };
33763
+ const getColumns$1 = ({
33764
+ t,
33765
+ goTo,
33766
+ user,
33767
+ options,
33768
+ activeTab,
33769
+ getRedirectLink,
33770
+ theme,
33771
+ subject,
33772
+ data,
33773
+ applications
33774
+ }) => [{
33775
+ dataIndex: 'datastakeId',
33776
+ title: t('ID'),
33777
+ ellipsis: true,
33778
+ show: true,
33779
+ render: (v, all) => {
33780
+ if (all.empty) {
33781
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
33782
+ className: "daf-default-cell"
33783
+ });
33784
+ }
33785
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
33786
+ title: v,
33787
+ children: v
33788
+ });
33789
+ }
33790
+ }, {
33791
+ dataIndex: 'name',
33792
+ title: t('Title'),
33793
+ ellipsis: true,
33794
+ show: true,
33795
+ render: (v, all) => {
33796
+ if (all.empty) {
33797
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
33798
+ className: "daf-default-cell"
33799
+ });
33800
+ }
33801
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
33802
+ title: v,
33803
+ children: v
33804
+ });
33805
+ }
33806
+ }, {
33807
+ title: t("Date"),
33808
+ dataIndex: "date",
33809
+ key: "date",
33810
+ render: (date, all) => {
33811
+ if (all.empty) {
33812
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
33813
+ className: "daf-default-cell"
33814
+ });
33815
+ }
33816
+ const _date = date ? renderDateFormatted(date, "DD MMM YYYY", user?.language || 'en') : "-";
33817
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
33818
+ title: _date,
33819
+ children: _date
33820
+ });
33821
+ },
33822
+ ellipsis: true
33823
+ }, {
33824
+ dataIndex: 'mineSite',
33825
+ title: t('Location'),
33826
+ ellipsis: true,
33827
+ show: true,
33828
+ render: (v, all) => {
33829
+ if (all.empty) {
33830
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
33831
+ className: "daf-default-cell"
33832
+ });
33833
+ }
33834
+
33835
+ // const country = findOptions(v, data?.options?.positionSupplyChainOptions);
33836
+ const mineSite = all?.location?.name;
33837
+ return mineSite ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
33838
+ title: mineSite,
33839
+ children: mineSite
33840
+ }) : '-';
33841
+ }
33842
+ }, {
33843
+ dataIndex: 'province',
33844
+ title: t('Province'),
33845
+ ellipsis: true,
33846
+ show: true,
33847
+ render: (v, all) => {
33848
+ if (all.empty) {
33849
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
33850
+ className: "daf-default-cell"
33851
+ });
33852
+ }
33853
+ const region = getLinkValue$1(all?.location?.administrativeLevel1, all?.location?.linking?.SCL);
33854
+ return region ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
33855
+ title: region,
33856
+ children: region
33857
+ }) : '-';
33858
+ }
33859
+ }, {
33860
+ dataIndex: 'territory',
33861
+ title: t('Territory'),
33862
+ ellipsis: true,
33863
+ show: true,
33864
+ render: (v, all) => {
33865
+ if (all.empty) {
33866
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
33867
+ className: "daf-default-cell"
33868
+ });
33869
+ }
33870
+ const district = getLinkValue$1(all?.location?.administrativeLevel2, all?.location?.linking?.SCL);
33871
+ return district ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
33872
+ title: district,
33873
+ children: district
33874
+ }) : '-';
33875
+ }
33876
+ }, {
33877
+ dataIndex: 'eventCategory',
33878
+ title: t('Category'),
33879
+ ellipsis: true,
33880
+ show: true,
33881
+ render: (v, all) => {
33882
+ if (all.empty) {
33883
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
33884
+ className: "daf-default-cell"
33885
+ });
33886
+ }
33887
+ const eventCategory = findOptions(v, data?.options?.eventCategoryOptions);
33888
+ const categoryValue = getEventCategoryBySubject(eventCategory, subject);
33889
+ return categoryValue ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
33890
+ title: categoryValue,
33891
+ children: categoryValue
33892
+ }) : '-';
33893
+ }
33894
+ }, {
33895
+ title: t("Sources"),
33896
+ dataIndex: "sources",
33897
+ key: "sources",
33898
+ show: activeTab !== "own",
33899
+ render: (val, all) => {
33900
+ if (all.empty) {
33901
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
33902
+ className: "daf-default-cell"
33903
+ });
33904
+ }
33905
+ const sources = sourceAvatarConfig(val, user, applications);
33906
+ return /*#__PURE__*/jsxRuntime.jsx(AvatarGroup, {
33907
+ items: sources
33908
+ });
33909
+ }
33910
+ }, {
33911
+ title: t("Status"),
33912
+ dataIndex: "status",
33913
+ key: "status",
33914
+ show: activeTab === "own",
33915
+ render: (val, all) => {
33916
+ if (all.empty) {
33917
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
33918
+ className: "daf-default-cell"
33919
+ });
33920
+ }
33921
+ const _val = all?.published || all?.status === "submitted" ? "submitted" : val;
33922
+ return renderStatusTag({
33923
+ value: _val,
33924
+ t
33925
+ });
33926
+ }
33927
+ }, {
33928
+ title: t("Last Update"),
33929
+ dataIndex: "updatedAt",
33930
+ key: "updatedAt",
33931
+ render: (date, all) => {
33932
+ if (all.empty) {
33933
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
33934
+ className: "daf-default-cell"
33935
+ });
33936
+ }
33937
+ const _date = date ? renderDateFormatted(date, "DD MMM YYYY", user?.language || 'en') : "-";
33938
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
33939
+ title: _date,
33940
+ children: _date
33941
+ });
33942
+ },
33943
+ ellipsis: true
33944
+ }, {
33945
+ id: 'actions',
33946
+ title: "",
33947
+ width: 60,
33948
+ render: (_, all) => {
33949
+ if (all.empty) {
33950
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
33951
+ className: "daf-default-cell"
33952
+ });
33953
+ }
33954
+ const link = `/app/view/${subject}/${all.datastakeId}`;
33955
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
33956
+ style: {
33957
+ display: "flex",
33958
+ justifyContent: "center"
33959
+ },
33960
+ children: /*#__PURE__*/jsxRuntime.jsx("a", {
33961
+ href: getRedirectLink(link),
33962
+ children: /*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
33963
+ name: "Link",
33964
+ size: 15,
33965
+ color: theme.baseGray70
33966
+ })
33967
+ })
33968
+ });
33969
+ }
33970
+ }].filter(column => column.show !== false);
33971
+
33972
+ const checkboxConfig$1 = {
33973
+ name: 'Name',
33974
+ datastakeId: 'ID'
33975
+ };
33976
+ const getFiltersConfig$1 = ({
33977
+ t
33978
+ }) => {
33979
+ return {
33980
+ country: {
33981
+ type: 'select',
33982
+ label: 'Country',
33983
+ placeholder: t => `${t('Filter by')} ${t('Country').toLowerCase()}`,
33984
+ style: {
33985
+ flex: 1
33986
+ },
33987
+ labelStyle: {
33988
+ flex: 1
33989
+ },
33990
+ getLabel: option => option.label,
33991
+ getValue: option => option.value
33992
+ },
33993
+ administrativeLevel1: {
33994
+ type: 'ajaxSelect',
33995
+ label: ({
33996
+ t = s => s,
33997
+ options = {},
33998
+ filters = {},
33999
+ language = 'en'
34000
+ }) => {
34001
+ const {
34002
+ administrativeLevel1
34003
+ } = options;
34004
+ if (administrativeLevel1) {
34005
+ if (options.country) {
34006
+ const _item = administrativeLevel1[filters.country];
34007
+ if (_item) {
34008
+ if (_item[language]) {
34009
+ return _item[language];
34010
+ }
34011
+ }
34012
+ }
34013
+ }
34014
+ return t('Province');
34015
+ },
34016
+ placeholder: t => `${t('Filter by')} ${t('Province').toLowerCase()}`,
34017
+ filters: data => ({
34018
+ country: data.country,
34019
+ level: 'level_1'
34020
+ }),
34021
+ show: data => !data.country,
34022
+ disabled: data => !data.country,
34023
+ mapper: {
34024
+ label: "name",
34025
+ value: "id"
34026
+ },
34027
+ method: 'getOptions',
34028
+ entity: 'AdministrativeLevel',
34029
+ style: {
34030
+ flex: 1
34031
+ },
34032
+ labelStyle: {
34033
+ flex: 1
34034
+ }
34035
+ },
34036
+ administrativeLevel2: {
34037
+ type: 'ajaxSelect',
34038
+ label: ({
34039
+ t = s => s,
34040
+ options = {},
34041
+ filters = {},
34042
+ language = 'en'
34043
+ }) => {
34044
+ const {
34045
+ administrativeLevel2
34046
+ } = options;
34047
+ if (administrativeLevel2) {
34048
+ if (options.country) {
34049
+ const _item = administrativeLevel2[filters.country];
34050
+ if (_item) {
34051
+ if (_item[language]) {
34052
+ return _item[language];
34053
+ }
34054
+ }
34055
+ }
34056
+ }
34057
+ return t('Province');
34058
+ },
34059
+ show: data => !(data.country && data.administrativeLevel1),
34060
+ placeholder: t => `${t('Filter by')} ${t('Territory').toLowerCase()}`,
34061
+ filters: data => ({
34062
+ country: data.country,
34063
+ level: 'level_2',
34064
+ administrativeLevel1: data.administrativeLevel1
34065
+ }),
34066
+ disabled: data => !(data.country && data.administrativeLevel1),
34067
+ mapper: {
34068
+ label: "name",
34069
+ value: "id"
34070
+ },
34071
+ method: 'getOptions',
34072
+ entity: 'AdministrativeLevel',
34073
+ style: {
34074
+ flex: 1
34075
+ },
34076
+ labelStyle: {
34077
+ flex: 1
34078
+ }
34079
+ },
34080
+ activity: {
34081
+ type: 'select',
34082
+ label: 'Activity',
34083
+ placeholder: t => `${t('Filter by')} ${t('Activity').toLowerCase()}`,
34084
+ style: {
34085
+ flex: 1
34086
+ },
34087
+ labelStyle: {
34088
+ flex: 1
34089
+ },
34090
+ getLabel: option => option.label,
34091
+ getValue: option => option.value,
34092
+ filterOptions: val => {
34093
+ if (val) {
34094
+ const {
34095
+ option,
34096
+ filters
34097
+ } = val;
34098
+ if (filters && option) {
34099
+ const {
34100
+ filters: optionFilters
34101
+ } = option;
34102
+ if (Array.isArray(optionFilters) && optionFilters.length) {
34103
+ const {
34104
+ value,
34105
+ condition
34106
+ } = optionFilters[0];
34107
+ if (condition === 'includes') {
34108
+ return value.includes('corporation');
34109
+ }
34110
+ }
34111
+ }
34112
+ }
34113
+ return true;
34114
+ }
34115
+ },
34116
+ positionInTheMineralSupplyChain: {
34117
+ type: 'select',
34118
+ label: 'Position',
34119
+ placeholder: t => `${t('Filter by')} ${t('Position').toLowerCase()}`,
34120
+ style: {
34121
+ flex: 1
34122
+ },
34123
+ labelStyle: {
34124
+ flex: 1
34125
+ },
34126
+ getLabel: option => option.label,
34127
+ getValue: option => option.value
34128
+ },
34129
+ status: {
34130
+ type: "select",
34131
+ label: "Status",
34132
+ placeholder: t => `${t("Filter by")} ${t("Status").toLowerCase()}`,
34133
+ style: {
34134
+ flex: 1
34135
+ },
34136
+ labelStyle: {
34137
+ fley: 1
34138
+ },
34139
+ getLabel: option => option.label,
34140
+ getValue: option => option.value
34141
+ }
34142
+ };
34143
+ };
34144
+ const filtersConfig$1 = {
34145
+ name: '',
34146
+ datastakeId: ''
34147
+ };
34148
+ const getFilterOptions$1 = (options, t) => {
34149
+ const {
34150
+ statusOptions = [],
34151
+ categoryOptions = [],
34152
+ countries = [],
34153
+ subCategory = [],
34154
+ activityAtSiteOptions = [],
34155
+ stakeholderCategoryOptions,
34156
+ stakeholderSubCategoriesOptions,
34157
+ administrativeLevel1,
34158
+ administrativeLevel2,
34159
+ positionInMineralSupplyChainOptions,
34160
+ subCategoriesOptions
34161
+ } = options || {};
34162
+ const _default = {
34163
+ status: [{
34164
+ value: "submitted",
34165
+ label: "Submitted"
34166
+ }, {
34167
+ value: "private",
34168
+ label: "Private"
34169
+ }],
34170
+ category: stakeholderCategoryOptions || categoryOptions,
34171
+ country: countries,
34172
+ subCategory: subCategoriesOptions,
34173
+ activity: activityAtSiteOptions,
34174
+ administrativeLevel1,
34175
+ administrativeLevel2,
34176
+ positionInTheMineralSupplyChain: positionInMineralSupplyChainOptions
34177
+ };
34178
+ return _default;
34179
+ };
34180
+
34181
+ const StakeholdersCreate = ({
34182
+ namespace = "incident",
34183
+ view = "incident",
34184
+ edit = false,
34185
+ formData = {},
34186
+ loading = false,
34187
+ onSubmitted = () => {},
34188
+ onCancel = () => {},
34189
+ getData = () => {},
34190
+ saveData = () => {},
34191
+ form: formConfig = {},
34192
+ formValue = {},
34193
+ defaultData = {},
34194
+ user = {},
34195
+ APP,
34196
+ query,
34197
+ goTo = () => {},
34198
+ t = () => {},
34199
+ ajaxForms = {},
34200
+ changeAjaxForms = () => {},
34201
+ ajaxOptions = {},
34202
+ changeAjaxOptions = () => {},
34203
+ getAppHeader = () => {},
34204
+ getApiBaseUrl = () => {}
34205
+ }) => {
34206
+ let {
34207
+ form = {},
34208
+ data = defaultData || {}
34209
+ } = !edit ? formData[`${APP}-${view}`] || {} : {
34210
+ form: formConfig,
34211
+ data: formValue
34212
+ };
34213
+ React.useEffect(() => {
34214
+ if (Object.keys(form).length === 0 && !formData[`${APP}-${view}`]) {
34215
+ if (!edit) {
34216
+ getData({
34217
+ namespace,
34218
+ module: APP,
34219
+ view,
34220
+ scope: 'createIncident'
34221
+ });
34222
+ } else {
34223
+ form = formConfig;
34224
+ data = formValue;
34225
+ }
34226
+ }
34227
+ }, [edit, user?.language]);
34228
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
34229
+ className: "daf-create-form",
34230
+ children: /*#__PURE__*/jsxRuntime.jsx(DynamicForm, {
34231
+ form: form,
34232
+ data: {
34233
+ ...defaultData,
34234
+ ...data
34235
+ },
34236
+ showSaveAndNext: false,
34237
+ module: APP,
34238
+ onCancel: onCancel,
34239
+ isCreate: true,
34240
+ t: t,
34241
+ excludedKeys: ["title"],
34242
+ user: user,
34243
+ ajaxForms: ajaxForms,
34244
+ ajaxOptions: ajaxOptions,
34245
+ getAppHeader: getAppHeader,
34246
+ getApiBaseUrl: getApiBaseUrl,
34247
+ changeAjaxOptions: changeAjaxOptions,
34248
+ app: APP,
34249
+ query: query,
34250
+ goTo: goTo,
34251
+ changeAjaxForms: changeAjaxForms,
34252
+ submit: (payload, setSelectedFormNext) => {
34253
+ const payloadData = {
34254
+ ...payload,
34255
+ module: APP,
34256
+ namespace
34257
+ };
34258
+ const newPayload = {
34259
+ ...defaultData,
34260
+ ...payloadData,
34261
+ form: 'worker'
34262
+ };
34263
+ const callback = (type, m, data) => {
34264
+ if (setSelectedFormNext) {
34265
+ setSelectedFormNext();
34266
+ }
34267
+ if (type === MessageTypes.SUCCESS) {
34268
+ if (onSubmitted) onSubmitted(type, m, data);
34269
+ } else {
34270
+ antd.message.error(m);
34271
+ }
34272
+ };
34273
+ saveData(!data && !data.id ? newPayload : Object.assign(newPayload, {
34274
+ id: data.id
34275
+ }), callback);
34276
+ },
34277
+ isFormDisabled: () => {
34278
+ return !data || !data.typeOfEvent;
34279
+ }
34280
+ })
34281
+ });
34282
+ };
34283
+
34284
+ const IncidentsTable = ({
34285
+ t = () => {},
34286
+ goTo = () => {},
31521
34287
  user = {},
31522
34288
  options = {},
31523
34289
  getRedirectLink = () => {},
@@ -31541,7 +34307,9 @@ const EventsTable = ({
31541
34307
  formData = {},
31542
34308
  formValue = {},
31543
34309
  form = {},
31544
- extendingFilters = {}
34310
+ extendingFilters = {},
34311
+ createDefaultValues = {},
34312
+ applications = []
31545
34313
  }) => {
31546
34314
  const [selectOptions, setSelectOptions] = React.useState();
31547
34315
  const [activeTab, setActiveTab] = React.useState();
@@ -31553,9 +34321,10 @@ const EventsTable = ({
31553
34321
  activeTab,
31554
34322
  getRedirectLink,
31555
34323
  theme,
31556
- subject: 'events',
31557
- data
31558
- }), [t, goTo, user, options, activeTab, getRedirectLink, theme, data]);
34324
+ subject: 'incidents',
34325
+ data,
34326
+ applications
34327
+ }), [t, goTo, user, options, activeTab, getRedirectLink, theme, data, applications]);
31559
34328
  const breadCrumbs = [];
31560
34329
  const {
31561
34330
  paginationQuery,
@@ -31566,32 +34335,26 @@ const EventsTable = ({
31566
34335
  } = useGetQueryParams({
31567
34336
  location
31568
34337
  });
31569
- const filters = React.useMemo(() => {
34338
+ React.useMemo(() => {
31570
34339
  return {
31571
34340
  ...otherParams,
31572
34341
  ...extendingFilters
31573
34342
  };
31574
34343
  }, [otherParams, extendingFilters]);
31575
34344
  React.useEffect(() => {
31576
- console.log("fetching data");
31577
34345
  getData({
31578
34346
  pagination: paginationQuery,
31579
- ...(Object.keys(filters).length > 0 && {
31580
- filters: filters
31581
- }),
31582
34347
  ...(Object.keys(searchParams).length > 0 && {
31583
34348
  search: searchParams
31584
34349
  }),
34350
+ ...otherParams,
31585
34351
  tab: activeTab,
31586
34352
  sortBy: {
31587
34353
  [sortBy || "updatedAt"]: sortDir ? sortDir === "ascend" ? 1 : -1 : -1
31588
- }
31589
- }, 'events');
31590
- console.log("data fetched");
34354
+ },
34355
+ ...extendingFilters
34356
+ }, 'incidents');
31591
34357
  }, [location.search, activeTab, JSON.stringify(extendingFilters)]);
31592
- console.log({
31593
- data
31594
- });
31595
34358
  const selectFiltersConfig = React.useMemo(() => {
31596
34359
  return getFiltersConfig$1({
31597
34360
  t
@@ -31608,7 +34371,7 @@ const EventsTable = ({
31608
34371
  }, []);
31609
34372
  return /*#__PURE__*/jsxRuntime.jsx(TablePageWithTabs, {
31610
34373
  t: t,
31611
- title: t("events"),
34374
+ title: t("Incidents"),
31612
34375
  breadCrumbs: breadCrumbs,
31613
34376
  location: location,
31614
34377
  loading: loading,
@@ -31624,15 +34387,16 @@ const EventsTable = ({
31624
34387
  getRedirectLink: getRedirectLink,
31625
34388
  filtersConfig: filtersConfig$1,
31626
34389
  isMobile: isMobile,
31627
- view: "events",
34390
+ view: "incidents",
31628
34391
  getActiveTab: handleActiveTabChange,
31629
34392
  onDownload: () => {
31630
34393
  console.log("download");
31631
34394
  },
31632
- drawerTitle: t("Create Events"),
34395
+ drawerTitle: t("Create Incidents"),
31633
34396
  children: ({
31634
34397
  onDrawerClose
31635
- }) => /*#__PURE__*/jsxRuntime.jsx(EventsCreate, {
34398
+ }) => /*#__PURE__*/jsxRuntime.jsx(StakeholdersCreate, {
34399
+ defaultData: createDefaultValues,
31636
34400
  t: t,
31637
34401
  goTo: goTo,
31638
34402
  user: user,
@@ -31646,7 +34410,7 @@ const EventsTable = ({
31646
34410
  if (data.datastakeId) {
31647
34411
  displayMessage(type, t("affirmations::subject-created-successfully") || m);
31648
34412
  // goTo(`/app/edit/stakeholders/${data.datastakeId}`);
31649
- goTo(`/app/edit/events/${data.datastakeId}`);
34413
+ goTo(`/app/edit/incidents/${data.datastakeId}`);
31650
34414
  }
31651
34415
  },
31652
34416
  onCancel: onDrawerClose,
@@ -31662,6 +34426,12 @@ const EventsTable = ({
31662
34426
  });
31663
34427
  };
31664
34428
 
34429
+ const getLinkValue = (value, linkingObject) => {
34430
+ if (linkingObject && linkingObject?.[value]) {
34431
+ return linkingObject?.[value]?.name;
34432
+ }
34433
+ return null;
34434
+ };
31665
34435
  const getColumns = ({
31666
34436
  t,
31667
34437
  goTo,
@@ -31683,30 +34453,83 @@ const getColumns = ({
31683
34453
  className: "daf-default-cell"
31684
34454
  });
31685
34455
  }
31686
- return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
31687
- title: v,
31688
- children: v
31689
- });
34456
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
34457
+ title: v,
34458
+ children: v
34459
+ });
34460
+ }
34461
+ }, {
34462
+ dataIndex: 'name',
34463
+ title: t('Name'),
34464
+ ellipsis: true,
34465
+ show: true,
34466
+ render: (v, all) => {
34467
+ if (all.empty) {
34468
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
34469
+ className: "daf-default-cell"
34470
+ });
34471
+ }
34472
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
34473
+ title: v,
34474
+ children: v
34475
+ });
34476
+ }
34477
+ }, {
34478
+ dataIndex: 'province',
34479
+ title: t('Province'),
34480
+ ellipsis: true,
34481
+ show: true,
34482
+ render: (v, all) => {
34483
+ if (all.empty) {
34484
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
34485
+ className: "daf-default-cell"
34486
+ });
34487
+ }
34488
+ const region = getLinkValue(all?.location?.administrativeLevel1, all?.location?.linking?.SCL);
34489
+ return region ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
34490
+ title: region,
34491
+ children: region
34492
+ }) : '-';
34493
+ }
34494
+ }, {
34495
+ dataIndex: 'territory',
34496
+ title: t('Territory'),
34497
+ ellipsis: true,
34498
+ show: true,
34499
+ render: (v, all) => {
34500
+ if (all.empty) {
34501
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
34502
+ className: "daf-default-cell"
34503
+ });
34504
+ }
34505
+ const district = getLinkValue(all?.location?.administrativeLevel2, all?.location?.linking?.SCL);
34506
+ return district ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
34507
+ title: district,
34508
+ children: district
34509
+ }) : '-';
31690
34510
  }
31691
34511
  }, {
31692
- dataIndex: 'title',
31693
- title: t('Title'),
31694
- ellipsis: true,
31695
- show: true,
31696
- render: (v, all) => {
34512
+ title: t("Products"),
34513
+ dataIndex: "products",
34514
+ key: "products",
34515
+ show: activeTab !== "own",
34516
+ render: (val, all) => {
31697
34517
  if (all.empty) {
31698
34518
  return /*#__PURE__*/jsxRuntime.jsx("div", {
31699
34519
  className: "daf-default-cell"
31700
34520
  });
31701
34521
  }
31702
- return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
31703
- title: v,
31704
- children: v
34522
+ console.log({
34523
+ val,
34524
+ all
34525
+ });
34526
+ return /*#__PURE__*/jsxRuntime.jsx(AvatarGroup, {
34527
+ items: val
31705
34528
  });
31706
34529
  }
31707
- }, {
31708
- dataIndex: 'type',
31709
- title: t('Type'),
34530
+ },, {
34531
+ dataIndex: 'operator',
34532
+ title: t('Operator'),
31710
34533
  ellipsis: true,
31711
34534
  show: true,
31712
34535
  render: (v, all) => {
@@ -31715,10 +34538,10 @@ const getColumns = ({
31715
34538
  className: "daf-default-cell"
31716
34539
  });
31717
34540
  }
31718
- const type = findOptions(v, data?.options?.locationCategories);
31719
- return type ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
31720
- title: type,
31721
- children: type
34541
+ const operator = getLinkValue(all?.operator, all?.linking?.SCL);
34542
+ return operator ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
34543
+ title: operator,
34544
+ children: operator
31722
34545
  }) : '-';
31723
34546
  }
31724
34547
  }, {
@@ -31740,23 +34563,21 @@ const getColumns = ({
31740
34563
  },
31741
34564
  ellipsis: true
31742
34565
  }, {
31743
- title: t("Sources"),
31744
- dataIndex: "sources",
31745
- key: "sources",
31746
- show: activeTab !== "own",
31747
- render: (val, all) => {
34566
+ title: t("Status"),
34567
+ dataIndex: 'status',
34568
+ ellipsis: true,
34569
+ show: activeTab == "own",
34570
+ render: (v, all) => {
31748
34571
  if (all.empty) {
31749
34572
  return /*#__PURE__*/jsxRuntime.jsx("div", {
31750
34573
  className: "daf-default-cell"
31751
34574
  });
31752
34575
  }
31753
- console.log({
31754
- val,
31755
- all
31756
- });
31757
- return /*#__PURE__*/jsxRuntime.jsx(AvatarGroup, {
31758
- items: val
31759
- });
34576
+ const status = findOptions(v, data?.options?.statusOptions);
34577
+ return status ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
34578
+ title: status,
34579
+ children: status
34580
+ }) : '-';
31760
34581
  }
31761
34582
  }, {
31762
34583
  id: 'actions',
@@ -31796,7 +34617,144 @@ const getFiltersConfig = ({
31796
34617
  return {
31797
34618
  country: {
31798
34619
  type: 'select',
31799
- placeholder: t('Country'),
34620
+ label: 'Country',
34621
+ placeholder: t => `${t('Filter by')} ${t('Country').toLowerCase()}`,
34622
+ style: {
34623
+ flex: 1
34624
+ },
34625
+ labelStyle: {
34626
+ flex: 1
34627
+ },
34628
+ getLabel: option => option.label,
34629
+ getValue: option => option.value
34630
+ },
34631
+ administrativeLevel1: {
34632
+ type: 'ajaxSelect',
34633
+ label: ({
34634
+ t = s => s,
34635
+ options = {},
34636
+ filters = {},
34637
+ language = 'en'
34638
+ }) => {
34639
+ const {
34640
+ administrativeLevel1
34641
+ } = options;
34642
+ if (administrativeLevel1) {
34643
+ if (options.country) {
34644
+ const _item = administrativeLevel1[filters.country];
34645
+ if (_item) {
34646
+ if (_item[language]) {
34647
+ return _item[language];
34648
+ }
34649
+ }
34650
+ }
34651
+ }
34652
+ return t('Province');
34653
+ },
34654
+ placeholder: t => `${t('Filter by')} ${t('Province').toLowerCase()}`,
34655
+ filters: data => ({
34656
+ country: data.country,
34657
+ level: 'level_1'
34658
+ }),
34659
+ show: data => !data.country,
34660
+ disabled: data => !data.country,
34661
+ mapper: {
34662
+ label: "name",
34663
+ value: "id"
34664
+ },
34665
+ method: 'getOptions',
34666
+ entity: 'AdministrativeLevel',
34667
+ style: {
34668
+ flex: 1
34669
+ },
34670
+ labelStyle: {
34671
+ flex: 1
34672
+ }
34673
+ },
34674
+ administrativeLevel2: {
34675
+ type: 'ajaxSelect',
34676
+ label: ({
34677
+ t = s => s,
34678
+ options = {},
34679
+ filters = {},
34680
+ language = 'en'
34681
+ }) => {
34682
+ const {
34683
+ administrativeLevel2
34684
+ } = options;
34685
+ if (administrativeLevel2) {
34686
+ if (options.country) {
34687
+ const _item = administrativeLevel2[filters.country];
34688
+ if (_item) {
34689
+ if (_item[language]) {
34690
+ return _item[language];
34691
+ }
34692
+ }
34693
+ }
34694
+ }
34695
+ return t('Province');
34696
+ },
34697
+ show: data => !(data.country && data.administrativeLevel1),
34698
+ placeholder: t => `${t('Filter by')} ${t('Territory').toLowerCase()}`,
34699
+ filters: data => ({
34700
+ country: data.country,
34701
+ level: 'level_2',
34702
+ administrativeLevel1: data.administrativeLevel1
34703
+ }),
34704
+ disabled: data => !(data.country && data.administrativeLevel1),
34705
+ mapper: {
34706
+ label: "name",
34707
+ value: "id"
34708
+ },
34709
+ method: 'getOptions',
34710
+ entity: 'AdministrativeLevel',
34711
+ style: {
34712
+ flex: 1
34713
+ },
34714
+ labelStyle: {
34715
+ flex: 1
34716
+ }
34717
+ },
34718
+ product: {
34719
+ type: 'select',
34720
+ label: 'Product',
34721
+ placeholder: t => `${t('Filter by')} ${t('Product').toLowerCase()}`,
34722
+ style: {
34723
+ flex: 1
34724
+ },
34725
+ labelStyle: {
34726
+ flex: 1
34727
+ },
34728
+ getLabel: option => option.label,
34729
+ getValue: option => option.value,
34730
+ filterOptions: val => {
34731
+ if (val) {
34732
+ const {
34733
+ option,
34734
+ filters
34735
+ } = val;
34736
+ if (filters && option) {
34737
+ const {
34738
+ filters: optionFilters
34739
+ } = option;
34740
+ if (Array.isArray(optionFilters) && optionFilters.length) {
34741
+ const {
34742
+ value,
34743
+ condition
34744
+ } = optionFilters[0];
34745
+ if (condition === 'includes') {
34746
+ return value.includes('corporation');
34747
+ }
34748
+ }
34749
+ }
34750
+ }
34751
+ return true;
34752
+ }
34753
+ },
34754
+ positionInTheMineralSupplyChain: {
34755
+ type: 'select',
34756
+ label: 'Position',
34757
+ placeholder: t => `${t('Filter by')} ${t('Position').toLowerCase()}`,
31800
34758
  style: {
31801
34759
  flex: 1
31802
34760
  },
@@ -31805,6 +34763,19 @@ const getFiltersConfig = ({
31805
34763
  },
31806
34764
  getLabel: option => option.label,
31807
34765
  getValue: option => option.value
34766
+ },
34767
+ status: {
34768
+ type: "select",
34769
+ label: "Status",
34770
+ placeholder: t => `${t("Filter by")} ${t("Status").toLowerCase()}`,
34771
+ style: {
34772
+ flex: 1
34773
+ },
34774
+ labelStyle: {
34775
+ fley: 1
34776
+ },
34777
+ getLabel: option => option.label,
34778
+ getValue: option => option.value
31808
34779
  }
31809
34780
  };
31810
34781
  };
@@ -31814,17 +34785,41 @@ const filtersConfig = {
31814
34785
  };
31815
34786
  const getFilterOptions = (options, t) => {
31816
34787
  const {
31817
- countries
34788
+ statusOptions = [],
34789
+ categoryOptions = [],
34790
+ countries = [],
34791
+ product = [],
34792
+ subCategory = [],
34793
+ subCategoriesOptions,
34794
+ stakeholderCategoryOptions,
34795
+ stakeholderSubCategoriesOptions,
34796
+ administrativeLevel1,
34797
+ administrativeLevel2
31818
34798
  } = options || {};
34799
+ console.log({
34800
+ options
34801
+ });
31819
34802
  const _default = {
31820
- country: countries
34803
+ category: stakeholderCategoryOptions || categoryOptions,
34804
+ country: countries,
34805
+ product: product,
34806
+ administrativeLevel1,
34807
+ administrativeLevel2,
34808
+ subCategory: subCategoriesOptions,
34809
+ status: [{
34810
+ value: "submitted",
34811
+ label: "Submitted"
34812
+ }, {
34813
+ value: "private",
34814
+ label: "Private"
34815
+ }]
31821
34816
  };
31822
34817
  return _default;
31823
34818
  };
31824
34819
 
31825
- const DocumentsCreate = ({
31826
- namespace = 'documents',
31827
- view = 'scoping',
34820
+ const ProductionSitesCreate = ({
34821
+ namespace = "PRODUCTION SITES",
34822
+ view = ['scoping', 'new'],
31828
34823
  edit = false,
31829
34824
  formData = {},
31830
34825
  loading = false,
@@ -31873,7 +34868,10 @@ const DocumentsCreate = ({
31873
34868
  className: "daf-create-form",
31874
34869
  children: /*#__PURE__*/jsxRuntime.jsx(DynamicForm, {
31875
34870
  form: form,
31876
- data: data,
34871
+ data: {
34872
+ ...defaultData,
34873
+ ...data
34874
+ },
31877
34875
  showSaveAndNext: false,
31878
34876
  module: APP,
31879
34877
  onCancel: onCancel,
@@ -31899,7 +34897,7 @@ const DocumentsCreate = ({
31899
34897
  const newPayload = {
31900
34898
  ...defaultData,
31901
34899
  ...payloadData,
31902
- form: 'document'
34900
+ form: 'production-sites'
31903
34901
  };
31904
34902
  const callback = (type, m, data) => {
31905
34903
  if (setSelectedFormNext) {
@@ -31922,7 +34920,7 @@ const DocumentsCreate = ({
31922
34920
  });
31923
34921
  };
31924
34922
 
31925
- const DocumentsTable = ({
34923
+ const ProductionSitesTable = ({
31926
34924
  t = () => {},
31927
34925
  goTo = () => {},
31928
34926
  user = {},
@@ -31948,7 +34946,8 @@ const DocumentsTable = ({
31948
34946
  formData = {},
31949
34947
  formValue = {},
31950
34948
  form = {},
31951
- extendingFilters = {}
34949
+ extendingFilters = {},
34950
+ createDefaultValues = {}
31952
34951
  }) => {
31953
34952
  const [selectOptions, setSelectOptions] = React.useState();
31954
34953
  const [activeTab, setActiveTab] = React.useState();
@@ -31960,7 +34959,7 @@ const DocumentsTable = ({
31960
34959
  activeTab,
31961
34960
  getRedirectLink,
31962
34961
  theme,
31963
- subject: 'documents',
34962
+ subject: 'production-sites',
31964
34963
  data
31965
34964
  }), [t, goTo, user, options, activeTab, getRedirectLink, theme, data]);
31966
34965
  const breadCrumbs = [];
@@ -31973,32 +34972,26 @@ const DocumentsTable = ({
31973
34972
  } = useGetQueryParams({
31974
34973
  location
31975
34974
  });
31976
- const filters = React.useMemo(() => {
34975
+ React.useMemo(() => {
31977
34976
  return {
31978
34977
  ...otherParams,
31979
34978
  ...extendingFilters
31980
34979
  };
31981
34980
  }, [otherParams, extendingFilters]);
31982
34981
  React.useEffect(() => {
31983
- console.log("fetching data");
31984
34982
  getData({
31985
34983
  pagination: paginationQuery,
31986
- ...(Object.keys(filters).length > 0 && {
31987
- filters: filters
31988
- }),
31989
34984
  ...(Object.keys(searchParams).length > 0 && {
31990
34985
  search: searchParams
31991
34986
  }),
34987
+ ...otherParams,
31992
34988
  tab: activeTab,
31993
34989
  sortBy: {
31994
34990
  [sortBy || "updatedAt"]: sortDir ? sortDir === "ascend" ? 1 : -1 : -1
31995
- }
31996
- }, 'documents');
31997
- console.log("data fetched");
34991
+ },
34992
+ ...extendingFilters
34993
+ }, 'production-sites');
31998
34994
  }, [location.search, activeTab, JSON.stringify(extendingFilters)]);
31999
- console.log({
32000
- data
32001
- });
32002
34995
  const selectFiltersConfig = React.useMemo(() => {
32003
34996
  return getFiltersConfig({
32004
34997
  t
@@ -32015,7 +35008,7 @@ const DocumentsTable = ({
32015
35008
  }, []);
32016
35009
  return /*#__PURE__*/jsxRuntime.jsx(TablePageWithTabs, {
32017
35010
  t: t,
32018
- title: t("documents"),
35011
+ title: t("production-sites"),
32019
35012
  breadCrumbs: breadCrumbs,
32020
35013
  location: location,
32021
35014
  loading: loading,
@@ -32031,15 +35024,16 @@ const DocumentsTable = ({
32031
35024
  getRedirectLink: getRedirectLink,
32032
35025
  filtersConfig: filtersConfig,
32033
35026
  isMobile: isMobile,
32034
- view: "documents",
35027
+ view: "production-sites",
32035
35028
  getActiveTab: handleActiveTabChange,
32036
35029
  onDownload: () => {
32037
35030
  console.log("download");
32038
35031
  },
32039
- drawerTitle: t("Create Document"),
35032
+ drawerTitle: t("Create Production Site"),
32040
35033
  children: ({
32041
35034
  onDrawerClose
32042
- }) => /*#__PURE__*/jsxRuntime.jsx(DocumentsCreate, {
35035
+ }) => /*#__PURE__*/jsxRuntime.jsx(ProductionSitesCreate, {
35036
+ defaultData: createDefaultValues,
32043
35037
  t: t,
32044
35038
  goTo: goTo,
32045
35039
  user: user,
@@ -32053,7 +35047,7 @@ const DocumentsTable = ({
32053
35047
  if (data.datastakeId) {
32054
35048
  displayMessage(type, t("affirmations::subject-created-successfully") || m);
32055
35049
  // goTo(`/app/edit/stakeholders/${data.datastakeId}`);
32056
- goTo(`/app/edit/documents/${data.datastakeId}`);
35050
+ goTo(`/app/edit/production-sites/${data.datastakeId}`);
32057
35051
  }
32058
35052
  },
32059
35053
  onCancel: onDrawerClose,
@@ -32069,11 +35063,15 @@ const DocumentsTable = ({
32069
35063
  });
32070
35064
  };
32071
35065
 
35066
+ exports.ActivitiesTable = ActivitiesTable;
32072
35067
  exports.DocumentsTable = DocumentsTable;
32073
35068
  exports.EventsTable = EventsTable;
35069
+ exports.IncidentsTable = IncidentsTable;
32074
35070
  exports.LocationsTable = LocationsTable;
32075
35071
  exports.OperatorsTable = OperatorsTable;
35072
+ exports.ProductionSitesTable = ProductionSitesTable;
32076
35073
  exports.StakeholdersTable = StakeholdersTable;
32077
35074
  exports.SupplyChainDashboard = SupplyChain;
32078
35075
  exports.TablePageWithTabs = TablePageWithTabs;
32079
35076
  exports.UserDashboard = UserDashboard;
35077
+ exports.WorkersTable = WorkersTable;