datastake-daf 0.6.741 → 0.6.743

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 (26) hide show
  1. package/dist/pages/index.js +1539 -126
  2. package/dist/services/index.js +1 -1
  3. package/package.json +1 -1
  4. package/src/@daf/pages/dashboards/AllInformation/Documents/columns.js +4 -3
  5. package/src/@daf/pages/dashboards/AllInformation/Documents/index.jsx +3 -1
  6. package/src/@daf/pages/dashboards/AllInformation/Events/columns.js +4 -3
  7. package/src/@daf/pages/dashboards/AllInformation/Events/index.jsx +3 -1
  8. package/src/@daf/pages/dashboards/AllInformation/Locations/columns.js +4 -3
  9. package/src/@daf/pages/dashboards/AllInformation/Locations/index.jsx +3 -1
  10. package/src/@daf/pages/dashboards/AllInformation/Stakeholders/columns.js +5 -2
  11. package/src/@daf/pages/dashboards/AllInformation/Stakeholders/index.jsx +4 -2
  12. package/src/@daf/pages/dashboards/DueDilligence/Activities/columns.js +221 -0
  13. package/src/@daf/pages/dashboards/DueDilligence/Activities/config.js +166 -0
  14. package/src/@daf/pages/dashboards/DueDilligence/Activities/create.jsx +104 -0
  15. package/src/@daf/pages/dashboards/DueDilligence/Activities/index.jsx +157 -0
  16. package/src/@daf/pages/dashboards/Operations/Operators/columns.js +17 -16
  17. package/src/@daf/pages/dashboards/Operations/Operators/config.js +0 -1
  18. package/src/@daf/pages/dashboards/Operations/Operators/index.jsx +3 -1
  19. package/src/@daf/pages/dashboards/Operations/Workers/columns.js +176 -0
  20. package/src/@daf/pages/dashboards/Operations/Workers/config.js +166 -0
  21. package/src/@daf/pages/dashboards/Operations/Workers/create.jsx +104 -0
  22. package/src/@daf/pages/dashboards/Operations/Workers/index.jsx +157 -0
  23. package/src/@daf/pages/pages/TablePageWithTabs/index.jsx +1 -1
  24. package/src/@daf/services/OperatorService.js +1 -1
  25. package/src/helpers/sourceAvatarConfig.js +37 -0
  26. package/src/pages.js +3 -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$7 = (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$7(t, filters, locationCategories), [activeTab, filters, t, locationCategories]);
13760
13760
  const onFilterChange = filters => {
13761
13761
  setFilters(p => ({
13762
13762
  ...p,
@@ -15841,7 +15841,7 @@ const TablePageWithTabs = ({
15841
15841
  location,
15842
15842
  loading = false,
15843
15843
  goTo = () => {},
15844
- defaultActiveTab = "all",
15844
+ defaultActiveTab = "own",
15845
15845
  checkboxConfig = {},
15846
15846
  columns = [],
15847
15847
  data = {},
@@ -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$3 = (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$6 = ({
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'),
@@ -16041,8 +16075,8 @@ const getColumns$4 = ({
16041
16075
  });
16042
16076
  }
16043
16077
  }, {
16044
- dataIndex: 'country',
16045
- title: t('Country'),
16078
+ dataIndex: 'positionSupplyChain',
16079
+ title: t('Position'),
16046
16080
  ellipsis: true,
16047
16081
  show: true,
16048
16082
  render: (v, all) => {
@@ -16051,15 +16085,15 @@ const getColumns$4 = ({
16051
16085
  className: "daf-default-cell"
16052
16086
  });
16053
16087
  }
16054
- const country = findOptions(v, options?.countries);
16088
+ const country = findOptions(v, data?.options?.positionSupplyChainOptions);
16055
16089
  return country ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
16056
16090
  title: country,
16057
16091
  children: country
16058
16092
  }) : '-';
16059
16093
  }
16060
16094
  }, {
16061
- dataIndex: 'type',
16062
- title: t('Type'),
16095
+ dataIndex: 'subCategory',
16096
+ title: t('Legal Form'),
16063
16097
  ellipsis: true,
16064
16098
  show: true,
16065
16099
  render: (v, all) => {
@@ -16068,17 +16102,15 @@ const getColumns$4 = ({
16068
16102
  className: "daf-default-cell"
16069
16103
  });
16070
16104
  }
16071
-
16072
- // const category = findOptions(v, data?.options?.locationCategories);
16073
-
16074
- return v ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
16075
- title: v,
16076
- children: v
16105
+ const subCategory = findOptions(v, data?.options?.subCategoriesOptions);
16106
+ return subCategory ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
16107
+ title: subCategory,
16108
+ children: subCategory
16077
16109
  }) : '-';
16078
16110
  }
16079
16111
  }, {
16080
- dataIndex: 'registration',
16081
- title: t('Registration'),
16112
+ dataIndex: 'province',
16113
+ title: t('Province'),
16082
16114
  ellipsis: true,
16083
16115
  show: true,
16084
16116
  render: (v, all) => {
@@ -16087,15 +16119,15 @@ const getColumns$4 = ({
16087
16119
  className: "daf-default-cell"
16088
16120
  });
16089
16121
  }
16090
- const region = getLinkValue$2(v, all?.linking?.SCL);
16122
+ const region = getLinkValue$3(all?.location?.administrativeLevel1, all?.location?.linking?.SCL);
16091
16123
  return region ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
16092
16124
  title: region,
16093
16125
  children: region
16094
16126
  }) : '-';
16095
16127
  }
16096
16128
  }, {
16097
- dataIndex: 'status',
16098
- title: t('Status'),
16129
+ dataIndex: 'territory',
16130
+ title: t('Territory'),
16099
16131
  ellipsis: true,
16100
16132
  show: true,
16101
16133
  render: (v, all) => {
@@ -16104,7 +16136,7 @@ const getColumns$4 = ({
16104
16136
  className: "daf-default-cell"
16105
16137
  });
16106
16138
  }
16107
- const district = getLinkValue$2(v, all?.linking?.SCL);
16139
+ const district = getLinkValue$3(all?.location?.administrativeLevel2, all?.location?.linking?.SCL);
16108
16140
  return district ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
16109
16141
  title: district,
16110
16142
  children: district
@@ -16121,12 +16153,9 @@ const getColumns$4 = ({
16121
16153
  className: "daf-default-cell"
16122
16154
  });
16123
16155
  }
16124
- console.log({
16125
- val,
16126
- all
16127
- });
16156
+ const sources = sourceAvatarConfig(val, user, applications);
16128
16157
  return /*#__PURE__*/jsxRuntime.jsx(AvatarGroup, {
16129
- items: val
16158
+ items: sources
16130
16159
  });
16131
16160
  }
16132
16161
  }, {
@@ -16175,11 +16204,11 @@ const getColumns$4 = ({
16175
16204
  }
16176
16205
  }].filter(column => column.show !== false);
16177
16206
 
16178
- const checkboxConfig$4 = {
16207
+ const checkboxConfig$6 = {
16179
16208
  name: 'Name',
16180
16209
  datastakeId: 'ID'
16181
16210
  };
16182
- const getFiltersConfig$4 = ({
16211
+ const getFiltersConfig$6 = ({
16183
16212
  t
16184
16213
  }) => {
16185
16214
  return {
@@ -16347,11 +16376,11 @@ const getFiltersConfig$4 = ({
16347
16376
  }
16348
16377
  };
16349
16378
  };
16350
- const filtersConfig$4 = {
16379
+ const filtersConfig$6 = {
16351
16380
  name: '',
16352
16381
  datastakeId: ''
16353
16382
  };
16354
- const getFilterOptions$4 = (options, t) => {
16383
+ const getFilterOptions$6 = (options, t) => {
16355
16384
  const {
16356
16385
  statusOptions = [],
16357
16386
  categoryOptions = [],
@@ -16363,9 +16392,6 @@ const getFilterOptions$4 = (options, t) => {
16363
16392
  administrativeLevel1,
16364
16393
  administrativeLevel2
16365
16394
  } = options || {};
16366
- console.log({
16367
- options
16368
- });
16369
16395
  const _default = {
16370
16396
  category: stakeholderCategoryOptions || categoryOptions,
16371
16397
  country: countries,
@@ -30084,7 +30110,7 @@ function DynamicForm({
30084
30110
  });
30085
30111
  }
30086
30112
 
30087
- const StakeholdersCreate$2 = ({
30113
+ const StakeholdersCreate$4 = ({
30088
30114
  namespace = "OPERATOR",
30089
30115
  view = ['scoping', 'new'],
30090
30116
  edit = false,
@@ -30214,11 +30240,12 @@ const OperatorsTable = ({
30214
30240
  formValue = {},
30215
30241
  form = {},
30216
30242
  extendingFilters = {},
30217
- createDefaultValues = {}
30243
+ createDefaultValues = {},
30244
+ applications = []
30218
30245
  }) => {
30219
30246
  const [selectOptions, setSelectOptions] = React.useState();
30220
30247
  const [activeTab, setActiveTab] = React.useState();
30221
- const columns = React.useMemo(() => getColumns$4({
30248
+ const columns = React.useMemo(() => getColumns$6({
30222
30249
  t,
30223
30250
  goTo,
30224
30251
  user,
@@ -30227,8 +30254,9 @@ const OperatorsTable = ({
30227
30254
  getRedirectLink,
30228
30255
  theme,
30229
30256
  subject: 'operators',
30230
- data
30231
- }), [t, goTo, user, options, activeTab, getRedirectLink, theme, data]);
30257
+ data,
30258
+ applications
30259
+ }), [t, goTo, user, options, activeTab, getRedirectLink, theme, data, applications]);
30232
30260
  const breadCrumbs = [];
30233
30261
  const {
30234
30262
  paginationQuery,
@@ -30260,14 +30288,14 @@ const OperatorsTable = ({
30260
30288
  }, 'operators');
30261
30289
  }, [location.search, activeTab, JSON.stringify(extendingFilters)]);
30262
30290
  const selectFiltersConfig = React.useMemo(() => {
30263
- return getFiltersConfig$4({
30291
+ return getFiltersConfig$6({
30264
30292
  t
30265
30293
  });
30266
30294
  }, [t]);
30267
30295
  React.useEffect(() => {
30268
30296
  setSelectOptions(prev => ({
30269
30297
  ...prev,
30270
- ...getFilterOptions$4(options)
30298
+ ...getFilterOptions$6(options)
30271
30299
  }));
30272
30300
  }, [options, t]);
30273
30301
  const handleActiveTabChange = React.useCallback(value => {
@@ -30283,13 +30311,13 @@ const OperatorsTable = ({
30283
30311
  defaultActiveTab: "all",
30284
30312
  columns: columns,
30285
30313
  data: data,
30286
- checkboxConfig: checkboxConfig$4,
30314
+ checkboxConfig: checkboxConfig$6,
30287
30315
  APP: APP,
30288
30316
  getApiBaseUrl: getApiBaseUrl,
30289
30317
  selectOptions: selectOptions,
30290
30318
  selectFiltersConfig: selectFiltersConfig,
30291
30319
  getRedirectLink: getRedirectLink,
30292
- filtersConfig: filtersConfig$4,
30320
+ filtersConfig: filtersConfig$6,
30293
30321
  isMobile: isMobile,
30294
30322
  view: "operators",
30295
30323
  getActiveTab: handleActiveTabChange,
@@ -30299,7 +30327,7 @@ const OperatorsTable = ({
30299
30327
  drawerTitle: t("Create Operator"),
30300
30328
  children: ({
30301
30329
  onDrawerClose
30302
- }) => /*#__PURE__*/jsxRuntime.jsx(StakeholdersCreate$2, {
30330
+ }) => /*#__PURE__*/jsxRuntime.jsx(StakeholdersCreate$4, {
30303
30331
  defaultData: createDefaultValues,
30304
30332
  t: t,
30305
30333
  goTo: goTo,
@@ -30330,13 +30358,13 @@ const OperatorsTable = ({
30330
30358
  });
30331
30359
  };
30332
30360
 
30333
- const getLinkValue$1 = (value, linkingObject) => {
30361
+ const getLinkValue$2 = (value, linkingObject) => {
30334
30362
  if (linkingObject && linkingObject?.[value]) {
30335
30363
  return linkingObject?.[value]?.name;
30336
30364
  }
30337
30365
  return null;
30338
30366
  };
30339
- const getColumns$3 = ({
30367
+ const getColumns$5 = ({
30340
30368
  t,
30341
30369
  goTo,
30342
30370
  user,
@@ -30345,7 +30373,8 @@ const getColumns$3 = ({
30345
30373
  getRedirectLink,
30346
30374
  theme,
30347
30375
  subject,
30348
- data
30376
+ data,
30377
+ applications
30349
30378
  }) => [{
30350
30379
  dataIndex: 'datastakeId',
30351
30380
  title: t('ID'),
@@ -30423,7 +30452,7 @@ const getColumns$3 = ({
30423
30452
  className: "daf-default-cell"
30424
30453
  });
30425
30454
  }
30426
- const region = getLinkValue$1(v, all?.linking?.SCL);
30455
+ const region = getLinkValue$2(v, all?.linking?.SCL);
30427
30456
  return region ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
30428
30457
  title: region,
30429
30458
  children: region
@@ -30440,7 +30469,7 @@ const getColumns$3 = ({
30440
30469
  className: "daf-default-cell"
30441
30470
  });
30442
30471
  }
30443
- const district = getLinkValue$1(v, all?.linking?.SCL);
30472
+ const district = getLinkValue$2(v, all?.linking?.SCL);
30444
30473
  return district ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
30445
30474
  title: district,
30446
30475
  children: district
@@ -30475,12 +30504,9 @@ const getColumns$3 = ({
30475
30504
  className: "daf-default-cell"
30476
30505
  });
30477
30506
  }
30478
- console.log({
30479
- val,
30480
- all
30481
- });
30507
+ const sources = sourceAvatarConfig(val, user, applications);
30482
30508
  return /*#__PURE__*/jsxRuntime.jsx(AvatarGroup, {
30483
- items: val
30509
+ items: sources
30484
30510
  });
30485
30511
  }
30486
30512
  }, {
@@ -30511,11 +30537,11 @@ const getColumns$3 = ({
30511
30537
  }
30512
30538
  }].filter(column => column.show !== false);
30513
30539
 
30514
- const checkboxConfig$3 = {
30540
+ const checkboxConfig$5 = {
30515
30541
  name: 'Name',
30516
30542
  datastakeId: 'ID'
30517
30543
  };
30518
- const getFiltersConfig$3 = ({
30544
+ const getFiltersConfig$5 = ({
30519
30545
  t
30520
30546
  }) => {
30521
30547
  return {
@@ -30533,11 +30559,11 @@ const getFiltersConfig$3 = ({
30533
30559
  }
30534
30560
  };
30535
30561
  };
30536
- const filtersConfig$3 = {
30562
+ const filtersConfig$5 = {
30537
30563
  name: '',
30538
30564
  datastakeId: ''
30539
30565
  };
30540
- const getFilterOptions$3 = (options, t) => {
30566
+ const getFilterOptions$5 = (options, t) => {
30541
30567
  const {
30542
30568
  countries
30543
30569
  } = options || {};
@@ -30547,7 +30573,7 @@ const getFilterOptions$3 = (options, t) => {
30547
30573
  return _default;
30548
30574
  };
30549
30575
 
30550
- const StakeholdersCreate$1 = ({
30576
+ const StakeholdersCreate$3 = ({
30551
30577
  namespace = 'locations',
30552
30578
  view = 'scoping',
30553
30579
  edit = false,
@@ -30672,11 +30698,12 @@ const LocationsTable = ({
30672
30698
  changeAjaxOptions = () => {},
30673
30699
  formData = {},
30674
30700
  formValue = {},
30675
- form = {}
30701
+ form = {},
30702
+ applications = []
30676
30703
  }) => {
30677
30704
  const [selectOptions, setSelectOptions] = React.useState();
30678
30705
  const [activeTab, setActiveTab] = React.useState();
30679
- const columns = React.useMemo(() => getColumns$3({
30706
+ const columns = React.useMemo(() => getColumns$5({
30680
30707
  t,
30681
30708
  goTo,
30682
30709
  user,
@@ -30685,8 +30712,9 @@ const LocationsTable = ({
30685
30712
  getRedirectLink,
30686
30713
  theme,
30687
30714
  subject: 'locations',
30688
- data
30689
- }), [t, goTo, user, options, activeTab, getRedirectLink, theme, data]);
30715
+ data,
30716
+ applications
30717
+ }), [t, goTo, user, options, activeTab, getRedirectLink, theme, data, applications]);
30690
30718
  const breadCrumbs = [];
30691
30719
  const {
30692
30720
  paginationQuery,
@@ -30711,14 +30739,14 @@ const LocationsTable = ({
30711
30739
  data
30712
30740
  });
30713
30741
  const selectFiltersConfig = React.useMemo(() => {
30714
- return getFiltersConfig$3({
30742
+ return getFiltersConfig$5({
30715
30743
  t
30716
30744
  });
30717
30745
  }, [t]);
30718
30746
  React.useEffect(() => {
30719
30747
  setSelectOptions(prev => ({
30720
30748
  ...prev,
30721
- ...getFilterOptions$3(options)
30749
+ ...getFilterOptions$5(options)
30722
30750
  }));
30723
30751
  }, [options, t]);
30724
30752
  const handleActiveTabChange = React.useCallback(value => {
@@ -30734,13 +30762,13 @@ const LocationsTable = ({
30734
30762
  defaultActiveTab: "all",
30735
30763
  columns: columns,
30736
30764
  data: data,
30737
- checkboxConfig: checkboxConfig$3,
30765
+ checkboxConfig: checkboxConfig$5,
30738
30766
  APP: APP,
30739
30767
  getApiBaseUrl: getApiBaseUrl,
30740
30768
  selectOptions: selectOptions,
30741
30769
  selectFiltersConfig: selectFiltersConfig,
30742
30770
  getRedirectLink: getRedirectLink,
30743
- filtersConfig: filtersConfig$3,
30771
+ filtersConfig: filtersConfig$5,
30744
30772
  isMobile: isMobile,
30745
30773
  view: "locations",
30746
30774
  getActiveTab: handleActiveTabChange,
@@ -30750,7 +30778,7 @@ const LocationsTable = ({
30750
30778
  drawerTitle: t("Create Location"),
30751
30779
  children: ({
30752
30780
  onDrawerClose
30753
- }) => /*#__PURE__*/jsxRuntime.jsx(StakeholdersCreate$1, {
30781
+ }) => /*#__PURE__*/jsxRuntime.jsx(StakeholdersCreate$3, {
30754
30782
  t: t,
30755
30783
  goTo: goTo,
30756
30784
  user: user,
@@ -30779,7 +30807,7 @@ const LocationsTable = ({
30779
30807
  });
30780
30808
  };
30781
30809
 
30782
- const getColumns$2 = ({
30810
+ const getColumns$4 = ({
30783
30811
  t,
30784
30812
  goTo,
30785
30813
  user,
@@ -30787,7 +30815,8 @@ const getColumns$2 = ({
30787
30815
  activeTab,
30788
30816
  getRedirectLink,
30789
30817
  theme,
30790
- subject
30818
+ subject,
30819
+ applications
30791
30820
  }) => [{
30792
30821
  dataIndex: 'datastakeId',
30793
30822
  title: t('ID'),
@@ -30903,8 +30932,9 @@ const getColumns$2 = ({
30903
30932
  if (!val || val?.length === 0) {
30904
30933
  return "--";
30905
30934
  }
30935
+ const sources = sourceAvatarConfig(val, user, applications);
30906
30936
  return /*#__PURE__*/jsxRuntime.jsx(AvatarGroup, {
30907
- items: val
30937
+ items: sources
30908
30938
  });
30909
30939
  }
30910
30940
  }, {
@@ -30935,11 +30965,11 @@ const getColumns$2 = ({
30935
30965
  }
30936
30966
  }].filter(column => column.show !== false);
30937
30967
 
30938
- const checkboxConfig$2 = {
30968
+ const checkboxConfig$4 = {
30939
30969
  name: 'Name',
30940
30970
  datastakeId: 'ID'
30941
30971
  };
30942
- const getFiltersConfig$2 = ({
30972
+ const getFiltersConfig$4 = ({
30943
30973
  t
30944
30974
  }) => {
30945
30975
  return {
@@ -30957,11 +30987,11 @@ const getFiltersConfig$2 = ({
30957
30987
  }
30958
30988
  };
30959
30989
  };
30960
- const filtersConfig$2 = {
30990
+ const filtersConfig$4 = {
30961
30991
  name: '',
30962
30992
  datastakeId: ''
30963
30993
  };
30964
- const getFilterOptions$2 = (options, t) => {
30994
+ const getFilterOptions$4 = (options, t) => {
30965
30995
  const {
30966
30996
  countries
30967
30997
  } = options || {};
@@ -30971,7 +31001,7 @@ const getFilterOptions$2 = (options, t) => {
30971
31001
  return _default;
30972
31002
  };
30973
31003
 
30974
- const StakeholdersCreate = ({
31004
+ const StakeholdersCreate$2 = ({
30975
31005
  namespace = 'stakeholders',
30976
31006
  view = 'scoping',
30977
31007
  edit = false,
@@ -31096,11 +31126,12 @@ const StakeholdersTable = ({
31096
31126
  changeAjaxOptions = () => {},
31097
31127
  formData = {},
31098
31128
  formValue = {},
31099
- form = {}
31129
+ form = {},
31130
+ applications = []
31100
31131
  }) => {
31101
31132
  const [selectOptions, setSelectOptions] = React.useState();
31102
31133
  const [activeTab, setActiveTab] = React.useState();
31103
- const columns = React.useMemo(() => getColumns$2({
31134
+ const columns = React.useMemo(() => getColumns$4({
31104
31135
  t,
31105
31136
  goTo,
31106
31137
  user,
@@ -31108,8 +31139,9 @@ const StakeholdersTable = ({
31108
31139
  activeTab,
31109
31140
  getRedirectLink,
31110
31141
  theme,
31111
- subject: 'stakeholders'
31112
- }), [t, goTo, user, options, activeTab, getRedirectLink, theme]);
31142
+ subject: 'stakeholders',
31143
+ applications
31144
+ }), [t, goTo, user, options, activeTab, getRedirectLink, theme, applications]);
31113
31145
  const breadCrumbs = [];
31114
31146
  const {
31115
31147
  paginationQuery,
@@ -31131,14 +31163,14 @@ const StakeholdersTable = ({
31131
31163
  }, 'stakeholders');
31132
31164
  }, [paginationQuery, otherParams, searchParams, activeTab]);
31133
31165
  const selectFiltersConfig = React.useMemo(() => {
31134
- return getFiltersConfig$2({
31166
+ return getFiltersConfig$4({
31135
31167
  t
31136
31168
  });
31137
31169
  }, [t]);
31138
31170
  React.useEffect(() => {
31139
31171
  setSelectOptions(prev => ({
31140
31172
  ...prev,
31141
- ...getFilterOptions$2(options)
31173
+ ...getFilterOptions$4(options)
31142
31174
  }));
31143
31175
  }, [options, t]);
31144
31176
  const handleActiveTabChange = React.useCallback(value => {
@@ -31154,13 +31186,13 @@ const StakeholdersTable = ({
31154
31186
  defaultActiveTab: "all",
31155
31187
  columns: columns,
31156
31188
  data: data,
31157
- checkboxConfig: checkboxConfig$2,
31189
+ checkboxConfig: checkboxConfig$4,
31158
31190
  APP: APP,
31159
31191
  getApiBaseUrl: getApiBaseUrl,
31160
31192
  selectOptions: selectOptions,
31161
31193
  selectFiltersConfig: selectFiltersConfig,
31162
31194
  getRedirectLink: getRedirectLink,
31163
- filtersConfig: filtersConfig$2,
31195
+ filtersConfig: filtersConfig$4,
31164
31196
  isMobile: isMobile,
31165
31197
  view: "stakeholders",
31166
31198
  getActiveTab: handleActiveTabChange,
@@ -31170,7 +31202,7 @@ const StakeholdersTable = ({
31170
31202
  drawerTitle: t("Create Stakeholder"),
31171
31203
  children: ({
31172
31204
  onDrawerClose
31173
- }) => /*#__PURE__*/jsxRuntime.jsx(StakeholdersCreate, {
31205
+ }) => /*#__PURE__*/jsxRuntime.jsx(StakeholdersCreate$2, {
31174
31206
  t: t,
31175
31207
  goTo: goTo,
31176
31208
  user: user,
@@ -31199,13 +31231,13 @@ const StakeholdersTable = ({
31199
31231
  });
31200
31232
  };
31201
31233
 
31202
- const getLinkValue = (value, linkingObject) => {
31234
+ const getLinkValue$1 = (value, linkingObject) => {
31203
31235
  if (linkingObject && linkingObject?.[value]) {
31204
31236
  return linkingObject?.[value]?.name;
31205
31237
  }
31206
31238
  return null;
31207
31239
  };
31208
- const getColumns$1 = ({
31240
+ const getColumns$3 = ({
31209
31241
  t,
31210
31242
  goTo,
31211
31243
  user,
@@ -31214,7 +31246,8 @@ const getColumns$1 = ({
31214
31246
  getRedirectLink,
31215
31247
  theme,
31216
31248
  subject,
31217
- data
31249
+ data,
31250
+ applications
31218
31251
  }) => [{
31219
31252
  dataIndex: 'datastakeId',
31220
31253
  title: t('ID'),
@@ -31292,7 +31325,7 @@ const getColumns$1 = ({
31292
31325
  className: "daf-default-cell"
31293
31326
  });
31294
31327
  }
31295
- const scope = getLinkValue(v, all?.linking?.SCL);
31328
+ const scope = getLinkValue$1(v, all?.linking?.SCL);
31296
31329
  return scope ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
31297
31330
  title: scope,
31298
31331
  children: scope
@@ -31345,12 +31378,9 @@ const getColumns$1 = ({
31345
31378
  className: "daf-default-cell"
31346
31379
  });
31347
31380
  }
31348
- console.log({
31349
- val,
31350
- all
31351
- });
31381
+ const sources = sourceAvatarConfig(val, user, applications);
31352
31382
  return /*#__PURE__*/jsxRuntime.jsx(AvatarGroup, {
31353
- items: val
31383
+ items: sources
31354
31384
  });
31355
31385
  }
31356
31386
  }, {
@@ -31381,11 +31411,11 @@ const getColumns$1 = ({
31381
31411
  }
31382
31412
  }].filter(column => column.show !== false);
31383
31413
 
31384
- const checkboxConfig$1 = {
31414
+ const checkboxConfig$3 = {
31385
31415
  name: 'Name',
31386
31416
  datastakeId: 'ID'
31387
31417
  };
31388
- const getFiltersConfig$1 = ({
31418
+ const getFiltersConfig$3 = ({
31389
31419
  t
31390
31420
  }) => {
31391
31421
  return {
@@ -31403,11 +31433,11 @@ const getFiltersConfig$1 = ({
31403
31433
  }
31404
31434
  };
31405
31435
  };
31406
- const filtersConfig$1 = {
31436
+ const filtersConfig$3 = {
31407
31437
  name: '',
31408
31438
  datastakeId: ''
31409
31439
  };
31410
- const getFilterOptions$1 = (options, t) => {
31440
+ const getFilterOptions$3 = (options, t) => {
31411
31441
  const {
31412
31442
  countries
31413
31443
  } = options || {};
@@ -31543,11 +31573,12 @@ const EventsTable = ({
31543
31573
  formData = {},
31544
31574
  formValue = {},
31545
31575
  form = {},
31546
- extendingFilters = {}
31576
+ extendingFilters = {},
31577
+ applications = []
31547
31578
  }) => {
31548
31579
  const [selectOptions, setSelectOptions] = React.useState();
31549
31580
  const [activeTab, setActiveTab] = React.useState();
31550
- const columns = React.useMemo(() => getColumns$1({
31581
+ const columns = React.useMemo(() => getColumns$3({
31551
31582
  t,
31552
31583
  goTo,
31553
31584
  user,
@@ -31556,8 +31587,9 @@ const EventsTable = ({
31556
31587
  getRedirectLink,
31557
31588
  theme,
31558
31589
  subject: 'events',
31559
- data
31560
- }), [t, goTo, user, options, activeTab, getRedirectLink, theme, data]);
31590
+ data,
31591
+ applications
31592
+ }), [t, goTo, user, options, activeTab, getRedirectLink, theme, data, applications]);
31561
31593
  const breadCrumbs = [];
31562
31594
  const {
31563
31595
  paginationQuery,
@@ -31595,14 +31627,14 @@ const EventsTable = ({
31595
31627
  data
31596
31628
  });
31597
31629
  const selectFiltersConfig = React.useMemo(() => {
31598
- return getFiltersConfig$1({
31630
+ return getFiltersConfig$3({
31599
31631
  t
31600
31632
  });
31601
31633
  }, [t]);
31602
31634
  React.useEffect(() => {
31603
31635
  setSelectOptions(prev => ({
31604
31636
  ...prev,
31605
- ...getFilterOptions$1(options)
31637
+ ...getFilterOptions$3(options)
31606
31638
  }));
31607
31639
  }, [options, t]);
31608
31640
  const handleActiveTabChange = React.useCallback(value => {
@@ -31618,13 +31650,13 @@ const EventsTable = ({
31618
31650
  defaultActiveTab: "all",
31619
31651
  columns: columns,
31620
31652
  data: data,
31621
- checkboxConfig: checkboxConfig$1,
31653
+ checkboxConfig: checkboxConfig$3,
31622
31654
  APP: APP,
31623
31655
  getApiBaseUrl: getApiBaseUrl,
31624
31656
  selectOptions: selectOptions,
31625
31657
  selectFiltersConfig: selectFiltersConfig,
31626
31658
  getRedirectLink: getRedirectLink,
31627
- filtersConfig: filtersConfig$1,
31659
+ filtersConfig: filtersConfig$3,
31628
31660
  isMobile: isMobile,
31629
31661
  view: "events",
31630
31662
  getActiveTab: handleActiveTabChange,
@@ -31664,7 +31696,7 @@ const EventsTable = ({
31664
31696
  });
31665
31697
  };
31666
31698
 
31667
- const getColumns = ({
31699
+ const getColumns$2 = ({
31668
31700
  t,
31669
31701
  goTo,
31670
31702
  user,
@@ -31673,7 +31705,8 @@ const getColumns = ({
31673
31705
  getRedirectLink,
31674
31706
  theme,
31675
31707
  subject,
31676
- data
31708
+ data,
31709
+ applications
31677
31710
  }) => [{
31678
31711
  dataIndex: 'datastakeId',
31679
31712
  title: t('ID'),
@@ -31752,12 +31785,9 @@ const getColumns = ({
31752
31785
  className: "daf-default-cell"
31753
31786
  });
31754
31787
  }
31755
- console.log({
31756
- val,
31757
- all
31758
- });
31788
+ const sources = sourceAvatarConfig(val, user, applications);
31759
31789
  return /*#__PURE__*/jsxRuntime.jsx(AvatarGroup, {
31760
- items: val
31790
+ items: sources
31761
31791
  });
31762
31792
  }
31763
31793
  }, {
@@ -31788,11 +31818,11 @@ const getColumns = ({
31788
31818
  }
31789
31819
  }].filter(column => column.show !== false);
31790
31820
 
31791
- const checkboxConfig = {
31821
+ const checkboxConfig$2 = {
31792
31822
  name: 'Name',
31793
31823
  datastakeId: 'ID'
31794
31824
  };
31795
- const getFiltersConfig = ({
31825
+ const getFiltersConfig$2 = ({
31796
31826
  t
31797
31827
  }) => {
31798
31828
  return {
@@ -31810,11 +31840,11 @@ const getFiltersConfig = ({
31810
31840
  }
31811
31841
  };
31812
31842
  };
31813
- const filtersConfig = {
31843
+ const filtersConfig$2 = {
31814
31844
  name: '',
31815
31845
  datastakeId: ''
31816
31846
  };
31817
- const getFilterOptions = (options, t) => {
31847
+ const getFilterOptions$2 = (options, t) => {
31818
31848
  const {
31819
31849
  countries
31820
31850
  } = options || {};
@@ -31950,11 +31980,12 @@ const DocumentsTable = ({
31950
31980
  formData = {},
31951
31981
  formValue = {},
31952
31982
  form = {},
31953
- extendingFilters = {}
31983
+ extendingFilters = {},
31984
+ applications = []
31954
31985
  }) => {
31955
31986
  const [selectOptions, setSelectOptions] = React.useState();
31956
31987
  const [activeTab, setActiveTab] = React.useState();
31957
- const columns = React.useMemo(() => getColumns({
31988
+ const columns = React.useMemo(() => getColumns$2({
31958
31989
  t,
31959
31990
  goTo,
31960
31991
  user,
@@ -31963,8 +31994,9 @@ const DocumentsTable = ({
31963
31994
  getRedirectLink,
31964
31995
  theme,
31965
31996
  subject: 'documents',
31966
- data
31967
- }), [t, goTo, user, options, activeTab, getRedirectLink, theme, data]);
31997
+ data,
31998
+ applications
31999
+ }), [t, goTo, user, options, activeTab, getRedirectLink, theme, data, applications]);
31968
32000
  const breadCrumbs = [];
31969
32001
  const {
31970
32002
  paginationQuery,
@@ -32002,14 +32034,14 @@ const DocumentsTable = ({
32002
32034
  data
32003
32035
  });
32004
32036
  const selectFiltersConfig = React.useMemo(() => {
32005
- return getFiltersConfig({
32037
+ return getFiltersConfig$2({
32006
32038
  t
32007
32039
  });
32008
32040
  }, [t]);
32009
32041
  React.useEffect(() => {
32010
32042
  setSelectOptions(prev => ({
32011
32043
  ...prev,
32012
- ...getFilterOptions(options)
32044
+ ...getFilterOptions$2(options)
32013
32045
  }));
32014
32046
  }, [options, t]);
32015
32047
  const handleActiveTabChange = React.useCallback(value => {
@@ -32025,13 +32057,13 @@ const DocumentsTable = ({
32025
32057
  defaultActiveTab: "all",
32026
32058
  columns: columns,
32027
32059
  data: data,
32028
- checkboxConfig: checkboxConfig,
32060
+ checkboxConfig: checkboxConfig$2,
32029
32061
  APP: APP,
32030
32062
  getApiBaseUrl: getApiBaseUrl,
32031
32063
  selectOptions: selectOptions,
32032
32064
  selectFiltersConfig: selectFiltersConfig,
32033
32065
  getRedirectLink: getRedirectLink,
32034
- filtersConfig: filtersConfig,
32066
+ filtersConfig: filtersConfig$2,
32035
32067
  isMobile: isMobile,
32036
32068
  view: "documents",
32037
32069
  getActiveTab: handleActiveTabChange,
@@ -32071,6 +32103,1386 @@ const DocumentsTable = ({
32071
32103
  });
32072
32104
  };
32073
32105
 
32106
+ const renderStatusTag$1 = ({
32107
+ value,
32108
+ t = s => s
32109
+ }) => {
32110
+ const width = 87;
32111
+ switch (value) {
32112
+ case "edited":
32113
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
32114
+ color: "yellow",
32115
+ style: {
32116
+ width
32117
+ },
32118
+ className: "text-center",
32119
+ children: t("Edited")
32120
+ });
32121
+ case "submitted":
32122
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
32123
+ color: "green",
32124
+ style: {
32125
+ width
32126
+ },
32127
+ className: "text-center",
32128
+ children: t("Submitted")
32129
+ });
32130
+ default:
32131
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
32132
+ color: "blue",
32133
+ style: {
32134
+ width
32135
+ },
32136
+ className: "text-center",
32137
+ children: t("Private")
32138
+ });
32139
+ }
32140
+ };
32141
+ const getColumns$1 = ({
32142
+ t,
32143
+ goTo,
32144
+ user,
32145
+ options,
32146
+ activeTab,
32147
+ getRedirectLink,
32148
+ theme,
32149
+ subject,
32150
+ data,
32151
+ applications
32152
+ }) => [
32153
+ // {
32154
+ // dataIndex: 'datastakeId',
32155
+ // title: t('ID'),
32156
+ // ellipsis: true,
32157
+ // show: true,
32158
+ // render: (v, all) => {
32159
+ // if (all.empty) {
32160
+ // return <div className="daf-default-cell" />
32161
+ // }
32162
+
32163
+ // return <Tooltip title={v}>{v}</Tooltip>;
32164
+ // },
32165
+ // },
32166
+ {
32167
+ dataIndex: 'name',
32168
+ title: t('Name'),
32169
+ ellipsis: true,
32170
+ show: true,
32171
+ render: (v, all) => {
32172
+ if (all.empty) {
32173
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32174
+ className: "daf-default-cell"
32175
+ });
32176
+ }
32177
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
32178
+ title: v,
32179
+ children: v
32180
+ });
32181
+ }
32182
+ }, {
32183
+ dataIndex: 'mineSite',
32184
+ title: t('Position'),
32185
+ ellipsis: true,
32186
+ show: true,
32187
+ render: (v, all) => {
32188
+ if (all.empty) {
32189
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32190
+ className: "daf-default-cell"
32191
+ });
32192
+ }
32193
+
32194
+ // const country = findOptions(v, data?.options?.positionSupplyChainOptions);
32195
+ const mineSite = all?.location?.name;
32196
+ return mineSite ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
32197
+ title: mineSite,
32198
+ children: mineSite
32199
+ }) : '-';
32200
+ }
32201
+ }, {
32202
+ dataIndex: 'activity',
32203
+ title: t('Activity'),
32204
+ ellipsis: true,
32205
+ show: true,
32206
+ render: (v, all) => {
32207
+ if (all.empty) {
32208
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32209
+ className: "daf-default-cell"
32210
+ });
32211
+ }
32212
+ const activity = findOptions(v, data?.options?.activityAtSiteOptions);
32213
+ return activity ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
32214
+ title: activity,
32215
+ children: activity
32216
+ }) : '-';
32217
+ }
32218
+ }, {
32219
+ dataIndex: 'origin',
32220
+ title: t('Origin'),
32221
+ ellipsis: true,
32222
+ show: true,
32223
+ render: (v, all) => {
32224
+ if (all.empty) {
32225
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32226
+ className: "daf-default-cell"
32227
+ });
32228
+ }
32229
+ const origin = all?.placeOfBirth?.name;
32230
+ return origin ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
32231
+ title: origin,
32232
+ children: origin
32233
+ }) : '-';
32234
+ }
32235
+ }, {
32236
+ title: t("Census Update"),
32237
+ dataIndex: "createdAt",
32238
+ key: "createdAt",
32239
+ render: (date, all) => {
32240
+ if (all.empty) {
32241
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32242
+ className: "daf-default-cell"
32243
+ });
32244
+ }
32245
+ const _date = date ? renderDateFormatted(date, "DD MMM YYYY", user?.language || 'en') : "-";
32246
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
32247
+ title: _date,
32248
+ children: _date
32249
+ });
32250
+ },
32251
+ ellipsis: true
32252
+ }, {
32253
+ title: t("Sources"),
32254
+ dataIndex: "sources",
32255
+ key: "sources",
32256
+ show: activeTab !== "own",
32257
+ render: (val, all) => {
32258
+ if (all.empty) {
32259
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32260
+ className: "daf-default-cell"
32261
+ });
32262
+ }
32263
+ sourceAvatarConfig(val, user, applications);
32264
+ return /*#__PURE__*/jsxRuntime.jsx(AvatarGroup, {
32265
+ items: val
32266
+ });
32267
+ }
32268
+ }, {
32269
+ title: t("Status"),
32270
+ dataIndex: "status",
32271
+ key: "status",
32272
+ show: activeTab === "own",
32273
+ render: (val, all) => {
32274
+ if (all.empty) {
32275
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32276
+ className: "daf-default-cell"
32277
+ });
32278
+ }
32279
+ const _val = all?.published || all?.status === "submitted" ? "submitted" : val;
32280
+ return renderStatusTag$1({
32281
+ value: _val,
32282
+ t
32283
+ });
32284
+ }
32285
+ }, {
32286
+ id: 'actions',
32287
+ title: "",
32288
+ width: 60,
32289
+ render: (_, all) => {
32290
+ if (all.empty) {
32291
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32292
+ className: "daf-default-cell"
32293
+ });
32294
+ }
32295
+ const link = `/app/view/${subject}/${all.datastakeId}`;
32296
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32297
+ style: {
32298
+ display: "flex",
32299
+ justifyContent: "center"
32300
+ },
32301
+ children: /*#__PURE__*/jsxRuntime.jsx("a", {
32302
+ href: getRedirectLink(link),
32303
+ children: /*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
32304
+ name: "Link",
32305
+ size: 15,
32306
+ color: theme.baseGray70
32307
+ })
32308
+ })
32309
+ });
32310
+ }
32311
+ }].filter(column => column.show !== false);
32312
+
32313
+ const checkboxConfig$1 = {
32314
+ name: 'Name',
32315
+ datastakeId: 'ID'
32316
+ };
32317
+ const getFiltersConfig$1 = ({
32318
+ t
32319
+ }) => {
32320
+ return {
32321
+ country: {
32322
+ type: 'select',
32323
+ label: 'Country',
32324
+ placeholder: t => `${t('Filter by')} ${t('Country').toLowerCase()}`,
32325
+ style: {
32326
+ flex: 1
32327
+ },
32328
+ labelStyle: {
32329
+ flex: 1
32330
+ },
32331
+ getLabel: option => option.label,
32332
+ getValue: option => option.value
32333
+ },
32334
+ administrativeLevel1: {
32335
+ type: 'ajaxSelect',
32336
+ label: ({
32337
+ t = s => s,
32338
+ options = {},
32339
+ filters = {},
32340
+ language = 'en'
32341
+ }) => {
32342
+ const {
32343
+ administrativeLevel1
32344
+ } = options;
32345
+ if (administrativeLevel1) {
32346
+ if (options.country) {
32347
+ const _item = administrativeLevel1[filters.country];
32348
+ if (_item) {
32349
+ if (_item[language]) {
32350
+ return _item[language];
32351
+ }
32352
+ }
32353
+ }
32354
+ }
32355
+ return t('Province');
32356
+ },
32357
+ placeholder: t => `${t('Filter by')} ${t('Province').toLowerCase()}`,
32358
+ filters: data => ({
32359
+ country: data.country,
32360
+ level: 'level_1'
32361
+ }),
32362
+ show: data => !data.country,
32363
+ disabled: data => !data.country,
32364
+ mapper: {
32365
+ label: "name",
32366
+ value: "id"
32367
+ },
32368
+ method: 'getOptions',
32369
+ entity: 'AdministrativeLevel',
32370
+ style: {
32371
+ flex: 1
32372
+ },
32373
+ labelStyle: {
32374
+ flex: 1
32375
+ }
32376
+ },
32377
+ administrativeLevel2: {
32378
+ type: 'ajaxSelect',
32379
+ label: ({
32380
+ t = s => s,
32381
+ options = {},
32382
+ filters = {},
32383
+ language = 'en'
32384
+ }) => {
32385
+ const {
32386
+ administrativeLevel2
32387
+ } = options;
32388
+ if (administrativeLevel2) {
32389
+ if (options.country) {
32390
+ const _item = administrativeLevel2[filters.country];
32391
+ if (_item) {
32392
+ if (_item[language]) {
32393
+ return _item[language];
32394
+ }
32395
+ }
32396
+ }
32397
+ }
32398
+ return t('Province');
32399
+ },
32400
+ show: data => !(data.country && data.administrativeLevel1),
32401
+ placeholder: t => `${t('Filter by')} ${t('Territory').toLowerCase()}`,
32402
+ filters: data => ({
32403
+ country: data.country,
32404
+ level: 'level_2',
32405
+ administrativeLevel1: data.administrativeLevel1
32406
+ }),
32407
+ disabled: data => !(data.country && data.administrativeLevel1),
32408
+ mapper: {
32409
+ label: "name",
32410
+ value: "id"
32411
+ },
32412
+ method: 'getOptions',
32413
+ entity: 'AdministrativeLevel',
32414
+ style: {
32415
+ flex: 1
32416
+ },
32417
+ labelStyle: {
32418
+ flex: 1
32419
+ }
32420
+ },
32421
+ activity: {
32422
+ type: 'select',
32423
+ label: 'Activity',
32424
+ placeholder: t => `${t('Filter by')} ${t('Activity').toLowerCase()}`,
32425
+ style: {
32426
+ flex: 1
32427
+ },
32428
+ labelStyle: {
32429
+ flex: 1
32430
+ },
32431
+ getLabel: option => option.label,
32432
+ getValue: option => option.value,
32433
+ filterOptions: val => {
32434
+ if (val) {
32435
+ const {
32436
+ option,
32437
+ filters
32438
+ } = val;
32439
+ if (filters && option) {
32440
+ const {
32441
+ filters: optionFilters
32442
+ } = option;
32443
+ if (Array.isArray(optionFilters) && optionFilters.length) {
32444
+ const {
32445
+ value,
32446
+ condition
32447
+ } = optionFilters[0];
32448
+ if (condition === 'includes') {
32449
+ return value.includes('corporation');
32450
+ }
32451
+ }
32452
+ }
32453
+ }
32454
+ return true;
32455
+ }
32456
+ },
32457
+ positionInTheMineralSupplyChain: {
32458
+ type: 'select',
32459
+ label: 'Position',
32460
+ placeholder: t => `${t('Filter by')} ${t('Position').toLowerCase()}`,
32461
+ style: {
32462
+ flex: 1
32463
+ },
32464
+ labelStyle: {
32465
+ flex: 1
32466
+ },
32467
+ getLabel: option => option.label,
32468
+ getValue: option => option.value
32469
+ },
32470
+ status: {
32471
+ type: "select",
32472
+ label: "Status",
32473
+ placeholder: t => `${t("Filter by")} ${t("Status").toLowerCase()}`,
32474
+ style: {
32475
+ flex: 1
32476
+ },
32477
+ labelStyle: {
32478
+ fley: 1
32479
+ },
32480
+ getLabel: option => option.label,
32481
+ getValue: option => option.value
32482
+ }
32483
+ };
32484
+ };
32485
+ const filtersConfig$1 = {
32486
+ name: '',
32487
+ datastakeId: ''
32488
+ };
32489
+ const getFilterOptions$1 = (options, t) => {
32490
+ const {
32491
+ statusOptions = [],
32492
+ categoryOptions = [],
32493
+ countries = [],
32494
+ subCategory = [],
32495
+ activityAtSiteOptions = [],
32496
+ stakeholderCategoryOptions,
32497
+ stakeholderSubCategoriesOptions,
32498
+ administrativeLevel1,
32499
+ administrativeLevel2,
32500
+ positionInMineralSupplyChainOptions,
32501
+ subCategoriesOptions
32502
+ } = options || {};
32503
+ const _default = {
32504
+ status: [{
32505
+ value: "submitted",
32506
+ label: "Submitted"
32507
+ }, {
32508
+ value: "private",
32509
+ label: "Private"
32510
+ }],
32511
+ category: stakeholderCategoryOptions || categoryOptions,
32512
+ country: countries,
32513
+ subCategory: subCategoriesOptions,
32514
+ activity: activityAtSiteOptions,
32515
+ administrativeLevel1,
32516
+ administrativeLevel2,
32517
+ positionInTheMineralSupplyChain: positionInMineralSupplyChainOptions
32518
+ };
32519
+ return _default;
32520
+ };
32521
+
32522
+ const StakeholdersCreate$1 = ({
32523
+ namespace = "WORKERS",
32524
+ view = ['scoping', 'new'],
32525
+ edit = false,
32526
+ formData = {},
32527
+ loading = false,
32528
+ onSubmitted = () => {},
32529
+ onCancel = () => {},
32530
+ getData = () => {},
32531
+ saveData = () => {},
32532
+ form: formConfig = {},
32533
+ formValue = {},
32534
+ defaultData = {},
32535
+ user = {},
32536
+ APP,
32537
+ query,
32538
+ goTo = () => {},
32539
+ t = () => {},
32540
+ ajaxForms = {},
32541
+ changeAjaxForms = () => {},
32542
+ ajaxOptions = {},
32543
+ changeAjaxOptions = () => {},
32544
+ getAppHeader = () => {},
32545
+ getApiBaseUrl = () => {}
32546
+ }) => {
32547
+ let {
32548
+ form = {},
32549
+ data = defaultData || {}
32550
+ } = !edit ? formData[`${APP}-${view}`] || {} : {
32551
+ form: formConfig,
32552
+ data: formValue
32553
+ };
32554
+ React.useEffect(() => {
32555
+ if (Object.keys(form).length === 0 && !formData[`${APP}-${view}`]) {
32556
+ if (!edit) {
32557
+ getData({
32558
+ namespace,
32559
+ module: APP,
32560
+ view,
32561
+ scope: 'global'
32562
+ });
32563
+ } else {
32564
+ form = formConfig;
32565
+ data = formValue;
32566
+ }
32567
+ }
32568
+ }, [edit, user?.language]);
32569
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32570
+ className: "daf-create-form",
32571
+ children: /*#__PURE__*/jsxRuntime.jsx(DynamicForm, {
32572
+ form: form,
32573
+ data: {
32574
+ ...defaultData,
32575
+ ...data
32576
+ },
32577
+ showSaveAndNext: false,
32578
+ module: APP,
32579
+ onCancel: onCancel,
32580
+ isCreate: true,
32581
+ t: t,
32582
+ excludedKeys: ["title"],
32583
+ user: user,
32584
+ ajaxForms: ajaxForms,
32585
+ ajaxOptions: ajaxOptions,
32586
+ getAppHeader: getAppHeader,
32587
+ getApiBaseUrl: getApiBaseUrl,
32588
+ changeAjaxOptions: changeAjaxOptions,
32589
+ app: APP,
32590
+ query: query,
32591
+ goTo: goTo,
32592
+ changeAjaxForms: changeAjaxForms,
32593
+ submit: (payload, setSelectedFormNext) => {
32594
+ const payloadData = {
32595
+ ...payload,
32596
+ module: APP,
32597
+ namespace
32598
+ };
32599
+ const newPayload = {
32600
+ ...defaultData,
32601
+ ...payloadData,
32602
+ form: 'worker'
32603
+ };
32604
+ const callback = (type, m, data) => {
32605
+ if (setSelectedFormNext) {
32606
+ setSelectedFormNext();
32607
+ }
32608
+ if (type === MessageTypes.SUCCESS) {
32609
+ if (onSubmitted) onSubmitted(type, m, data);
32610
+ } else {
32611
+ antd.message.error(m);
32612
+ }
32613
+ };
32614
+ saveData(!data && !data.id ? newPayload : Object.assign(newPayload, {
32615
+ id: data.id
32616
+ }), callback);
32617
+ },
32618
+ isFormDisabled: () => {
32619
+ return !data || !data.typeOfEvent;
32620
+ }
32621
+ })
32622
+ });
32623
+ };
32624
+
32625
+ const WorkersTable = ({
32626
+ t = () => {},
32627
+ goTo = () => {},
32628
+ user = {},
32629
+ options = {},
32630
+ getRedirectLink = () => {},
32631
+ theme = {},
32632
+ loading = false,
32633
+ data = {},
32634
+ isMobile,
32635
+ APP,
32636
+ location,
32637
+ getData = () => {},
32638
+ getApiBaseUrl = () => {},
32639
+ getAppHeader = () => {},
32640
+ getFormData = () => {},
32641
+ saveFormData = () => {},
32642
+ formLoading = false,
32643
+ query = {},
32644
+ ajaxForms = {},
32645
+ changeAjaxForms = () => {},
32646
+ ajaxOptions = {},
32647
+ changeAjaxOptions = () => {},
32648
+ formData = {},
32649
+ formValue = {},
32650
+ form = {},
32651
+ extendingFilters = {},
32652
+ createDefaultValues = {},
32653
+ applications = []
32654
+ }) => {
32655
+ const [selectOptions, setSelectOptions] = React.useState();
32656
+ const [activeTab, setActiveTab] = React.useState();
32657
+ const columns = React.useMemo(() => getColumns$1({
32658
+ t,
32659
+ goTo,
32660
+ user,
32661
+ options,
32662
+ activeTab,
32663
+ getRedirectLink,
32664
+ theme,
32665
+ subject: 'workers',
32666
+ data,
32667
+ applications
32668
+ }), [t, goTo, user, options, activeTab, getRedirectLink, theme, data, applications]);
32669
+ const breadCrumbs = [];
32670
+ const {
32671
+ paginationQuery,
32672
+ searchParams,
32673
+ otherParams,
32674
+ sortBy,
32675
+ sortDir
32676
+ } = useGetQueryParams({
32677
+ location
32678
+ });
32679
+ React.useMemo(() => {
32680
+ return {
32681
+ ...otherParams,
32682
+ ...extendingFilters
32683
+ };
32684
+ }, [otherParams, extendingFilters]);
32685
+ React.useEffect(() => {
32686
+ getData({
32687
+ pagination: paginationQuery,
32688
+ ...(Object.keys(searchParams).length > 0 && {
32689
+ search: searchParams
32690
+ }),
32691
+ ...otherParams,
32692
+ tab: activeTab,
32693
+ sortBy: {
32694
+ [sortBy || "updatedAt"]: sortDir ? sortDir === "ascend" ? 1 : -1 : -1
32695
+ },
32696
+ ...extendingFilters
32697
+ }, 'workers');
32698
+ }, [location.search, activeTab, JSON.stringify(extendingFilters)]);
32699
+ const selectFiltersConfig = React.useMemo(() => {
32700
+ return getFiltersConfig$1({
32701
+ t
32702
+ });
32703
+ }, [t]);
32704
+ React.useEffect(() => {
32705
+ setSelectOptions(prev => ({
32706
+ ...prev,
32707
+ ...getFilterOptions$1(options)
32708
+ }));
32709
+ }, [options, t]);
32710
+ const handleActiveTabChange = React.useCallback(value => {
32711
+ setActiveTab(value);
32712
+ }, []);
32713
+ return /*#__PURE__*/jsxRuntime.jsx(TablePageWithTabs, {
32714
+ t: t,
32715
+ title: t("Workers"),
32716
+ breadCrumbs: breadCrumbs,
32717
+ location: location,
32718
+ loading: loading,
32719
+ goTo: goTo,
32720
+ defaultActiveTab: "all",
32721
+ columns: columns,
32722
+ data: data,
32723
+ checkboxConfig: checkboxConfig$1,
32724
+ APP: APP,
32725
+ getApiBaseUrl: getApiBaseUrl,
32726
+ selectOptions: selectOptions,
32727
+ selectFiltersConfig: selectFiltersConfig,
32728
+ getRedirectLink: getRedirectLink,
32729
+ filtersConfig: filtersConfig$1,
32730
+ isMobile: isMobile,
32731
+ view: "workers",
32732
+ getActiveTab: handleActiveTabChange,
32733
+ onDownload: () => {
32734
+ console.log("download");
32735
+ },
32736
+ drawerTitle: t("Create Worker"),
32737
+ children: ({
32738
+ onDrawerClose
32739
+ }) => /*#__PURE__*/jsxRuntime.jsx(StakeholdersCreate$1, {
32740
+ defaultData: createDefaultValues,
32741
+ t: t,
32742
+ goTo: goTo,
32743
+ user: user,
32744
+ APP: APP,
32745
+ getApiBaseUrl: getApiBaseUrl,
32746
+ getAppHeader: getAppHeader,
32747
+ getData: getFormData,
32748
+ saveData: saveFormData,
32749
+ loading: formLoading,
32750
+ onSubmitted: (type, m, data) => {
32751
+ if (data.datastakeId) {
32752
+ displayMessage(type, t("affirmations::subject-created-successfully") || m);
32753
+ // goTo(`/app/edit/stakeholders/${data.datastakeId}`);
32754
+ goTo(`/app/edit/workers/${data.datastakeId}`);
32755
+ }
32756
+ },
32757
+ onCancel: onDrawerClose,
32758
+ query: query,
32759
+ ajaxForms: ajaxForms,
32760
+ changeAjaxForms: changeAjaxForms,
32761
+ ajaxOptions: ajaxOptions,
32762
+ changeAjaxOptions: changeAjaxOptions,
32763
+ formData: formData,
32764
+ formValue: formValue,
32765
+ form: form
32766
+ })
32767
+ });
32768
+ };
32769
+
32770
+ const getLinkValue = (value, linkingObject) => {
32771
+ if (linkingObject && linkingObject?.[value]) {
32772
+ return linkingObject?.[value]?.name;
32773
+ }
32774
+ return null;
32775
+ };
32776
+ const getEventCategoryBySubject = (eventCategoryObject, subject) => {
32777
+ if (!eventCategoryObject || typeof eventCategoryObject !== 'object') {
32778
+ return null;
32779
+ }
32780
+ const subjectSingular = subject.endsWith('ies') ? subject.slice(0, -3) + 'y' : subject.endsWith('s') ? subject.slice(0, -1) : subject;
32781
+ const key = `typeOfEvent is ${subjectSingular}`;
32782
+ return eventCategoryObject[key] || null;
32783
+ };
32784
+ const renderStatusTag = ({
32785
+ value,
32786
+ t = s => s
32787
+ }) => {
32788
+ const width = 87;
32789
+ switch (value) {
32790
+ case "edited":
32791
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
32792
+ color: "yellow",
32793
+ style: {
32794
+ width
32795
+ },
32796
+ className: "text-center",
32797
+ children: t("Edited")
32798
+ });
32799
+ case "submitted":
32800
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
32801
+ color: "green",
32802
+ style: {
32803
+ width
32804
+ },
32805
+ className: "text-center",
32806
+ children: t("Submitted")
32807
+ });
32808
+ default:
32809
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
32810
+ color: "blue",
32811
+ style: {
32812
+ width
32813
+ },
32814
+ className: "text-center",
32815
+ children: t("Private")
32816
+ });
32817
+ }
32818
+ };
32819
+ const getColumns = ({
32820
+ t,
32821
+ goTo,
32822
+ user,
32823
+ options,
32824
+ activeTab,
32825
+ getRedirectLink,
32826
+ theme,
32827
+ subject,
32828
+ data,
32829
+ applications
32830
+ }) => [{
32831
+ dataIndex: 'datastakeId',
32832
+ title: t('ID'),
32833
+ ellipsis: true,
32834
+ show: true,
32835
+ render: (v, all) => {
32836
+ if (all.empty) {
32837
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32838
+ className: "daf-default-cell"
32839
+ });
32840
+ }
32841
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
32842
+ title: v,
32843
+ children: v
32844
+ });
32845
+ }
32846
+ }, {
32847
+ dataIndex: 'name',
32848
+ title: t('Title'),
32849
+ ellipsis: true,
32850
+ show: true,
32851
+ render: (v, all) => {
32852
+ if (all.empty) {
32853
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32854
+ className: "daf-default-cell"
32855
+ });
32856
+ }
32857
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
32858
+ title: v,
32859
+ children: v
32860
+ });
32861
+ }
32862
+ }, {
32863
+ title: t("Date"),
32864
+ dataIndex: "date",
32865
+ key: "date",
32866
+ render: (date, all) => {
32867
+ if (all.empty) {
32868
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32869
+ className: "daf-default-cell"
32870
+ });
32871
+ }
32872
+ const _date = date ? renderDateFormatted(date, "DD MMM YYYY", user?.language || 'en') : "-";
32873
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
32874
+ title: _date,
32875
+ children: _date
32876
+ });
32877
+ },
32878
+ ellipsis: true
32879
+ }, {
32880
+ dataIndex: 'mineSite',
32881
+ title: t('Location'),
32882
+ ellipsis: true,
32883
+ show: true,
32884
+ render: (v, all) => {
32885
+ if (all.empty) {
32886
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32887
+ className: "daf-default-cell"
32888
+ });
32889
+ }
32890
+
32891
+ // const country = findOptions(v, data?.options?.positionSupplyChainOptions);
32892
+ const mineSite = all?.location?.name;
32893
+ return mineSite ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
32894
+ title: mineSite,
32895
+ children: mineSite
32896
+ }) : '-';
32897
+ }
32898
+ }, {
32899
+ dataIndex: 'province',
32900
+ title: t('Province'),
32901
+ ellipsis: true,
32902
+ show: true,
32903
+ render: (v, all) => {
32904
+ if (all.empty) {
32905
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32906
+ className: "daf-default-cell"
32907
+ });
32908
+ }
32909
+ const region = getLinkValue(all?.location?.administrativeLevel1, all?.location?.linking?.SCL);
32910
+ return region ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
32911
+ title: region,
32912
+ children: region
32913
+ }) : '-';
32914
+ }
32915
+ }, {
32916
+ dataIndex: 'territory',
32917
+ title: t('Territory'),
32918
+ ellipsis: true,
32919
+ show: true,
32920
+ render: (v, all) => {
32921
+ if (all.empty) {
32922
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32923
+ className: "daf-default-cell"
32924
+ });
32925
+ }
32926
+ const district = getLinkValue(all?.location?.administrativeLevel2, all?.location?.linking?.SCL);
32927
+ return district ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
32928
+ title: district,
32929
+ children: district
32930
+ }) : '-';
32931
+ }
32932
+ }, {
32933
+ dataIndex: 'eventCategory',
32934
+ title: t('Category'),
32935
+ ellipsis: true,
32936
+ show: true,
32937
+ render: (v, all) => {
32938
+ if (all.empty) {
32939
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32940
+ className: "daf-default-cell"
32941
+ });
32942
+ }
32943
+ const eventCategory = findOptions(v, data?.options?.eventCategoryOptions);
32944
+ const categoryValue = getEventCategoryBySubject(eventCategory, subject);
32945
+ return categoryValue ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
32946
+ title: categoryValue,
32947
+ children: categoryValue
32948
+ }) : '-';
32949
+ }
32950
+ }, {
32951
+ title: t("Sources"),
32952
+ dataIndex: "sources",
32953
+ key: "sources",
32954
+ show: activeTab !== "own",
32955
+ render: (val, all) => {
32956
+ if (all.empty) {
32957
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32958
+ className: "daf-default-cell"
32959
+ });
32960
+ }
32961
+ const sources = sourceAvatarConfig(val, user, applications);
32962
+ return /*#__PURE__*/jsxRuntime.jsx(AvatarGroup, {
32963
+ items: sources
32964
+ });
32965
+ }
32966
+ }, {
32967
+ title: t("Status"),
32968
+ dataIndex: "status",
32969
+ key: "status",
32970
+ show: activeTab === "own",
32971
+ render: (val, all) => {
32972
+ if (all.empty) {
32973
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32974
+ className: "daf-default-cell"
32975
+ });
32976
+ }
32977
+ const _val = all?.published || all?.status === "submitted" ? "submitted" : val;
32978
+ return renderStatusTag({
32979
+ value: _val,
32980
+ t
32981
+ });
32982
+ }
32983
+ }, {
32984
+ title: t("Last Update"),
32985
+ dataIndex: "updatedAt",
32986
+ key: "updatedAt",
32987
+ render: (date, all) => {
32988
+ if (all.empty) {
32989
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32990
+ className: "daf-default-cell"
32991
+ });
32992
+ }
32993
+ const _date = date ? renderDateFormatted(date, "DD MMM YYYY", user?.language || 'en') : "-";
32994
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
32995
+ title: _date,
32996
+ children: _date
32997
+ });
32998
+ },
32999
+ ellipsis: true
33000
+ }, {
33001
+ id: 'actions',
33002
+ title: "",
33003
+ width: 60,
33004
+ render: (_, all) => {
33005
+ if (all.empty) {
33006
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
33007
+ className: "daf-default-cell"
33008
+ });
33009
+ }
33010
+ const link = `/app/view/${subject}/${all.datastakeId}`;
33011
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
33012
+ style: {
33013
+ display: "flex",
33014
+ justifyContent: "center"
33015
+ },
33016
+ children: /*#__PURE__*/jsxRuntime.jsx("a", {
33017
+ href: getRedirectLink(link),
33018
+ children: /*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
33019
+ name: "Link",
33020
+ size: 15,
33021
+ color: theme.baseGray70
33022
+ })
33023
+ })
33024
+ });
33025
+ }
33026
+ }].filter(column => column.show !== false);
33027
+
33028
+ const checkboxConfig = {
33029
+ name: 'Name',
33030
+ datastakeId: 'ID'
33031
+ };
33032
+ const getFiltersConfig = ({
33033
+ t
33034
+ }) => {
33035
+ return {
33036
+ country: {
33037
+ type: 'select',
33038
+ label: 'Country',
33039
+ placeholder: t => `${t('Filter by')} ${t('Country').toLowerCase()}`,
33040
+ style: {
33041
+ flex: 1
33042
+ },
33043
+ labelStyle: {
33044
+ flex: 1
33045
+ },
33046
+ getLabel: option => option.label,
33047
+ getValue: option => option.value
33048
+ },
33049
+ administrativeLevel1: {
33050
+ type: 'ajaxSelect',
33051
+ label: ({
33052
+ t = s => s,
33053
+ options = {},
33054
+ filters = {},
33055
+ language = 'en'
33056
+ }) => {
33057
+ const {
33058
+ administrativeLevel1
33059
+ } = options;
33060
+ if (administrativeLevel1) {
33061
+ if (options.country) {
33062
+ const _item = administrativeLevel1[filters.country];
33063
+ if (_item) {
33064
+ if (_item[language]) {
33065
+ return _item[language];
33066
+ }
33067
+ }
33068
+ }
33069
+ }
33070
+ return t('Province');
33071
+ },
33072
+ placeholder: t => `${t('Filter by')} ${t('Province').toLowerCase()}`,
33073
+ filters: data => ({
33074
+ country: data.country,
33075
+ level: 'level_1'
33076
+ }),
33077
+ show: data => !data.country,
33078
+ disabled: data => !data.country,
33079
+ mapper: {
33080
+ label: "name",
33081
+ value: "id"
33082
+ },
33083
+ method: 'getOptions',
33084
+ entity: 'AdministrativeLevel',
33085
+ style: {
33086
+ flex: 1
33087
+ },
33088
+ labelStyle: {
33089
+ flex: 1
33090
+ }
33091
+ },
33092
+ administrativeLevel2: {
33093
+ type: 'ajaxSelect',
33094
+ label: ({
33095
+ t = s => s,
33096
+ options = {},
33097
+ filters = {},
33098
+ language = 'en'
33099
+ }) => {
33100
+ const {
33101
+ administrativeLevel2
33102
+ } = options;
33103
+ if (administrativeLevel2) {
33104
+ if (options.country) {
33105
+ const _item = administrativeLevel2[filters.country];
33106
+ if (_item) {
33107
+ if (_item[language]) {
33108
+ return _item[language];
33109
+ }
33110
+ }
33111
+ }
33112
+ }
33113
+ return t('Province');
33114
+ },
33115
+ show: data => !(data.country && data.administrativeLevel1),
33116
+ placeholder: t => `${t('Filter by')} ${t('Territory').toLowerCase()}`,
33117
+ filters: data => ({
33118
+ country: data.country,
33119
+ level: 'level_2',
33120
+ administrativeLevel1: data.administrativeLevel1
33121
+ }),
33122
+ disabled: data => !(data.country && data.administrativeLevel1),
33123
+ mapper: {
33124
+ label: "name",
33125
+ value: "id"
33126
+ },
33127
+ method: 'getOptions',
33128
+ entity: 'AdministrativeLevel',
33129
+ style: {
33130
+ flex: 1
33131
+ },
33132
+ labelStyle: {
33133
+ flex: 1
33134
+ }
33135
+ },
33136
+ activity: {
33137
+ type: 'select',
33138
+ label: 'Activity',
33139
+ placeholder: t => `${t('Filter by')} ${t('Activity').toLowerCase()}`,
33140
+ style: {
33141
+ flex: 1
33142
+ },
33143
+ labelStyle: {
33144
+ flex: 1
33145
+ },
33146
+ getLabel: option => option.label,
33147
+ getValue: option => option.value,
33148
+ filterOptions: val => {
33149
+ if (val) {
33150
+ const {
33151
+ option,
33152
+ filters
33153
+ } = val;
33154
+ if (filters && option) {
33155
+ const {
33156
+ filters: optionFilters
33157
+ } = option;
33158
+ if (Array.isArray(optionFilters) && optionFilters.length) {
33159
+ const {
33160
+ value,
33161
+ condition
33162
+ } = optionFilters[0];
33163
+ if (condition === 'includes') {
33164
+ return value.includes('corporation');
33165
+ }
33166
+ }
33167
+ }
33168
+ }
33169
+ return true;
33170
+ }
33171
+ },
33172
+ positionInTheMineralSupplyChain: {
33173
+ type: 'select',
33174
+ label: 'Position',
33175
+ placeholder: t => `${t('Filter by')} ${t('Position').toLowerCase()}`,
33176
+ style: {
33177
+ flex: 1
33178
+ },
33179
+ labelStyle: {
33180
+ flex: 1
33181
+ },
33182
+ getLabel: option => option.label,
33183
+ getValue: option => option.value
33184
+ },
33185
+ status: {
33186
+ type: "select",
33187
+ label: "Status",
33188
+ placeholder: t => `${t("Filter by")} ${t("Status").toLowerCase()}`,
33189
+ style: {
33190
+ flex: 1
33191
+ },
33192
+ labelStyle: {
33193
+ fley: 1
33194
+ },
33195
+ getLabel: option => option.label,
33196
+ getValue: option => option.value
33197
+ }
33198
+ };
33199
+ };
33200
+ const filtersConfig = {
33201
+ name: '',
33202
+ datastakeId: ''
33203
+ };
33204
+ const getFilterOptions = (options, t) => {
33205
+ const {
33206
+ statusOptions = [],
33207
+ categoryOptions = [],
33208
+ countries = [],
33209
+ subCategory = [],
33210
+ activityAtSiteOptions = [],
33211
+ stakeholderCategoryOptions,
33212
+ stakeholderSubCategoriesOptions,
33213
+ administrativeLevel1,
33214
+ administrativeLevel2,
33215
+ positionInMineralSupplyChainOptions,
33216
+ subCategoriesOptions
33217
+ } = options || {};
33218
+ const _default = {
33219
+ status: [{
33220
+ value: "submitted",
33221
+ label: "Submitted"
33222
+ }, {
33223
+ value: "private",
33224
+ label: "Private"
33225
+ }],
33226
+ category: stakeholderCategoryOptions || categoryOptions,
33227
+ country: countries,
33228
+ subCategory: subCategoriesOptions,
33229
+ activity: activityAtSiteOptions,
33230
+ administrativeLevel1,
33231
+ administrativeLevel2,
33232
+ positionInTheMineralSupplyChain: positionInMineralSupplyChainOptions
33233
+ };
33234
+ return _default;
33235
+ };
33236
+
33237
+ const StakeholdersCreate = ({
33238
+ namespace = "corrective-actions",
33239
+ view = "corrective-actions",
33240
+ edit = false,
33241
+ formData = {},
33242
+ loading = false,
33243
+ onSubmitted = () => {},
33244
+ onCancel = () => {},
33245
+ getData = () => {},
33246
+ saveData = () => {},
33247
+ form: formConfig = {},
33248
+ formValue = {},
33249
+ defaultData = {},
33250
+ user = {},
33251
+ APP,
33252
+ query,
33253
+ goTo = () => {},
33254
+ t = () => {},
33255
+ ajaxForms = {},
33256
+ changeAjaxForms = () => {},
33257
+ ajaxOptions = {},
33258
+ changeAjaxOptions = () => {},
33259
+ getAppHeader = () => {},
33260
+ getApiBaseUrl = () => {}
33261
+ }) => {
33262
+ let {
33263
+ form = {},
33264
+ data = defaultData || {}
33265
+ } = !edit ? formData[`${APP}-${view}`] || {} : {
33266
+ form: formConfig,
33267
+ data: formValue
33268
+ };
33269
+ React.useEffect(() => {
33270
+ if (Object.keys(form).length === 0 && !formData[`${APP}-${view}`]) {
33271
+ if (!edit) {
33272
+ getData({
33273
+ namespace,
33274
+ module: APP,
33275
+ view,
33276
+ scope: 'createActivity'
33277
+ });
33278
+ } else {
33279
+ form = formConfig;
33280
+ data = formValue;
33281
+ }
33282
+ }
33283
+ }, [edit, user?.language]);
33284
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
33285
+ className: "daf-create-form",
33286
+ children: /*#__PURE__*/jsxRuntime.jsx(DynamicForm, {
33287
+ form: form,
33288
+ data: {
33289
+ ...defaultData,
33290
+ ...data
33291
+ },
33292
+ showSaveAndNext: false,
33293
+ module: APP,
33294
+ onCancel: onCancel,
33295
+ isCreate: true,
33296
+ t: t,
33297
+ excludedKeys: ["title"],
33298
+ user: user,
33299
+ ajaxForms: ajaxForms,
33300
+ ajaxOptions: ajaxOptions,
33301
+ getAppHeader: getAppHeader,
33302
+ getApiBaseUrl: getApiBaseUrl,
33303
+ changeAjaxOptions: changeAjaxOptions,
33304
+ app: APP,
33305
+ query: query,
33306
+ goTo: goTo,
33307
+ changeAjaxForms: changeAjaxForms,
33308
+ submit: (payload, setSelectedFormNext) => {
33309
+ const payloadData = {
33310
+ ...payload,
33311
+ module: APP,
33312
+ namespace
33313
+ };
33314
+ const newPayload = {
33315
+ ...defaultData,
33316
+ ...payloadData,
33317
+ form: 'worker'
33318
+ };
33319
+ const callback = (type, m, data) => {
33320
+ if (setSelectedFormNext) {
33321
+ setSelectedFormNext();
33322
+ }
33323
+ if (type === MessageTypes.SUCCESS) {
33324
+ if (onSubmitted) onSubmitted(type, m, data);
33325
+ } else {
33326
+ antd.message.error(m);
33327
+ }
33328
+ };
33329
+ saveData(!data && !data.id ? newPayload : Object.assign(newPayload, {
33330
+ id: data.id
33331
+ }), callback);
33332
+ },
33333
+ isFormDisabled: () => {
33334
+ return !data || !data.typeOfEvent;
33335
+ }
33336
+ })
33337
+ });
33338
+ };
33339
+
33340
+ const ActivitiesTable = ({
33341
+ t = () => {},
33342
+ goTo = () => {},
33343
+ user = {},
33344
+ options = {},
33345
+ getRedirectLink = () => {},
33346
+ theme = {},
33347
+ loading = false,
33348
+ data = {},
33349
+ isMobile,
33350
+ APP,
33351
+ location,
33352
+ getData = () => {},
33353
+ getApiBaseUrl = () => {},
33354
+ getAppHeader = () => {},
33355
+ getFormData = () => {},
33356
+ saveFormData = () => {},
33357
+ formLoading = false,
33358
+ query = {},
33359
+ ajaxForms = {},
33360
+ changeAjaxForms = () => {},
33361
+ ajaxOptions = {},
33362
+ changeAjaxOptions = () => {},
33363
+ formData = {},
33364
+ formValue = {},
33365
+ form = {},
33366
+ extendingFilters = {},
33367
+ createDefaultValues = {},
33368
+ applications = []
33369
+ }) => {
33370
+ const [selectOptions, setSelectOptions] = React.useState();
33371
+ const [activeTab, setActiveTab] = React.useState();
33372
+ const columns = React.useMemo(() => getColumns({
33373
+ t,
33374
+ goTo,
33375
+ user,
33376
+ options,
33377
+ activeTab,
33378
+ getRedirectLink,
33379
+ theme,
33380
+ subject: 'activities',
33381
+ data,
33382
+ applications
33383
+ }), [t, goTo, user, options, activeTab, getRedirectLink, theme, data, applications]);
33384
+ const breadCrumbs = [];
33385
+ const {
33386
+ paginationQuery,
33387
+ searchParams,
33388
+ otherParams,
33389
+ sortBy,
33390
+ sortDir
33391
+ } = useGetQueryParams({
33392
+ location
33393
+ });
33394
+ React.useMemo(() => {
33395
+ return {
33396
+ ...otherParams,
33397
+ ...extendingFilters
33398
+ };
33399
+ }, [otherParams, extendingFilters]);
33400
+ React.useEffect(() => {
33401
+ getData({
33402
+ pagination: paginationQuery,
33403
+ ...(Object.keys(searchParams).length > 0 && {
33404
+ search: searchParams
33405
+ }),
33406
+ ...otherParams,
33407
+ tab: activeTab,
33408
+ sortBy: {
33409
+ [sortBy || "updatedAt"]: sortDir ? sortDir === "ascend" ? 1 : -1 : -1
33410
+ },
33411
+ ...extendingFilters
33412
+ }, 'activities');
33413
+ }, [location.search, activeTab, JSON.stringify(extendingFilters)]);
33414
+ const selectFiltersConfig = React.useMemo(() => {
33415
+ return getFiltersConfig({
33416
+ t
33417
+ });
33418
+ }, [t]);
33419
+ React.useEffect(() => {
33420
+ setSelectOptions(prev => ({
33421
+ ...prev,
33422
+ ...getFilterOptions(options)
33423
+ }));
33424
+ }, [options, t]);
33425
+ const handleActiveTabChange = React.useCallback(value => {
33426
+ setActiveTab(value);
33427
+ }, []);
33428
+ return /*#__PURE__*/jsxRuntime.jsx(TablePageWithTabs, {
33429
+ t: t,
33430
+ title: t("Activities"),
33431
+ breadCrumbs: breadCrumbs,
33432
+ location: location,
33433
+ loading: loading,
33434
+ goTo: goTo,
33435
+ defaultActiveTab: "all",
33436
+ columns: columns,
33437
+ data: data,
33438
+ checkboxConfig: checkboxConfig,
33439
+ APP: APP,
33440
+ getApiBaseUrl: getApiBaseUrl,
33441
+ selectOptions: selectOptions,
33442
+ selectFiltersConfig: selectFiltersConfig,
33443
+ getRedirectLink: getRedirectLink,
33444
+ filtersConfig: filtersConfig,
33445
+ isMobile: isMobile,
33446
+ view: "activities",
33447
+ getActiveTab: handleActiveTabChange,
33448
+ onDownload: () => {
33449
+ console.log("download");
33450
+ },
33451
+ drawerTitle: t("Create Activity"),
33452
+ children: ({
33453
+ onDrawerClose
33454
+ }) => /*#__PURE__*/jsxRuntime.jsx(StakeholdersCreate, {
33455
+ defaultData: createDefaultValues,
33456
+ t: t,
33457
+ goTo: goTo,
33458
+ user: user,
33459
+ APP: APP,
33460
+ getApiBaseUrl: getApiBaseUrl,
33461
+ getAppHeader: getAppHeader,
33462
+ getData: getFormData,
33463
+ saveData: saveFormData,
33464
+ loading: formLoading,
33465
+ onSubmitted: (type, m, data) => {
33466
+ if (data.datastakeId) {
33467
+ displayMessage(type, t("affirmations::subject-created-successfully") || m);
33468
+ // goTo(`/app/edit/stakeholders/${data.datastakeId}`);
33469
+ goTo(`/app/edit/activities/${data.datastakeId}`);
33470
+ }
33471
+ },
33472
+ onCancel: onDrawerClose,
33473
+ query: query,
33474
+ ajaxForms: ajaxForms,
33475
+ changeAjaxForms: changeAjaxForms,
33476
+ ajaxOptions: ajaxOptions,
33477
+ changeAjaxOptions: changeAjaxOptions,
33478
+ formData: formData,
33479
+ formValue: formValue,
33480
+ form: form
33481
+ })
33482
+ });
33483
+ };
33484
+
33485
+ exports.ActivitiesTable = ActivitiesTable;
32074
33486
  exports.DocumentsTable = DocumentsTable;
32075
33487
  exports.EventsTable = EventsTable;
32076
33488
  exports.LocationsTable = LocationsTable;
@@ -32079,3 +33491,4 @@ exports.StakeholdersTable = StakeholdersTable;
32079
33491
  exports.SupplyChainDashboard = SupplyChain;
32080
33492
  exports.TablePageWithTabs = TablePageWithTabs;
32081
33493
  exports.UserDashboard = UserDashboard;
33494
+ exports.WorkersTable = WorkersTable;