@undp/carbon-library 1.0.140 → 1.0.142
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.
- package/dist/cjs/index.js +100 -28
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +100 -28
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
@@ -24498,7 +24498,7 @@ var css_248z$4 = ".steps-actions {\n display: flex;\n flex-direction: row-reve
|
|
24498
24498
|
styleInject(css_248z$4);
|
24499
24499
|
|
24500
24500
|
var NdcDetailsComponent = function (props) {
|
24501
|
-
var t = props.t; props.useConnection;
|
24501
|
+
var t = props.t; props.useConnection; var useUserContext = props.useUserContext;
|
24502
24502
|
var RangePicker = DatePicker.RangePicker;
|
24503
24503
|
var _a = useState([]), ndcDetailsData = _a[0], setNdcDetailsData = _a[1];
|
24504
24504
|
var _b = useState(false), loading = _b[0]; _b[1];
|
@@ -24506,6 +24506,20 @@ var NdcDetailsComponent = function (props) {
|
|
24506
24506
|
var _c = useState([]), periodItems = _c[0], setPeriodItems = _c[1];
|
24507
24507
|
var _d = useState("add_new"), selectedTab = _d[0], setSelectedTab = _d[1];
|
24508
24508
|
var selectedPeriod = useRef({});
|
24509
|
+
var addedNdcDetailId = useRef(0);
|
24510
|
+
var userInfoState = useUserContext().userInfoState;
|
24511
|
+
var isAddRangeVisible = function () {
|
24512
|
+
return (((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.MINISTRY ||
|
24513
|
+
(userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.GOVERNMENT) &&
|
24514
|
+
(userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== Role.ViewOnly);
|
24515
|
+
};
|
24516
|
+
var isAddNdcActionVisible = function () {
|
24517
|
+
return ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.GOVERNMENT &&
|
24518
|
+
(userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== Role.ViewOnly);
|
24519
|
+
};
|
24520
|
+
var inRange = function (num, min, max) {
|
24521
|
+
return num >= min && num <= max;
|
24522
|
+
};
|
24509
24523
|
var handleSave = function (row) {
|
24510
24524
|
var newData = __spreadArray([], ndcDetailsData, true);
|
24511
24525
|
var index = newData.findIndex(function (item) { return row.key === item.key; });
|
@@ -24513,6 +24527,18 @@ var NdcDetailsComponent = function (props) {
|
|
24513
24527
|
newData.splice(index, 1, __assign(__assign({}, item), row));
|
24514
24528
|
setNdcDetailsData(newData);
|
24515
24529
|
};
|
24530
|
+
var getNdcDetailsForPeriod = function () {
|
24531
|
+
var range = selectedTab.split("-");
|
24532
|
+
if (range.length > 1) {
|
24533
|
+
var filteredData = ndcDetailsData.filter(function (item) {
|
24534
|
+
return inRange(Number(moment(item.startDate).year()), Number(range[0]), Number(range[1]));
|
24535
|
+
});
|
24536
|
+
return filteredData;
|
24537
|
+
}
|
24538
|
+
else {
|
24539
|
+
return [];
|
24540
|
+
}
|
24541
|
+
};
|
24516
24542
|
var defaultColumns = [
|
24517
24543
|
{
|
24518
24544
|
title: t("ndc:ndcColumnsNationalPlanObj"),
|
@@ -24542,11 +24568,14 @@ var NdcDetailsComponent = function (props) {
|
|
24542
24568
|
}); } });
|
24543
24569
|
});
|
24544
24570
|
function onAddNewNdcDetail() {
|
24571
|
+
var range = selectedTab.split("-");
|
24572
|
+
addedNdcDetailId.current = addedNdcDetailId.current + 1;
|
24545
24573
|
var newData = {
|
24546
|
-
|
24547
|
-
|
24548
|
-
|
24549
|
-
|
24574
|
+
key: addedNdcDetailId.current,
|
24575
|
+
startDate: new Date("".concat(Number(range[0]), "-01-24 23:12:00")),
|
24576
|
+
endDate: new Date("".concat(Number(range[0]), "-12-24 23:12:00")),
|
24577
|
+
nationalPlanObj: t("ndc:enterNewPlanTxt"),
|
24578
|
+
kpi: 0,
|
24550
24579
|
};
|
24551
24580
|
setNdcDetailsData(__spreadArray(__spreadArray([], ndcDetailsData, true), [newData], false));
|
24552
24581
|
}
|
@@ -24589,7 +24618,10 @@ var NdcDetailsComponent = function (props) {
|
|
24589
24618
|
end: selectedPeriod.current.end,
|
24590
24619
|
children: ndcDetailsTableContent(),
|
24591
24620
|
};
|
24592
|
-
var existingIndex = periodItemsRef.current.findIndex(function (item) {
|
24621
|
+
var existingIndex = periodItemsRef.current.findIndex(function (item) {
|
24622
|
+
return inRange(newPeriodItem_1.start, item.start, item.end) ||
|
24623
|
+
inRange(newPeriodItem_1.end, item.start, item.end);
|
24624
|
+
});
|
24593
24625
|
if (existingIndex === -1) {
|
24594
24626
|
setPeriodItems(function (items) { return __spreadArray(__spreadArray([], items, true), [newPeriodItem_1], false); });
|
24595
24627
|
periodItemsRef.current = __spreadArray(__spreadArray([], periodItemsRef.current, true), [newPeriodItem_1], false);
|
@@ -24631,31 +24663,69 @@ var NdcDetailsComponent = function (props) {
|
|
24631
24663
|
useEffect(function () {
|
24632
24664
|
var defaultNdcDetails = [
|
24633
24665
|
{
|
24666
|
+
key: 1,
|
24667
|
+
startDate: new Date("2019-03-25"),
|
24668
|
+
endDate: new Date("2020-03-25"),
|
24669
|
+
nationalPlanObj: "Enhance value addition in key growth opportunities",
|
24670
|
+
kpi: 25,
|
24671
|
+
},
|
24672
|
+
{
|
24673
|
+
key: 2,
|
24674
|
+
startDate: new Date("2019-03-25"),
|
24675
|
+
endDate: new Date("2019-08-25"),
|
24676
|
+
nationalPlanObj: "Strengthen the private sector to create 10,000 jobs",
|
24677
|
+
kpi: 10500,
|
24678
|
+
},
|
24679
|
+
{
|
24680
|
+
key: 3,
|
24681
|
+
startDate: new Date("2021-03-25"),
|
24682
|
+
endDate: new Date("2022-03-25"),
|
24683
|
+
nationalPlanObj: "Consolidate and increase the stock and quality of productive infrastructure by 50%",
|
24684
|
+
kpi: 48,
|
24685
|
+
},
|
24686
|
+
{
|
24687
|
+
key: 4,
|
24688
|
+
startDate: new Date("2022-03-25"),
|
24689
|
+
endDate: new Date("2022-05-25"),
|
24690
|
+
nationalPlanObj: "Enhance the productivity and social wellbeing of the population",
|
24691
|
+
kpi: 20,
|
24692
|
+
},
|
24693
|
+
{
|
24694
|
+
key: 5,
|
24634
24695
|
startDate: new Date("2022-03-25"),
|
24635
24696
|
endDate: new Date("2023-03-25"),
|
24636
|
-
nationalPlanObj: "
|
24637
|
-
kpi:
|
24697
|
+
nationalPlanObj: "Strengthen the role of the state in guiding and facilitating development",
|
24698
|
+
kpi: 10,
|
24638
24699
|
},
|
24700
|
+
];
|
24701
|
+
var initialPeriods = [
|
24639
24702
|
{
|
24640
|
-
|
24641
|
-
|
24642
|
-
|
24643
|
-
|
24703
|
+
key: "2019-2020",
|
24704
|
+
label: "2019-2020",
|
24705
|
+
start: 2019,
|
24706
|
+
end: 2020,
|
24707
|
+
children: ndcDetailsTableContent(),
|
24644
24708
|
},
|
24645
24709
|
{
|
24646
|
-
|
24647
|
-
|
24648
|
-
|
24649
|
-
|
24710
|
+
key: "2021-2023",
|
24711
|
+
label: "2021-2023",
|
24712
|
+
start: 2021,
|
24713
|
+
end: 2021,
|
24714
|
+
children: ndcDetailsTableContent(),
|
24650
24715
|
},
|
24651
24716
|
];
|
24652
|
-
|
24653
|
-
|
24654
|
-
|
24655
|
-
|
24656
|
-
|
24657
|
-
|
24658
|
-
|
24717
|
+
if (isAddRangeVisible()) {
|
24718
|
+
initialPeriods.unshift({
|
24719
|
+
key: "add_new",
|
24720
|
+
label: "Add New",
|
24721
|
+
start: 0,
|
24722
|
+
end: 0,
|
24723
|
+
children: addNewPeriodContent(),
|
24724
|
+
});
|
24725
|
+
}
|
24726
|
+
addedNdcDetailId.current = 5;
|
24727
|
+
setPeriodItems(initialPeriods);
|
24728
|
+
periodItemsRef.current = initialPeriods;
|
24659
24729
|
setNdcDetailsData(defaultNdcDetails);
|
24660
24730
|
}, []);
|
24661
24731
|
return (React.createElement("div", { className: "ndc-management content-container" },
|
@@ -24668,11 +24738,13 @@ var NdcDetailsComponent = function (props) {
|
|
24668
24738
|
React.createElement(Tabs, { centered: false, defaultActiveKey: "1", items: periodItems, activeKey: selectedTab, onChange: onTabChange })),
|
24669
24739
|
selectedTab !== "add_new" && (React.createElement("div", null,
|
24670
24740
|
React.createElement("div", null,
|
24671
|
-
React.createElement(Table, { components: components, rowClassName: function () { return "editable-row"; }, bordered: true, dataSource:
|
24672
|
-
React.createElement(
|
24673
|
-
|
24674
|
-
|
24675
|
-
|
24741
|
+
React.createElement(Table, { components: components, rowClassName: function () { return "editable-row"; }, bordered: true, dataSource: getNdcDetailsForPeriod(), columns: columns, footer: function () {
|
24742
|
+
return isAddNdcActionVisible() && (React.createElement(Row, { justify: "center" },
|
24743
|
+
React.createElement(Button, { onClick: onAddNewNdcDetail, type: "default", style: {
|
24744
|
+
marginBottom: 16,
|
24745
|
+
width: "100%",
|
24746
|
+
} }, t("ndc:addNdcAction"))));
|
24747
|
+
} }))))));
|
24676
24748
|
};
|
24677
24749
|
|
24678
24750
|
var ImgWithFallback = function (_a) {
|