@iapps/ng-dhis2-ui 1.2.119 → 1.2.121

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.
@@ -28,7 +28,7 @@ import { isObject, isString, debounce, sortBy, isArray, find, camelCase, flatten
28
28
  import cx from 'classnames';
29
29
  import { getNowInCalendar, generateFixedPeriods } from '@dhis2/multi-calendar-dates';
30
30
  import { Pager, DataOrderCriteria, DataQueryFilter, DataFilterCondition, ProgramRuleEngine } from '@iapps/d2-web-sdk';
31
- import { parseISO, isValid, format, parse as parse$1, addDays } from 'date-fns';
31
+ import { parseISO, isValid, format, addDays } from 'date-fns';
32
32
  import { map as map$1 } from 'rxjs/operators';
33
33
  import * as XLSX from 'xlsx';
34
34
  import * as i2 from '@angular/forms';
@@ -4104,6 +4104,7 @@ const getTrackedEntityTableData = (response, programId, pager, metaData, searche
4104
4104
  id: element.id,
4105
4105
  options: element.optionSet?.options.map((opt) => ({
4106
4106
  name: opt.name,
4107
+ code: opt.code,
4107
4108
  color: opt.style?.color,
4108
4109
  })),
4109
4110
  }));
@@ -4125,13 +4126,19 @@ const getTrackedEntityTableData = (response, programId, pager, metaData, searche
4125
4126
  type: 'attribute',
4126
4127
  }));
4127
4128
  const getOptionColor = (option) => option?.color || option?.style?.color;
4129
+ // const formatDate = (value: string): string => {
4130
+ // try {
4131
+ // return format(parse(value, 'yyyy-MM-dd', new Date()), 'dd/MM/yyyy');
4132
+ // } catch {
4133
+ // return value;
4134
+ // }
4135
+ // };
4128
4136
  const formatDate = (value) => {
4129
- try {
4130
- return format(parse$1(value, 'yyyy-MM-dd', new Date()), 'dd/MM/yyyy');
4131
- }
4132
- catch {
4133
- return value;
4137
+ const date = new Date(value);
4138
+ if (isValid(date)) {
4139
+ return format(date, 'dd/MM/yyyy');
4134
4140
  }
4141
+ return value;
4135
4142
  };
4136
4143
  const trackedEntityAttributeMap = new Map();
4137
4144
  (metaData.programTrackedEntityAttributes || []).forEach(({ trackedEntityAttribute }) => {
@@ -4192,9 +4199,9 @@ const getTrackedEntityTableData = (response, programId, pager, metaData, searche
4192
4199
  if (!dataElementId || value == null)
4193
4200
  return;
4194
4201
  const dataElementOption = dataElementOptionMap.get(dataElementId);
4195
- const matchedOption = dataElementOption?.options?.find((opt) => opt.name === value);
4202
+ const matchedOption = dataElementOption?.options?.find((opt) => opt.code === value);
4196
4203
  row[dataElementId] = {
4197
- value,
4204
+ value: matchedOption?.name || value,
4198
4205
  ...(getOptionColor(matchedOption) && {
4199
4206
  style: getOptionColor(matchedOption),
4200
4207
  }),