datastake-daf 0.6.774 → 0.6.775

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.
@@ -7069,7 +7069,7 @@ const getRowConfig$1 = ({
7069
7069
  const MOBILE_W = 850;
7070
7070
  const MOBILE_WIDTH = `max-width: ${MOBILE_W}px`;
7071
7071
 
7072
- const Style$f = styled__default["default"].div`
7072
+ const Style$g = styled__default["default"].div`
7073
7073
  overflow-x: auto;
7074
7074
 
7075
7075
  @media (${MOBILE_WIDTH}) {
@@ -7467,7 +7467,7 @@ function KeyIndicatorsWidget({
7467
7467
  className: formatClassname(["flex-1 h-w-btn-header with-border-header", widgetClassName]),
7468
7468
  title: noTitle ? undefined : t(title),
7469
7469
  noTitle: noTitle,
7470
- children: [children, /*#__PURE__*/jsxRuntime.jsx(Style$f, {
7470
+ children: [children, /*#__PURE__*/jsxRuntime.jsx(Style$g, {
7471
7471
  className: formatClassname(["flex", className]),
7472
7472
  children: config.map((c, i) => /*#__PURE__*/jsxRuntime.jsxs("div", {
7473
7473
  className: "row-item",
@@ -7563,7 +7563,7 @@ KeyIndicators$1.propTypes = {
7563
7563
  goTo: PropTypes__default["default"].func
7564
7564
  };
7565
7565
 
7566
- const Style$e = styled__default["default"].div`
7566
+ const Style$f = styled__default["default"].div`
7567
7567
  display: flex;
7568
7568
  flex-direction: row;
7569
7569
  position: relative;
@@ -9119,7 +9119,7 @@ function LocationIcon({
9119
9119
  });
9120
9120
  }
9121
9121
 
9122
- const Style$d = styled__default["default"].div`
9122
+ const Style$e = styled__default["default"].div`
9123
9123
  .main {
9124
9124
  width: 24px;
9125
9125
  height: 24px;
@@ -9264,7 +9264,7 @@ function StakeholderIcon({
9264
9264
  onClickLink: () => onClickLink(marker)
9265
9265
  }),
9266
9266
  getPopupContainer: () => document.getElementById("map"),
9267
- children: /*#__PURE__*/jsxRuntime.jsx(Style$d
9267
+ children: /*#__PURE__*/jsxRuntime.jsx(Style$e
9268
9268
  // onClick={toggleOpen}
9269
9269
  , {
9270
9270
  className: `map-marker marker closed`,
@@ -9277,7 +9277,7 @@ function StakeholderIcon({
9277
9277
  })
9278
9278
  });
9279
9279
  }
9280
- return /*#__PURE__*/jsxRuntime.jsxs(Style$d, {
9280
+ return /*#__PURE__*/jsxRuntime.jsxs(Style$e, {
9281
9281
  onClick: toggleOpen,
9282
9282
  className: `map-marker marker ${isActive ? "opened" : "closed"}`,
9283
9283
  children: [/*#__PURE__*/jsxRuntime.jsx("div", {
@@ -10116,7 +10116,7 @@ const useMap = ({
10116
10116
  };
10117
10117
  };
10118
10118
 
10119
- const Style$c = styled__default["default"].div`
10119
+ const Style$d = styled__default["default"].div`
10120
10120
  position: relative;
10121
10121
  width: 100%;
10122
10122
  height: 100%;
@@ -10189,7 +10189,7 @@ function ComponentWithFocus({
10189
10189
  setClosed(false);
10190
10190
  }
10191
10191
  }, [closed]);
10192
- return /*#__PURE__*/jsxRuntime.jsxs(Style$c, {
10192
+ return /*#__PURE__*/jsxRuntime.jsxs(Style$d, {
10193
10193
  className: className,
10194
10194
  ref: ref,
10195
10195
  style: style,
@@ -10201,7 +10201,7 @@ function ComponentWithFocus({
10201
10201
  });
10202
10202
  }
10203
10203
 
10204
- const Style$b = styled__default["default"].div`
10204
+ const Style$c = styled__default["default"].div`
10205
10205
  position: absolute;
10206
10206
  top: 24px;
10207
10207
  left: 24px;
@@ -10376,7 +10376,7 @@ function Filters({
10376
10376
  return null;
10377
10377
  }
10378
10378
  };
10379
- return /*#__PURE__*/jsxRuntime.jsxs(Style$b, {
10379
+ return /*#__PURE__*/jsxRuntime.jsxs(Style$c, {
10380
10380
  children: [/*#__PURE__*/jsxRuntime.jsxs(antd.Button, {
10381
10381
  onClick: () => setOpened(p => !p),
10382
10382
  children: [t("Filter"), /*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
@@ -10457,7 +10457,7 @@ function Map$1({
10457
10457
  isSatellite
10458
10458
  });
10459
10459
  return /*#__PURE__*/jsxRuntime.jsx(ComponentWithFocus, {
10460
- children: /*#__PURE__*/jsxRuntime.jsxs(Style$e, {
10460
+ children: /*#__PURE__*/jsxRuntime.jsxs(Style$f, {
10461
10461
  className: formatClassname([showSider && activeMarker && "with-sider"]),
10462
10462
  children: [filtersConfig ? /*#__PURE__*/jsxRuntime.jsx(Filters, {
10463
10463
  t: t,
@@ -10666,7 +10666,7 @@ function PrimaryNode({
10666
10666
  style: {
10667
10667
  opacity: 0
10668
10668
  }
10669
- }), /*#__PURE__*/jsxRuntime.jsxs(Style$a, {
10669
+ }), /*#__PURE__*/jsxRuntime.jsxs(Style$b, {
10670
10670
  $isPdf: isPdf,
10671
10671
  className: "flex",
10672
10672
  children: [" ", /*#__PURE__*/jsxRuntime.jsx("div", {
@@ -10777,7 +10777,7 @@ function PrimaryNode({
10777
10777
  })]
10778
10778
  });
10779
10779
  }
10780
- const Style$a = styled__default["default"].div`
10780
+ const Style$b = styled__default["default"].div`
10781
10781
  width: ${MAIN_NODE_WIDTH}px;
10782
10782
  height: ${MAIN_NODE_HEIGHT}px; /* Explicitly set height */
10783
10783
  display: flex;
@@ -10913,7 +10913,7 @@ function IconNode({
10913
10913
  }), /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
10914
10914
  title: data?.name,
10915
10915
  defaultOpen: data?.ONLY_IN_STORYBOOK,
10916
- children: /*#__PURE__*/jsxRuntime.jsx(Style$9, {
10916
+ children: /*#__PURE__*/jsxRuntime.jsx(Style$a, {
10917
10917
  hoverColor: data?.iconHoverColor,
10918
10918
  children: /*#__PURE__*/jsxRuntime.jsx(antd.ConfigProvider, {
10919
10919
  theme: {
@@ -10956,7 +10956,7 @@ function IconNode({
10956
10956
  })]
10957
10957
  });
10958
10958
  }
10959
- const Style$9 = styled__default["default"].div`
10959
+ const Style$a = styled__default["default"].div`
10960
10960
  height: 40px;
10961
10961
  width: 40px;
10962
10962
 
@@ -11034,7 +11034,7 @@ function NameNode({
11034
11034
  style: {
11035
11035
  opacity: 0
11036
11036
  }
11037
- }), /*#__PURE__*/jsxRuntime.jsxs(Style$8, {
11037
+ }), /*#__PURE__*/jsxRuntime.jsxs(Style$9, {
11038
11038
  $isPdf: isPdf,
11039
11039
  style: {
11040
11040
  opacity: data.isEmpty ? 0.5 : 1
@@ -11122,7 +11122,7 @@ function NameNode({
11122
11122
  })]
11123
11123
  });
11124
11124
  }
11125
- const Style$8 = styled__default["default"].div`
11125
+ const Style$9 = styled__default["default"].div`
11126
11126
  width: ${NAME_CARD_WIDTH}px;
11127
11127
  height: 55px;
11128
11128
  display: flex;
@@ -11153,7 +11153,7 @@ const Style$8 = styled__default["default"].div`
11153
11153
  }
11154
11154
  `;
11155
11155
 
11156
- const Style$7 = styled__default["default"].div`
11156
+ const Style$8 = styled__default["default"].div`
11157
11157
  width: 405px;
11158
11158
  display: flex;
11159
11159
  height: 140px;
@@ -11264,7 +11264,7 @@ function ExpandedNode({
11264
11264
  style: {
11265
11265
  opacity: 0
11266
11266
  }
11267
- }), /*#__PURE__*/jsxRuntime.jsxs(Style$7, {
11267
+ }), /*#__PURE__*/jsxRuntime.jsxs(Style$8, {
11268
11268
  style: {
11269
11269
  opacity
11270
11270
  },
@@ -12516,7 +12516,7 @@ Identification.propTypes = {
12516
12516
  theme: PropTypes__default["default"].object
12517
12517
  };
12518
12518
 
12519
- const Style$6 = styled__default["default"].div`
12519
+ const Style$7 = styled__default["default"].div`
12520
12520
  position: absolute;
12521
12521
  display: flex;
12522
12522
  gap: 12px;
@@ -12531,7 +12531,7 @@ function Tooltip({
12531
12531
  mouseY = 0,
12532
12532
  children = null
12533
12533
  }) {
12534
- return /*#__PURE__*/jsxRuntime.jsx(Style$6, {
12534
+ return /*#__PURE__*/jsxRuntime.jsx(Style$7, {
12535
12535
  style: {
12536
12536
  top: mouseY,
12537
12537
  left: mouseX
@@ -15224,7 +15224,7 @@ const renderStatusTag = ({
15224
15224
  }
15225
15225
  };
15226
15226
 
15227
- const getColumns$b = ({
15227
+ const getColumns$c = ({
15228
15228
  t,
15229
15229
  goTo,
15230
15230
  user,
@@ -20881,7 +20881,7 @@ function Comments({
20881
20881
  });
20882
20882
  }
20883
20883
 
20884
- var Style$5 = styled__default["default"].div`
20884
+ var Style$6 = styled__default["default"].div`
20885
20885
  border: 1px solid var(--base-gray-40);
20886
20886
  padding: 12px;
20887
20887
  background: var(--base-gray-20);
@@ -21027,7 +21027,7 @@ function GroupInfoHOC({
21027
21027
  meta,
21028
21028
  t
21029
21029
  });
21030
- return /*#__PURE__*/jsxRuntime.jsxs(Style$5, {
21030
+ return /*#__PURE__*/jsxRuntime.jsxs(Style$6, {
21031
21031
  className: formatClassname([!isExpanded && 'collapsed', className, isSuccess && 'success']),
21032
21032
  children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
21033
21033
  className: "cont-header",
@@ -21184,7 +21184,7 @@ function GroupInfo({
21184
21184
  });
21185
21185
  }
21186
21186
  };
21187
- return /*#__PURE__*/jsxRuntime.jsxs(Style$5, {
21187
+ return /*#__PURE__*/jsxRuntime.jsxs(Style$6, {
21188
21188
  className: formatClassname([!isExpanded && 'collapsed', className]),
21189
21189
  children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
21190
21190
  className: "cont-header",
@@ -21225,7 +21225,7 @@ function GroupInfos({
21225
21225
  }, key));
21226
21226
  }
21227
21227
 
21228
- const Style$4 = styled__default["default"].div`
21228
+ const Style$5 = styled__default["default"].div`
21229
21229
  gap: 16px;
21230
21230
  display: flex;
21231
21231
  max-width: 465px;
@@ -21247,7 +21247,7 @@ function EvaluationPopover({
21247
21247
  t = s => s,
21248
21248
  evaluationConfig = []
21249
21249
  }) {
21250
- return /*#__PURE__*/jsxRuntime.jsx(Style$4, {
21250
+ return /*#__PURE__*/jsxRuntime.jsx(Style$5, {
21251
21251
  children: evaluationConfig.map(c =>
21252
21252
  /*#__PURE__*/
21253
21253
  //? ASK REDI
@@ -23219,7 +23219,7 @@ const useMapHelper = ({
23219
23219
  };
23220
23220
  };
23221
23221
 
23222
- const Style$3 = styled__default["default"].div`
23222
+ const Style$4 = styled__default["default"].div`
23223
23223
  width: 100%;
23224
23224
  height: 20rem;
23225
23225
  flex: 1;
@@ -23346,7 +23346,7 @@ function PolygonSelector({
23346
23346
  searchForLocation(mapRef);
23347
23347
  }
23348
23348
  }, [searchValue, mapRef]);
23349
- return /*#__PURE__*/jsxRuntime.jsxs(Style$3, {
23349
+ return /*#__PURE__*/jsxRuntime.jsxs(Style$4, {
23350
23350
  className: "polygon-selector",
23351
23351
  children: [/*#__PURE__*/jsxRuntime.jsx("div", {
23352
23352
  className: "map-container",
@@ -30104,7 +30104,7 @@ const NavigationAction = ({
30104
30104
  });
30105
30105
  };
30106
30106
 
30107
- const getColumns$a = ({
30107
+ const getColumns$b = ({
30108
30108
  t,
30109
30109
  goTo,
30110
30110
  user,
@@ -30676,7 +30676,7 @@ const viewConfig$6 = {
30676
30676
  createTitle: "Create Worker"
30677
30677
  };
30678
30678
 
30679
- const getColumns$9 = ({
30679
+ const getColumns$a = ({
30680
30680
  t,
30681
30681
  goTo,
30682
30682
  user,
@@ -31178,7 +31178,7 @@ MoreTags.propTypes = {
31178
31178
  limit: PropTypes__default["default"].number
31179
31179
  };
31180
31180
 
31181
- const getColumns$8 = ({
31181
+ const getColumns$9 = ({
31182
31182
  t,
31183
31183
  goTo,
31184
31184
  user,
@@ -31633,7 +31633,7 @@ const getEventCategoryBySubject = (eventCategoryObject, subject, isSingular = fa
31633
31633
  return eventCategoryObject[key] || null;
31634
31634
  };
31635
31635
 
31636
- const getColumns$7 = ({
31636
+ const getColumns$8 = ({
31637
31637
  t,
31638
31638
  goTo,
31639
31639
  user,
@@ -32058,6 +32058,264 @@ const viewConfig$3 = {
32058
32058
  createTitle: "Create Incident"
32059
32059
  };
32060
32060
 
32061
+ const getColumns$7 = ({
32062
+ t,
32063
+ goTo,
32064
+ user,
32065
+ options,
32066
+ activeTab,
32067
+ getRedirectLink,
32068
+ theme,
32069
+ subject,
32070
+ data,
32071
+ applications
32072
+ }) => [{
32073
+ dataIndex: 'datastakeId',
32074
+ title: t('ID'),
32075
+ ellipsis: true,
32076
+ show: true,
32077
+ render: (v, all) => {
32078
+ if (all.empty) {
32079
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32080
+ className: "daf-default-cell"
32081
+ });
32082
+ }
32083
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
32084
+ title: v,
32085
+ children: v
32086
+ });
32087
+ }
32088
+ }, {
32089
+ dataIndex: 'name',
32090
+ title: t('Title'),
32091
+ ellipsis: true,
32092
+ show: true,
32093
+ render: (v, all) => {
32094
+ if (all.empty) {
32095
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32096
+ className: "daf-default-cell"
32097
+ });
32098
+ }
32099
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
32100
+ title: v,
32101
+ children: v
32102
+ });
32103
+ }
32104
+ }, {
32105
+ title: t("Date"),
32106
+ dataIndex: "date",
32107
+ key: "date",
32108
+ render: (date, all) => {
32109
+ if (all.empty) {
32110
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32111
+ className: "daf-default-cell"
32112
+ });
32113
+ }
32114
+ const _date = date ? renderDateFormatted(date, "DD MMM YYYY", user?.language || 'en') : "-";
32115
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
32116
+ title: _date,
32117
+ children: _date
32118
+ });
32119
+ },
32120
+ ellipsis: true
32121
+ }, {
32122
+ dataIndex: 'mineSite',
32123
+ title: t('Location'),
32124
+ ellipsis: true,
32125
+ show: true,
32126
+ render: (v, all) => {
32127
+ if (all.empty) {
32128
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32129
+ className: "daf-default-cell"
32130
+ });
32131
+ }
32132
+
32133
+ // const country = findOptions(v, data?.options?.positionSupplyChainOptions);
32134
+ const mineSite = all?.location?.name;
32135
+ return mineSite ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
32136
+ title: mineSite,
32137
+ children: mineSite
32138
+ }) : '-';
32139
+ }
32140
+ }, {
32141
+ dataIndex: 'province',
32142
+ title: t('Province'),
32143
+ ellipsis: true,
32144
+ show: true,
32145
+ render: (v, all) => {
32146
+ if (all.empty) {
32147
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32148
+ className: "daf-default-cell"
32149
+ });
32150
+ }
32151
+ const region = getLinkValue(all?.location?.administrativeLevel1, all?.location?.linking?.SCL);
32152
+ return region ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
32153
+ title: region,
32154
+ children: region
32155
+ }) : '-';
32156
+ }
32157
+ }, {
32158
+ dataIndex: 'territory',
32159
+ title: t('Territory'),
32160
+ ellipsis: true,
32161
+ show: true,
32162
+ render: (v, all) => {
32163
+ if (all.empty) {
32164
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32165
+ className: "daf-default-cell"
32166
+ });
32167
+ }
32168
+ const district = getLinkValue(all?.location?.administrativeLevel2, all?.location?.linking?.SCL);
32169
+ return district ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
32170
+ title: district,
32171
+ children: district
32172
+ }) : '-';
32173
+ }
32174
+ }, {
32175
+ dataIndex: 'eventCategory',
32176
+ title: t('Category'),
32177
+ ellipsis: true,
32178
+ show: true,
32179
+ render: (v, all) => {
32180
+ if (all.empty) {
32181
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32182
+ className: "daf-default-cell"
32183
+ });
32184
+ }
32185
+ const eventCategory = findOptions(v, data?.options?.eventCategoryOptions);
32186
+ const categoryValue = getEventCategoryBySubject(eventCategory, subject);
32187
+ return categoryValue ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
32188
+ title: categoryValue,
32189
+ children: categoryValue
32190
+ }) : '-';
32191
+ }
32192
+ }, {
32193
+ title: t("Sources"),
32194
+ dataIndex: "sources",
32195
+ key: "sources",
32196
+ show: activeTab !== "own",
32197
+ render: (val, all) => {
32198
+ if (all.empty) {
32199
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32200
+ className: "daf-default-cell"
32201
+ });
32202
+ }
32203
+ const sources = sourceAvatarConfig(val, user, applications);
32204
+ return /*#__PURE__*/jsxRuntime.jsx(AvatarGroup, {
32205
+ items: sources
32206
+ });
32207
+ }
32208
+ }, {
32209
+ title: t("Status"),
32210
+ dataIndex: "status",
32211
+ key: "status",
32212
+ show: activeTab === "own",
32213
+ render: (val, all) => {
32214
+ if (all.empty) {
32215
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32216
+ className: "daf-default-cell"
32217
+ });
32218
+ }
32219
+ const _val = all?.published || all?.status === "submitted" ? "submitted" : val;
32220
+ return renderStatusTag({
32221
+ value: _val,
32222
+ t
32223
+ });
32224
+ }
32225
+ }, {
32226
+ title: t("Last Update"),
32227
+ dataIndex: "updatedAt",
32228
+ key: "updatedAt",
32229
+ render: (date, all) => {
32230
+ if (all.empty) {
32231
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32232
+ className: "daf-default-cell"
32233
+ });
32234
+ }
32235
+ const _date = date ? renderDateFormatted(date, "DD MMM YYYY", user?.language || 'en') : "-";
32236
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
32237
+ title: _date,
32238
+ children: _date
32239
+ });
32240
+ },
32241
+ ellipsis: true
32242
+ }, {
32243
+ id: 'actions',
32244
+ title: "",
32245
+ width: 60,
32246
+ render: (_, all) => {
32247
+ if (all.empty) {
32248
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
32249
+ className: "daf-default-cell"
32250
+ });
32251
+ }
32252
+ const onClick = () => {
32253
+ let link = `/app/view/${subject}/${all.datastakeId}`;
32254
+ if (activeTab === "shared") {
32255
+ link += `?sourceId=${all?.authorId?.id}`;
32256
+ }
32257
+ goTo(getRedirectLink(link));
32258
+ };
32259
+ return /*#__PURE__*/jsxRuntime.jsx(NavigationAction, {
32260
+ onClick: onClick,
32261
+ theme: theme
32262
+ });
32263
+ }
32264
+ }].filter(column => column.show !== false);
32265
+
32266
+ const getFiltersConfig$4 = ({
32267
+ t
32268
+ }) => {
32269
+ return {
32270
+ country: {
32271
+ type: 'select',
32272
+ placeholder: t('Country'),
32273
+ style: {
32274
+ flex: 1
32275
+ },
32276
+ labelStyle: {
32277
+ flex: 1
32278
+ },
32279
+ getLabel: option => option.label,
32280
+ getValue: option => option.value
32281
+ },
32282
+ category: {
32283
+ type: 'select',
32284
+ label: 'Category',
32285
+ placeholder: t => `${t('Filter by')} ${t('Category').toLowerCase()}`,
32286
+ style: {
32287
+ flex: 1
32288
+ },
32289
+ labelStyle: {
32290
+ flex: 1
32291
+ },
32292
+ getLabel: option => option.label,
32293
+ getValue: option => option.value
32294
+ }
32295
+ };
32296
+ };
32297
+ const getFilterOptions$4 = (options, t) => {
32298
+ const {
32299
+ countries = [],
32300
+ category = [],
32301
+ locationCategories = []
32302
+ } = options || {};
32303
+ return {
32304
+ country: countries,
32305
+ category: locationCategories || category
32306
+ };
32307
+ };
32308
+ const formConfig$2 = {
32309
+ namespace: 'locations',
32310
+ view: 'scoping',
32311
+ scope: 'create',
32312
+ formType: 'location'
32313
+ };
32314
+ const viewConfig$2 = {
32315
+ title: "Locations",
32316
+ createTitle: "Create Location"
32317
+ };
32318
+
32061
32319
  const getColumns$6 = ({
32062
32320
  t,
32063
32321
  goTo,
@@ -32085,264 +32343,6 @@ const getColumns$6 = ({
32085
32343
  children: v
32086
32344
  });
32087
32345
  }
32088
- }, {
32089
- dataIndex: 'name',
32090
- title: t('Title'),
32091
- ellipsis: true,
32092
- show: true,
32093
- render: (v, all) => {
32094
- if (all.empty) {
32095
- return /*#__PURE__*/jsxRuntime.jsx("div", {
32096
- className: "daf-default-cell"
32097
- });
32098
- }
32099
- return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
32100
- title: v,
32101
- children: v
32102
- });
32103
- }
32104
- }, {
32105
- title: t("Date"),
32106
- dataIndex: "date",
32107
- key: "date",
32108
- render: (date, all) => {
32109
- if (all.empty) {
32110
- return /*#__PURE__*/jsxRuntime.jsx("div", {
32111
- className: "daf-default-cell"
32112
- });
32113
- }
32114
- const _date = date ? renderDateFormatted(date, "DD MMM YYYY", user?.language || 'en') : "-";
32115
- return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
32116
- title: _date,
32117
- children: _date
32118
- });
32119
- },
32120
- ellipsis: true
32121
- }, {
32122
- dataIndex: 'mineSite',
32123
- title: t('Location'),
32124
- ellipsis: true,
32125
- show: true,
32126
- render: (v, all) => {
32127
- if (all.empty) {
32128
- return /*#__PURE__*/jsxRuntime.jsx("div", {
32129
- className: "daf-default-cell"
32130
- });
32131
- }
32132
-
32133
- // const country = findOptions(v, data?.options?.positionSupplyChainOptions);
32134
- const mineSite = all?.location?.name;
32135
- return mineSite ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
32136
- title: mineSite,
32137
- children: mineSite
32138
- }) : '-';
32139
- }
32140
- }, {
32141
- dataIndex: 'province',
32142
- title: t('Province'),
32143
- ellipsis: true,
32144
- show: true,
32145
- render: (v, all) => {
32146
- if (all.empty) {
32147
- return /*#__PURE__*/jsxRuntime.jsx("div", {
32148
- className: "daf-default-cell"
32149
- });
32150
- }
32151
- const region = getLinkValue(all?.location?.administrativeLevel1, all?.location?.linking?.SCL);
32152
- return region ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
32153
- title: region,
32154
- children: region
32155
- }) : '-';
32156
- }
32157
- }, {
32158
- dataIndex: 'territory',
32159
- title: t('Territory'),
32160
- ellipsis: true,
32161
- show: true,
32162
- render: (v, all) => {
32163
- if (all.empty) {
32164
- return /*#__PURE__*/jsxRuntime.jsx("div", {
32165
- className: "daf-default-cell"
32166
- });
32167
- }
32168
- const district = getLinkValue(all?.location?.administrativeLevel2, all?.location?.linking?.SCL);
32169
- return district ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
32170
- title: district,
32171
- children: district
32172
- }) : '-';
32173
- }
32174
- }, {
32175
- dataIndex: 'eventCategory',
32176
- title: t('Category'),
32177
- ellipsis: true,
32178
- show: true,
32179
- render: (v, all) => {
32180
- if (all.empty) {
32181
- return /*#__PURE__*/jsxRuntime.jsx("div", {
32182
- className: "daf-default-cell"
32183
- });
32184
- }
32185
- const eventCategory = findOptions(v, data?.options?.eventCategoryOptions);
32186
- const categoryValue = getEventCategoryBySubject(eventCategory, subject);
32187
- return categoryValue ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
32188
- title: categoryValue,
32189
- children: categoryValue
32190
- }) : '-';
32191
- }
32192
- }, {
32193
- title: t("Sources"),
32194
- dataIndex: "sources",
32195
- key: "sources",
32196
- show: activeTab !== "own",
32197
- render: (val, all) => {
32198
- if (all.empty) {
32199
- return /*#__PURE__*/jsxRuntime.jsx("div", {
32200
- className: "daf-default-cell"
32201
- });
32202
- }
32203
- const sources = sourceAvatarConfig(val, user, applications);
32204
- return /*#__PURE__*/jsxRuntime.jsx(AvatarGroup, {
32205
- items: sources
32206
- });
32207
- }
32208
- }, {
32209
- title: t("Status"),
32210
- dataIndex: "status",
32211
- key: "status",
32212
- show: activeTab === "own",
32213
- render: (val, all) => {
32214
- if (all.empty) {
32215
- return /*#__PURE__*/jsxRuntime.jsx("div", {
32216
- className: "daf-default-cell"
32217
- });
32218
- }
32219
- const _val = all?.published || all?.status === "submitted" ? "submitted" : val;
32220
- return renderStatusTag({
32221
- value: _val,
32222
- t
32223
- });
32224
- }
32225
- }, {
32226
- title: t("Last Update"),
32227
- dataIndex: "updatedAt",
32228
- key: "updatedAt",
32229
- render: (date, all) => {
32230
- if (all.empty) {
32231
- return /*#__PURE__*/jsxRuntime.jsx("div", {
32232
- className: "daf-default-cell"
32233
- });
32234
- }
32235
- const _date = date ? renderDateFormatted(date, "DD MMM YYYY", user?.language || 'en') : "-";
32236
- return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
32237
- title: _date,
32238
- children: _date
32239
- });
32240
- },
32241
- ellipsis: true
32242
- }, {
32243
- id: 'actions',
32244
- title: "",
32245
- width: 60,
32246
- render: (_, all) => {
32247
- if (all.empty) {
32248
- return /*#__PURE__*/jsxRuntime.jsx("div", {
32249
- className: "daf-default-cell"
32250
- });
32251
- }
32252
- const onClick = () => {
32253
- let link = `/app/view/${subject}/${all.datastakeId}`;
32254
- if (activeTab === "shared") {
32255
- link += `?sourceId=${all?.authorId?.id}`;
32256
- }
32257
- goTo(getRedirectLink(link));
32258
- };
32259
- return /*#__PURE__*/jsxRuntime.jsx(NavigationAction, {
32260
- onClick: onClick,
32261
- theme: theme
32262
- });
32263
- }
32264
- }].filter(column => column.show !== false);
32265
-
32266
- const getFiltersConfig$4 = ({
32267
- t
32268
- }) => {
32269
- return {
32270
- country: {
32271
- type: 'select',
32272
- placeholder: t('Country'),
32273
- style: {
32274
- flex: 1
32275
- },
32276
- labelStyle: {
32277
- flex: 1
32278
- },
32279
- getLabel: option => option.label,
32280
- getValue: option => option.value
32281
- },
32282
- category: {
32283
- type: 'select',
32284
- label: 'Category',
32285
- placeholder: t => `${t('Filter by')} ${t('Category').toLowerCase()}`,
32286
- style: {
32287
- flex: 1
32288
- },
32289
- labelStyle: {
32290
- flex: 1
32291
- },
32292
- getLabel: option => option.label,
32293
- getValue: option => option.value
32294
- }
32295
- };
32296
- };
32297
- const getFilterOptions$4 = (options, t) => {
32298
- const {
32299
- countries = [],
32300
- category = [],
32301
- locationCategories = []
32302
- } = options || {};
32303
- return {
32304
- country: countries,
32305
- category: locationCategories || category
32306
- };
32307
- };
32308
- const formConfig$2 = {
32309
- namespace: 'locations',
32310
- view: 'scoping',
32311
- scope: 'create',
32312
- formType: 'location'
32313
- };
32314
- const viewConfig$2 = {
32315
- title: "Locations",
32316
- createTitle: "Create Location"
32317
- };
32318
-
32319
- const getColumns$5 = ({
32320
- t,
32321
- goTo,
32322
- user,
32323
- options,
32324
- activeTab,
32325
- getRedirectLink,
32326
- theme,
32327
- subject,
32328
- data,
32329
- applications
32330
- }) => [{
32331
- dataIndex: 'datastakeId',
32332
- title: t('ID'),
32333
- ellipsis: true,
32334
- show: true,
32335
- render: (v, all) => {
32336
- if (all.empty) {
32337
- return /*#__PURE__*/jsxRuntime.jsx("div", {
32338
- className: "daf-default-cell"
32339
- });
32340
- }
32341
- return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
32342
- title: v,
32343
- children: v
32344
- });
32345
- }
32346
32346
  }, {
32347
32347
  dataIndex: 'name',
32348
32348
  title: t('Name'),
@@ -32730,7 +32730,7 @@ MoreOptions.propTypes = {
32730
32730
  limit: PropTypes__default["default"].number
32731
32731
  };
32732
32732
 
32733
- const getColumns$4 = ({
32733
+ const getColumns$5 = ({
32734
32734
  t,
32735
32735
  goTo,
32736
32736
  user,
@@ -32966,7 +32966,7 @@ const viewConfig = {
32966
32966
  createTitle: "Create Document"
32967
32967
  };
32968
32968
 
32969
- const getColumns$3 = ({
32969
+ const getColumns$4 = ({
32970
32970
  t,
32971
32971
  goTo,
32972
32972
  user,
@@ -33091,63 +33091,63 @@ const FILTER_REGISTRY = {
33091
33091
  options: getFilterOptions$a,
33092
33092
  formConfig: formConfig$8,
33093
33093
  viewConfig: viewConfig$8,
33094
- columns: getColumns$a
33094
+ columns: getColumns$b
33095
33095
  },
33096
33096
  workers: {
33097
33097
  config: getFiltersConfig$8,
33098
33098
  options: getFilterOptions$8,
33099
33099
  formConfig: formConfig$6,
33100
33100
  viewConfig: viewConfig$6,
33101
- columns: getColumns$9
33101
+ columns: getColumns$a
33102
33102
  },
33103
33103
  operators: {
33104
33104
  config: getFiltersConfig$9,
33105
33105
  options: getFilterOptions$9,
33106
33106
  formConfig: formConfig$7,
33107
33107
  viewConfig: viewConfig$7,
33108
- columns: getColumns$b
33108
+ columns: getColumns$c
33109
33109
  },
33110
33110
  events: {
33111
33111
  config: getFiltersConfig$7,
33112
33112
  options: getFilterOptions$7,
33113
33113
  formConfig: formConfig$5,
33114
33114
  viewConfig: viewConfig$5,
33115
- columns: getColumns$8
33115
+ columns: getColumns$9
33116
33116
  },
33117
33117
  activities: {
33118
33118
  config: getFiltersConfig$6,
33119
33119
  options: getFilterOptions$6,
33120
33120
  formConfig: formConfig$4,
33121
33121
  viewConfig: viewConfig$4,
33122
- columns: getColumns$7
33122
+ columns: getColumns$8
33123
33123
  },
33124
33124
  incidents: {
33125
33125
  config: getFiltersConfig$5,
33126
33126
  options: getFilterOptions$5,
33127
33127
  formConfig: formConfig$3,
33128
33128
  viewConfig: viewConfig$3,
33129
- columns: getColumns$6
33129
+ columns: getColumns$7
33130
33130
  },
33131
33131
  locations: {
33132
33132
  config: getFiltersConfig$4,
33133
33133
  options: getFilterOptions$4,
33134
33134
  formConfig: formConfig$2,
33135
33135
  viewConfig: viewConfig$2,
33136
- columns: getColumns$5
33136
+ columns: getColumns$6
33137
33137
  },
33138
33138
  'production-sites': {
33139
33139
  config: getFiltersConfig$3,
33140
33140
  options: getFilterOptions$3,
33141
33141
  formConfig: formConfig$1,
33142
33142
  viewConfig: viewConfig$1,
33143
- columns: getColumns$4
33143
+ columns: getColumns$5
33144
33144
  },
33145
33145
  documents: {
33146
33146
  config: getFiltersConfig$2,
33147
33147
  options: getFilterOptions$2,
33148
33148
  formConfig: formConfig,
33149
33149
  viewConfig: viewConfig,
33150
- columns: getColumns$3
33150
+ columns: getColumns$4
33151
33151
  }
33152
33152
  };
33153
33153
  const DEFAULT_SUBJECT = 'stakeholders';
@@ -33198,7 +33198,7 @@ const getViewConfig = ({
33198
33198
  return registry?.viewConfig;
33199
33199
  };
33200
33200
 
33201
- const getColumns$2 = ({
33201
+ const getColumns$3 = ({
33202
33202
  t,
33203
33203
  goTo,
33204
33204
  user,
@@ -33285,7 +33285,7 @@ const useTablePage = ({
33285
33285
  extendingFilters: extendingFilters,
33286
33286
  subject
33287
33287
  });
33288
- const columns = React.useMemo(() => getColumns$2({
33288
+ const columns = React.useMemo(() => getColumns$3({
33289
33289
  t,
33290
33290
  goTo,
33291
33291
  user,
@@ -33296,7 +33296,7 @@ const useTablePage = ({
33296
33296
  subject,
33297
33297
  data,
33298
33298
  applications
33299
- }), [t, goTo, user, options, activeTab, getRedirectLink, theme, data, applications, subject, getColumns$2]);
33299
+ }), [t, goTo, user, options, activeTab, getRedirectLink, theme, data, applications, subject, getColumns$3]);
33300
33300
  const selectFiltersConfig = React.useMemo(() => getFiltersConfig$1({
33301
33301
  t,
33302
33302
  subject
@@ -33861,7 +33861,7 @@ const WorkersTable = ({
33861
33861
  getData: getData,
33862
33862
  getApiBaseUrl: getApiBaseUrl,
33863
33863
  getAppHeader: getAppHeader,
33864
- getColumns: getColumns$9,
33864
+ getColumns: getColumns$a,
33865
33865
  breadcrumbs: breadcrumbs,
33866
33866
  extendingFilters: extendingFilters,
33867
33867
  formConfig: {
@@ -34086,7 +34086,7 @@ const ProductionSitesTable = ({
34086
34086
  });
34087
34087
  };
34088
34088
 
34089
- const getColumns$1 = ({
34089
+ const getColumns$2 = ({
34090
34090
  t,
34091
34091
  goTo,
34092
34092
  user,
@@ -34564,7 +34564,7 @@ const UsersTable = ({
34564
34564
  const params = new URLSearchParams(location?.search);
34565
34565
  const [openCreateModal, setOpenCreateModal] = React.useState(params.has("create"));
34566
34566
  const [userToEdit, setUserToEdit] = React.useState(null);
34567
- const columns = React.useMemo(() => getColumns$1({
34567
+ const columns = React.useMemo(() => getColumns$2({
34568
34568
  t,
34569
34569
  goTo,
34570
34570
  user,
@@ -34955,7 +34955,7 @@ const partnershipTypes = [{
34955
34955
  value: "exchange"
34956
34956
  }];
34957
34957
 
34958
- const getColumns = ({
34958
+ const getColumns$1 = ({
34959
34959
  t,
34960
34960
  accept,
34961
34961
  decline,
@@ -35465,7 +35465,7 @@ const Create = ({
35465
35465
  });
35466
35466
  };
35467
35467
 
35468
- const Style$2 = styled__default["default"].div`
35468
+ const Style$3 = styled__default["default"].div`
35469
35469
  display: flex;
35470
35470
  gap: 8px;
35471
35471
  justify-content: center;
@@ -35488,7 +35488,7 @@ function Footer({
35488
35488
  disabledFooterText,
35489
35489
  disabledFooter
35490
35490
  }) {
35491
- return /*#__PURE__*/jsxRuntime.jsxs(Style$2, {
35491
+ return /*#__PURE__*/jsxRuntime.jsxs(Style$3, {
35492
35492
  className: className,
35493
35493
  children: [disabledFooterText ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
35494
35494
  title: t(disabledFooterText),
@@ -35700,7 +35700,7 @@ const PartnersTable = ({
35700
35700
  setTotalRequests,
35701
35701
  t
35702
35702
  });
35703
- const columns = React.useMemo(() => getColumns({
35703
+ const columns = React.useMemo(() => getColumns$1({
35704
35704
  t,
35705
35705
  accept,
35706
35706
  decline,
@@ -37867,7 +37867,63 @@ const OperatorSummary = ({
37867
37867
  });
37868
37868
  };
37869
37869
 
37870
- styled__default["default"].div`
37870
+ function StickyTable({
37871
+ size = "small",
37872
+ maxHeight = 300,
37873
+ containerHeight = 525,
37874
+ dataSource = [],
37875
+ columns = {},
37876
+ pagination = false,
37877
+ doEmptyRows = true,
37878
+ ...props
37879
+ }) {
37880
+ const data = React__default["default"].useMemo(() => {
37881
+ if (!doEmptyRows) {
37882
+ return dataSource;
37883
+ }
37884
+ const MIN_ROWS = 4;
37885
+ if (dataSource.length < MIN_ROWS) {
37886
+ const paddedData = [...dataSource];
37887
+ while (paddedData.length < MIN_ROWS) {
37888
+ paddedData.push({
37889
+ empty: true
37890
+ });
37891
+ }
37892
+ return paddedData;
37893
+ }
37894
+ return dataSource;
37895
+ }, [dataSource, doEmptyRows]);
37896
+ const Wrapper = React__default["default"].useMemo(() => {
37897
+ return data.length > 5 ? ComponentWithFocus : "div";
37898
+ }, [data.length]);
37899
+ return /*#__PURE__*/jsxRuntime.jsx(Wrapper, {
37900
+ children: /*#__PURE__*/jsxRuntime.jsx(Style$2, {
37901
+ children: /*#__PURE__*/jsxRuntime.jsx("div", {
37902
+ className: "daf-table-wrapper",
37903
+ style: {
37904
+ maxHeight: containerHeight,
37905
+ overflowY: "auto"
37906
+ },
37907
+ children: /*#__PURE__*/jsxRuntime.jsx("div", {
37908
+ className: "daf-sticky-table",
37909
+ children: /*#__PURE__*/jsxRuntime.jsx(antd.Table, {
37910
+ ...props,
37911
+ size: size,
37912
+ scroll: true,
37913
+ sticky: true,
37914
+ style: {
37915
+ maxHeight
37916
+ },
37917
+ dataSource: data,
37918
+ columns: columns,
37919
+ pagination: pagination
37920
+ })
37921
+ })
37922
+ })
37923
+ })
37924
+ });
37925
+ }
37926
+ const Style$2 = styled__default["default"].div`
37871
37927
  max-width: calc(100% - 48px);
37872
37928
  margin-left: var(--size-lg);
37873
37929
  overflow: hidden;
@@ -37891,13 +37947,13 @@ styled__default["default"].div`
37891
37947
  padding-top: 16px;
37892
37948
  }
37893
37949
  `;
37894
- ({
37950
+ StickyTable.propTypes = {
37895
37951
  size: PropTypes__default["default"].any,
37896
37952
  maxHeight: PropTypes__default["default"].number,
37897
37953
  dataSource: PropTypes__default["default"].array,
37898
37954
  columns: PropTypes__default["default"].object,
37899
37955
  pagination: PropTypes__default["default"].any
37900
- });
37956
+ };
37901
37957
 
37902
37958
  ({
37903
37959
  content: PropTypes__default["default"].string,
@@ -40829,6 +40885,25 @@ styled__default["default"].div`
40829
40885
  }
40830
40886
  `;
40831
40887
 
40888
+ /**
40889
+ * Formats a number for display with locale-specific formatting
40890
+ * @param {any} val - The value to format
40891
+ * @param {boolean} doubleDigit - Whether to ensure single digit numbers are padded with a leading zero
40892
+ * @returns {string} Formatted number string or '--' if input is not a number
40893
+ */
40894
+ const renderNumber = (val, doubleDigit = false) => {
40895
+ if (typeof val !== 'number') {
40896
+ return '--';
40897
+ }
40898
+ const _string = Number(val).toLocaleString('en-us');
40899
+ if (doubleDigit) {
40900
+ if (_string.length === 1) {
40901
+ return '0' + _string;
40902
+ }
40903
+ }
40904
+ return _string;
40905
+ };
40906
+
40832
40907
  styled__default["default"].div`
40833
40908
  height: 333px;
40834
40909
  width: calc(100% - 48px);
@@ -41851,6 +41926,13 @@ styled__default["default"].div`
41851
41926
  }
41852
41927
  `;
41853
41928
 
41929
+ const getRedirectLink = (link, APP) => {
41930
+ if (window.location.pathname.includes(`/${APP}`)) {
41931
+ return `${APP}${link}`;
41932
+ }
41933
+ return link;
41934
+ };
41935
+
41854
41936
  styled__default["default"].div`
41855
41937
  display: flex;
41856
41938
  flex-direction: column;
@@ -42836,6 +42918,551 @@ const calculateStatChange = (data, options = {}) => {
42836
42918
  };
42837
42919
  };
42838
42920
 
42921
+ /**
42922
+ * Formats a date based on the time filter
42923
+ * @param {dayjs.Dayjs} date - The date to format
42924
+ * @param {boolean} breakLine - Whether to add a line break (for tooltips)
42925
+ * @param {string} timeFilter - The time filter ('daily', 'weekly', 'monthly')
42926
+ * @returns {string} Formatted date string
42927
+ */
42928
+ const getFormatDate = (date, breakLine = false, timeFilter = 'monthly') => {
42929
+ switch (timeFilter) {
42930
+ case "daily":
42931
+ return date.format("DD/MM");
42932
+ case "weekly":
42933
+ return `W${renderNumber(date.week())}`;
42934
+ default:
42935
+ // Monthly format: "Dec 24", "Jan 25", etc.
42936
+
42937
+ return breakLine ? `${capitalize(date.format("MMM"))}\n${date.format("YY")}` : `${capitalize(date.format("MMM"))} ${date.format("YY")}`;
42938
+ }
42939
+ };
42940
+
42941
+ /**
42942
+ * Gets the time quantity string for dayjs operations
42943
+ * @param {string} timeFilter - The time filter ('daily', 'weekly', 'monthly')
42944
+ * @returns {string} Time quantity string ('days', 'weeks', 'months')
42945
+ */
42946
+ const getTimeQuantity = (timeFilter = 'monthly') => {
42947
+ return timeFilter === "monthly" ? "months" : timeFilter === "daily" ? "days" : "weeks";
42948
+ };
42949
+
42950
+ /**
42951
+ * Gets previous cumulative score from data before start date
42952
+ * @param {Array} dates - Array of data objects with date field
42953
+ * @param {dayjs.Dayjs} startDate - The start date
42954
+ * @param {string} timeFilter - The time filter
42955
+ * @param {string} valueField - The field name to extract value from (default: 'total')
42956
+ * @returns {Object} Object with hasPreviousData, previousCumulativeScore, previousMaxScore
42957
+ */
42958
+ const getPreviousGraphData = (dates, startDate, timeFilter, valueField = 'total') => {
42959
+ let previousCumulativeScore = 0;
42960
+ let previousMaxScore = 0;
42961
+ let hasPreviousData = false;
42962
+ dates.forEach(d => {
42963
+ const date = dayjs__default["default"](d.date, "YYYY-MM-DD");
42964
+ if (!date.isValid()) return;
42965
+ let isBeforeStart = false;
42966
+ switch (timeFilter) {
42967
+ case "daily":
42968
+ isBeforeStart = date.isBefore(startDate, 'day');
42969
+ break;
42970
+ case "weekly":
42971
+ isBeforeStart = date.isBefore(startDate, 'week');
42972
+ break;
42973
+ default:
42974
+ isBeforeStart = date.isBefore(startDate, 'month');
42975
+ break;
42976
+ }
42977
+ if (isBeforeStart) {
42978
+ hasPreviousData = true;
42979
+ const value = Number(d[valueField] || d.count || d.jobs || d.value || 0) || 0;
42980
+ previousCumulativeScore += value;
42981
+ previousMaxScore = Math.max(previousMaxScore, value);
42982
+ }
42983
+ });
42984
+ return {
42985
+ hasPreviousData,
42986
+ previousCumulativeScore,
42987
+ previousMaxScore
42988
+ };
42989
+ };
42990
+
42991
+ /**
42992
+ * Processes chart data with time filtering support
42993
+ * @param {Object} params - Parameters object
42994
+ * @param {Array} params.mainData - Array of data objects with date and value fields
42995
+ * @param {string} params.timeFilter - Time filter ('daily', 'weekly', 'monthly')
42996
+ * @param {Object} params.filters - Optional filters object with timeframe
42997
+ * @param {boolean} params.isCumulative - Whether to calculate cumulative values (default: false)
42998
+ * @param {string} params.valueField - Field name to extract value from (default: 'total', also checks 'count', 'jobs', 'value')
42999
+ * @returns {Array} Processed chart data array
43000
+ */
43001
+ const processChartDateData = ({
43002
+ mainData,
43003
+ timeFilter: filter,
43004
+ filters = {},
43005
+ isCumulative = false,
43006
+ valueField = 'total'
43007
+ }) => {
43008
+ if (!mainData || !Array.isArray(mainData) || mainData.length === 0) {
43009
+ return [];
43010
+ }
43011
+ const timeQuantity = getTimeQuantity(filter);
43012
+ const dates = mainData;
43013
+ const _data = [];
43014
+ let end = filters?.timeframe?.endDate || dayjs__default["default"]();
43015
+ let start = filters?.timeframe?.startDate || dayjs__default["default"]().add(-12, timeQuantity);
43016
+
43017
+ // Normalize start and end to period boundaries
43018
+ if (filter === "daily") {
43019
+ start = start.startOf('day');
43020
+ end = end.startOf('day');
43021
+ } else if (filter === "weekly") {
43022
+ start = start.startOf('week');
43023
+ end = end.startOf('week');
43024
+ } else {
43025
+ start = start.startOf('month');
43026
+ end = end.startOf('month');
43027
+ }
43028
+ let i = 0;
43029
+ let cumulativeScore = 0;
43030
+
43031
+ // Calculate initial cumulative value if needed
43032
+ if (isCumulative) {
43033
+ const {
43034
+ hasPreviousData,
43035
+ previousCumulativeScore
43036
+ } = getPreviousGraphData(dates, start, filter, valueField);
43037
+ cumulativeScore = hasPreviousData ? previousCumulativeScore : 0;
43038
+ }
43039
+
43040
+ // Loop until we reach the end date
43041
+ let currentDate = start.clone();
43042
+ while (currentDate.isBefore(end) || currentDate.isSame(end, filter === "daily" ? "day" : filter === "weekly" ? "week" : "month")) {
43043
+ // Filter data points that fall within this period
43044
+ const score = dates.filter(d => {
43045
+ if (!d.date) return false;
43046
+ switch (filter) {
43047
+ case "daily":
43048
+ return d.date === currentDate.format("YYYY-MM-DD");
43049
+ case "weekly":
43050
+ return dayjs__default["default"](d.date, "YYYY-MM-DD").week() === currentDate.week() && dayjs__default["default"](d.date, "YYYY-MM-DD").year() === currentDate.year();
43051
+ default:
43052
+ return dayjs__default["default"](d.date, "YYYY-MM-DD").format("YYYY-MM") === currentDate.format("YYYY-MM");
43053
+ }
43054
+ }).reduce((a, b) => {
43055
+ const value = Number(b[valueField] || b.count || b.jobs || b.value || 0) || 0;
43056
+ return a + value;
43057
+ }, 0);
43058
+ if (isCumulative) {
43059
+ cumulativeScore += score;
43060
+ }
43061
+ _data.push({
43062
+ date: getFormatDate(currentDate, false, filter),
43063
+ value: isCumulative ? cumulativeScore : score,
43064
+ period: score,
43065
+ // Period value for tooltip
43066
+ jobs: score,
43067
+ // For compatibility with jobs field
43068
+ month: currentDate.format('YYYY-MM-DD'),
43069
+ // For compatibility
43070
+ key: i
43071
+ });
43072
+ currentDate = currentDate.add(1, timeQuantity);
43073
+ i++;
43074
+ }
43075
+ return _data;
43076
+ };
43077
+
43078
+ /**
43079
+ * Formats date axis labels, checking if already formatted
43080
+ * @param {string} label - The label to format
43081
+ * @param {Function} getFormatDateFn - Function to format dates
43082
+ * @returns {string} Formatted date string
43083
+ */
43084
+ const formatDateAxis = (label, getFormatDateFn) => {
43085
+ if (!label) return label;
43086
+
43087
+ // Check if label is already in the correct format (MMM YY, DD/MM, or W#)
43088
+ // If it matches our format patterns, return as-is
43089
+ if (typeof label === 'string') {
43090
+ // Check for MMM YY format (e.g., "Dec 24", "Jan 25")
43091
+ if (/^[A-Z][a-z]{2} \d{2}$/.test(label)) {
43092
+ return label;
43093
+ }
43094
+ // Check for DD/MM format (e.g., "03/11")
43095
+ if (/^\d{2}\/\d{2}$/.test(label)) {
43096
+ return label;
43097
+ }
43098
+ // Check for W# format (e.g., "W1", "W12")
43099
+ if (/^W\d+$/.test(label)) {
43100
+ return label;
43101
+ }
43102
+ }
43103
+
43104
+ // Otherwise, try to parse and format it
43105
+ let date = dayjs__default["default"](label);
43106
+
43107
+ // If first attempt fails, try parsing as ISO date string
43108
+ if (!date.isValid() && typeof label === 'string') {
43109
+ date = dayjs__default["default"](label, ['YYYY-MM-DD', 'YYYY-MM', 'MMM YY', 'MMM YYYY', 'DD/MM'], true);
43110
+ }
43111
+
43112
+ // If it's a valid date, format it using getFormatDate
43113
+ if (date.isValid() && getFormatDateFn) {
43114
+ return getFormatDateFn(date, false);
43115
+ }
43116
+
43117
+ // Return as-is if we can't parse it
43118
+ return label;
43119
+ };
43120
+
43121
+ /**
43122
+ * Custom hook for time filtering functionality
43123
+ * Provides state management and formatting functions for time-based charts
43124
+ *
43125
+ * @param {Object} options - Configuration options
43126
+ * @param {string} options.defaultFilter - Default time filter ('daily', 'weekly', 'monthly')
43127
+ * @returns {Object} Time filter state and utilities
43128
+ */
43129
+ const useTimeFilter = ({
43130
+ defaultFilter = 'monthly'
43131
+ } = {}) => {
43132
+ const [timeFilter, setTimeFilter] = React.useState(defaultFilter);
43133
+
43134
+ // Memoized format date function bound to current timeFilter
43135
+ const getFormatDateFn = React.useCallback((date, breakLine = false) => getFormatDate(date, breakLine, timeFilter), [timeFilter]);
43136
+
43137
+ // Memoized time quantity function bound to current timeFilter
43138
+ const getTimeQuantityFn = React.useCallback(() => getTimeQuantity(timeFilter), [timeFilter]);
43139
+
43140
+ // Memoized date axis formatter
43141
+ const formatDateAxisFn = React.useMemo(() => label => formatDateAxis(label, getFormatDateFn), [getFormatDateFn]);
43142
+
43143
+ // Process chart data with current time filter
43144
+ const processData = React.useCallback(({
43145
+ mainData,
43146
+ filters = {},
43147
+ isCumulative = false,
43148
+ valueField = 'total'
43149
+ }) => {
43150
+ return processChartDateData({
43151
+ mainData,
43152
+ timeFilter,
43153
+ filters,
43154
+ isCumulative,
43155
+ valueField
43156
+ });
43157
+ }, [timeFilter]);
43158
+ return {
43159
+ timeFilter,
43160
+ setTimeFilter,
43161
+ getFormatDate: getFormatDateFn,
43162
+ getTimeQuantity: getTimeQuantityFn,
43163
+ formatDateAxis: formatDateAxisFn,
43164
+ processChartDateData: processData
43165
+ };
43166
+ };
43167
+
43168
+ const selectOptions$2 = [{
43169
+ label: "Daily",
43170
+ value: "daily"
43171
+ }, {
43172
+ label: "Weekly",
43173
+ value: "weekly"
43174
+ }, {
43175
+ label: "Monthly",
43176
+ value: "monthly"
43177
+ }];
43178
+ const RestoredArea = ({
43179
+ restoredAreaChart,
43180
+ t = s => s
43181
+ }) => {
43182
+ const {
43183
+ timeFilter,
43184
+ setTimeFilter,
43185
+ formatDateAxis,
43186
+ processChartDateData
43187
+ } = useTimeFilter({
43188
+ defaultFilter: 'monthly'
43189
+ });
43190
+
43191
+ // Map restoredAreaChart data to LineChart format with time filter support
43192
+ // Y-axis: total/cumulated value
43193
+ // X-axis: date (formatted based on timeFilter)
43194
+ // Fill all periods in the range, even if empty
43195
+ const restoredAreaChartData = React.useMemo(() => {
43196
+ if (!restoredAreaChart || !Array.isArray(restoredAreaChart) || restoredAreaChart.length === 0) {
43197
+ return [];
43198
+ }
43199
+
43200
+ // Process data with cumulative calculation (for restored area)
43201
+ return processChartDateData({
43202
+ mainData: restoredAreaChart,
43203
+ isCumulative: true,
43204
+ valueField: 'total'
43205
+ });
43206
+ }, [restoredAreaChart, processChartDateData]);
43207
+
43208
+ // Calculate max value for yAxis dynamically (round up to nearest 10)
43209
+ const maxYValue = React.useMemo(() => {
43210
+ if (!restoredAreaChartData || restoredAreaChartData.length === 0) {
43211
+ return 80;
43212
+ }
43213
+ const maxValue = Math.max(...restoredAreaChartData.map(item => item.value || 0));
43214
+ // If max is 0, set default to 80 to show Y-axis
43215
+ // Otherwise, round up to nearest 10
43216
+ if (maxValue === 0) {
43217
+ return 80;
43218
+ }
43219
+ return Math.ceil(maxValue / 10) * 10 || 80;
43220
+ }, [restoredAreaChartData]);
43221
+ return /*#__PURE__*/jsxRuntime.jsx(Widget, {
43222
+ title: t("Restored Area"),
43223
+ className: "with-border-header h-w-btn-header",
43224
+ addedHeader: /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
43225
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
43226
+ className: "flex-1"
43227
+ }), /*#__PURE__*/jsxRuntime.jsx(antd.Select, {
43228
+ value: timeFilter,
43229
+ style: {
43230
+ width: 100
43231
+ },
43232
+ onChange: value => setTimeFilter(value),
43233
+ options: selectOptions$2,
43234
+ popupMatchSelectWidth: 120
43235
+ })]
43236
+ }),
43237
+ children: /*#__PURE__*/jsxRuntime.jsx("div", {
43238
+ className: "flex flex-1 flex-column justify-content-center",
43239
+ children: /*#__PURE__*/jsxRuntime.jsx("div", {
43240
+ className: "flex justify-content-center w-full",
43241
+ children: /*#__PURE__*/jsxRuntime.jsx(LineChart, {
43242
+ animated: true,
43243
+ isArea: true,
43244
+ color: '#00AEB1',
43245
+ data: restoredAreaChartData,
43246
+ fillOpacity: 0.7,
43247
+ height: 200,
43248
+ renderTooltipContent: (title, data) => {
43249
+ if (!data || data.length === 0) return {};
43250
+ const item = data[0]?.data || data[0];
43251
+ const periodValue = item?.period !== undefined ? item.period : item?.value || 0;
43252
+ const cumulatedValue = item?.value || 0;
43253
+ return {
43254
+ title: t("Restored Area"),
43255
+ subTitle: formatDateAxis(title),
43256
+ items: [{
43257
+ label: t("Period"),
43258
+ value: `${periodValue.toLocaleString()} ha`
43259
+ }, {
43260
+ label: t("Cumulated"),
43261
+ value: `${cumulatedValue.toLocaleString()} ha`
43262
+ }]
43263
+ };
43264
+ },
43265
+ xFieldKey: "date",
43266
+ yFieldKey: "value",
43267
+ formattedXAxis: formatDateAxis,
43268
+ style: {
43269
+ width: '100%'
43270
+ },
43271
+ yAxis: {
43272
+ min: 0,
43273
+ max: maxYValue,
43274
+ tickMethod: () => {
43275
+ // Generate ticks every 10 units for maxYValue of 80
43276
+ // For other values, show ticks every 10 units
43277
+ const step = maxYValue <= 80 ? 10 : Math.max(10, Math.floor(maxYValue / 8));
43278
+ const ticks = [];
43279
+ for (let i = 0; i <= maxYValue; i += step) {
43280
+ ticks.push(i);
43281
+ }
43282
+ // Ensure max value is included
43283
+ if (ticks.length === 0 || ticks[ticks.length - 1] < maxYValue) {
43284
+ ticks.push(maxYValue);
43285
+ }
43286
+ return ticks;
43287
+ },
43288
+ label: {
43289
+ style: {
43290
+ fontSize: 12,
43291
+ fill: '#666'
43292
+ }
43293
+ },
43294
+ grid: {
43295
+ line: {
43296
+ style: {
43297
+ stroke: '#E5E7EB',
43298
+ lineWidth: 1
43299
+ }
43300
+ }
43301
+ }
43302
+ },
43303
+ xAxis: {
43304
+ label: {
43305
+ formatter: formatDateAxis,
43306
+ style: {
43307
+ fontSize: 12,
43308
+ fill: '#666'
43309
+ }
43310
+ }
43311
+ }
43312
+ })
43313
+ })
43314
+ })
43315
+ });
43316
+ };
43317
+
43318
+ const selectOptions$1 = [{
43319
+ label: "Daily",
43320
+ value: "daily"
43321
+ }, {
43322
+ label: "Weekly",
43323
+ value: "weekly"
43324
+ }, {
43325
+ label: "Monthly",
43326
+ value: "monthly"
43327
+ }];
43328
+ const PlantingActivitiesTimeline = ({
43329
+ activitiesTimelineChart,
43330
+ t = s => s
43331
+ }) => {
43332
+ const {
43333
+ timeFilter,
43334
+ setTimeFilter,
43335
+ formatDateAxis,
43336
+ processChartDateData
43337
+ } = useTimeFilter({
43338
+ defaultFilter: 'monthly'
43339
+ });
43340
+
43341
+ // Map activitiesTimelineChart data to ColumnChart format with time filter support
43342
+ // Data structure: [{count: 2, date: "2025-11-03"}]
43343
+ // Fill all periods in the range, even if empty
43344
+ const activitiesTimelineData = React.useMemo(() => {
43345
+ if (!activitiesTimelineChart || !Array.isArray(activitiesTimelineChart) || activitiesTimelineChart.length === 0) {
43346
+ return [];
43347
+ }
43348
+
43349
+ // Process data without cumulative calculation (for activities timeline)
43350
+ return processChartDateData({
43351
+ mainData: activitiesTimelineChart,
43352
+ isCumulative: false,
43353
+ valueField: 'count'
43354
+ });
43355
+ }, [activitiesTimelineChart, processChartDateData]);
43356
+
43357
+ // Calculate max value for Y-axis (default to 100 if all values are 0 or very small)
43358
+ const maxActivitiesYValue = React.useMemo(() => {
43359
+ if (!activitiesTimelineData || activitiesTimelineData.length === 0) {
43360
+ return 100;
43361
+ }
43362
+ const maxValue = Math.max(...activitiesTimelineData.map(item => item.jobs || 0));
43363
+ // If max is 0, set default to 100 to show Y-axis
43364
+ if (maxValue === 0) {
43365
+ return 100;
43366
+ }
43367
+ // Round up to nearest 10, but ensure minimum of 100
43368
+ const roundedMax = Math.ceil(maxValue / 10) * 10;
43369
+ return Math.max(100, roundedMax);
43370
+ }, [activitiesTimelineData]);
43371
+ return /*#__PURE__*/jsxRuntime.jsx(Widget, {
43372
+ title: t("Planting Activities Timeline"),
43373
+ className: "with-border-header h-w-btn-header",
43374
+ addedHeader: /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
43375
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
43376
+ className: "flex-1"
43377
+ }), /*#__PURE__*/jsxRuntime.jsx(antd.Select, {
43378
+ value: timeFilter,
43379
+ style: {
43380
+ width: 100
43381
+ },
43382
+ onChange: value => setTimeFilter(value),
43383
+ options: selectOptions$1,
43384
+ popupMatchSelectWidth: 120
43385
+ })]
43386
+ }),
43387
+ children: /*#__PURE__*/jsxRuntime.jsx("div", {
43388
+ className: "flex flex-1 flex-column justify-content-center",
43389
+ children: /*#__PURE__*/jsxRuntime.jsx("div", {
43390
+ className: "flex justify-content-center w-full",
43391
+ children: /*#__PURE__*/jsxRuntime.jsx(ColumnChart, {
43392
+ data: activitiesTimelineData,
43393
+ xFieldKey: "date",
43394
+ yFieldKey: "jobs",
43395
+ animated: true,
43396
+ height: 400,
43397
+ color: "#016C6E",
43398
+ renderTooltipContent: (title, data) => {
43399
+ if (!data || data.length === 0) return {};
43400
+ // For ColumnChart, data structure: data[0]?.data contains the actual data point
43401
+ const item = data[0]?.data || data[0];
43402
+ const count = item?.jobs || item?.value || 0;
43403
+ // Title is the X-axis value (month/date), use it for formatting
43404
+ const dateValue = item?.date || title || '';
43405
+ return {
43406
+ title: t("Planting Activities"),
43407
+ subTitle: formatDateAxis(dateValue),
43408
+ items: [{
43409
+ label: t("Total"),
43410
+ value: count
43411
+ }]
43412
+ };
43413
+ },
43414
+ formattedXAxis: formatDateAxis,
43415
+ formattedYAxis: value => {
43416
+ return `${value}`.replace(/\d{1,3}(?=(\d{3})+$)/g, s => `${s},`);
43417
+ },
43418
+ yAxis: {
43419
+ min: 0,
43420
+ max: maxActivitiesYValue,
43421
+ tickMethod: () => {
43422
+ // Generate ticks: for 100 max, show 0, 20, 40, 60, 80, 100
43423
+ // For other values, show ticks every 20 units
43424
+ const step = maxActivitiesYValue <= 100 ? 20 : Math.max(20, Math.floor(maxActivitiesYValue / 5));
43425
+ const ticks = [];
43426
+ for (let i = 0; i <= maxActivitiesYValue; i += step) {
43427
+ ticks.push(i);
43428
+ }
43429
+ // Ensure max value is included
43430
+ if (ticks.length === 0 || ticks[ticks.length - 1] < maxActivitiesYValue) {
43431
+ ticks.push(maxActivitiesYValue);
43432
+ }
43433
+ return ticks;
43434
+ },
43435
+ label: {
43436
+ style: {
43437
+ fontSize: 12,
43438
+ fill: '#666'
43439
+ }
43440
+ },
43441
+ grid: {
43442
+ line: {
43443
+ style: {
43444
+ stroke: '#E5E7EB',
43445
+ lineWidth: 1
43446
+ }
43447
+ }
43448
+ }
43449
+ },
43450
+ xAxis: {
43451
+ label: {
43452
+ formatter: formatDateAxis,
43453
+ autoHide: true,
43454
+ style: {
43455
+ fontSize: 12,
43456
+ fill: '#666'
43457
+ }
43458
+ }
43459
+ }
43460
+ })
43461
+ })
43462
+ })
43463
+ });
43464
+ };
43465
+
42839
43466
  const CycleOutcomes = ({
42840
43467
  id,
42841
43468
  getSummaryDetail,
@@ -42896,223 +43523,6 @@ const CycleOutcomes = ({
42896
43523
  format: 'absolute'
42897
43524
  });
42898
43525
  }, [locationsCount, t]);
42899
-
42900
- // Map restoredAreaChart data to LineChart format
42901
- // Y-axis: total/cumulated value
42902
- // X-axis: date
42903
- // Fill all months in the range, even if empty
42904
- const restoredAreaChartData = React.useMemo(() => {
42905
- // Always show last 12 months, even if no data
42906
- const now = dayjs__default["default"]().startOf('month');
42907
- const twelveMonthsAgo = now.subtract(11, 'month'); // 11 months ago + current month = 12 months
42908
-
42909
- // Create a map of existing data by month (YYYY-MM format)
42910
- const dataMap = new Map();
42911
- const dates = [];
42912
-
42913
- // Process restored area data if available
42914
- if (restoredAreaChart && Array.isArray(restoredAreaChart) && restoredAreaChart.length > 0) {
42915
- restoredAreaChart.forEach(item => {
42916
- if (typeof item === 'object' && item !== null) {
42917
- // Priority: look for date field first
42918
- const dateValue = item.date || item.label || item.name || item.period || item.month;
42919
- if (dateValue) {
42920
- const date = dayjs__default["default"](dateValue);
42921
- if (date.isValid()) {
42922
- const monthKey = date.format('YYYY-MM');
42923
- // Total/cumulated value for Y-axis (this is what gets plotted)
42924
- const totalValue = Number(item.cumulated || item.cumulative || item.total || item.value || 0) || 0;
42925
- // Period value for tooltip only
42926
- const periodValue = Number(item.period || item.area || item.count || 0) || 0;
42927
- dates.push(date);
42928
-
42929
- // If multiple entries for same month, use the latest one (or sum if needed)
42930
- if (!dataMap.has(monthKey) || dataMap.get(monthKey).value < totalValue) {
42931
- dataMap.set(monthKey, {
42932
- date: dateValue,
42933
- value: totalValue,
42934
- period: periodValue
42935
- });
42936
- }
42937
- }
42938
- }
42939
- }
42940
- });
42941
- }
42942
-
42943
- // Determine date range
42944
- let minDate = twelveMonthsAgo;
42945
- let maxDate = now;
42946
-
42947
- // If we have data, adjust range to include it
42948
- if (dates.length > 0) {
42949
- const sortedDates = dates.sort((a, b) => a.valueOf() - b.valueOf());
42950
- const firstDataDate = sortedDates[0].startOf('month');
42951
- const lastDataDate = sortedDates[sortedDates.length - 1].startOf('month');
42952
-
42953
- // Start from the earlier of: 12 months ago, or first data date
42954
- minDate = twelveMonthsAgo.isBefore(firstDataDate) ? twelveMonthsAgo : firstDataDate;
42955
-
42956
- // End at the later of: current month, or last data date
42957
- maxDate = now.isAfter(lastDataDate) ? now : lastDataDate;
42958
- }
42959
-
42960
- // Generate all months in the range
42961
- const result = [];
42962
- let currentDate = minDate.clone();
42963
- let lastKnownValue = 0; // For cumulative data, carry forward the last known value
42964
-
42965
- while (currentDate.isBefore(maxDate) || currentDate.isSame(maxDate, 'month')) {
42966
- const monthKey = currentDate.format('YYYY-MM');
42967
- const existingData = dataMap.get(monthKey);
42968
- if (existingData) {
42969
- lastKnownValue = existingData.value;
42970
- result.push(existingData);
42971
- } else {
42972
- // Fill missing month - for cumulative data, use last known value
42973
- result.push({
42974
- date: currentDate.format('YYYY-MM-DD'),
42975
- value: lastKnownValue,
42976
- // Carry forward cumulative value
42977
- period: 0
42978
- });
42979
- }
42980
- currentDate = currentDate.add(1, 'month');
42981
- }
42982
- return result;
42983
- }, [restoredAreaChart]);
42984
-
42985
- // Calculate max value for yAxis dynamically (round up to nearest 10)
42986
- const maxYValue = React.useMemo(() => {
42987
- if (!restoredAreaChartData || restoredAreaChartData.length === 0) {
42988
- return 80;
42989
- }
42990
- const maxValue = Math.max(...restoredAreaChartData.map(item => item.value || 0));
42991
- // If max is 0, set default to 80 to show Y-axis
42992
- // Otherwise, round up to nearest 10
42993
- if (maxValue === 0) {
42994
- return 80;
42995
- }
42996
- return Math.ceil(maxValue / 10) * 10 || 80;
42997
- }, [restoredAreaChartData]);
42998
-
42999
- // Format date to "Mmm YY" format for X-axis
43000
- const formatDateAxis = React.useMemo(() => {
43001
- return label => {
43002
- if (!label) return label;
43003
-
43004
- // Try to parse the date using dayjs with various formats
43005
- let date = dayjs__default["default"](label);
43006
-
43007
- // If first attempt fails, try parsing as ISO date string
43008
- if (!date.isValid() && typeof label === 'string') {
43009
- date = dayjs__default["default"](label, ['YYYY-MM-DD', 'YYYY-MM', 'MMM YY', 'MMM YYYY'], true);
43010
- }
43011
-
43012
- // If it's a valid date, format it as "Mmm YY"
43013
- if (date.isValid()) {
43014
- return date.format('MMM YY');
43015
- }
43016
-
43017
- // If it's already in "Mmm YY" format or similar, return as is
43018
- // Otherwise return the original label
43019
- return label;
43020
- };
43021
- }, []);
43022
-
43023
- // Map activitiesTimelineChart data to ColumnChart format
43024
- // Data structure: [{count: 2, date: "2025-11-03"}]
43025
- // Fill all months in the range, even if empty
43026
- const activitiesTimelineData = React.useMemo(() => {
43027
- // Always show last 12 months, even if no data
43028
- const now = dayjs__default["default"]().startOf('month');
43029
- const twelveMonthsAgo = now.subtract(11, 'month'); // 11 months ago + current month = 12 months
43030
-
43031
- // Create a map of existing data by month (YYYY-MM format)
43032
- const dataMap = new Map();
43033
- const dates = [];
43034
-
43035
- // Process activities timeline data if available
43036
- if (activitiesTimelineChart && Array.isArray(activitiesTimelineChart) && activitiesTimelineChart.length > 0) {
43037
- activitiesTimelineChart.forEach(item => {
43038
- if (typeof item === 'object' && item !== null && item.date) {
43039
- const date = dayjs__default["default"](item.date);
43040
- if (date.isValid()) {
43041
- const monthKey = date.format('YYYY-MM');
43042
- const count = Number(item.count || item.jobs || item.value || 0) || 0;
43043
- dates.push(date);
43044
-
43045
- // If multiple entries for same month, sum them
43046
- if (dataMap.has(monthKey)) {
43047
- dataMap.set(monthKey, {
43048
- ...dataMap.get(monthKey),
43049
- jobs: dataMap.get(monthKey).jobs + count
43050
- });
43051
- } else {
43052
- dataMap.set(monthKey, {
43053
- month: item.date,
43054
- jobs: count,
43055
- date: item.date
43056
- });
43057
- }
43058
- }
43059
- }
43060
- });
43061
- }
43062
-
43063
- // Determine date range
43064
- let minDate = twelveMonthsAgo;
43065
- let maxDate = now;
43066
-
43067
- // If we have data, adjust range to include it
43068
- if (dates.length > 0) {
43069
- const sortedDates = dates.sort((a, b) => a.valueOf() - b.valueOf());
43070
- const firstDataDate = sortedDates[0].startOf('month');
43071
- const lastDataDate = sortedDates[sortedDates.length - 1].startOf('month');
43072
-
43073
- // Start from the earlier of: 12 months ago, or first data date
43074
- minDate = twelveMonthsAgo.isBefore(firstDataDate) ? twelveMonthsAgo : firstDataDate;
43075
-
43076
- // End at the later of: current month, or last data date
43077
- maxDate = now.isAfter(lastDataDate) ? now : lastDataDate;
43078
- }
43079
-
43080
- // Generate all months in the range
43081
- const result = [];
43082
- let currentDate = minDate.clone();
43083
- while (currentDate.isBefore(maxDate) || currentDate.isSame(maxDate, 'month')) {
43084
- const monthKey = currentDate.format('YYYY-MM');
43085
- const existingData = dataMap.get(monthKey);
43086
- if (existingData) {
43087
- result.push(existingData);
43088
- } else {
43089
- // Fill missing month with 0
43090
- result.push({
43091
- month: currentDate.format('YYYY-MM-DD'),
43092
- // Use first day of month
43093
- jobs: 0,
43094
- date: currentDate.format('YYYY-MM-DD')
43095
- });
43096
- }
43097
- currentDate = currentDate.add(1, 'month');
43098
- }
43099
- return result;
43100
- }, [activitiesTimelineChart]);
43101
-
43102
- // Calculate max value for Y-axis (default to 100 if all values are 0 or very small)
43103
- const maxActivitiesYValue = React.useMemo(() => {
43104
- if (!activitiesTimelineData || activitiesTimelineData.length === 0) {
43105
- return 100;
43106
- }
43107
- const maxValue = Math.max(...activitiesTimelineData.map(item => item.jobs || 0));
43108
- // If max is 0, set default to 100 to show Y-axis
43109
- if (maxValue === 0) {
43110
- return 100;
43111
- }
43112
- // Round up to nearest 10, but ensure minimum of 100
43113
- const roundedMax = Math.ceil(maxValue / 10) * 10;
43114
- return Math.max(100, roundedMax);
43115
- }, [activitiesTimelineData]);
43116
43526
  return /*#__PURE__*/jsxRuntime.jsx("section", {
43117
43527
  children: /*#__PURE__*/jsxRuntime.jsxs(Widget, {
43118
43528
  title: t("Restoration Cycle Outcomes"),
@@ -43154,172 +43564,17 @@ const CycleOutcomes = ({
43154
43564
  style: {
43155
43565
  flex: 1
43156
43566
  },
43157
- children: /*#__PURE__*/jsxRuntime.jsx(Widget, {
43158
- title: t("Restored Area"),
43159
- className: "with-border-header h-w-btn-header",
43160
- children: /*#__PURE__*/jsxRuntime.jsx("div", {
43161
- className: "flex flex-1 flex-column justify-content-center",
43162
- children: /*#__PURE__*/jsxRuntime.jsx("div", {
43163
- className: "flex justify-content-center w-full",
43164
- children: /*#__PURE__*/jsxRuntime.jsx(LineChart, {
43165
- animated: true,
43166
- isArea: true,
43167
- color: '#00AEB1',
43168
- data: restoredAreaChartData,
43169
- fillOpacity: 0.7,
43170
- height: 200,
43171
- renderTooltipContent: (title, data) => {
43172
- if (!data || data.length === 0) return {};
43173
- const item = data[0]?.data || data[0];
43174
- const periodValue = item?.period !== undefined ? item.period : item?.value || 0;
43175
- const cumulatedValue = item?.value || 0;
43176
- return {
43177
- title: t("Restored Area"),
43178
- subTitle: formatDateAxis(title),
43179
- items: [{
43180
- label: t("Period"),
43181
- value: `${periodValue.toLocaleString()} ha`
43182
- }, {
43183
- label: t("Cumulated"),
43184
- value: `${cumulatedValue.toLocaleString()} ha`
43185
- }]
43186
- };
43187
- },
43188
- xFieldKey: "date",
43189
- yFieldKey: "value",
43190
- formattedXAxis: formatDateAxis,
43191
- style: {
43192
- width: '100%'
43193
- },
43194
- yAxis: {
43195
- min: 0,
43196
- max: maxYValue,
43197
- tickMethod: () => {
43198
- // Generate ticks every 10 units for maxYValue of 80
43199
- // For other values, show ticks every 10 units
43200
- const step = maxYValue <= 80 ? 10 : Math.max(10, Math.floor(maxYValue / 8));
43201
- const ticks = [];
43202
- for (let i = 0; i <= maxYValue; i += step) {
43203
- ticks.push(i);
43204
- }
43205
- // Ensure max value is included
43206
- if (ticks.length === 0 || ticks[ticks.length - 1] < maxYValue) {
43207
- ticks.push(maxYValue);
43208
- }
43209
- return ticks;
43210
- },
43211
- label: {
43212
- style: {
43213
- fontSize: 12,
43214
- fill: '#666'
43215
- }
43216
- },
43217
- grid: {
43218
- line: {
43219
- style: {
43220
- stroke: '#E5E7EB',
43221
- lineWidth: 1
43222
- }
43223
- }
43224
- }
43225
- },
43226
- xAxis: {
43227
- label: {
43228
- formatter: formatDateAxis,
43229
- // Ensure formatter is applied
43230
- style: {
43231
- fontSize: 12,
43232
- fill: '#666'
43233
- }
43234
- }
43235
- }
43236
- })
43237
- })
43238
- })
43567
+ children: /*#__PURE__*/jsxRuntime.jsx(RestoredArea, {
43568
+ restoredAreaChart: restoredAreaChart,
43569
+ t: t
43239
43570
  })
43240
43571
  }), /*#__PURE__*/jsxRuntime.jsx("section", {
43241
43572
  style: {
43242
43573
  flex: 1
43243
43574
  },
43244
- children: /*#__PURE__*/jsxRuntime.jsx(Widget, {
43245
- title: t("Planting Activities Timeline"),
43246
- className: "with-border-header h-w-btn-header",
43247
- children: /*#__PURE__*/jsxRuntime.jsx("div", {
43248
- className: "flex flex-1 flex-column justify-content-center",
43249
- children: /*#__PURE__*/jsxRuntime.jsx("div", {
43250
- className: "flex justify-content-center w-full",
43251
- children: /*#__PURE__*/jsxRuntime.jsx(ColumnChart, {
43252
- data: activitiesTimelineData,
43253
- xFieldKey: "month",
43254
- yFieldKey: "jobs",
43255
- animated: true,
43256
- height: 400,
43257
- color: "#016C6E",
43258
- renderTooltipContent: (title, data) => {
43259
- if (!data || data.length === 0) return {};
43260
- // For ColumnChart, data structure: data[0]?.data contains the actual data point
43261
- const item = data[0]?.data || data[0];
43262
- const count = item?.jobs || item?.value || 0;
43263
- // Title is the X-axis value (month/date), use it for formatting
43264
- const dateValue = item?.date || title || '';
43265
- return {
43266
- title: t("Planting Activities"),
43267
- subTitle: formatDateAxis(dateValue),
43268
- items: [{
43269
- label: t("Total"),
43270
- value: count
43271
- }]
43272
- };
43273
- },
43274
- formattedXAxis: formatDateAxis,
43275
- formattedYAxis: value => {
43276
- return `${value}`.replace(/\d{1,3}(?=(\d{3})+$)/g, s => `${s},`);
43277
- },
43278
- yAxis: {
43279
- min: 0,
43280
- max: maxActivitiesYValue,
43281
- tickMethod: () => {
43282
- // Generate ticks: for 100 max, show 0, 20, 40, 60, 80, 100
43283
- // For other values, show ticks every 20 units
43284
- const step = maxActivitiesYValue <= 100 ? 20 : Math.max(20, Math.floor(maxActivitiesYValue / 5));
43285
- const ticks = [];
43286
- for (let i = 0; i <= maxActivitiesYValue; i += step) {
43287
- ticks.push(i);
43288
- }
43289
- // Ensure max value is included
43290
- if (ticks.length === 0 || ticks[ticks.length - 1] < maxActivitiesYValue) {
43291
- ticks.push(maxActivitiesYValue);
43292
- }
43293
- return ticks;
43294
- },
43295
- label: {
43296
- style: {
43297
- fontSize: 12,
43298
- fill: '#666'
43299
- }
43300
- },
43301
- grid: {
43302
- line: {
43303
- style: {
43304
- stroke: '#E5E7EB',
43305
- lineWidth: 1
43306
- }
43307
- }
43308
- }
43309
- },
43310
- xAxis: {
43311
- label: {
43312
- formatter: formatDateAxis,
43313
- autoHide: true,
43314
- style: {
43315
- fontSize: 12,
43316
- fill: '#666'
43317
- }
43318
- }
43319
- }
43320
- })
43321
- })
43322
- })
43575
+ children: /*#__PURE__*/jsxRuntime.jsx(PlantingActivitiesTimeline, {
43576
+ activitiesTimelineChart: activitiesTimelineChart,
43577
+ t: t
43323
43578
  })
43324
43579
  })]
43325
43580
  })]
@@ -43445,8 +43700,8 @@ const CyclePartners = ({
43445
43700
  };
43446
43701
 
43447
43702
  const HEALTH_SAFETY_COLORS = {
43448
- compliant: '#52C41A',
43449
- notCompliant: '#FF4D4F',
43703
+ compliant: '#016C6E',
43704
+ notCompliant: '#F97066',
43450
43705
  empty: '#D9D9D9'
43451
43706
  };
43452
43707
  const getIndicatorType = value => {
@@ -43515,8 +43770,9 @@ const isHealthAndSafetyDistributionEmpty = healthAndSafetyDistributionData => {
43515
43770
  const calculateHealthAndSafetyPieData = (healthAndSafetyDistributionData, t) => {
43516
43771
  const total = Object.values(healthAndSafetyDistributionData).reduce((all, val) => all + (val || 0), 0);
43517
43772
  const labels = {
43518
- compliant: t("Compliant"),
43519
- notCompliant: t("Not Compliant")
43773
+ compliant: t("Available"),
43774
+ notCompliant: t("Not available"),
43775
+ empty: t("Not answered")
43520
43776
  };
43521
43777
  return Object.keys(healthAndSafetyDistributionData).map(key => {
43522
43778
  const color = HEALTH_SAFETY_COLORS[key] || '#D9D9D9';
@@ -43554,8 +43810,9 @@ const getHealthAndSafetyTooltipChildren = (item, isEmpty, healthAndSafetyDistrib
43554
43810
  return null;
43555
43811
  }
43556
43812
  const labels = {
43557
- compliant: t("Compliant"),
43558
- notCompliant: t("Not Compliant")
43813
+ compliant: t("Available"),
43814
+ notCompliant: t("Not available"),
43815
+ empty: t("Not answered")
43559
43816
  };
43560
43817
 
43561
43818
  // Filter items with values > 0
@@ -43582,16 +43839,93 @@ const getHealthAndSafetyTooltipChildren = (item, isEmpty, healthAndSafetyDistrib
43582
43839
  };
43583
43840
 
43584
43841
  const HealthAndSafety = ({
43585
- activityData,
43842
+ id,
43843
+ getSummaryDetail,
43586
43844
  loading = false,
43587
43845
  t = s => s
43588
43846
  }) => {
43589
- const healthAndSafetyDistributionData = React.useMemo(() => getHealthAndSafetyDistributionData(activityData), [activityData]);
43847
+ const defaultConfig = React.useMemo(() => ({
43848
+ basepath: "planting-cycle",
43849
+ url: `/summary/${id}/filtered-piechart`,
43850
+ filters: {
43851
+ field: 'duosFormed'
43852
+ },
43853
+ stop: !id
43854
+ }), [id]);
43855
+ const customGetData = React.useMemo(() => {
43856
+ if (getSummaryDetail && id) {
43857
+ return rest => {
43858
+ const {
43859
+ url,
43860
+ filters: restFilters
43861
+ } = rest;
43862
+ const match = url.match(/\/summary\/[^/]+\/(.+)/);
43863
+ if (match) {
43864
+ const [, type] = match;
43865
+ // Pass filters as params for the query string
43866
+ const params = {
43867
+ ...(restFilters || {})
43868
+ };
43869
+ return getSummaryDetail(id, type, params);
43870
+ }
43871
+ throw new Error(`Invalid URL format: ${url}`);
43872
+ };
43873
+ }
43874
+ return undefined;
43875
+ }, [getSummaryDetail, id]);
43876
+ const {
43877
+ loading: pieChartLoading,
43878
+ data: pieChartData
43879
+ } = useWidgetFetch({
43880
+ config: defaultConfig,
43881
+ getData: customGetData
43882
+ });
43883
+
43884
+ // Process the fetched pie chart data
43885
+ // The API returns data in format: [{count: 1, duosFormed: "null"}, {count: 1, duosFormed: "no"}, {count: 1, duosFormed: "yes"}]
43886
+ const healthAndSafetyDistributionData = React.useMemo(() => {
43887
+ if (!pieChartData) return {
43888
+ compliant: 0,
43889
+ notCompliant: 0,
43890
+ empty: 0
43891
+ };
43892
+
43893
+ // If it's already a distribution object
43894
+ if (pieChartData.compliant !== undefined || pieChartData.notCompliant !== undefined) {
43895
+ return pieChartData;
43896
+ }
43897
+
43898
+ // If it's an array, process it
43899
+ if (Array.isArray(pieChartData)) {
43900
+ const distribution = {
43901
+ compliant: 0,
43902
+ notCompliant: 0,
43903
+ empty: 0
43904
+ };
43905
+ pieChartData.forEach(item => {
43906
+ const duosFormedValue = item.duosFormed;
43907
+ const count = item.count || 0;
43908
+
43909
+ // Map duosFormed values to distribution categories
43910
+ if (duosFormedValue === "yes" || duosFormedValue === true) {
43911
+ distribution.compliant += count;
43912
+ } else if (duosFormedValue === "no" || duosFormedValue === false) {
43913
+ distribution.notCompliant += count;
43914
+ } else if (duosFormedValue === "null" || duosFormedValue === null || duosFormedValue === undefined) {
43915
+ distribution.empty += count;
43916
+ }
43917
+ });
43918
+ return distribution;
43919
+ }
43920
+
43921
+ // Fallback: try to extract from activityData-like structure
43922
+ return getHealthAndSafetyDistributionData(pieChartData);
43923
+ }, [pieChartData]);
43590
43924
  const isEmpty = React.useMemo(() => isHealthAndSafetyDistributionEmpty(healthAndSafetyDistributionData), [healthAndSafetyDistributionData]);
43591
43925
  const pieData = React.useMemo(() => calculateHealthAndSafetyPieData(healthAndSafetyDistributionData, t), [healthAndSafetyDistributionData, t]);
43592
43926
  const getTooltipChildren = React.useCallback(item => getHealthAndSafetyTooltipChildren(item, isEmpty, healthAndSafetyDistributionData, t, renderTooltipJsx), [t, isEmpty, healthAndSafetyDistributionData]);
43593
43927
  return /*#__PURE__*/jsxRuntime.jsx(Widget, {
43594
- loading: loading,
43928
+ loading: loading || pieChartLoading,
43595
43929
  title: /*#__PURE__*/jsxRuntime.jsx("div", {
43596
43930
  children: t("Health and Safety")
43597
43931
  }),
@@ -43726,7 +44060,8 @@ const CycleIndicators = ({
43726
44060
  flex: 1
43727
44061
  },
43728
44062
  children: /*#__PURE__*/jsxRuntime.jsx(HealthAndSafety, {
43729
- activityData: indicatorsData,
44063
+ id: id,
44064
+ getSummaryDetail: getSummaryDetail,
43730
44065
  loading: indicatorsLoading,
43731
44066
  t: t
43732
44067
  })
@@ -43873,110 +44208,43 @@ const GenderDistribution = ({
43873
44208
  });
43874
44209
  };
43875
44210
 
44211
+ const selectOptions = [{
44212
+ label: "Daily",
44213
+ value: "daily"
44214
+ }, {
44215
+ label: "Weekly",
44216
+ value: "weekly"
44217
+ }, {
44218
+ label: "Monthly",
44219
+ value: "monthly"
44220
+ }];
43876
44221
  const JobsTimeline = ({
43877
44222
  dayJobsTimeline,
43878
44223
  loading = false,
43879
44224
  t = s => s
43880
44225
  }) => {
43881
- console.log('dayJobsTimeline', dayJobsTimeline);
44226
+ const {
44227
+ timeFilter,
44228
+ setTimeFilter,
44229
+ formatDateAxis,
44230
+ processChartDateData
44231
+ } = useTimeFilter({
44232
+ defaultFilter: 'monthly'
44233
+ });
43882
44234
  const jobsData = Array.isArray(dayJobsTimeline) ? dayJobsTimeline : dayJobsTimeline?.jobsTimeline || dayJobsTimeline?.jobs || dayJobsTimeline?.timeline || [];
43883
- const formatDateAxis = React.useMemo(() => {
43884
- return label => {
43885
- if (!label) return label;
43886
-
43887
- // Try to parse the date using dayjs with various formats
43888
- let date = dayjs__default["default"](label);
43889
-
43890
- // If first attempt fails, try parsing as ISO date string
43891
- if (!date.isValid() && typeof label === 'string') {
43892
- date = dayjs__default["default"](label, ['YYYY-MM-DD', 'YYYY-MM', 'MMM YY', 'MMM YYYY'], true);
43893
- }
43894
-
43895
- // If it's a valid date, format it as "Mmm YY"
43896
- if (date.isValid()) {
43897
- return date.format('MMM YY');
43898
- }
43899
-
43900
- // If it's already in "Mmm YY" format or similar, return as is
43901
- // Otherwise return the original label
43902
- return label;
43903
- };
43904
- }, []);
43905
44235
  const jobsTimelineData = React.useMemo(() => {
43906
- // Always show last 12 months, even if no data
43907
- const now = dayjs__default["default"]().startOf('month');
43908
- const twelveMonthsAgo = now.subtract(11, 'month'); // 11 months ago + current month = 12 months
43909
-
43910
- // Create a map of existing data by month (YYYY-MM format)
43911
- const dataMap = new Map();
43912
- const dates = [];
43913
-
43914
- // Process jobs data if available
43915
- if (jobsData && Array.isArray(jobsData) && jobsData.length > 0) {
43916
- jobsData.forEach(item => {
43917
- if (typeof item === 'object' && item !== null && item.date) {
43918
- const date = dayjs__default["default"](item.date);
43919
- if (date.isValid()) {
43920
- const monthKey = date.format('YYYY-MM');
43921
- const count = Number(item.total || item.count || item.jobs || item.value || 0) || 0;
43922
- dates.push(date);
43923
-
43924
- // If multiple entries for same month, sum them
43925
- if (dataMap.has(monthKey)) {
43926
- dataMap.set(monthKey, {
43927
- ...dataMap.get(monthKey),
43928
- jobs: dataMap.get(monthKey).jobs + count
43929
- });
43930
- } else {
43931
- dataMap.set(monthKey, {
43932
- month: item.date,
43933
- jobs: count,
43934
- date: item.date
43935
- });
43936
- }
43937
- }
43938
- }
43939
- });
43940
- }
43941
-
43942
- // Determine date range
43943
- let minDate = twelveMonthsAgo;
43944
- let maxDate = now;
43945
-
43946
- // If we have data, adjust range to include it
43947
- if (dates.length > 0) {
43948
- const sortedDates = dates.sort((a, b) => a.valueOf() - b.valueOf());
43949
- const firstDataDate = sortedDates[0].startOf('month');
43950
- const lastDataDate = sortedDates[sortedDates.length - 1].startOf('month');
43951
-
43952
- // Start from the earlier of: 12 months ago, or first data date
43953
- minDate = twelveMonthsAgo.isBefore(firstDataDate) ? twelveMonthsAgo : firstDataDate;
43954
-
43955
- // End at the later of: current month, or last data date
43956
- maxDate = now.isAfter(lastDataDate) ? now : lastDataDate;
44236
+ if (!jobsData || !Array.isArray(jobsData) || jobsData.length === 0) {
44237
+ return [];
43957
44238
  }
43958
44239
 
43959
- // Generate all months in the range
43960
- const result = [];
43961
- let currentDate = minDate.clone();
43962
- while (currentDate.isBefore(maxDate) || currentDate.isSame(maxDate, 'month')) {
43963
- const monthKey = currentDate.format('YYYY-MM');
43964
- const existingData = dataMap.get(monthKey);
43965
- if (existingData) {
43966
- result.push(existingData);
43967
- } else {
43968
- // Fill missing month with 0
43969
- result.push({
43970
- month: currentDate.format('YYYY-MM-DD'),
43971
- // Use first day of month
43972
- jobs: 0,
43973
- date: currentDate.format('YYYY-MM-DD')
43974
- });
43975
- }
43976
- currentDate = currentDate.add(1, 'month');
43977
- }
43978
- return result;
43979
- }, [jobsData]);
44240
+ // Process data without cumulative calculation (for jobs timeline)
44241
+ // Try to find value in total, count, jobs, or value fields
44242
+ return processChartDateData({
44243
+ mainData: jobsData,
44244
+ isCumulative: false,
44245
+ valueField: 'total' // Will fallback to count/jobs/value if total doesn't exist
44246
+ });
44247
+ }, [jobsData, processChartDateData]);
43980
44248
  const maxYValue = React.useMemo(() => {
43981
44249
  if (!jobsTimelineData || jobsTimelineData.length === 0) {
43982
44250
  return 100;
@@ -43994,9 +44262,22 @@ const JobsTimeline = ({
43994
44262
  children: t("Day Jobs Timeline")
43995
44263
  }),
43996
44264
  className: "with-border-header h-w-btn-header ",
44265
+ addedHeader: /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
44266
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
44267
+ className: "flex-1"
44268
+ }), /*#__PURE__*/jsxRuntime.jsx(antd.Select, {
44269
+ value: timeFilter,
44270
+ style: {
44271
+ width: 100
44272
+ },
44273
+ onChange: value => setTimeFilter(value),
44274
+ options: selectOptions,
44275
+ popupMatchSelectWidth: 120
44276
+ })]
44277
+ }),
43997
44278
  children: /*#__PURE__*/jsxRuntime.jsx(ColumnChart, {
43998
44279
  data: jobsTimelineData,
43999
- xFieldKey: "month",
44280
+ xFieldKey: "date",
44000
44281
  yFieldKey: "jobs",
44001
44282
  animated: true
44002
44283
  // height={200}
@@ -44238,37 +44519,732 @@ const CommunityParticipation = ({
44238
44519
  });
44239
44520
  };
44240
44521
 
44522
+ const ACTIVITIES_TAB$1 = 'activities';
44523
+ const PARTNERS_TAB$1 = 'partners';
44524
+ const INCIDENTS_TAB$1 = 'incidents';
44525
+ const getColumns = ({
44526
+ projectId,
44527
+ t,
44528
+ show = 'show',
44529
+ navigate,
44530
+ selectOptions,
44531
+ view,
44532
+ getRedirectLink,
44533
+ activeTab = ACTIVITIES_TAB$1
44534
+ }) => {
44535
+ if (activeTab === ACTIVITIES_TAB$1) {
44536
+ return [{
44537
+ title: "",
44538
+ dataIndex: 'image',
44539
+ key: 'image',
44540
+ active: true,
44541
+ width: 80,
44542
+ pending: true,
44543
+ suspended: true,
44544
+ ellipsis: true,
44545
+ render: (v, all) => {
44546
+ if (all.empty) {
44547
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
44548
+ className: "daf-default-cell"
44549
+ });
44550
+ }
44551
+ const firstGroupPhoto = all?.groupPhotos?.[0];
44552
+ const pictures = firstGroupPhoto?.pictures;
44553
+ const firstPicture = Array.isArray(pictures) && pictures.length > 0 ? pictures[0] : null;
44554
+ let imageUrl = firstPicture?.url;
44555
+ const normalizeUrl = url => url?.endsWith(':') ? url.slice(0, -1) : url;
44556
+ let normalizedUrl = imageUrl ? normalizeUrl(imageUrl.trim()) : null;
44557
+ if (normalizedUrl && !normalizedUrl.startsWith('http://') && !normalizedUrl.startsWith('https://') && !normalizedUrl.startsWith('//')) {
44558
+ if (normalizedUrl.startsWith('cdn.') || normalizedUrl.includes('.') && !normalizedUrl.startsWith('/')) {
44559
+ normalizedUrl = `https://${normalizedUrl}`;
44560
+ }
44561
+ }
44562
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
44563
+ className: "daf-default-cell",
44564
+ style: {
44565
+ display: 'flex',
44566
+ alignItems: 'center',
44567
+ justifyContent: 'center'
44568
+ },
44569
+ children: /*#__PURE__*/jsxRuntime.jsx("div", {
44570
+ style: {
44571
+ width: 32,
44572
+ height: 32,
44573
+ borderWidth: '1px',
44574
+ borderStyle: 'solid',
44575
+ borderColor: '#E5E7EB',
44576
+ borderRadius: '6px',
44577
+ background: '#F9FAFB',
44578
+ display: 'flex',
44579
+ alignItems: 'center',
44580
+ justifyContent: 'center',
44581
+ overflow: 'hidden',
44582
+ position: 'relative'
44583
+ },
44584
+ children: normalizedUrl && /*#__PURE__*/jsxRuntime.jsx("img", {
44585
+ src: normalizedUrl,
44586
+ alt: all.name || 'Activity image',
44587
+ style: {
44588
+ width: '100%',
44589
+ height: '100%',
44590
+ objectFit: 'cover',
44591
+ borderRadius: '6px'
44592
+ },
44593
+ onError: e => {
44594
+ e.target.style.display = 'none';
44595
+ }
44596
+ })
44597
+ })
44598
+ });
44599
+ }
44600
+ }, {
44601
+ title: t('ID'),
44602
+ dataIndex: 'datastakeId',
44603
+ key: 'datastakeId',
44604
+ active: true,
44605
+ pending: true,
44606
+ suspended: true,
44607
+ ellipsis: true,
44608
+ render: (v, all) => {
44609
+ if (all.empty) {
44610
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
44611
+ className: "daf-default-cell"
44612
+ });
44613
+ }
44614
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
44615
+ className: "daf-default-cell",
44616
+ children: all.datastakeId
44617
+ });
44618
+ }
44619
+ }, {
44620
+ title: t("Title"),
44621
+ dataIndex: "name",
44622
+ key: "name",
44623
+ ellipsis: true,
44624
+ active: true,
44625
+ pending: true,
44626
+ suspended: true,
44627
+ render: value => /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
44628
+ title: value,
44629
+ children: value
44630
+ })
44631
+ }, {
44632
+ title: t("Type"),
44633
+ dataIndex: "type",
44634
+ key: "type",
44635
+ ellipsis: true,
44636
+ active: true,
44637
+ pending: true,
44638
+ suspended: true,
44639
+ render: (value, all) => {
44640
+ if (all.empty) {
44641
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
44642
+ className: "daf-default-cell"
44643
+ });
44644
+ }
44645
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
44646
+ title: value,
44647
+ children: capitalize(value) || '-'
44648
+ });
44649
+ }
44650
+ }, {
44651
+ title: t("Location"),
44652
+ dataIndex: "location",
44653
+ key: "location",
44654
+ ellipsis: true,
44655
+ active: true,
44656
+ pending: true,
44657
+ width: 220,
44658
+ suspended: true,
44659
+ show: true,
44660
+ render: (value, all) => {
44661
+ if (all.empty) {
44662
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
44663
+ className: "daf-default-cell"
44664
+ });
44665
+ }
44666
+ const location = all.location || value;
44667
+ if (location && typeof location === 'object' && typeof location.latitude === 'number' && typeof location.longitude === 'number') {
44668
+ const coordinates = convertDMS(location.latitude, location.longitude);
44669
+ const iconColor = "#016C6E";
44670
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
44671
+ style: {
44672
+ display: 'flex',
44673
+ alignItems: 'center',
44674
+ gap: '8px',
44675
+ flexWrap: 'nowrap'
44676
+ },
44677
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
44678
+ style: {
44679
+ display: 'flex',
44680
+ alignItems: 'center',
44681
+ gap: '4px'
44682
+ },
44683
+ children: [/*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
44684
+ name: "SpacingHeight",
44685
+ width: 14,
44686
+ height: 14,
44687
+ fill: iconColor
44688
+ }), /*#__PURE__*/jsxRuntime.jsx("span", {
44689
+ children: coordinates[0]
44690
+ })]
44691
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
44692
+ style: {
44693
+ display: 'flex',
44694
+ alignItems: 'center',
44695
+ gap: '4px'
44696
+ },
44697
+ children: [/*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
44698
+ name: "SpacingWidth",
44699
+ width: 14,
44700
+ height: 14,
44701
+ fill: iconColor
44702
+ }), /*#__PURE__*/jsxRuntime.jsx("span", {
44703
+ children: coordinates[1]
44704
+ })]
44705
+ })]
44706
+ });
44707
+ }
44708
+ let locationDisplay = '-';
44709
+ if (all.project?.name || all.project?.title) {
44710
+ locationDisplay = all.project?.name || all.project?.title;
44711
+ } else if (location?.name) {
44712
+ locationDisplay = location.name;
44713
+ } else if (value && typeof value === 'string') {
44714
+ locationDisplay = value;
44715
+ }
44716
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
44717
+ title: locationDisplay,
44718
+ children: locationDisplay
44719
+ });
44720
+ }
44721
+ }, {
44722
+ title: t("Implementer"),
44723
+ dataIndex: "technicalPartner",
44724
+ key: "implementer",
44725
+ ellipsis: true,
44726
+ show: true,
44727
+ render: (value, all) => {
44728
+ if (all.empty) {
44729
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
44730
+ className: "daf-default-cell"
44731
+ });
44732
+ }
44733
+ const implementerName = all.technicalPartner || all.implementer?.name || all.implementer?.title || value || '-';
44734
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
44735
+ title: implementerName,
44736
+ children: implementerName
44737
+ });
44738
+ }
44739
+ }, {
44740
+ title: t("Status"),
44741
+ dataIndex: "published",
44742
+ key: "published",
44743
+ ellipsis: false,
44744
+ show: true,
44745
+ render: (value, all) => {
44746
+ if (all.empty) {
44747
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
44748
+ className: "daf-default-cell"
44749
+ });
44750
+ }
44751
+ let statusDisplay = '-';
44752
+ let color = 'default';
44753
+ if (value !== undefined) {
44754
+ statusDisplay = value ? t('Published') : t('Unpublished');
44755
+ color = value ? 'green' : 'default';
44756
+ }
44757
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
44758
+ color: color,
44759
+ style: {
44760
+ width: 100
44761
+ },
44762
+ className: "text-center",
44763
+ children: t(statusDisplay)
44764
+ });
44765
+ }
44766
+ }, {
44767
+ title: t("Date"),
44768
+ dataIndex: "lastUpdated",
44769
+ key: "lastUpdated",
44770
+ ellipsis: true,
44771
+ active: true,
44772
+ pending: false,
44773
+ suspended: true,
44774
+ show: true,
44775
+ render: (val, all) => {
44776
+ if (all.empty) {
44777
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
44778
+ className: "daf-default-cell"
44779
+ });
44780
+ }
44781
+ const title = renderDateFormatted(all.updatedAt || all.date, "DD MMM YYYY");
44782
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
44783
+ title: title,
44784
+ children: title
44785
+ });
44786
+ }
44787
+ }, {
44788
+ title: "",
44789
+ dataIndex: "actions",
44790
+ key: "actions",
44791
+ width: 60,
44792
+ render: (_, val) => {
44793
+ if (val.empty) {
44794
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
44795
+ className: "daf-default-cell"
44796
+ });
44797
+ }
44798
+ const items = [{
44799
+ key: "viewSummary",
44800
+ label: t("Summary"),
44801
+ onClick: () => {
44802
+ const link = `/app/projects/${projectId}/restoration/summary/${val.datastakeId}`;
44803
+ navigate(getRedirectLink(link));
44804
+ }
44805
+ }, {
44806
+ key: "viewDetails",
44807
+ label: t("Details"),
44808
+ onClick: () => {
44809
+ const link = `/app/projects/${projectId}/restoration/view/general/${val.datastakeId}/identification`;
44810
+ navigate(getRedirectLink(link));
44811
+ }
44812
+ }];
44813
+ return /*#__PURE__*/jsxRuntime.jsx(MoreMenu, {
44814
+ items: items
44815
+ });
44816
+ },
44817
+ ellipsis: true
44818
+ }];
44819
+ }
44820
+ if (activeTab === PARTNERS_TAB$1) {
44821
+ return [{
44822
+ title: t('ID'),
44823
+ dataIndex: 'datastakeId',
44824
+ key: 'datastakeId',
44825
+ ellipsis: true,
44826
+ width: 160,
44827
+ render: (v, all) => {
44828
+ if (all.empty) {
44829
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
44830
+ className: "daf-default-cell"
44831
+ });
44832
+ }
44833
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
44834
+ title: v,
44835
+ children: v || '-'
44836
+ });
44837
+ }
44838
+ }, {
44839
+ title: t("Name"),
44840
+ dataIndex: "name",
44841
+ key: "name",
44842
+ ellipsis: true,
44843
+ render: (value, all) => {
44844
+ if (all.empty) {
44845
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
44846
+ className: "daf-default-cell"
44847
+ });
44848
+ }
44849
+ const name = value || all.nickName || '-';
44850
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
44851
+ title: name,
44852
+ children: name
44853
+ });
44854
+ }
44855
+ }, {
44856
+ title: t("Category"),
44857
+ dataIndex: "category",
44858
+ key: "category",
44859
+ ellipsis: true,
44860
+ render: (value, all) => {
44861
+ if (all.empty) {
44862
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
44863
+ className: "daf-default-cell"
44864
+ });
44865
+ }
44866
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
44867
+ title: value,
44868
+ children: value || '-'
44869
+ });
44870
+ }
44871
+ }, {
44872
+ title: t("Subcategory"),
44873
+ dataIndex: "subcategory",
44874
+ key: "subcategory",
44875
+ ellipsis: true,
44876
+ render: (value, all) => {
44877
+ if (all.empty) {
44878
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
44879
+ className: "daf-default-cell"
44880
+ });
44881
+ }
44882
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
44883
+ title: value,
44884
+ children: value || '-'
44885
+ });
44886
+ }
44887
+ }, {
44888
+ title: t("Country"),
44889
+ dataIndex: "country",
44890
+ key: "country",
44891
+ ellipsis: true,
44892
+ render: (value, all) => {
44893
+ if (all.empty) {
44894
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
44895
+ className: "daf-default-cell"
44896
+ });
44897
+ }
44898
+ const title = findOptions(value, selectOptions?.country || []) || '-';
44899
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
44900
+ title: title,
44901
+ children: title
44902
+ });
44903
+ }
44904
+ }, {
44905
+ title: t("Last Update"),
44906
+ dataIndex: "lastUpdated",
44907
+ key: "lastUpdated",
44908
+ ellipsis: true,
44909
+ render: (val, all) => {
44910
+ if (all.empty) {
44911
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
44912
+ className: "daf-default-cell"
44913
+ });
44914
+ }
44915
+ const title = renderDateFormatted(all.updatedAt || all.lastUpdated, "DD MMM YYYY");
44916
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
44917
+ title: title,
44918
+ children: title
44919
+ });
44920
+ }
44921
+ }, {
44922
+ title: t(''),
44923
+ dataIndex: 'actions',
44924
+ key: 'actions',
44925
+ width: 60,
44926
+ render: (_, record) => {
44927
+ const onClick = () => {
44928
+ record.id;
44929
+ const link = `/app/projects/${projectId}/implementation-partners/view/general/${record?.datastakeId}/identification`;
44930
+ navigate(getRedirectLink(link));
44931
+ };
44932
+ return !record.empty ? /*#__PURE__*/jsxRuntime.jsx("div", {
44933
+ className: "cursor-pointer",
44934
+ onClick: onClick,
44935
+ children: /*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
44936
+ name: "Link",
44937
+ width: 16,
44938
+ height: 16,
44939
+ color: "#6C737F"
44940
+ })
44941
+ }) : null;
44942
+ },
44943
+ active: true,
44944
+ pending: true,
44945
+ suspended: true
44946
+ }];
44947
+ }
44948
+ if (activeTab === INCIDENTS_TAB$1) {
44949
+ return [{
44950
+ title: t('ID'),
44951
+ dataIndex: 'datastakeId',
44952
+ key: 'datastakeId',
44953
+ ellipsis: true,
44954
+ width: 160,
44955
+ render: (v, all) => {
44956
+ if (all.empty) {
44957
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
44958
+ className: "daf-default-cell"
44959
+ });
44960
+ }
44961
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
44962
+ title: v,
44963
+ children: v
44964
+ });
44965
+ }
44966
+ }, {
44967
+ title: t("Title"),
44968
+ dataIndex: "name",
44969
+ key: "name",
44970
+ ellipsis: true,
44971
+ render: value => /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
44972
+ title: value,
44973
+ children: value
44974
+ })
44975
+ }, {
44976
+ title: t("Date"),
44977
+ dataIndex: "date",
44978
+ key: "date",
44979
+ ellipsis: true,
44980
+ render: (val, all) => {
44981
+ if (all.empty) {
44982
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
44983
+ className: "daf-default-cell"
44984
+ });
44985
+ }
44986
+ const title = renderDateFormatted(all.date || all.updatedAt, "DD MMM YYYY");
44987
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
44988
+ title: title,
44989
+ children: title
44990
+ });
44991
+ }
44992
+ }, {
44993
+ title: t("Location"),
44994
+ dataIndex: "location",
44995
+ key: "location",
44996
+ ellipsis: true,
44997
+ render: (value, all) => {
44998
+ if (all.empty) {
44999
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
45000
+ className: "daf-default-cell"
45001
+ });
45002
+ }
45003
+ let locationDisplay = '-';
45004
+ if (all.location?.name) {
45005
+ locationDisplay = all.location.name;
45006
+ } else if (all.mineSite?.name) {
45007
+ locationDisplay = all.mineSite.name;
45008
+ } else if (all.location && typeof all.location === 'object' && all.location.latitude && all.location.longitude) {
45009
+ locationDisplay = `${all.location.latitude.toFixed(6)}, ${all.location.longitude.toFixed(6)}`;
45010
+ } else if (value && typeof value === 'string') {
45011
+ locationDisplay = value;
45012
+ }
45013
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
45014
+ title: locationDisplay,
45015
+ children: locationDisplay
45016
+ });
45017
+ }
45018
+ }, {
45019
+ title: t("Province"),
45020
+ dataIndex: "province",
45021
+ key: "province",
45022
+ ellipsis: true,
45023
+ render: (value, all) => {
45024
+ if (all.empty) {
45025
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
45026
+ className: "daf-default-cell"
45027
+ });
45028
+ }
45029
+ let province = '-';
45030
+ if (all.province) {
45031
+ province = all.province;
45032
+ } else if (all.location && typeof all.location === 'object' && all.location.administrativeLevel1) {
45033
+ province = all.location.administrativeLevel1;
45034
+ }
45035
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
45036
+ title: province,
45037
+ children: province
45038
+ });
45039
+ }
45040
+ }, {
45041
+ title: t("Territory"),
45042
+ dataIndex: "territory",
45043
+ key: "territory",
45044
+ ellipsis: true,
45045
+ render: (value, all) => {
45046
+ if (all.empty) {
45047
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
45048
+ className: "daf-default-cell"
45049
+ });
45050
+ }
45051
+ let territory = '-';
45052
+ if (all.territory) {
45053
+ territory = all.territory;
45054
+ } else if (all.location && typeof all.location === 'object' && all.location.administrativeLevel2) {
45055
+ territory = all.location.administrativeLevel2;
45056
+ }
45057
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
45058
+ title: territory,
45059
+ children: territory
45060
+ });
45061
+ }
45062
+ }, {
45063
+ title: t("Category"),
45064
+ dataIndex: "category",
45065
+ key: "category",
45066
+ ellipsis: true,
45067
+ render: (value, all) => {
45068
+ if (all.empty) {
45069
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
45070
+ className: "daf-default-cell"
45071
+ });
45072
+ }
45073
+ const category = all.eventCategory || all.category || value || '-';
45074
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
45075
+ title: category,
45076
+ children: category
45077
+ });
45078
+ }
45079
+ }, {
45080
+ title: t(''),
45081
+ dataIndex: 'actions',
45082
+ key: 'actions',
45083
+ width: 60,
45084
+ render: (_, record) => {
45085
+ const onClick = () => {
45086
+ const link = `/app/projects/${projectId}/implementation-partners/view/general/${record.datastakeId}/identification`;
45087
+ getRedirectLink(link);
45088
+ };
45089
+ return !record.empty ? /*#__PURE__*/jsxRuntime.jsx("div", {
45090
+ className: "cursor-pointer",
45091
+ onClick: onClick,
45092
+ children: /*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
45093
+ name: "Link",
45094
+ width: 16,
45095
+ height: 16,
45096
+ color: "#6C737F"
45097
+ })
45098
+ }) : null;
45099
+ },
45100
+ active: true,
45101
+ pending: true,
45102
+ suspended: true
45103
+ }];
45104
+ }
45105
+ return [];
45106
+ };
45107
+
44241
45108
  const ACTIVITIES_TAB = 'activities';
44242
45109
  const PARTNERS_TAB = 'partners';
44243
45110
  const INCIDENTS_TAB = 'incidents';
45111
+ const DEFAULT_SEARCH_FIELDS = ["name", "datastakeId"];
45112
+ const URL_PATTERN = /\/summary\/[^/]+\/(.+)/;
45113
+
45114
+ // Configuration
45115
+ const TABS_CONFIG = [{
45116
+ label: "straatos::activities",
45117
+ value: ACTIVITIES_TAB
45118
+ }, {
45119
+ label: "straatos::partners",
45120
+ value: PARTNERS_TAB
45121
+ }, {
45122
+ label: "straatos::incidents",
45123
+ value: INCIDENTS_TAB,
45124
+ disabled: true
45125
+ }];
45126
+
45127
+ // Helper functions
45128
+ const getSearchFields = activeTab => DEFAULT_SEARCH_FIELDS;
45129
+ const buildSearchFilter = (search, fields) => search ? {
45130
+ search: {
45131
+ qs: search,
45132
+ fields
45133
+ }
45134
+ } : {};
45135
+ const extractTypeFromUrl = url => {
45136
+ const match = url.match(URL_PATTERN);
45137
+ if (!match) {
45138
+ throw new Error(`Invalid URL format: ${url}`);
45139
+ }
45140
+ return match[1];
45141
+ };
45142
+ const ensureArray = data => Array.isArray(data) ? data : [];
44244
45143
  const AssociatedInformation = ({
44245
- activityData,
45144
+ id,
45145
+ navigate,
45146
+ getSummaryDetail,
44246
45147
  loading = false,
45148
+ projectId,
45149
+ basepath = "planting-cycle",
45150
+ endpoint = "associated-information",
45151
+ tabsConfig = TABS_CONFIG,
45152
+ searchFieldsMap = getSearchFields,
45153
+ selectOptions,
44247
45154
  t = s => s
44248
45155
  }) => {
44249
45156
  const [activeTab, setActiveTab] = React.useState(ACTIVITIES_TAB);
45157
+ const [search, setSearch] = React.useState('');
45158
+ const searchFields = React.useMemo(() => searchFieldsMap(activeTab), [activeTab, searchFieldsMap]);
45159
+ const filters = React.useMemo(() => ({
45160
+ type: activeTab,
45161
+ ...buildSearchFilter(search, searchFields)
45162
+ }), [activeTab, search, searchFields]);
45163
+ const defaultConfig = React.useMemo(() => ({
45164
+ basepath,
45165
+ url: `/summary/${id}/${endpoint}`,
45166
+ filters,
45167
+ stop: !id
45168
+ }), [id, filters, basepath, endpoint]);
45169
+ const customGetData = React.useMemo(() => {
45170
+ if (!getSummaryDetail || !id) return undefined;
45171
+ return rest => {
45172
+ const {
45173
+ url,
45174
+ filters: restFilters
45175
+ } = rest;
45176
+ const type = extractTypeFromUrl(url);
45177
+ const params = {
45178
+ ...(restFilters || {}),
45179
+ type: restFilters?.type || activeTab
45180
+ };
45181
+ return getSummaryDetail(id, type, params);
45182
+ };
45183
+ }, [getSummaryDetail, id, activeTab]);
45184
+ const {
45185
+ loading: associatedInformationLoading,
45186
+ data: associatedInformationData,
45187
+ setData
45188
+ } = useWidgetFetch({
45189
+ config: defaultConfig,
45190
+ getData: customGetData
45191
+ });
45192
+
45193
+ // Reset data and search when tab changes
45194
+ React.useEffect(() => {
45195
+ setData([]);
45196
+ setSearch('');
45197
+ }, [activeTab, setData]);
45198
+ const handleSearch = React.useCallback((activeFilter, searchValue) => {
45199
+ setSearch(searchValue || '');
45200
+ }, []);
45201
+ const handleTabChange = React.useCallback(value => {
45202
+ setActiveTab(value);
45203
+ }, []);
45204
+ const columns = React.useMemo(() => getColumns({
45205
+ t,
45206
+ activeTab,
45207
+ view: activeTab,
45208
+ projectId,
45209
+ navigate,
45210
+ getRedirectLink,
45211
+ selectOptions
45212
+ }), [t, activeTab, projectId, navigate, selectOptions]);
45213
+ const tableDataSource = React.useMemo(() => ensureArray(associatedInformationData), [associatedInformationData]);
45214
+ const translatedTabs = React.useMemo(() => tabsConfig.map(tab => ({
45215
+ ...tab,
45216
+ label: t(tab.label)
45217
+ })), [tabsConfig, t]);
44250
45218
  return /*#__PURE__*/jsxRuntime.jsx("section", {
44251
- children: /*#__PURE__*/jsxRuntime.jsx(Widget, {
44252
- className: "v2-widget no-px h-w-btn-header no-p-body",
45219
+ children: /*#__PURE__*/jsxRuntime.jsxs(Widget, {
45220
+ className: "v2-widget no-px no-p-body h-w-btn-header with-border-header",
44253
45221
  title: t("Associated Information"),
44254
45222
  tabsConfig: {
44255
- tabs: [{
44256
- label: t("straatos::activities"),
44257
- value: ACTIVITIES_TAB
44258
- }, {
44259
- label: t("straatos::partners"),
44260
- value: PARTNERS_TAB
44261
- }, {
44262
- label: t("straatos::incidents"),
44263
- value: INCIDENTS_TAB
44264
- }],
45223
+ tabs: translatedTabs,
44265
45224
  value: activeTab,
44266
- onChange: value => {
44267
- setActiveTab(value);
44268
- // setData([]);
44269
- }
45225
+ onChange: handleTabChange
44270
45226
  },
44271
- children: /*#__PURE__*/jsxRuntime.jsx("div", {})
45227
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
45228
+ className: "mt-6 ml-6 mr-6",
45229
+ children: /*#__PURE__*/jsxRuntime.jsx(SearchFilters, {
45230
+ t: t,
45231
+ showFilter: false,
45232
+ hasError: false,
45233
+ canClear: true,
45234
+ setHasError: () => {},
45235
+ onSearch: handleSearch,
45236
+ activeFilters: {
45237
+ search
45238
+ }
45239
+ })
45240
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
45241
+ className: "mb-6",
45242
+ children: /*#__PURE__*/jsxRuntime.jsx(StickyTable, {
45243
+ columns: columns,
45244
+ dataSource: tableDataSource,
45245
+ loading: associatedInformationLoading || loading
45246
+ })
45247
+ })]
44272
45248
  })
44273
45249
  });
44274
45250
  };
@@ -44365,12 +45341,15 @@ const PlantingCycleSummary = ({
44365
45341
  activityData,
44366
45342
  loading = false,
44367
45343
  id,
45344
+ projectId,
44368
45345
  t = () => {},
44369
- getSummaryDetail
45346
+ getSummaryDetail,
45347
+ navigate,
45348
+ selectOptions
44370
45349
  }) => {
44371
45350
  return /*#__PURE__*/jsxRuntime.jsxs(DashboardLayout, {
44372
45351
  header: /*#__PURE__*/jsxRuntime.jsx(DAFHeader, {
44373
- title: header?.title || '',
45352
+ title: header?.title + ' Summary' || '',
44374
45353
  supportText: header?.supportText || '',
44375
45354
  onDownload: header?.onDownload,
44376
45355
  downloadDisabled: header?.downloadDisabled,
@@ -44406,9 +45385,12 @@ const PlantingCycleSummary = ({
44406
45385
  t: t
44407
45386
  }), /*#__PURE__*/jsxRuntime.jsx(AssociatedInformation, {
44408
45387
  id: id,
45388
+ projectId: projectId,
44409
45389
  getSummaryDetail: getSummaryDetail,
44410
45390
  loading: loading,
44411
- t: t
45391
+ t: t,
45392
+ navigate: navigate,
45393
+ selectOptions: selectOptions
44412
45394
  })]
44413
45395
  });
44414
45396
  };