@hisptz/react-ui
Version:
A collection of reusable complex DHIS2 react ui components.
42 lines (40 loc) • 2.63 kB
JavaScript
import React from "react";
import i18n from "@dhis2/d2-i18n";
import { DataTable, DataTableColumnHeader, DataTableRow, TableBody, TableHead } from "@dhis2/ui";
import DictionaryContext from "../../../../../components/DictionaryAnalysis/Store/DictionaryContext";
import PropTypes from "prop-types";
import { useContext } from "react";
import Row from "./row";
export default function DataElementSIndicator(_ref) {
let {
resourceType
} = _ref;
;
const {
values
} = useContext(DictionaryContext);
const dataElements = values === null || values === void 0 ? void 0 : values.dataElements;
if ((dataElements === null || dataElements === void 0 ? void 0 : dataElements.length) === 0) {
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h3", null, " ", i18n.t("Data elements in {{variables}}", {
variables: resourceType
}), " "), /*#__PURE__*/React.createElement("p", null, i18n.t("There were no Data Elements in the {{variables}} Calculations", {
resourceType
}), " "));
}
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h3", null, " ", i18n.t("Data elements in {{variables}}", {
variables: resourceType
}), " "), /*#__PURE__*/React.createElement("p", null, " ", i18n.t("The following is the summary of the data elements used in calculations:"), " "), /*#__PURE__*/React.createElement(DataTable, null, /*#__PURE__*/React.createElement(TableHead, null, /*#__PURE__*/React.createElement(DataTableRow, null, /*#__PURE__*/React.createElement(DataTableColumnHeader, {
bordered: true
}, i18n.t("Data Element")), /*#__PURE__*/React.createElement(DataTableColumnHeader, {
bordered: true
}, i18n.t("Expression part (Numerator/ Denominator)")), /*#__PURE__*/React.createElement(DataTableColumnHeader, null, i18n.t("Value Type")), /*#__PURE__*/React.createElement(DataTableColumnHeader, null, i18n.t("Zero Significance")), /*#__PURE__*/React.createElement(DataTableColumnHeader, null, i18n.t("Categories")), /*#__PURE__*/React.createElement(DataTableColumnHeader, null, i18n.t("Datasets/ Programs")), /*#__PURE__*/React.createElement(DataTableColumnHeader, null, i18n.t("Groups")))), /*#__PURE__*/React.createElement(TableBody, null, dataElements === null || dataElements === void 0 ? void 0 : dataElements.map((dtEle, index) => {
return /*#__PURE__*/React.createElement(Row, {
key: index,
datEl: dtEle,
location: dtEle === null || dtEle === void 0 ? void 0 : dtEle.location
});
}))));
}
DataElementSIndicator.PropTypes = {
resourceType: PropTypes.string.isRequired
};