@undp/carbon-library 1.0.135-CARBON-343.12 → 1.0.135-CARBON-343.14

Sign up to get free protection for your applications and to get access to all the features.
package/dist/cjs/index.js CHANGED
@@ -23628,7 +23628,7 @@ var css_248z$4 = ".steps-actions {\n display: flex;\n flex-direction: row-reve
23628
23628
  styleInject(css_248z$4);
23629
23629
 
23630
23630
  var NdcDetailsComponent = function (props) {
23631
- var t = props.t; props.useConnection;
23631
+ var t = props.t; props.useConnection; var useUserContext = props.useUserContext;
23632
23632
  var RangePicker = antd.DatePicker.RangePicker;
23633
23633
  var _a = React.useState([]), ndcDetailsData = _a[0], setNdcDetailsData = _a[1];
23634
23634
  var _b = React.useState(false), loading = _b[0]; _b[1];
@@ -23636,6 +23636,16 @@ var NdcDetailsComponent = function (props) {
23636
23636
  var _c = React.useState([]), periodItems = _c[0], setPeriodItems = _c[1];
23637
23637
  var _d = React.useState("add_new"), selectedTab = _d[0], setSelectedTab = _d[1];
23638
23638
  var selectedPeriod = React.useRef({});
23639
+ var userInfoState = useUserContext().userInfoState;
23640
+ var isAddRangeVisible = function () {
23641
+ return (((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.MINISTRY ||
23642
+ (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.GOVERNMENT) &&
23643
+ (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== exports.Role.ViewOnly);
23644
+ };
23645
+ var isAddNdcActionVisible = function () {
23646
+ return ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.GOVERNMENT &&
23647
+ (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== exports.Role.ViewOnly);
23648
+ };
23639
23649
  var inRange = function (num, min, max) {
23640
23650
  return num >= min && num <= max;
23641
23651
  };
@@ -23687,11 +23697,12 @@ var NdcDetailsComponent = function (props) {
23687
23697
  }); } });
23688
23698
  });
23689
23699
  function onAddNewNdcDetail() {
23700
+ var range = selectedTab.split("-");
23690
23701
  var newData = {
23691
- startDate: new Date("2014-12-24 23:12:00"),
23692
- endDate: new Date("2014-12-24 23:12:00"),
23693
- nationalPlanObj: "sample text2",
23694
- kpi: 34,
23702
+ startDate: new Date("".concat(Number(range[0]), "-01-24 23:12:00")),
23703
+ endDate: new Date("".concat(Number(range[0]), "-12-24 23:12:00")),
23704
+ nationalPlanObj: t("ndc:enterNewPlanTxt"),
23705
+ kpi: 0,
23695
23706
  };
23696
23707
  setNdcDetailsData(__spreadArray(__spreadArray([], ndcDetailsData, true), [newData], false));
23697
23708
  }
@@ -23785,8 +23796,8 @@ var NdcDetailsComponent = function (props) {
23785
23796
  kpi: 25,
23786
23797
  },
23787
23798
  {
23788
- startDate: new Date("2018-03-25"),
23789
- endDate: new Date("2019-03-25"),
23799
+ startDate: new Date("2019-03-25"),
23800
+ endDate: new Date("2019-08-25"),
23790
23801
  nationalPlanObj: "Strengthen the private sector to create 10,000 jobs",
23791
23802
  kpi: 10500,
23792
23803
  },
@@ -23810,11 +23821,6 @@ var NdcDetailsComponent = function (props) {
23810
23821
  },
23811
23822
  ];
23812
23823
  var initialPeriods = [
23813
- {
23814
- key: "add_new",
23815
- label: "Add New",
23816
- children: addNewPeriodContent(),
23817
- },
23818
23824
  {
23819
23825
  key: "2019-2020",
23820
23826
  label: "2019-2020",
@@ -23823,18 +23829,22 @@ var NdcDetailsComponent = function (props) {
23823
23829
  children: ndcDetailsTableContent(),
23824
23830
  },
23825
23831
  {
23826
- key: "2020-2023",
23827
- label: "2020-2023",
23828
- start: 2020,
23829
- end: 2023,
23832
+ key: "2021-2023",
23833
+ label: "2021-2023",
23834
+ start: 2021,
23835
+ end: 2021,
23830
23836
  children: ndcDetailsTableContent(),
23831
23837
  },
23832
23838
  ];
23833
- ({
23834
- key: "add_new",
23835
- label: "Add New",
23836
- children: addNewPeriodContent(),
23837
- });
23839
+ if (isAddRangeVisible()) {
23840
+ initialPeriods.unshift({
23841
+ key: "add_new",
23842
+ label: "Add New",
23843
+ start: 0,
23844
+ end: 0,
23845
+ children: addNewPeriodContent(),
23846
+ });
23847
+ }
23838
23848
  setPeriodItems(initialPeriods);
23839
23849
  periodItemsRef.current = initialPeriods;
23840
23850
  setNdcDetailsData(defaultNdcDetails);
@@ -23849,11 +23859,13 @@ var NdcDetailsComponent = function (props) {
23849
23859
  React.createElement(antd.Tabs, { centered: false, defaultActiveKey: "1", items: periodItems, activeKey: selectedTab, onChange: onTabChange })),
23850
23860
  selectedTab !== "add_new" && (React.createElement("div", null,
23851
23861
  React.createElement("div", null,
23852
- React.createElement(antd.Table, { components: components, rowClassName: function () { return "editable-row"; }, bordered: true, dataSource: getNdcDetailsForPeriod(), columns: columns, footer: function () { return (React.createElement(antd.Row, { justify: "center" },
23853
- React.createElement(antd.Button, { onClick: onAddNewNdcDetail, type: "default", style: {
23854
- marginBottom: 16,
23855
- width: "100%",
23856
- } }, t("ndc:addNdcAction")))); } }))))));
23862
+ React.createElement(antd.Table, { components: components, rowClassName: function () { return "editable-row"; }, bordered: true, dataSource: getNdcDetailsForPeriod(), columns: columns, footer: function () {
23863
+ return isAddNdcActionVisible() && (React.createElement(antd.Row, { justify: "center" },
23864
+ React.createElement(antd.Button, { onClick: onAddNewNdcDetail, type: "default", style: {
23865
+ marginBottom: 16,
23866
+ width: "100%",
23867
+ } }, t("ndc:addNdcAction"))));
23868
+ } }))))));
23857
23869
  };
23858
23870
 
23859
23871
  var ImgWithFallback = function (_a) {