datastake-daf 0.6.835 → 0.6.837

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 (34) hide show
  1. package/dist/components/index.js +2327 -2204
  2. package/dist/hooks/index.js +7 -8
  3. package/dist/pages/index.js +409 -192
  4. package/dist/services/index.js +7 -8
  5. package/package.json +1 -1
  6. package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/TopContributors/hook.js +3 -3
  7. package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/TopContributors/index.jsx +2 -2
  8. package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/index.jsx +2 -6
  9. package/src/@daf/core/components/Screens/Admin/AdminTables/AccountTable/index.jsx +0 -1
  10. package/src/@daf/{core/components/Screens → pages/Dashboards}/ConflictManagement/components/KeyIndicators/config.js +2 -3
  11. package/src/@daf/{core/components/Screens → pages/Dashboards}/ConflictManagement/components/KeyIndicators/index.js +2 -2
  12. package/src/@daf/{core/components/Screens → pages/Dashboards}/ConflictManagement/components/MineSite/index.js +3 -3
  13. package/src/@daf/pages/Dashboards/ConflictManagement/components/RisksWidget/components/IncidentsTime/config.js +206 -0
  14. package/src/@daf/pages/Dashboards/ConflictManagement/components/RisksWidget/components/IncidentsTime/hook.js +48 -0
  15. package/src/@daf/pages/Dashboards/ConflictManagement/components/RisksWidget/components/IncidentsTime/index.js +154 -0
  16. package/src/@daf/pages/Dashboards/ConflictManagement/components/RisksWidget/components/ProblemSolver/hook.js +83 -0
  17. package/src/@daf/{core/components/Screens → pages/Dashboards}/ConflictManagement/components/RisksWidget/components/ProblemSolver/index.js +14 -7
  18. package/src/@daf/pages/Dashboards/ConflictManagement/components/RisksWidget/components/TerritorialDistribution/config.js +10 -0
  19. package/src/@daf/{core/components/Screens → pages/Dashboards}/ConflictManagement/components/RisksWidget/components/TerritorialDistribution/index.js +18 -13
  20. package/src/@daf/{core/components/Screens → pages/Dashboards}/ConflictManagement/components/RisksWidget/index.js +1 -1
  21. package/src/@daf/{core/components/Screens → pages/Dashboards}/ConflictManagement/index.js +17 -19
  22. package/src/@daf/services/DashboardService.js +8 -8
  23. package/src/pages.js +1 -1
  24. package/build/favicon.ico +0 -0
  25. package/build/logo192.png +0 -0
  26. package/build/logo512.png +0 -0
  27. package/build/manifest.json +0 -25
  28. package/build/robots.txt +0 -3
  29. package/src/@daf/core/components/Screens/ConflictManagement/components/RisksWidget/components/IncidentsTime/hook.js +0 -32
  30. package/src/@daf/core/components/Screens/ConflictManagement/components/RisksWidget/components/IncidentsTime/index.js +0 -73
  31. package/src/@daf/core/components/Screens/ConflictManagement/components/RisksWidget/components/ProblemSolver/hook.js +0 -86
  32. package/src/@daf/core/components/Screens/ConflictManagement/components/RisksWidget/components/TerritorialDistribution/config.js +0 -34
  33. /package/src/@daf/{core/components/Screens → pages/Dashboards}/ConflictManagement/components/MineSite/helper.js +0 -0
  34. /package/src/@daf/{core/components/Screens → pages/Dashboards}/ConflictManagement/components/RisksWidget/config.js +0 -0
@@ -7476,14 +7476,13 @@ class DashboardService extends BaseService {
7476
7476
  isUserManager: true
7477
7477
  });
7478
7478
  }
7479
-
7480
- // getWidgetConflictManagement({ url, params = {}, filters = {} }) {
7481
- // return this.apiGet({
7482
- // url: `/dashboard/conflict-management${url}`,
7483
- // params: { ...params, ...filters },
7484
- // isApp: true,
7485
- // });
7486
- // }
7479
+ getWidgetConflictManagement(url, params, basepath = "dashboard/conflict-management") {
7480
+ return this.apiGet({
7481
+ url: `/${basepath}${url}`,
7482
+ params,
7483
+ isApp: true
7484
+ });
7485
+ }
7487
7486
  }
7488
7487
  var DashboardService$1 = createLazyService(DashboardService);
7489
7488
 
@@ -7495,7 +7494,7 @@ var DashboardService$1 = createLazyService(DashboardService);
7495
7494
  // basePath: string,
7496
7495
  // }
7497
7496
 
7498
- const useWidgetFetch$1 = ({
7497
+ const useWidgetFetch = ({
7499
7498
  config,
7500
7499
  getData = DashboardService$1.getWidget,
7501
7500
  onFetch = () => {}
@@ -8197,7 +8196,7 @@ function KeyIndicators$2({
8197
8196
  const {
8198
8197
  data,
8199
8198
  loading
8200
- } = useWidgetFetch$1({
8199
+ } = useWidgetFetch({
8201
8200
  config: fetchConfig
8202
8201
  });
8203
8202
  const config = React.useMemo(() => {
@@ -11304,7 +11303,7 @@ function SupplyChainMap({
11304
11303
  const {
11305
11304
  loading,
11306
11305
  data
11307
- } = useWidgetFetch$1({
11306
+ } = useWidgetFetch({
11308
11307
  config: defaultConfig
11309
11308
  });
11310
11309
  return /*#__PURE__*/jsxRuntime.jsx(Widget, {
@@ -13897,7 +13896,7 @@ function ChartsContainer({
13897
13896
  const {
13898
13897
  loading,
13899
13898
  data
13900
- } = useWidgetFetch$1({
13899
+ } = useWidgetFetch({
13901
13900
  config: defaultConfig,
13902
13901
  onFetch: () => setPreviousRange(selectedRange)
13903
13902
  });
@@ -14196,7 +14195,7 @@ function KeyIndicators$1({
14196
14195
  const {
14197
14196
  data,
14198
14197
  loading
14199
- } = useWidgetFetch$1({
14198
+ } = useWidgetFetch({
14200
14199
  config: fetchConfig
14201
14200
  });
14202
14201
  const config = React.useMemo(() => getRowConfig$1({
@@ -14433,7 +14432,7 @@ function MineSites$1({
14433
14432
  const {
14434
14433
  data: _formData,
14435
14434
  loading: formLoading
14436
- } = useWidgetFetch$1({
14435
+ } = useWidgetFetch({
14437
14436
  config: _formFetchConfig
14438
14437
  });
14439
14438
  React.useEffect(() => {
@@ -14462,7 +14461,7 @@ function MineSites$1({
14462
14461
  data,
14463
14462
  loading,
14464
14463
  setData
14465
- } = useWidgetFetch$1({
14464
+ } = useWidgetFetch({
14466
14465
  config: dataFetchConfig
14467
14466
  });
14468
14467
  const tabs = React.useMemo(() => getTabs(t), [t]);
@@ -14840,7 +14839,7 @@ function AccumulationGraph({
14840
14839
  const {
14841
14840
  data,
14842
14841
  loading
14843
- } = useWidgetFetch$1({
14842
+ } = useWidgetFetch({
14844
14843
  config: fetchConfig
14845
14844
  });
14846
14845
  const selectOptions = React.useMemo(() => [{
@@ -15188,7 +15187,7 @@ function ContributionsGraph({
15188
15187
  const {
15189
15188
  data,
15190
15189
  loading
15191
- } = useWidgetFetch$1({
15190
+ } = useWidgetFetch({
15192
15191
  config: fetchConfig
15193
15192
  });
15194
15193
  const chartConfig = useContributionsGraph({
@@ -15318,7 +15317,7 @@ function Triangulation({
15318
15317
  const {
15319
15318
  data: widgetData,
15320
15319
  loading
15321
- } = useWidgetFetch$1({
15320
+ } = useWidgetFetch({
15322
15321
  config: fetchConfig
15323
15322
  });
15324
15323
  const {
@@ -15479,7 +15478,7 @@ function DataChainOfCustody({
15479
15478
  const {
15480
15479
  data,
15481
15480
  loading
15482
- } = useWidgetFetch$1({
15481
+ } = useWidgetFetch({
15483
15482
  config: fetchConfig
15484
15483
  });
15485
15484
  const mappedData = mapDataForChainOfCustody(Object.keys(data)?.length > 0 ? data : hardcodedData, options, goTo);
@@ -17102,7 +17101,7 @@ function AssociatedInformation$1({
17102
17101
  const {
17103
17102
  data,
17104
17103
  loading
17105
- } = useWidgetFetch$1({
17104
+ } = useWidgetFetch({
17106
17105
  config: defaultConfig
17107
17106
  });
17108
17107
  console.log({
@@ -46405,7 +46404,7 @@ const InformationAvailability = ({
46405
46404
  const {
46406
46405
  data,
46407
46406
  loading
46408
- } = useWidgetFetch$1({
46407
+ } = useWidgetFetch({
46409
46408
  config: defaultFetchConfig
46410
46409
  });
46411
46410
  return /*#__PURE__*/jsxRuntime.jsx(Widget, {
@@ -46623,7 +46622,7 @@ const useTradeRelationship = ({
46623
46622
  }), [id, filters?.products, selectedPartners?.partners, selectedPartners?.loading]);
46624
46623
  const {
46625
46624
  data
46626
- } = useWidgetFetch$1({
46625
+ } = useWidgetFetch({
46627
46626
  config: config
46628
46627
  });
46629
46628
  const mapItem$1 = data => {
@@ -47655,7 +47654,7 @@ const Governance = ({
47655
47654
  const {
47656
47655
  data,
47657
47656
  loading
47658
- } = useWidgetFetch$1({
47657
+ } = useWidgetFetch({
47659
47658
  config: defaultFetchConfig
47660
47659
  });
47661
47660
  const graphData = React.useMemo(() => {
@@ -55544,7 +55543,7 @@ const PlantingLocations = ({
55544
55543
  const {
55545
55544
  loading: plantingLocationsLoading,
55546
55545
  data: plantingLocationsData
55547
- } = useWidgetFetch$1({
55546
+ } = useWidgetFetch({
55548
55547
  config: defaultConfig,
55549
55548
  getData: customGetData
55550
55549
  });
@@ -56242,7 +56241,7 @@ const CycleOutcomes = ({
56242
56241
  const {
56243
56242
  loading: dataDetailsLoading,
56244
56243
  data: dataDetails
56245
- } = useWidgetFetch$1({
56244
+ } = useWidgetFetch({
56246
56245
  config: defaultConfig,
56247
56246
  getData: customGetData
56248
56247
  });
@@ -56630,7 +56629,7 @@ const HealthAndSafety = ({
56630
56629
  const {
56631
56630
  loading: pieChartLoading,
56632
56631
  data: pieChartData
56633
- } = useWidgetFetch$1({
56632
+ } = useWidgetFetch({
56634
56633
  config: defaultConfig,
56635
56634
  getData: customGetData
56636
56635
  });
@@ -56759,7 +56758,7 @@ const CycleIndicators = ({
56759
56758
  const {
56760
56759
  loading: indicatorsLoading,
56761
56760
  data: indicatorsData
56762
- } = useWidgetFetch$1({
56761
+ } = useWidgetFetch({
56763
56762
  config: defaultConfig,
56764
56763
  getData: customGetData
56765
56764
  });
@@ -57268,7 +57267,7 @@ const CommunityParticipation = ({
57268
57267
  const {
57269
57268
  loading: communityParticipationLoading,
57270
57269
  data: communityParticipationData
57271
- } = useWidgetFetch$1({
57270
+ } = useWidgetFetch({
57272
57271
  config: defaultConfig,
57273
57272
  getData: customGetData
57274
57273
  });
@@ -57989,7 +57988,7 @@ const AssociatedInformation = ({
57989
57988
  loading: associatedInformationLoading,
57990
57989
  data: associatedInformationData,
57991
57990
  setData
57992
- } = useWidgetFetch$1({
57991
+ } = useWidgetFetch({
57993
57992
  config: defaultConfig,
57994
57993
  getData: customGetData
57995
57994
  });
@@ -58123,7 +58122,7 @@ const KeyInformation$1 = ({
58123
58122
  const {
58124
58123
  loading: keyInformationLoading,
58125
58124
  data: keyInformationData
58126
- } = useWidgetFetch$1({
58125
+ } = useWidgetFetch({
58127
58126
  config: defaultConfig,
58128
58127
  getData: customGetData
58129
58128
  });
@@ -58273,7 +58272,7 @@ const KeyInformation = ({
58273
58272
  const {
58274
58273
  loading: keyInformationLoading,
58275
58274
  data: keyInformationData
58276
- } = useWidgetFetch$1({
58275
+ } = useWidgetFetch({
58277
58276
  config: defaultConfig,
58278
58277
  getData: customGetData
58279
58278
  });
@@ -58330,7 +58329,7 @@ const MonitoringScopeAndFindings = ({
58330
58329
  const {
58331
58330
  loading: monitoringScopeLoading,
58332
58331
  data: monitoringScopeData
58333
- } = useWidgetFetch$1({
58332
+ } = useWidgetFetch({
58334
58333
  config: defaultConfig,
58335
58334
  getData: customGetData
58336
58335
  });
@@ -59118,7 +59117,7 @@ const MangroveGrowth = ({
59118
59117
  const {
59119
59118
  loading: outcomesLoading,
59120
59119
  data: outcomesData
59121
- } = useWidgetFetch$1({
59120
+ } = useWidgetFetch({
59122
59121
  config: defaultConfig,
59123
59122
  getData: customGetData
59124
59123
  });
@@ -59398,7 +59397,7 @@ const BiodiversityHabitat = ({
59398
59397
  const {
59399
59398
  loading: outcomesLoading,
59400
59399
  data: outcomesData
59401
- } = useWidgetFetch$1({
59400
+ } = useWidgetFetch({
59402
59401
  config: defaultConfig,
59403
59402
  getData: customGetData
59404
59403
  });
@@ -59790,7 +59789,7 @@ const SoilWaterProfile = ({
59790
59789
  const {
59791
59790
  loading: outcomesLoading,
59792
59791
  data: outcomesData
59793
- } = useWidgetFetch$1({
59792
+ } = useWidgetFetch({
59794
59793
  config: defaultConfig,
59795
59794
  getData: customGetData
59796
59795
  });
@@ -60028,7 +60027,7 @@ const StakeholderMapping = ({
60028
60027
  const {
60029
60028
  data,
60030
60029
  loading
60031
- } = useWidgetFetch$1({
60030
+ } = useWidgetFetch({
60032
60031
  config: defaultFilter
60033
60032
  });
60034
60033
  const graphData = React.useMemo(() => {
@@ -60194,7 +60193,7 @@ const MineDetailsSection = ({
60194
60193
  const {
60195
60194
  data,
60196
60195
  loading: loadingData
60197
- } = useWidgetFetch$1({
60196
+ } = useWidgetFetch({
60198
60197
  config: defaultFetchConfig
60199
60198
  });
60200
60199
  return /*#__PURE__*/jsxRuntime.jsxs("section", {
@@ -63547,7 +63546,7 @@ const getRowConfig = ({
63547
63546
  children: t("Reported Incidents")
63548
63547
  }), /*#__PURE__*/jsxRuntime.jsx("div", {
63549
63548
  className: "cursor-pointer",
63550
- onClick: () => goTo(getRedirectLink("/app/incident")),
63549
+ onClick: () => goTo(getRedirectLink("/app/incidents")),
63551
63550
  children: /*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
63552
63551
  name: "LinkNewTab",
63553
63552
  width: 16,
@@ -63644,7 +63643,7 @@ function KeyIndicators({
63644
63643
  const {
63645
63644
  data,
63646
63645
  loading
63647
- } = useWidgetFetch$1({
63646
+ } = useWidgetFetch({
63648
63647
  config: fetchConfig
63649
63648
  });
63650
63649
  const config = React.useMemo(() => getRowConfig({
@@ -63711,7 +63710,7 @@ function MineSites({
63711
63710
  const {
63712
63711
  data,
63713
63712
  loading
63714
- } = useWidgetFetch$1({
63713
+ } = useWidgetFetch({
63715
63714
  config: defaultFetchConfig
63716
63715
  });
63717
63716
  // const { user } = useSelector((state) => state.authentication);
@@ -63866,19 +63865,195 @@ function MineSites({
63866
63865
  });
63867
63866
  }
63868
63867
 
63868
+ var isoWeek = createCommonjsModule(function (module, exports) {
63869
+ !function(e,t){module.exports=t();}(commonjsGlobal,(function(){var e="day";return function(t,i,s){var a=function(t){return t.add(4-t.isoWeekday(),e)},d=i.prototype;d.isoWeekYear=function(){return a(this).year()},d.isoWeek=function(t){if(!this.$utils().u(t))return this.add(7*(t-this.isoWeek()),e);var i,d,n,o,r=a(this),u=(i=this.isoWeekYear(),d=this.$u,n=(d?s.utc:s)().year(i).startOf("year"),o=4-n.isoWeekday(),n.isoWeekday()>4&&(o+=7),n.add(o,e));return r.diff(u,"week")+1},d.isoWeekday=function(e){return this.$utils().u(e)?this.day()||7:this.day(this.day()%7?e:e-7)};var n=d.startOf;d.startOf=function(e,t){var i=this.$utils(),s=!!i.u(t)||t;return "isoweek"===i.p(e)?s?this.date(this.date()-(this.isoWeekday()-1)).startOf("day"):this.date(this.date()-1-(this.isoWeekday()-1)+7).endOf("day"):n.bind(this)(e,t)};}}));
63870
+ });
63871
+
63872
+ dayjs__default["default"].extend(isoWeek);
63873
+ function useTimelineBase({
63874
+ language,
63875
+ selectedRange
63876
+ }) {
63877
+ const locale = React.useMemo(() => language === "sp" ? "es" : language || "en", [language]);
63878
+ const baseMonths = React.useMemo(() => {
63879
+ if (selectedRange === "12") {
63880
+ const y = dayjs__default["default"]().year();
63881
+ const arr = [];
63882
+ for (let i = 0; i < 12; i++) {
63883
+ const d = dayjs__default["default"]().year(y).month(i);
63884
+ arr.push({
63885
+ key: d.format("YYYY-MM"),
63886
+ label: d.locale(locale).format("MMM YYYY"),
63887
+ date: d.toISOString()
63888
+ });
63889
+ }
63890
+ return arr;
63891
+ }
63892
+ if (selectedRange === "3") {
63893
+ const end = dayjs__default["default"]().endOf("month");
63894
+ const start = end.subtract(2, "month").startOf("month");
63895
+ const diff = end.diff(start, "month");
63896
+ const arr = [];
63897
+ for (let i = 0; i <= diff; i++) {
63898
+ const d = start.add(i, "month");
63899
+ arr.push({
63900
+ key: d.format("YYYY-MM"),
63901
+ label: d.locale(locale).format("MMM YYYY"),
63902
+ date: d.toISOString()
63903
+ });
63904
+ }
63905
+ return arr;
63906
+ }
63907
+ return [];
63908
+ }, [locale, selectedRange]);
63909
+ const baseWeeks = React.useMemo(() => {
63910
+ if (selectedRange !== "3") return [];
63911
+ const end = dayjs__default["default"]().endOf("week");
63912
+ const start = end.subtract(12, "week");
63913
+ const diff = end.diff(start, "week");
63914
+ const arr = [];
63915
+ for (let i = 0; i <= diff; i++) {
63916
+ const d = start.add(i, "week");
63917
+ arr.push({
63918
+ key: d.format("GGGG-[W]WW"),
63919
+ label: d.format("[W]WW"),
63920
+ date: d.toISOString()
63921
+ });
63922
+ }
63923
+ return arr;
63924
+ }, [selectedRange]);
63925
+ const severityOrder = ["minor", "moderate", "major"];
63926
+ const mergeWithData = React.useCallback((backendData = []) => {
63927
+ let events = [];
63928
+ if (Array.isArray(backendData)) {
63929
+ backendData.forEach(entry => {
63930
+ if (!entry) return;
63931
+ if (typeof entry === "object" && !Array.isArray(entry)) {
63932
+ Object.values(entry).forEach(arr => {
63933
+ if (Array.isArray(arr)) events.push(...arr);
63934
+ });
63935
+ } else if (Array.isArray(entry)) {
63936
+ events.push(...entry);
63937
+ }
63938
+ });
63939
+ } else if (backendData && typeof backendData === "object") {
63940
+ Object.values(backendData).forEach(arr => {
63941
+ if (Array.isArray(arr)) events.push(...arr);
63942
+ });
63943
+ }
63944
+ if (selectedRange === "12") {
63945
+ const monthBuckets = baseMonths.reduce((acc, m) => {
63946
+ acc[m.key] = [];
63947
+ return acc;
63948
+ }, {});
63949
+ events.forEach(ev => {
63950
+ const d = dayjs__default["default"](ev.date);
63951
+ const key = d.format("YYYY-MM");
63952
+ if (monthBuckets[key]) monthBuckets[key].push(ev);
63953
+ });
63954
+ const res = [];
63955
+ baseMonths.forEach(m => {
63956
+ const arr = monthBuckets[m.key];
63957
+ if (!arr.length) {
63958
+ res.push({
63959
+ label: m.label,
63960
+ key: m.key,
63961
+ severity: "placeholder",
63962
+ category: "placeholder",
63963
+ value: 1,
63964
+ isPlaceholder: true
63965
+ });
63966
+ return;
63967
+ }
63968
+ arr.sort((a, b) => severityOrder.indexOf(a.severity) - severityOrder.indexOf(b.severity)).forEach((ev, idx) => {
63969
+ const source = Array.isArray(ev.source) ? ev.source.join(", ") : ev.source;
63970
+ res.push({
63971
+ ...ev,
63972
+ source,
63973
+ label: m.label,
63974
+ key: m.key,
63975
+ indexInGroup: idx + 1,
63976
+ severity: ev.severity || "undetermined",
63977
+ category: ev.severity || "undetermined",
63978
+ value: 1
63979
+ });
63980
+ });
63981
+ });
63982
+ return res;
63983
+ }
63984
+ if (selectedRange === "3") {
63985
+ const weekBuckets = baseWeeks.reduce((acc, w) => {
63986
+ acc[w.key] = [];
63987
+ return acc;
63988
+ }, {});
63989
+ events.forEach(ev => {
63990
+ const d = dayjs__default["default"](ev.date);
63991
+ const key = d.format("GGGG-[W]WW");
63992
+ if (weekBuckets[key]) weekBuckets[key].push(ev);
63993
+ });
63994
+ const res = [];
63995
+ baseWeeks.forEach(w => {
63996
+ const arr = weekBuckets[w.key];
63997
+ if (!arr.length) {
63998
+ res.push({
63999
+ label: w.label,
64000
+ key: w.key,
64001
+ severity: "placeholder",
64002
+ category: "placeholder",
64003
+ value: 1,
64004
+ isPlaceholder: true
64005
+ });
64006
+ return;
64007
+ }
64008
+ arr.sort((a, b) => severityOrder.indexOf(a.severity) - severityOrder.indexOf(b.severity)).forEach((ev, idx) => {
64009
+ const source = Array.isArray(ev.source) ? ev.source.join(", ") : ev.source;
64010
+ res.push({
64011
+ ...ev,
64012
+ source,
64013
+ label: w.label,
64014
+ key: w.key,
64015
+ indexInGroup: idx + 1,
64016
+ severity: ev.severity || "undetermined",
64017
+ category: ev.severity || "undetermined",
64018
+ value: 1
64019
+ });
64020
+ });
64021
+ });
64022
+ return res;
64023
+ }
64024
+ return [];
64025
+ }, [selectedRange, baseMonths, baseWeeks]);
64026
+ return {
64027
+ baseMonths,
64028
+ baseWeeks,
64029
+ mergeWithData
64030
+ };
64031
+ }
64032
+
63869
64033
  function useIncidentsTimeline({
63870
- t = () => {},
63871
- options = {}
64034
+ t,
64035
+ language,
64036
+ severityOptions = [],
64037
+ selectedRange = "12"
63872
64038
  }) {
63873
64039
  const [filters, setFilters] = React.useState({
63874
64040
  severity: "all"
63875
64041
  });
64042
+ const {
64043
+ baseMonths,
64044
+ baseWeeks,
64045
+ mergeWithData
64046
+ } = useTimelineBase({
64047
+ language,
64048
+ selectedRange
64049
+ });
63876
64050
  const filtersConfig = React.useMemo(() => ({
64051
+ language,
63877
64052
  filtersConfig: {
63878
64053
  severity: {
63879
64054
  type: "select",
63880
64055
  label: "",
63881
- placeholder: t => t(""),
64056
+ placeholder: tFn => tFn(""),
63882
64057
  style: {
63883
64058
  flex: 1
63884
64059
  },
@@ -63892,44 +64067,54 @@ function useIncidentsTimeline({
63892
64067
  severity: [{
63893
64068
  value: "all",
63894
64069
  label: t("All")
63895
- }, ...(options?.severityOptions || [])]
64070
+ }, ...(severityOptions || [])]
63896
64071
  },
63897
64072
  selectedFilters: filters,
63898
64073
  type: "small",
63899
64074
  t
63900
- }), [t, filters, options?.severityOptions]);
64075
+ }), [t, language, filters, severityOptions]);
63901
64076
  return {
63902
64077
  filters,
63903
- filtersConfig
64078
+ filtersConfig,
64079
+ setFilters,
64080
+ baseMonths,
64081
+ baseWeeks,
64082
+ mergeWithData
63904
64083
  };
63905
64084
  }
63906
64085
 
63907
- function IncidentsTime({
64086
+ function IncidentsTimeline({
63908
64087
  selectedRange,
63909
64088
  selectedPartners = {},
63910
- t = () => {},
63911
- goTo = s => s,
63912
- getRedirectLink = s => s,
63913
- theme = {},
63914
- APP,
63915
- options = {}
64089
+ t,
64090
+ language,
64091
+ goTo,
64092
+ user,
64093
+ options
63916
64094
  }) {
63917
64095
  const {
63918
64096
  filters,
63919
- filtersConfig
64097
+ filtersConfig,
64098
+ mergeWithData,
64099
+ baseMonths,
64100
+ baseWeeks
63920
64101
  } = useIncidentsTimeline({
63921
64102
  t,
63922
- options
64103
+ language,
64104
+ severityOptions: options?.severityOptions || [],
64105
+ selectedRange
63923
64106
  });
63924
- const {
63925
- user
63926
- } = useSelector(state => state.authentication);
63927
- React.useCallback(sourceId => {
63928
- if (user?.company?.id !== sourceId) {
63929
- return `?sourceId=${sourceId}`;
63930
- }
64107
+ const getSourceParam = React.useCallback(sourceId => {
64108
+ if (user?.company?.id !== sourceId) return `?sourceId=${sourceId}`;
63931
64109
  return "";
63932
64110
  }, [user?.company?.id]);
64111
+ const severityColors = React.useMemo(() => ({
64112
+ major: "#cf1322",
64113
+ minor: "#fadb14",
64114
+ moderate: "#fa8c16",
64115
+ undetermined: "#999999",
64116
+ placeholder: "transparent"
64117
+ }), []);
63933
64118
  const defaultFetchConfig = React.useMemo(() => ({
63934
64119
  url: `/incidents-timeline`,
63935
64120
  filters: {
@@ -63941,67 +64126,99 @@ function IncidentsTime({
63941
64126
  defaultData: [],
63942
64127
  stop: selectedPartners?.loading
63943
64128
  }), [filters, selectedRange, selectedPartners]);
63944
- const chartConfig = {};
64129
+ const getIncidentsTimelineData = React.useCallback(({
64130
+ url,
64131
+ filters
64132
+ }) => DashboardService$1.getWidgetConflictManagement(url, filters), []);
63945
64133
  const {
63946
64134
  data,
63947
64135
  loading
63948
- } = useWidgetFetch(defaultFetchConfig);
64136
+ } = useWidgetFetch({
64137
+ config: defaultFetchConfig,
64138
+ getData: getIncidentsTimelineData
64139
+ });
64140
+ const renderSeverity = val => {
64141
+ if (val === "major") return /*#__PURE__*/jsxRuntime.jsx("span", {
64142
+ style: {
64143
+ color: severityColors.major
64144
+ },
64145
+ children: t("Major")
64146
+ });
64147
+ if (val === "minor") return /*#__PURE__*/jsxRuntime.jsx("span", {
64148
+ style: {
64149
+ color: severityColors.minor
64150
+ },
64151
+ children: t("Minor")
64152
+ });
64153
+ if (val === "moderate") return /*#__PURE__*/jsxRuntime.jsx("span", {
64154
+ style: {
64155
+ color: severityColors.moderate
64156
+ },
64157
+ children: t("Moderate")
64158
+ });
64159
+ return /*#__PURE__*/jsxRuntime.jsx("span", {
64160
+ children: t("Undetermined")
64161
+ });
64162
+ };
64163
+ const chartData = React.useMemo(() => mergeWithData(data), [data, mergeWithData]);
64164
+ const categories = React.useMemo(() => {
64165
+ if (selectedRange === "12") return baseMonths.map(m => m.label);
64166
+ return baseWeeks.map(w => w.label);
64167
+ }, [selectedRange, baseMonths, baseWeeks]);
64168
+ const getTooltipContent = React.useCallback(({
64169
+ item
64170
+ }) => {
64171
+ if (!item) return {
64172
+ title: "",
64173
+ items: []
64174
+ };
64175
+ return {
64176
+ title: item.name || item.label || t("Undetermined"),
64177
+ subTitle: renderDateFormatted(item.date, "DD MMM YYYY"),
64178
+ link: true,
64179
+ onClickLink: () => {
64180
+ goTo(`/app/view/incidents/${item.datastakeId}/identification${getSourceParam(item?.sourceId)}`);
64181
+ },
64182
+ items: [{
64183
+ label: t("nashiriki::Source"),
64184
+ value: item?.source || "--"
64185
+ }, item.severity ? {
64186
+ label: t("Severity"),
64187
+ value: renderSeverity(item.severity)
64188
+ } : null].filter(Boolean)
64189
+ };
64190
+ }, [t, goTo, getSourceParam, renderSeverity]);
63949
64191
  return /*#__PURE__*/jsxRuntime.jsx(Widget, {
63950
64192
  loading: loading,
63951
64193
  filtersConfig: filtersConfig,
63952
- title: t("Incidents Timeline"),
64194
+ title: t("nashiriki::Incidents Timeline"),
63953
64195
  className: "with-border-header",
63954
- t: t,
63955
- children: /*#__PURE__*/jsxRuntime.jsx(StackChart, {
63956
- ...chartConfig,
63957
- height: "400px",
63958
- t: t
64196
+ children: /*#__PURE__*/jsxRuntime.jsx("div", {
64197
+ className: "mb-4 flex-1 flex flex-column justify-content-center",
64198
+ children: /*#__PURE__*/jsxRuntime.jsx(StackChart, {
64199
+ data: chartData,
64200
+ xFieldKey: "label",
64201
+ categories: categories,
64202
+ seriesField: "severity",
64203
+ colors: severityColors,
64204
+ doConstraints: false,
64205
+ renderTooltip: getTooltipContent
64206
+ })
63959
64207
  })
63960
64208
  });
63961
64209
  }
63962
- IncidentsTime.propTypes = {
64210
+ IncidentsTimeline.propTypes = {
63963
64211
  selectedRange: PropTypes__default["default"].string,
63964
64212
  selectedPartners: PropTypes__default["default"].object,
63965
- t: PropTypes__default["default"].func,
63966
- goTo: PropTypes__default["default"].func,
63967
- getRedirectLink: PropTypes__default["default"].func,
63968
- theme: PropTypes__default["default"].object,
63969
- APP: PropTypes__default["default"].string,
63970
- options: PropTypes__default["default"].object
64213
+ t: PropTypes__default["default"].func.isRequired,
64214
+ language: PropTypes__default["default"].string,
64215
+ goTo: PropTypes__default["default"].func.isRequired,
64216
+ user: PropTypes__default["default"].object,
64217
+ options: PropTypes__default["default"].shape({
64218
+ severityOptions: PropTypes__default["default"].array
64219
+ })
63971
64220
  };
63972
64221
 
63973
- function useTerritorialDistribution({
63974
- t = s => {
63975
- },
63976
- options = {}
63977
- }) {
63978
- const [filters, setFilters] = React.useState({
63979
- filter1: 'all',
63980
- filter2: 'all'
63981
- });
63982
- const filtersConfig = React.useMemo(t => ({
63983
- onApply: val => setFilters(val),
63984
- options: {
63985
- filter1: [{
63986
- label: t('All'),
63987
- value: 'all'
63988
- }],
63989
- filter2: [{
63990
- label: t('All'),
63991
- value: 'all'
63992
- }]
63993
- },
63994
- selectedFilters: filters,
63995
- type: 'small',
63996
- t
63997
- }), [t, filters]);
63998
- return {
63999
- filters,
64000
- filtersConfig,
64001
- setFilters,
64002
- t
64003
- };
64004
- }
64005
64222
  const getColors = theme => {
64006
64223
  return [theme.colorPrimary8, theme.colorPrimary7, theme.colorPrimary5, theme.colorPrimary6, theme.colorPrimary4];
64007
64224
  };
@@ -64016,29 +64233,31 @@ function TerritorialDistribution({
64016
64233
  goTo = () => {},
64017
64234
  getRedirectLink = () => {}
64018
64235
  }) {
64019
- const {
64020
- filters,
64021
- filtersConfig
64022
- } = useTerritorialDistribution({
64023
- t
64024
- });
64025
64236
  const colors = getColors(theme);
64026
64237
  const defaultFetchConfig = React.useMemo(() => ({
64027
64238
  url: "/territorial-distribution",
64239
+ basepath: "dashboard/conflict-management",
64028
64240
  filters: {
64029
- ...filters,
64030
64241
  category,
64031
64242
  period: selectedRange,
64032
64243
  sources: selectedPartners?.partners || []
64033
64244
  },
64034
- defaultData: [],
64245
+ defaultData: {},
64035
64246
  stop: selectedPartners?.loading
64036
- }), [filters, category, selectedRange, selectedPartners]);
64247
+ }), [category, selectedRange, selectedPartners]);
64248
+ const getData = React.useCallback(({
64249
+ url,
64250
+ filters,
64251
+ basepath
64252
+ }) => {
64253
+ return DashboardService$1.getWidgetConflictManagement(url, filters, basepath);
64254
+ }, []);
64037
64255
  const {
64038
64256
  data,
64039
64257
  loading
64040
- } = useWidgetFetch$1({
64041
- config: defaultFetchConfig
64258
+ } = useWidgetFetch({
64259
+ config: defaultFetchConfig,
64260
+ getData
64042
64261
  });
64043
64262
  const pieData = React.useMemo(() => {
64044
64263
  if (!data || Array.isArray(data)) return [];
@@ -64057,13 +64276,13 @@ function TerritorialDistribution({
64057
64276
  }, [data, colors]);
64058
64277
  const isEmpty = !pieData.length;
64059
64278
  const getTooltipChildren = React.useCallback(items => {
64060
- const item = items[0];
64279
+ const item = Array.isArray(items) ? items[0] : items;
64061
64280
  return renderTooltipJsx({
64062
64281
  title: item?.label || t("Undetermined"),
64063
64282
  link: true,
64064
64283
  onClickLink: () => {
64065
64284
  if (item?.label) {
64066
- goTo(`/app/incident?administrativeLevel1=${item?.locationData?.administrativeLevel1}&administrativeLevel2=${item?.locationData?.administrativeLevel2}&country=${item?.locationData?.country}`);
64285
+ goTo(`/app/incidents?administrativeLevel1=${item?.locationData?.administrativeLevel1}&administrativeLevel2=${item?.locationData?.administrativeLevel2}&country=${item?.locationData?.country}`);
64067
64286
  } else {
64068
64287
  goTo("/app/incident");
64069
64288
  }
@@ -64078,7 +64297,6 @@ function TerritorialDistribution({
64078
64297
  loading: loading || parentLoading,
64079
64298
  title: t("Territorial Distribution"),
64080
64299
  className: "with-border-header",
64081
- filtersConfig: filtersConfig,
64082
64300
  children: /*#__PURE__*/jsxRuntime.jsx(Chart, {
64083
64301
  mouseXOffset: 10,
64084
64302
  mouseYOffset: 10,
@@ -64101,7 +64319,9 @@ TerritorialDistribution.propTypes = {
64101
64319
  selectedRange: PropTypes__default["default"].string
64102
64320
  };
64103
64321
 
64104
- function useProblemSolvers(t = () => {}) {
64322
+ function useProblemSolvers({
64323
+ t = () => {}
64324
+ } = {}) {
64105
64325
  const [filters, setFilters] = React.useState({
64106
64326
  administrativeLevel1: "all"
64107
64327
  });
@@ -64111,25 +64331,25 @@ function useProblemSolvers(t = () => {}) {
64111
64331
  try {
64112
64332
  const {
64113
64333
  data
64114
- } = await DashboardService$1.getWidget({
64115
- url: "/problem-solvers"
64116
- });
64117
- const rawOptions = Object.keys(data).map(agentKey => {
64118
- const actions = data[agentKey]?.actions || [];
64334
+ } = await DashboardService$1.getWidgetConflictManagement("/problem-solvers", {}, "dashboard/conflict-management");
64335
+ const all = Object.keys(data);
64336
+ const options = all.map(key => {
64337
+ const actions = data[key].actions;
64119
64338
  return actions.map(action => {
64120
- const lvl1 = action?.location?.administrativeLevel1;
64121
- const name = action?.location?.name || action?.location?.administrativeLevel1 || null;
64122
- if (!lvl1 || !name) return undefined;
64339
+ if (action.location === undefined) {
64340
+ return;
64341
+ }
64342
+ const administrativeLevel1 = action?.location?.administrativeLevel1;
64343
+ const name = action?.location?.linking?.SCL?.[administrativeLevel1]?.name;
64123
64344
  return {
64124
64345
  label: name,
64125
- value: lvl1
64346
+ value: administrativeLevel1
64126
64347
  };
64127
- }).filter(Boolean);
64128
- }).flat();
64129
- const unique = [...new Map(rawOptions.map(item => [item.value, item])).values()];
64130
- setFilterOptions(unique);
64348
+ });
64349
+ }).flat().filter(item => item !== undefined);
64350
+ setFilterOptions(options);
64131
64351
  } catch (err) {
64132
- console.error("Problem Solvers fetch failed:", err);
64352
+ console.log(err);
64133
64353
  }
64134
64354
  }
64135
64355
  fetchOptions();
@@ -64178,10 +64398,12 @@ function ProblemSolvers({
64178
64398
  const {
64179
64399
  filters,
64180
64400
  filtersConfig
64181
- } = useProblemSolvers();
64401
+ } = useProblemSolvers({
64402
+ t
64403
+ });
64182
64404
  const defaultFetchConfig = React.useMemo(() => ({
64183
- basepath: "conflict-management",
64184
64405
  url: "/problem-solvers",
64406
+ basepath: "dashboard/conflict-management",
64185
64407
  filters: {
64186
64408
  ...filters,
64187
64409
  period: selectedRange,
@@ -64190,11 +64412,19 @@ function ProblemSolvers({
64190
64412
  defaultData: [],
64191
64413
  stop: selectedPartners?.loading
64192
64414
  }), [filters, selectedRange, selectedPartners]);
64415
+ const getData = React.useCallback(({
64416
+ url,
64417
+ filters,
64418
+ basepath
64419
+ }) => {
64420
+ return DashboardService$1.getWidgetConflictManagement(url, filters, basepath);
64421
+ }, []);
64193
64422
  const {
64194
64423
  data,
64195
64424
  loading
64196
- } = useWidgetFetch$1({
64197
- config: defaultFetchConfig
64425
+ } = useWidgetFetch({
64426
+ config: defaultFetchConfig,
64427
+ getData
64198
64428
  });
64199
64429
  const pieData = React.useMemo(() => {
64200
64430
  if (!data || Array.isArray(data)) return [];
@@ -64293,7 +64523,7 @@ function RisksWidget({
64293
64523
  }),
64294
64524
  children: /*#__PURE__*/jsxRuntime.jsxs("div", {
64295
64525
  className: "flex flex-row flex-col-mobile gap-6",
64296
- children: [/*#__PURE__*/jsxRuntime.jsx(IncidentsTime, {
64526
+ children: [/*#__PURE__*/jsxRuntime.jsx(IncidentsTimeline, {
64297
64527
  selectedRange: range,
64298
64528
  selectedPartners: selectedPartners,
64299
64529
  t: t,
@@ -64448,7 +64678,8 @@ function ConflictManagement({
64448
64678
  goTo = () => {},
64449
64679
  getRedirectLink = s => s,
64450
64680
  theme = {},
64451
- options = {}
64681
+ options = {},
64682
+ breadcrumbs = []
64452
64683
  }) {
64453
64684
  const {
64454
64685
  partners,
@@ -64492,9 +64723,8 @@ function ConflictManagement({
64492
64723
  };
64493
64724
  });
64494
64725
  }, [partners, user, theme]);
64495
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
64496
- className: "daf-analysis",
64497
- children: [/*#__PURE__*/jsxRuntime.jsx(DAFHeader, {
64726
+ return /*#__PURE__*/jsxRuntime.jsxs(DashboardLayout, {
64727
+ header: /*#__PURE__*/jsxRuntime.jsx(DAFHeader, {
64498
64728
  title: t("conflict-management"),
64499
64729
  breadcrumbs: breadCrumbs,
64500
64730
  supportText: /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
@@ -64505,10 +64735,8 @@ function ConflictManagement({
64505
64735
  children: t("European Union")
64506
64736
  })]
64507
64737
  }),
64508
- addedHeader: /*#__PURE__*/jsxRuntime.jsxs("div", {
64509
- children: [/*#__PURE__*/jsxRuntime.jsx("div", {
64510
- className: "flex-1"
64511
- }), /*#__PURE__*/jsxRuntime.jsx(Multiselect, {
64738
+ addedHeader: /*#__PURE__*/jsxRuntime.jsx("div", {
64739
+ children: /*#__PURE__*/jsxRuntime.jsx(Multiselect, {
64512
64740
  options: [...sourceOptions],
64513
64741
  isAvatarGroup: true,
64514
64742
  canUnselectLast: false,
@@ -64522,48 +64750,37 @@ function ConflictManagement({
64522
64750
  dropDownWidth: 200,
64523
64751
  selectionType: "checkbox",
64524
64752
  defaultSelected: partners.map(p => p.id) || []
64525
- }, partners?.length)]
64753
+ }, partners?.length)
64526
64754
  })
64527
- }), /*#__PURE__*/jsxRuntime.jsx("div", {
64528
- className: "content",
64529
- children: /*#__PURE__*/jsxRuntime.jsx("div", {
64530
- className: "view-content",
64531
- children: /*#__PURE__*/jsxRuntime.jsx("div", {
64532
- className: "daf-analysis-layout",
64533
- children: /*#__PURE__*/jsxRuntime.jsxs("div", {
64534
- className: "sections-cont w-pt",
64535
- children: [/*#__PURE__*/jsxRuntime.jsx("section", {
64536
- children: /*#__PURE__*/jsxRuntime.jsx(KeyIndicators, {
64537
- selectedPartners: selectedPartners,
64538
- partners: informationSources > 0 ? informationSources : selectedPartners?.partners?.length > 0 ? selectedPartners?.partners?.length : 0,
64539
- t: t,
64540
- goTo: goTo,
64541
- getRedirectLink: getRedirectLink,
64542
- theme: theme
64543
- })
64544
- }), /*#__PURE__*/jsxRuntime.jsx("section", {
64545
- children: /*#__PURE__*/jsxRuntime.jsx(MineSites, {
64546
- selectedPartners: selectedPartners,
64547
- t: t,
64548
- goTo: goTo,
64549
- getRedirectLink: getRedirectLink,
64550
- theme: theme,
64551
- APP: APP,
64552
- options: options
64553
- })
64554
- }), /*#__PURE__*/jsxRuntime.jsx("section", {
64555
- children: /*#__PURE__*/jsxRuntime.jsx(RisksWidget, {
64556
- selectedPartners: selectedPartners,
64557
- t: t,
64558
- goTo: goTo,
64559
- getRedirectLink: getRedirectLink,
64560
- theme: theme,
64561
- APP: APP,
64562
- options: options
64563
- })
64564
- })]
64565
- })
64566
- })
64755
+ }),
64756
+ children: [/*#__PURE__*/jsxRuntime.jsx("section", {
64757
+ children: /*#__PURE__*/jsxRuntime.jsx(KeyIndicators, {
64758
+ selectedPartners: selectedPartners,
64759
+ partners: informationSources > 0 ? informationSources : selectedPartners?.partners?.length > 0 ? selectedPartners?.partners?.length : 0,
64760
+ t: t,
64761
+ goTo: goTo,
64762
+ getRedirectLink: getRedirectLink,
64763
+ theme: theme
64764
+ })
64765
+ }), /*#__PURE__*/jsxRuntime.jsx("section", {
64766
+ children: /*#__PURE__*/jsxRuntime.jsx(MineSites, {
64767
+ selectedPartners: selectedPartners,
64768
+ t: t,
64769
+ goTo: goTo,
64770
+ getRedirectLink: getRedirectLink,
64771
+ theme: theme,
64772
+ APP: APP,
64773
+ options: options
64774
+ })
64775
+ }), /*#__PURE__*/jsxRuntime.jsx("section", {
64776
+ children: /*#__PURE__*/jsxRuntime.jsx(RisksWidget, {
64777
+ selectedPartners: selectedPartners,
64778
+ t: t,
64779
+ goTo: goTo,
64780
+ getRedirectLink: getRedirectLink,
64781
+ theme: theme,
64782
+ APP: APP,
64783
+ options: options
64567
64784
  })
64568
64785
  })]
64569
64786
  });