@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/esm/index.js CHANGED
@@ -23608,7 +23608,7 @@ var css_248z$4 = ".steps-actions {\n display: flex;\n flex-direction: row-reve
23608
23608
  styleInject(css_248z$4);
23609
23609
 
23610
23610
  var NdcDetailsComponent = function (props) {
23611
- var t = props.t; props.useConnection;
23611
+ var t = props.t; props.useConnection; var useUserContext = props.useUserContext;
23612
23612
  var RangePicker = DatePicker.RangePicker;
23613
23613
  var _a = useState([]), ndcDetailsData = _a[0], setNdcDetailsData = _a[1];
23614
23614
  var _b = useState(false), loading = _b[0]; _b[1];
@@ -23616,6 +23616,16 @@ var NdcDetailsComponent = function (props) {
23616
23616
  var _c = useState([]), periodItems = _c[0], setPeriodItems = _c[1];
23617
23617
  var _d = useState("add_new"), selectedTab = _d[0], setSelectedTab = _d[1];
23618
23618
  var selectedPeriod = useRef({});
23619
+ var userInfoState = useUserContext().userInfoState;
23620
+ var isAddRangeVisible = function () {
23621
+ return (((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.MINISTRY ||
23622
+ (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.GOVERNMENT) &&
23623
+ (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== Role.ViewOnly);
23624
+ };
23625
+ var isAddNdcActionVisible = function () {
23626
+ return ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.GOVERNMENT &&
23627
+ (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== Role.ViewOnly);
23628
+ };
23619
23629
  var inRange = function (num, min, max) {
23620
23630
  return num >= min && num <= max;
23621
23631
  };
@@ -23667,11 +23677,12 @@ var NdcDetailsComponent = function (props) {
23667
23677
  }); } });
23668
23678
  });
23669
23679
  function onAddNewNdcDetail() {
23680
+ var range = selectedTab.split("-");
23670
23681
  var newData = {
23671
- startDate: new Date("2014-12-24 23:12:00"),
23672
- endDate: new Date("2014-12-24 23:12:00"),
23673
- nationalPlanObj: "sample text2",
23674
- kpi: 34,
23682
+ startDate: new Date("".concat(Number(range[0]), "-01-24 23:12:00")),
23683
+ endDate: new Date("".concat(Number(range[0]), "-12-24 23:12:00")),
23684
+ nationalPlanObj: t("ndc:enterNewPlanTxt"),
23685
+ kpi: 0,
23675
23686
  };
23676
23687
  setNdcDetailsData(__spreadArray(__spreadArray([], ndcDetailsData, true), [newData], false));
23677
23688
  }
@@ -23765,8 +23776,8 @@ var NdcDetailsComponent = function (props) {
23765
23776
  kpi: 25,
23766
23777
  },
23767
23778
  {
23768
- startDate: new Date("2018-03-25"),
23769
- endDate: new Date("2019-03-25"),
23779
+ startDate: new Date("2019-03-25"),
23780
+ endDate: new Date("2019-08-25"),
23770
23781
  nationalPlanObj: "Strengthen the private sector to create 10,000 jobs",
23771
23782
  kpi: 10500,
23772
23783
  },
@@ -23790,11 +23801,6 @@ var NdcDetailsComponent = function (props) {
23790
23801
  },
23791
23802
  ];
23792
23803
  var initialPeriods = [
23793
- {
23794
- key: "add_new",
23795
- label: "Add New",
23796
- children: addNewPeriodContent(),
23797
- },
23798
23804
  {
23799
23805
  key: "2019-2020",
23800
23806
  label: "2019-2020",
@@ -23803,18 +23809,22 @@ var NdcDetailsComponent = function (props) {
23803
23809
  children: ndcDetailsTableContent(),
23804
23810
  },
23805
23811
  {
23806
- key: "2020-2023",
23807
- label: "2020-2023",
23808
- start: 2020,
23809
- end: 2023,
23812
+ key: "2021-2023",
23813
+ label: "2021-2023",
23814
+ start: 2021,
23815
+ end: 2021,
23810
23816
  children: ndcDetailsTableContent(),
23811
23817
  },
23812
23818
  ];
23813
- ({
23814
- key: "add_new",
23815
- label: "Add New",
23816
- children: addNewPeriodContent(),
23817
- });
23819
+ if (isAddRangeVisible()) {
23820
+ initialPeriods.unshift({
23821
+ key: "add_new",
23822
+ label: "Add New",
23823
+ start: 0,
23824
+ end: 0,
23825
+ children: addNewPeriodContent(),
23826
+ });
23827
+ }
23818
23828
  setPeriodItems(initialPeriods);
23819
23829
  periodItemsRef.current = initialPeriods;
23820
23830
  setNdcDetailsData(defaultNdcDetails);
@@ -23829,11 +23839,13 @@ var NdcDetailsComponent = function (props) {
23829
23839
  React.createElement(Tabs, { centered: false, defaultActiveKey: "1", items: periodItems, activeKey: selectedTab, onChange: onTabChange })),
23830
23840
  selectedTab !== "add_new" && (React.createElement("div", null,
23831
23841
  React.createElement("div", null,
23832
- React.createElement(Table, { components: components, rowClassName: function () { return "editable-row"; }, bordered: true, dataSource: getNdcDetailsForPeriod(), columns: columns, footer: function () { return (React.createElement(Row, { justify: "center" },
23833
- React.createElement(Button, { onClick: onAddNewNdcDetail, type: "default", style: {
23834
- marginBottom: 16,
23835
- width: "100%",
23836
- } }, t("ndc:addNdcAction")))); } }))))));
23842
+ React.createElement(Table, { components: components, rowClassName: function () { return "editable-row"; }, bordered: true, dataSource: getNdcDetailsForPeriod(), columns: columns, footer: function () {
23843
+ return isAddNdcActionVisible() && (React.createElement(Row, { justify: "center" },
23844
+ React.createElement(Button, { onClick: onAddNewNdcDetail, type: "default", style: {
23845
+ marginBottom: 16,
23846
+ width: "100%",
23847
+ } }, t("ndc:addNdcAction"))));
23848
+ } }))))));
23837
23849
  };
23838
23850
 
23839
23851
  var ImgWithFallback = function (_a) {