@undp/carbon-library 1.0.175-CARBON-347.2 → 1.0.175-CARBON-363.57

Sign up to get free protection for your applications and to get access to all the features.
package/dist/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { PlusOutlined, FilterOutlined, BankOutlined, SafetyOutlined, AuditOutlined, ExperimentOutlined, UploadOutlined, UserOutlined, MinusCircleOutlined, StarOutlined, ToolOutlined, EyeOutlined, SearchOutlined, EllipsisOutlined, EditOutlined, DeleteOutlined, FileAddOutlined, CheckCircleOutlined, ExclamationCircleOutlined, BookOutlined, CaretDownOutlined, EyeInvisibleOutlined, GlobalOutlined, FlagOutlined, LineChartOutlined, LikeOutlined, DislikeOutlined } from '@ant-design/icons';
1
+ import { PlusOutlined, FilterOutlined, BankOutlined, SafetyOutlined, AuditOutlined, ExperimentOutlined, UploadOutlined, UserOutlined, MinusCircleOutlined, StarOutlined, ToolOutlined, EyeOutlined, SearchOutlined, EllipsisOutlined, EditOutlined, DeleteOutlined, FileAddOutlined, CheckCircleOutlined, ExclamationCircleOutlined, BookOutlined, CaretDownOutlined, LockOutlined, EyeInvisibleOutlined, GlobalOutlined, FlagOutlined, LineChartOutlined, LikeOutlined, DislikeOutlined } from '@ant-design/icons';
2
2
  import { Input, Radio, Space, Row, Col, Button, Dropdown, Table, Empty, message, Form, Steps, Upload, InputNumber, Tooltip, Select, Modal, Alert, Skeleton, Card, Tag, Checkbox, DatePicker, Popover, List, Typography, Spin, Tabs, Progress } from 'antd';
3
- import React, { useState, useEffect, useRef, useContext } from 'react';
3
+ import React, { useState, useEffect, useRef } from 'react';
4
4
  import { DateTime } from 'luxon';
5
5
  import { Buffer } from 'buffer';
6
6
  import PhoneInput, { formatPhoneNumberIntl, formatPhoneNumber } from 'react-phone-number-input';
@@ -2027,7 +2027,7 @@ var NdcActionStatus;
2027
2027
  NdcActionStatus["PENDING"] = "Pending";
2028
2028
  NdcActionStatus["APPROVED"] = "Approved";
2029
2029
  })(NdcActionStatus || (NdcActionStatus = {}));
2030
- var getNdcActionStatusEnumVal = function (value) {
2030
+ var getNdcActionStatusEnumVal$1 = function (value) {
2031
2031
  var index = Object.keys(NdcActionStatus).indexOf(value);
2032
2032
  if (index < 0) {
2033
2033
  return value;
@@ -2035,7 +2035,7 @@ var getNdcActionStatusEnumVal = function (value) {
2035
2035
  return Object.values(NdcActionStatus)[index];
2036
2036
  };
2037
2037
  var getNdcStatusTagType = function (status) {
2038
- switch (getNdcActionStatusEnumVal(status)) {
2038
+ switch (getNdcActionStatusEnumVal$1(status)) {
2039
2039
  case NdcActionStatus.PENDING:
2040
2040
  return "processing";
2041
2041
  case NdcActionStatus.APPROVED:
@@ -26123,620 +26123,659 @@ var RegistryDashboardComponent = function (props) {
26123
26123
  lastUpdateTransferLocations))))))))) : ("")));
26124
26124
  };
26125
26125
 
26126
- var EditableContext = React.createContext(null);
26127
- var EditableRow = function (_a) {
26128
- _a.index; var props = __rest(_a, ["index"]);
26129
- var form = Form.useForm()[0];
26130
- return (React.createElement(Form, { form: form, component: false },
26131
- React.createElement(EditableContext.Provider, { value: form },
26132
- React.createElement("tr", __assign({}, props)))));
26133
- };
26126
+ React.createContext(null);
26134
26127
  var EditableCell = function (_a) {
26135
- var title = _a.title, editable = _a.editable, children = _a.children, dataIndex = _a.dataIndex, record = _a.record, handleSave = _a.handleSave, restProps = __rest(_a, ["title", "editable", "children", "dataIndex", "record", "handleSave"]);
26136
- var _b = useState(false), editing = _b[0], setEditing = _b[1];
26137
- var inputRef = useRef(null);
26138
- var form = useContext(EditableContext);
26139
- useEffect(function () {
26140
- if (editing) {
26141
- inputRef.current.focus();
26142
- }
26143
- }, [editing]);
26144
- var toggleEdit = function () {
26145
- var _a;
26146
- setEditing(!editing);
26147
- form.setFieldsValue((_a = {}, _a[dataIndex] = record[dataIndex], _a));
26148
- };
26149
- var save = function () { return __awaiter(void 0, void 0, void 0, function () {
26150
- var values, errInfo_1;
26151
- return __generator(this, function (_a) {
26152
- switch (_a.label) {
26153
- case 0:
26154
- _a.trys.push([0, 2, , 3]);
26155
- return [4 /*yield*/, form.validateFields()];
26156
- case 1:
26157
- values = _a.sent();
26158
- toggleEdit();
26159
- handleSave(__assign(__assign({}, record), values));
26160
- return [3 /*break*/, 3];
26161
- case 2:
26162
- errInfo_1 = _a.sent();
26163
- console.log("Save failed:", errInfo_1);
26164
- return [3 /*break*/, 3];
26165
- case 3: return [2 /*return*/];
26166
- }
26167
- });
26168
- }); };
26169
- var childNode = children;
26170
- if (editable) {
26171
- childNode = editing ? (React.createElement(Form.Item, { style: { margin: 0 }, name: dataIndex, rules: [
26172
- {
26173
- required: true,
26174
- message: "".concat(title, " is required."),
26175
- },
26176
- ] },
26177
- React.createElement(Input, { ref: inputRef, onPressEnter: save, onBlur: save }))) : (React.createElement("div", { className: "editable-cell-value-wrap", style: { paddingRight: 24, minWidth: "100px", minHeight: "20px" }, onClick: toggleEdit }, children));
26128
+ var editing = _a.editing, dataIndex = _a.dataIndex, title = _a.title; _a.inputType; var record = _a.record; _a.index; var children = _a.children, onBlurHandler = _a.onBlurHandler, restProps = __rest(_a, ["editing", "dataIndex", "title", "inputType", "record", "index", "children", "onBlurHandler"]);
26129
+ var inputNode;
26130
+ if (dataIndex === "nationalPlanObjective") {
26131
+ inputNode = (React.createElement(Input, { onBlur: function () { return onBlurHandler(record); }, placeholder: "Enter National Plan Objective" }));
26132
+ }
26133
+ else if (dataIndex === "kpi") {
26134
+ inputNode = (React.createElement(InputNumber, { onBlur: function () { return onBlurHandler(record); }, placeholder: "Enter Kpi" }));
26178
26135
  }
26179
- return React.createElement("td", __assign({}, restProps), childNode);
26136
+ return (React.createElement("td", __assign({}, restProps), editing ? (React.createElement(Form.Item, { name: dataIndex, style: { margin: 0 }, rules: [
26137
+ {
26138
+ required: true,
26139
+ message: "Please Input ".concat(title, "!"),
26140
+ },
26141
+ ] }, inputNode)) : (children)));
26180
26142
  };
26181
26143
 
26182
- var css_248z$4 = ".ndc-steps-actions {\n display: flex;\n flex-direction: row-reverse;\n margin-right: 1rem;\n justify-content: center; }\n .ndc-steps-actions .action-btn {\n border: 1px solid #16b1ff;\n color: #16b1ff;\n margin-right: 1rem; }\n .ndc-steps-actions .back-btn {\n border: 1px solid rgba(140, 140, 140, 0.7);\n color: rgba(140, 140, 140, 0.7);\n margin-right: 1rem; }\n .ndc-steps-actions .mg-left-1 {\n margin-left: 1rem; }\n";
26144
+ var css_248z$4 = ".ndc-steps-actions {\n display: flex;\n flex-direction: row-reverse;\n margin-right: 1rem;\n justify-content: center; }\n .ndc-steps-actions .action-btn {\n border: 1px solid #16b1ff;\n color: #16b1ff;\n margin-right: 1rem; }\n .ndc-steps-actions .back-btn {\n border: 1px solid rgba(140, 140, 140, 0.7);\n color: rgba(140, 140, 140, 0.7);\n margin-right: 1rem; }\n .ndc-steps-actions .mg-left-1 {\n margin-left: 1rem; }\n\n.ndc-details .ant-table-expanded-row .ant-table-cell {\n padding-left: 33px; }\n\n.ndc-details .ant-input-number-input-wrap {\n margin-right: 10px; }\n";
26183
26145
  styleInject(css_248z$4);
26184
26146
 
26185
- var NdcActionType;
26186
- (function (NdcActionType) {
26187
- NdcActionType[NdcActionType["main"] = 0] = "main";
26188
- NdcActionType[NdcActionType["sub"] = 1] = "sub";
26189
- })(NdcActionType || (NdcActionType = {}));
26147
+ var NdcDetailsActionType;
26148
+ (function (NdcDetailsActionType) {
26149
+ NdcDetailsActionType["MainAction"] = "MainAction";
26150
+ NdcDetailsActionType["SubAction"] = "SubAction";
26151
+ })(NdcDetailsActionType || (NdcDetailsActionType = {}));
26152
+ var NdcDetailsActionStatus;
26153
+ (function (NdcDetailsActionStatus) {
26154
+ NdcDetailsActionStatus["New"] = "New";
26155
+ NdcDetailsActionStatus["Pending"] = "Pending";
26156
+ NdcDetailsActionStatus["Approved"] = "Approved";
26157
+ NdcDetailsActionStatus["Rejected"] = "Rejected";
26158
+ })(NdcDetailsActionStatus || (NdcDetailsActionStatus = {}));
26159
+ var getNdcActionStatusEnumVal = function (value) {
26160
+ var index = Object.keys(NdcDetailsActionStatus).indexOf(value);
26161
+ if (index < 0) {
26162
+ return value;
26163
+ }
26164
+ return Object.values(NdcDetailsActionStatus)[index];
26165
+ };
26166
+ var getNdcActionStatusTagType = function (status) {
26167
+ switch (getNdcActionStatusEnumVal(status)) {
26168
+ case NdcDetailsActionStatus.Rejected:
26169
+ return "error";
26170
+ case NdcDetailsActionStatus.Pending:
26171
+ return "processing";
26172
+ case NdcDetailsActionStatus.Approved:
26173
+ return "success";
26174
+ default:
26175
+ return "default";
26176
+ }
26177
+ };
26178
+
26190
26179
  var NdcDetailsComponent = function (props) {
26191
- var t = props.t; props.useConnection; var useUserContext = props.useUserContext;
26180
+ var t = props.t, useConnection = props.useConnection, useUserContext = props.useUserContext;
26192
26181
  var RangePicker = DatePicker.RangePicker;
26193
- var _a = useState([]), ndcDetailsData = _a[0], setNdcDetailsData = _a[1];
26194
- var _b = useState(false), loading = _b[0]; _b[1];
26195
- var periodItemsRef = useRef([]);
26182
+ var _a = useState([]), ndcActionsList = _a[0], setNdcActionsList = _a[1];
26183
+ var _b = useState(false), loading = _b[0], setLoading = _b[1];
26196
26184
  var _c = useState([]), periodItems = _c[0], setPeriodItems = _c[1];
26197
- var _d = useState("add_new"), selectedTab = _d[0], setSelectedTab = _d[1];
26198
- var selectedPeriod = useRef({});
26199
- var addedNdcDetailId = useRef(0);
26200
- var selectedNdcDetail = useRef({});
26185
+ var _d = useState({}), selectedPeriod = _d[0], setSelectedPeriod = _d[1];
26186
+ var selectedDateRangeRef = useRef({});
26201
26187
  var _e = useState(0), tableKey = _e[0], setTableKey = _e[1];
26188
+ var _f = useConnection(), get = _f.get, post = _f.post, put = _f.put;
26189
+ var _g = useState([]), ministryOrgList = _g[0], setMinistryOrgList = _g[1];
26190
+ var _h = useState({}), actionInfo = _h[0], setActionInfo = _h[1];
26191
+ var _j = useState(false), openConfirmationModal = _j[0], setOpenConfirmationModal = _j[1];
26192
+ var form = Form.useForm()[0];
26193
+ var _k = useState(-1), editingKey = _k[0], setEditingKey = _k[1];
26194
+ var _l = useState(0), nextAvailableActionId = _l[0], setNextAvailableActionId = _l[1];
26195
+ var _m = useState([]), expandedRowKeys = _m[0], setExpandedRowKeys = _m[1];
26196
+ var _o = useState([]), subNdcActionsForPeriod = _o[0], setSubNdcActionsForPeriod = _o[1];
26197
+ var isEditing = function (record) { return record.id === editingKey; };
26202
26198
  var userInfoState = useUserContext().userInfoState;
26203
- var isAddRangeVisible = function () {
26204
- return (((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.MINISTRY ||
26205
- (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.GOVERNMENT) &&
26199
+ useEffect(function () {
26200
+ if (expandedRowKeys && expandedRowKeys.length > 0) {
26201
+ var expandedKey = expandedRowKeys[0];
26202
+ setNdcSubActionsForMainAction(expandedKey);
26203
+ }
26204
+ }, ndcActionsList);
26205
+ var loginMinistry = (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.GOVERNMENT
26206
+ ? process.env.REACT_APP_GOVERNMENT_MINISTRY
26207
+ ? process.env.REACT_APP_GOVERNMENT_MINISTRY
26208
+ : "Test ministryName"
26209
+ : (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.MINISTRY
26210
+ ? userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyName
26211
+ : undefined;
26212
+ var isGovernmentUser = (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.GOVERNMENT &&
26213
+ (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== Role.ViewOnly;
26214
+ var isMainNdcActionsEditable = !selectedPeriod.finalized &&
26215
+ (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.GOVERNMENT &&
26216
+ (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== Role.ViewOnly;
26217
+ var isSubNdcActionsEditable = function (record) {
26218
+ return (!selectedPeriod.finalized &&
26219
+ record.status !== NdcDetailsActionStatus.Approved &&
26220
+ ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.GOVERNMENT ||
26221
+ ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.MINISTRY &&
26222
+ (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyName) === record.ministryName)) &&
26206
26223
  (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== Role.ViewOnly);
26207
26224
  };
26208
- var isAddNdcActionVisible = function () {
26209
- return ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.GOVERNMENT &&
26210
- (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== Role.ViewOnly);
26225
+ var isNdcActionEditable = function (record) {
26226
+ if (record.actionType === NdcDetailsActionType.MainAction) {
26227
+ return isMainNdcActionsEditable;
26228
+ }
26229
+ else if (record.actionType === NdcDetailsActionType.SubAction) {
26230
+ return isSubNdcActionsEditable(record);
26231
+ }
26232
+ };
26233
+ var ndcMainDetailsForPeriod = selectedPeriod.key !== "add_new"
26234
+ ? ndcActionsList.filter(function (ndcDetail) {
26235
+ return (ndcDetail.periodId === parseInt(selectedPeriod.key) &&
26236
+ ndcDetail.actionType === NdcDetailsActionType.MainAction);
26237
+ })
26238
+ : [];
26239
+ var setNdcSubActionsForMainAction = function (mainActionId) {
26240
+ var subNdcDetails = ndcActionsList.filter(function (ndcDetail) {
26241
+ return (ndcDetail.parentActionId === mainActionId &&
26242
+ ndcDetail.actionType === NdcDetailsActionType.SubAction);
26243
+ });
26244
+ var emptySubNdcRow = {
26245
+ id: nextAvailableActionId,
26246
+ actionType: NdcDetailsActionType.SubAction,
26247
+ nationalPlanObjective: "",
26248
+ kpi: "",
26249
+ ministryName: loginMinistry,
26250
+ status: NdcDetailsActionStatus.New,
26251
+ parentActionId: mainActionId,
26252
+ };
26253
+ if (!selectedPeriod.finalized) {
26254
+ subNdcDetails = __spreadArray(__spreadArray([], subNdcDetails, true), [emptySubNdcRow], false);
26255
+ setEditingKey(nextAvailableActionId);
26256
+ setNextAvailableActionId(function (value) { return value + 1; });
26257
+ form.setFieldsValue({
26258
+ nationalPlanObjective: "",
26259
+ kpi: "",
26260
+ });
26261
+ }
26262
+ setSubNdcActionsForPeriod(subNdcDetails);
26211
26263
  };
26212
26264
  var inRange = function (num, min, max) {
26213
26265
  return num >= min && num <= max;
26214
26266
  };
26215
- function onAddNewSubNdcDetail() {
26216
- var range = selectedTab.split('-');
26217
- var ndcDetail = ndcDetailsData.find(function (item) { return item.key === selectedNdcDetail.current.key; });
26218
- var ndcDetailItemIndex = ndcDetailsData.findIndex(function (item) { return item.key === selectedNdcDetail.current.key; });
26219
- if (ndcDetail) {
26220
- addedNdcDetailId.current = addedNdcDetailId.current + 1;
26221
- var newData = {
26222
- key: addedNdcDetailId.current,
26223
- startDate: new Date("".concat(Number(range[0]), "-01-24 23:12:00")),
26224
- endDate: new Date("".concat(Number(range[0]), "-12-24 23:12:00")),
26225
- ndcActionId: ndcDetail === null || ndcDetail === void 0 ? void 0 : ndcDetail.key,
26226
- nationalPlanObj: '',
26227
- kpi: '',
26228
- ministry: '',
26229
- };
26230
- if (!ndcDetail.subNdcDetails) {
26231
- ndcDetail.subNdcDetails = [];
26232
- }
26233
- ndcDetail.subNdcDetails.push(newData);
26234
- }
26235
- ndcDetailsData[ndcDetailItemIndex] = ndcDetail;
26236
- setNdcDetailsData(ndcDetailsData);
26237
- setTableKey(function (key) { return key + 1; });
26238
- }
26239
- var handleSave = function (row) {
26240
- setNdcDetailsData(function (prevData) {
26241
- var newData = JSON.parse(JSON.stringify(prevData));
26242
- if (row.type === NdcActionType.main) {
26243
- var index = newData.findIndex(function (item) { return row.key === item.key; });
26244
- if (index !== -1) {
26245
- newData[index] = __assign(__assign({}, newData[index]), row);
26246
- }
26247
- }
26248
- else {
26249
- var parentIndex = newData.findIndex(function (item) { return row.ndcActionId === item.key; });
26250
- var parentItem = newData[parentIndex];
26251
- if (parentItem) {
26252
- if (parentItem.subNdcDetails) {
26253
- var itemIndex = parentItem.subNdcDetails.findIndex(function (item) { return row.key === item.key; });
26254
- if (itemIndex === -1) {
26255
- parentItem.subNdcDetails.push(row);
26256
- }
26257
- else {
26258
- parentItem.subNdcDetails[itemIndex] = __assign({}, row);
26259
- }
26267
+ var handleSave = function (row) { return __awaiter(void 0, void 0, void 0, function () {
26268
+ var updatedFields, updatedItem, exception_1;
26269
+ return __generator(this, function (_a) {
26270
+ switch (_a.label) {
26271
+ case 0:
26272
+ _a.trys.push([0, 6, , 7]);
26273
+ return [4 /*yield*/, form.validateFields()];
26274
+ case 1:
26275
+ updatedFields = (_a.sent());
26276
+ updatedItem = __assign(__assign({}, row), updatedFields);
26277
+ if (!(updatedItem.status === NdcDetailsActionStatus.New)) return [3 /*break*/, 3];
26278
+ if (isGovernmentUser &&
26279
+ updatedItem.actionType === NdcDetailsActionType.SubAction) {
26280
+ updatedItem.status = NdcDetailsActionStatus.Approved;
26260
26281
  }
26261
26282
  else {
26262
- parentItem.subNdcDetails = [row];
26283
+ updatedItem.status = NdcDetailsActionStatus.Pending;
26263
26284
  }
26264
- }
26265
- newData[parentIndex] = __assign({}, parentItem);
26266
- setTableKey(function (key) { return key + 1; });
26285
+ return [4 /*yield*/, post("national/programme/addNdcDetailsAction", __assign(__assign({}, updatedItem), { kpi: parseInt(updatedItem.kpi.toString()) }))];
26286
+ case 2:
26287
+ _a.sent();
26288
+ return [3 /*break*/, 5];
26289
+ case 3:
26290
+ updatedItem.status = NdcDetailsActionStatus.Pending;
26291
+ return [4 /*yield*/, put("national/programme/updateNdcDetailsAction", __assign(__assign({}, updatedItem), { kpi: parseInt(updatedItem.kpi.toString()) }))];
26292
+ case 4:
26293
+ _a.sent();
26294
+ _a.label = 5;
26295
+ case 5:
26296
+ fetchNdcDetailActions();
26297
+ setEditingKey(-1);
26298
+ return [3 /*break*/, 7];
26299
+ case 6:
26300
+ exception_1 = _a.sent();
26301
+ console.log("error", exception_1);
26302
+ return [3 /*break*/, 7];
26303
+ case 7: return [2 /*return*/];
26267
26304
  }
26268
- return newData;
26269
26305
  });
26270
- };
26271
- var getNdcDetailsForPeriod = function () {
26272
- var range = selectedTab.split("-");
26273
- if (range.length > 1) {
26274
- var filteredData = ndcDetailsData.filter(function (item) {
26275
- return inRange(Number(moment(item.startDate).year()), Number(range[0]), Number(range[1]));
26276
- });
26277
- return filteredData;
26278
- }
26279
- else {
26280
- return [];
26281
- }
26282
- };
26283
- var getSubNdcDetails = function (key) {
26284
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
26285
- var ndcDetail = ndcDetailsData.find(function (item) { return item.key === key; });
26286
- if (ndcDetail) {
26287
- if (((_b = ndcDetail === null || ndcDetail === void 0 ? void 0 : ndcDetail.subNdcDetails[((_a = ndcDetail === null || ndcDetail === void 0 ? void 0 : ndcDetail.subNdcDetails) === null || _a === void 0 ? void 0 : _a.length) - 1]) === null || _b === void 0 ? void 0 : _b.ministry.trim()) !== '' &&
26288
- ((_d = ndcDetail === null || ndcDetail === void 0 ? void 0 : ndcDetail.subNdcDetails[((_c = ndcDetail === null || ndcDetail === void 0 ? void 0 : ndcDetail.subNdcDetails) === null || _c === void 0 ? void 0 : _c.length) - 1]) === null || _d === void 0 ? void 0 : _d.ministry) &&
26289
- ((_f = ndcDetail === null || ndcDetail === void 0 ? void 0 : ndcDetail.subNdcDetails[((_e = ndcDetail === null || ndcDetail === void 0 ? void 0 : ndcDetail.subNdcDetails) === null || _e === void 0 ? void 0 : _e.length) - 1]) === null || _f === void 0 ? void 0 : _f.nationalPlanObj.trim()) !==
26290
- '' &&
26291
- ((_h = ndcDetail === null || ndcDetail === void 0 ? void 0 : ndcDetail.subNdcDetails[((_g = ndcDetail === null || ndcDetail === void 0 ? void 0 : ndcDetail.subNdcDetails) === null || _g === void 0 ? void 0 : _g.length) - 1]) === null || _h === void 0 ? void 0 : _h.nationalPlanObj) &&
26292
- String((_k = ndcDetail === null || ndcDetail === void 0 ? void 0 : ndcDetail.subNdcDetails[((_j = ndcDetail === null || ndcDetail === void 0 ? void 0 : ndcDetail.subNdcDetails) === null || _j === void 0 ? void 0 : _j.length) - 1]) === null || _k === void 0 ? void 0 : _k.kpi).trim() !== '' &&
26293
- String((_m = ndcDetail === null || ndcDetail === void 0 ? void 0 : ndcDetail.subNdcDetails[((_l = ndcDetail === null || ndcDetail === void 0 ? void 0 : ndcDetail.subNdcDetails) === null || _l === void 0 ? void 0 : _l.length) - 1]) === null || _m === void 0 ? void 0 : _m.kpi)) {
26294
- onAddNewSubNdcDetail();
26295
- }
26296
- return ndcDetail.subNdcDetails;
26306
+ }); };
26307
+ var actionMenu = function (record) {
26308
+ if (record.status === NdcDetailsActionStatus.Pending &&
26309
+ isGovernmentUser &&
26310
+ !selectedPeriod.finalized) {
26311
+ return (React.createElement(List, { className: "action-menu", size: "small", dataSource: [
26312
+ {
26313
+ text: t("ndc:approve"),
26314
+ icon: React.createElement(Icon.BoxArrowInDown, null),
26315
+ click: function () {
26316
+ setActionInfo({
26317
+ action: "Approve",
26318
+ headerText: t("ndc:actionApproveTitle"),
26319
+ type: "primary",
26320
+ icon: React.createElement(Icon.BoxArrowInDown, null),
26321
+ recordId: record.id,
26322
+ });
26323
+ setOpenConfirmationModal(true);
26324
+ },
26325
+ },
26326
+ {
26327
+ text: t("ndc:reject"),
26328
+ icon: React.createElement(Icon.XOctagon, null),
26329
+ click: function () {
26330
+ setActionInfo({
26331
+ action: "Reject",
26332
+ headerText: t("ndc:rejectApproveTitle"),
26333
+ type: "danger",
26334
+ icon: React.createElement(Icon.BoxArrowInDown, null),
26335
+ recordId: record.id,
26336
+ });
26337
+ setOpenConfirmationModal(true);
26338
+ },
26339
+ },
26340
+ ], renderItem: function (item) { return (React.createElement(List.Item, { onClick: item.click },
26341
+ React.createElement(Typography.Text, { className: "action-icon color-error" }, item.icon),
26342
+ React.createElement("span", null, item.text))); } }));
26297
26343
  }
26298
26344
  else {
26299
- return [];
26345
+ return null;
26300
26346
  }
26301
26347
  };
26302
26348
  var defaultColumns = [
26303
26349
  {
26304
26350
  title: t("ndc:ndcColumnsNationalPlanObj"),
26305
- dataIndex: "nationalPlanObj",
26306
- key: "nationalPlanObj",
26351
+ dataIndex: "nationalPlanObjective",
26352
+ key: "nationalPlanObjective",
26307
26353
  align: "left",
26354
+ width: 300,
26308
26355
  editable: true,
26309
- width: "50%",
26310
- render: function (_, record) { return (React.createElement(React.Fragment, null, record.nationalPlanObj ? (React.createElement(Space, { size: "middle" },
26311
- React.createElement("span", null, record.nationalPlanObj))) : (React.createElement("input", { placeholder: "Please add the National Plan Objective", className: "ant-input", type: "text" })))); },
26356
+ render: function (_, record) { return (React.createElement(Space, { size: "middle" }, record.nationalPlanObjective ? (React.createElement("span", null, record.nationalPlanObjective)) : (React.createElement(Input, { placeholder: "Enter National Plan Objective" })))); },
26312
26357
  },
26313
26358
  {
26314
26359
  title: t("ndc:ndcColumnsKpi"),
26315
26360
  dataIndex: "kpi",
26316
26361
  key: "kpi",
26317
26362
  align: "left",
26363
+ width: 100,
26318
26364
  editable: true,
26319
- width: "10%",
26320
- render: function (_, record) { return (React.createElement(React.Fragment, null, record.nationalPlanObj ? (React.createElement(Space, { size: "middle" },
26321
- React.createElement("span", null, record.kpi))) : (React.createElement("input", { placeholder: "Enter Kpi", className: "ant-input", type: "text" })))); },
26365
+ render: function (_, record) { return (React.createElement(Space, { size: "middle" }, record.kpi ? (React.createElement("span", null, record.kpi)) : (React.createElement(Input, { placeholder: "Enter Kpi" })))); },
26322
26366
  },
26323
26367
  {
26324
- title: "Ministry",
26325
- dataIndex: "ministry",
26326
- key: "ministry",
26368
+ title: t("ndc:ndcColumnsMinistry"),
26369
+ dataIndex: "ministryName",
26370
+ key: "ministryName",
26327
26371
  align: "left",
26328
- editable: true,
26329
- width: "40%",
26330
- render: function (_, record) { return (React.createElement(React.Fragment, null, record.nationalPlanObj ? (React.createElement(Space, { size: "middle" },
26331
- React.createElement("span", null, record.ministry))) : (React.createElement("input", { placeholder: "Please add the Ministry name", className: "ant-input", type: "text" })))); },
26372
+ width: 200,
26373
+ editable: false,
26374
+ render: function (_, record) { return (React.createElement(React.Fragment, null,
26375
+ React.createElement(Select, { disabled: !(isSubNdcActionsEditable(record) && isEditing(record)), defaultValue: record.ministryName ? record.ministryName : loginMinistry, style: { width: 320 }, onChange: function (value, option) {
26376
+ record.ministryName = option.label;
26377
+ handleSave(record);
26378
+ }, options: ministryOrgList }))); },
26379
+ },
26380
+ {
26381
+ title: t("ndc:ndcColumnsStatus"),
26382
+ dataIndex: "status",
26383
+ key: "status",
26384
+ align: "left",
26385
+ width: "15%",
26386
+ editable: false,
26387
+ render: function (_, record) {
26388
+ var menu = actionMenu(record);
26389
+ return (React.createElement("div", { onClick: function (event) { return event.stopPropagation(); } },
26390
+ record.actionType === NdcDetailsActionType.SubAction &&
26391
+ record.status !== NdcDetailsActionStatus.New ? (React.createElement(Tooltip, { title: record.status, color: TooltipColor, key: TooltipColor },
26392
+ React.createElement(Tag, { className: "clickable", color: getNdcActionStatusTagType(record.status) }, addSpaces(record.status)))) : (""),
26393
+ record.actionType === NdcDetailsActionType.SubAction && menu ? (React.createElement(Popover, { placement: "bottomRight", content: menu, trigger: "click" },
26394
+ React.createElement(EllipsisOutlined, { rotate: 90, style: {
26395
+ fontWeight: 600,
26396
+ fontSize: "1rem",
26397
+ cursor: "pointer",
26398
+ } }))) : (React.createElement("span", null))));
26399
+ },
26332
26400
  },
26333
26401
  ];
26334
26402
  var columns = defaultColumns.map(function (col) {
26335
26403
  if (!col.editable) {
26336
26404
  return col;
26337
26405
  }
26338
- return __assign(__assign({}, col), { onCell: function (record) { return ({
26339
- record: record,
26340
- editable: col.editable,
26341
- dataIndex: col.dataIndex,
26342
- title: col.title,
26343
- handleSave: handleSave,
26344
- }); } });
26406
+ return __assign(__assign({}, col), { onCell: function (record) {
26407
+ return {
26408
+ record: record,
26409
+ editing: isEditing(record),
26410
+ dataIndex: col.dataIndex,
26411
+ title: col.title,
26412
+ onBlurHandler: function (record) {
26413
+ if (isEditing(record)) {
26414
+ handleSave(record);
26415
+ }
26416
+ },
26417
+ };
26418
+ } });
26345
26419
  });
26346
- function onAddNewNdcDetail() {
26347
- var range = selectedTab.split("-");
26348
- var ndcActionId = ++addedNdcDetailId.current;
26349
- var newData = {
26350
- key: ndcActionId,
26351
- type: NdcActionType.main,
26352
- startDate: new Date("".concat(Number(range[0]), "-01-24 23:12:00")),
26353
- endDate: new Date("".concat(Number(range[0]), "-12-24 23:12:00")),
26354
- nationalPlanObj: "",
26355
- kpi: "",
26356
- ministry: "",
26357
- subNdcDetails: [
26358
- {
26359
- key: ++addedNdcDetailId.current,
26360
- ndcActionId: ndcActionId,
26361
- type: NdcActionType.sub,
26362
- startDate: new Date("2019-03-25"),
26363
- endDate: new Date("2020-03-25"),
26364
- nationalPlanObj: "",
26365
- kpi: "",
26366
- ministry: "",
26367
- },
26368
- ],
26369
- };
26370
- setNdcDetailsData(__spreadArray(__spreadArray([], ndcDetailsData, true), [newData], false));
26420
+ function onClickedAddNewNdcDetail() {
26421
+ return __awaiter(this, void 0, void 0, function () {
26422
+ var periodId, newData_1;
26423
+ return __generator(this, function (_a) {
26424
+ if (selectedPeriod.key !== "add_new") {
26425
+ form.setFieldsValue({
26426
+ nationalPlanObjective: "",
26427
+ kpi: "",
26428
+ });
26429
+ periodId = parseInt(selectedPeriod.key);
26430
+ newData_1 = {
26431
+ id: nextAvailableActionId,
26432
+ actionType: NdcDetailsActionType.MainAction,
26433
+ nationalPlanObjective: "",
26434
+ kpi: "",
26435
+ ministryName: loginMinistry,
26436
+ periodId: periodId,
26437
+ status: NdcDetailsActionStatus.New,
26438
+ };
26439
+ setEditingKey(nextAvailableActionId);
26440
+ setNextAvailableActionId(function (value) { return value + 1; });
26441
+ setNdcActionsList(function (ndcActionsList) { return __spreadArray(__spreadArray([], ndcActionsList, true), [
26442
+ newData_1,
26443
+ ], false); });
26444
+ setTableKey(function (key) { return key + 1; });
26445
+ }
26446
+ return [2 /*return*/];
26447
+ });
26448
+ });
26371
26449
  }
26372
26450
  var components = {
26373
26451
  body: {
26374
- row: EditableRow,
26375
26452
  cell: EditableCell,
26376
26453
  },
26377
26454
  };
26378
- //commented because rendering issue
26379
- function ndcDetailsTableContent() {
26380
- return (React.createElement("div", null)
26381
- // <div>
26382
- // <Button
26383
- // onClick={onAddNewNdcDetail}
26384
- // type="primary"
26385
- // style={{
26386
- // marginBottom: 16,
26387
- // }}
26388
- // >
26389
- // Add a row
26390
- // </Button>
26391
- // <Table
26392
- // components={components}
26393
- // rowClassName={() => 'editable-row'}
26394
- // bordered
26395
- // dataSource={ndcDetailsData}
26396
- // columns={columns}
26397
- // />
26398
- // </div>
26399
- );
26400
- }
26401
- var onCancelPeriod = function () { };
26402
- var onAddNewPeriod = function () {
26403
- if (selectedPeriod && selectedPeriod.current) {
26404
- var newPeriodItem_1 = {
26405
- key: "".concat(selectedPeriod.current.start, "-").concat(selectedPeriod.current.end),
26406
- label: "".concat(selectedPeriod.current.start, "-").concat(selectedPeriod.current.end),
26407
- start: selectedPeriod.current.start,
26408
- end: selectedPeriod.current.end,
26409
- children: ndcDetailsTableContent(),
26410
- };
26411
- var existingIndex = periodItemsRef.current.findIndex(function (item) {
26412
- return inRange(newPeriodItem_1.start, item.start, item.end) ||
26413
- inRange(newPeriodItem_1.end, item.start, item.end);
26455
+ var onClickedDeletePeriod = function () { return __awaiter(void 0, void 0, void 0, function () {
26456
+ return __generator(this, function (_a) {
26457
+ setActionInfo({
26458
+ action: "Delete",
26459
+ headerText: t("ndc:periodDeleteConfirmTitle"),
26460
+ type: "danger",
26461
+ icon: React.createElement(Icon.XCircle, null),
26462
+ recordId: selectedPeriod.key,
26414
26463
  });
26415
- if (existingIndex === -1) {
26416
- setPeriodItems(function (items) { return __spreadArray(__spreadArray([], items, true), [newPeriodItem_1], false); });
26417
- periodItemsRef.current = __spreadArray(__spreadArray([], periodItemsRef.current, true), [newPeriodItem_1], false);
26418
- }
26419
- else {
26464
+ setOpenConfirmationModal(true);
26465
+ return [2 /*return*/];
26466
+ });
26467
+ }); };
26468
+ var onClickedFinalizePeriod = function () { return __awaiter(void 0, void 0, void 0, function () {
26469
+ var pendingActions;
26470
+ return __generator(this, function (_a) {
26471
+ pendingActions = subNdcActionsForPeriod.filter(function (action) {
26472
+ return action.status === NdcDetailsActionStatus.Pending;
26473
+ });
26474
+ if (pendingActions && pendingActions.length > 0) {
26420
26475
  message.open({
26421
26476
  type: "error",
26422
- content: t("ndc:rangeAlreadyExists"),
26477
+ content: t("ndc:finalizeErrorText"),
26423
26478
  duration: 3,
26424
26479
  style: { textAlign: "right", marginRight: 15, marginTop: 10 },
26425
26480
  });
26426
26481
  }
26482
+ else {
26483
+ setActionInfo({
26484
+ action: "Finalize",
26485
+ headerText: t("ndc:finalizeApproveTitle"),
26486
+ text: t("ndc:finalizeApproveSubTitle"),
26487
+ type: "primary",
26488
+ icon: React.createElement(Icon.Clipboard2Check, null),
26489
+ recordId: selectedPeriod.key,
26490
+ });
26491
+ setOpenConfirmationModal(true);
26492
+ }
26493
+ return [2 /*return*/];
26494
+ });
26495
+ }); };
26496
+ var onMainTableRowExpand = function (expanded, record) {
26497
+ var keys = [];
26498
+ if (expanded) {
26499
+ keys.push(record.id);
26427
26500
  }
26428
- };
26429
- useEffect(function () {
26430
- if (periodItems && periodItems.length > 3) {
26431
- setSelectedTab(periodItems[periodItems.length - 1].key);
26432
- }
26433
- }, [periodItems]);
26434
- var onDateRangeChanged = function (range) {
26435
- var period = {
26436
- start: Number(moment(range[0]).year()),
26437
- end: Number(moment(range[1]).year()),
26438
- };
26439
- selectedPeriod.current = period;
26501
+ setExpandedRowKeys(keys);
26502
+ setNdcSubActionsForMainAction(record.id);
26440
26503
  };
26441
26504
  function addNewPeriodContent() {
26442
26505
  return (React.createElement("div", null,
26443
- React.createElement(Row, null,
26444
- React.createElement(RangePicker, { onChange: onDateRangeChanged, picker: "year" })),
26445
- React.createElement(Row, { className: "mg-top-1" },
26446
- React.createElement("div", { className: "ndc-steps-actions" },
26447
- React.createElement(Button, { type: "primary", onClick: onAddNewPeriod, htmlType: "submit", loading: loading }, t("ndc:submit")),
26448
- React.createElement(Button, { className: "back-btn", onClick: onCancelPeriod, loading: loading }, t("ndc:back"))))));
26506
+ React.createElement(Row, { justify: "start", align: "middle", gutter: [16, 16] },
26507
+ React.createElement(Col, { flex: "340px" },
26508
+ React.createElement(RangePicker, { onChange: onDateRangeChanged, picker: "year" })),
26509
+ React.createElement(Col, { flex: "auto" },
26510
+ React.createElement(Button, { type: "primary", onClick: onAddNewPeriod, htmlType: "submit", loading: loading }, t("ndc:submit"))))));
26449
26511
  }
26450
- function getSubNdcActionContent(record) {
26451
- selectedNdcDetail.current = record;
26452
- return (React.createElement(Table, { components: components, rowClassName: function () { return "editable-row"; }, bordered: true, dataSource: getSubNdcDetails(record.key), columns: columns, showHeader: false, pagination: false }));
26512
+ function mainNdcActionTableContent() {
26513
+ return (React.createElement("div", null,
26514
+ React.createElement(Row, null,
26515
+ React.createElement(Col, { span: 24 },
26516
+ React.createElement(Form, { form: form, component: false },
26517
+ React.createElement(Table, { key: tableKey, rowKey: "id", components: components, rowClassName: function () { return "editable-row"; }, bordered: true, loading: loading, dataSource: ndcMainDetailsForPeriod, columns: columns, expandedRowKeys: expandedRowKeys, onExpand: onMainTableRowExpand, expandable: {
26518
+ expandedRowRender: function (record) {
26519
+ return subNdcActionTableContent();
26520
+ },
26521
+ indentSize: 30,
26522
+ columnWidth: 30,
26523
+ }, onRow: function (record, rowIndex) {
26524
+ return {
26525
+ onClick: function (event) {
26526
+ if (record.id &&
26527
+ isNdcActionEditable(record) &&
26528
+ !isEditing(record)) {
26529
+ form.setFieldsValue(__assign({}, record));
26530
+ setEditingKey(record.id);
26531
+ }
26532
+ },
26533
+ onMouseLeave: function () {
26534
+ if (isEditing(record)) {
26535
+ handleSave(record);
26536
+ }
26537
+ },
26538
+ };
26539
+ }, footer: function () {
26540
+ return isGovernmentUser &&
26541
+ !selectedPeriod.finalized && (React.createElement(Row, { justify: "center" },
26542
+ React.createElement(Button, { onClick: onClickedAddNewNdcDetail, type: "default", style: {
26543
+ marginBottom: 16,
26544
+ width: "100%",
26545
+ } }, t("ndc:addNdcAction"))));
26546
+ } })))),
26547
+ isGovernmentUser && !selectedPeriod.finalized ? (React.createElement(Row, { justify: "end" },
26548
+ React.createElement(Button, { className: "mg-left-1", type: "primary", onClick: onClickedDeletePeriod, htmlType: "submit", loading: loading }, t("ndc:delete")),
26549
+ React.createElement(Button, { className: "mg-left-1", type: "primary", onClick: onClickedFinalizePeriod, htmlType: "submit", loading: loading }, t("ndc:finalize")))) : ("")));
26550
+ }
26551
+ function subNdcActionTableContent(record) {
26552
+ return (React.createElement(Table, { rowKey: "id", components: components, rowClassName: function () { return "editable-row"; }, bordered: true, dataSource: subNdcActionsForPeriod, loading: loading, onRow: function (record, rowIndex) {
26553
+ return {
26554
+ onClick: function (event) {
26555
+ if (record.id &&
26556
+ isNdcActionEditable(record) &&
26557
+ !isEditing(record)) {
26558
+ form.setFieldsValue(__assign({}, record));
26559
+ setEditingKey(record.id);
26560
+ }
26561
+ },
26562
+ onMouseLeave: function () {
26563
+ if (isEditing(record)) {
26564
+ handleSave(record);
26565
+ }
26566
+ },
26567
+ };
26568
+ }, columns: columns, showHeader: false, pagination: false }));
26453
26569
  }
26570
+ var onAddNewPeriod = function () { return __awaiter(void 0, void 0, void 0, function () {
26571
+ var periodItem_1, existingIndex, response, addedPeriodItem, updatedPeriodItem_1;
26572
+ return __generator(this, function (_a) {
26573
+ switch (_a.label) {
26574
+ case 0:
26575
+ if (!(selectedDateRangeRef && selectedDateRangeRef.current)) return [3 /*break*/, 3];
26576
+ periodItem_1 = {
26577
+ startYear: selectedDateRangeRef.current.startYear,
26578
+ endYear: selectedDateRangeRef.current.endYear,
26579
+ finalized: false,
26580
+ };
26581
+ existingIndex = periodItems.findIndex(function (item) {
26582
+ return inRange(periodItem_1.startYear, item.startYear, item.endYear) ||
26583
+ inRange(periodItem_1.endYear, item.startYear, item.endYear);
26584
+ });
26585
+ if (!(existingIndex === -1)) return [3 /*break*/, 2];
26586
+ return [4 /*yield*/, post("national/programme/addNdcDetailsPeriod", __assign({}, periodItem_1))];
26587
+ case 1:
26588
+ response = _a.sent();
26589
+ if (response && response.data) {
26590
+ addedPeriodItem = response.data;
26591
+ updatedPeriodItem_1 = __assign(__assign({}, addedPeriodItem), { key: addedPeriodItem.id, label: "".concat(addedPeriodItem.startYear, "-").concat(addedPeriodItem.endYear) });
26592
+ setPeriodItems(function (items) { return __spreadArray(__spreadArray([], items, true), [updatedPeriodItem_1], false); });
26593
+ setSelectedPeriod(updatedPeriodItem_1);
26594
+ }
26595
+ return [3 /*break*/, 3];
26596
+ case 2:
26597
+ message.open({
26598
+ type: "error",
26599
+ content: t("ndc:rangeAlreadyExists"),
26600
+ duration: 3,
26601
+ style: { textAlign: "right", marginRight: 15, marginTop: 10 },
26602
+ });
26603
+ _a.label = 3;
26604
+ case 3: return [2 /*return*/];
26605
+ }
26606
+ });
26607
+ }); };
26608
+ var onDateRangeChanged = function (range) {
26609
+ var period = {
26610
+ startYear: Number(moment(range[0]).year()),
26611
+ endYear: Number(moment(range[1]).year()),
26612
+ };
26613
+ selectedDateRangeRef.current = period;
26614
+ };
26454
26615
  var onTabChange = function (key) {
26455
- setSelectedTab(key);
26616
+ var selectedPeriod = periodItems.find(function (item) { return item.key === key; });
26617
+ if (selectedPeriod) {
26618
+ setSelectedPeriod(selectedPeriod);
26619
+ }
26620
+ };
26621
+ var onActionConfirmed = function () { return __awaiter(void 0, void 0, void 0, function () {
26622
+ var actionResponse;
26623
+ return __generator(this, function (_a) {
26624
+ switch (_a.label) {
26625
+ case 0:
26626
+ setLoading(true);
26627
+ if (!(actionInfo.action === "Approve")) return [3 /*break*/, 2];
26628
+ return [4 /*yield*/, post("national/programme/approveNdcDetailsAction", {
26629
+ id: actionInfo.recordId,
26630
+ })];
26631
+ case 1:
26632
+ actionResponse = _a.sent();
26633
+ return [3 /*break*/, 8];
26634
+ case 2:
26635
+ if (!(actionInfo.action === "Reject")) return [3 /*break*/, 4];
26636
+ return [4 /*yield*/, post("national/programme/rejectNdcDetailsAction", {
26637
+ id: actionInfo.recordId,
26638
+ })];
26639
+ case 3:
26640
+ actionResponse = _a.sent();
26641
+ return [3 /*break*/, 8];
26642
+ case 4:
26643
+ if (!(actionInfo.action === "Finalize")) return [3 /*break*/, 6];
26644
+ return [4 /*yield*/, post("national/programme/finalizeNdcDetailsPeriod", {
26645
+ id: selectedPeriod.key,
26646
+ })];
26647
+ case 5:
26648
+ actionResponse = _a.sent();
26649
+ return [3 /*break*/, 8];
26650
+ case 6:
26651
+ if (!(actionInfo.action === "Delete")) return [3 /*break*/, 8];
26652
+ return [4 /*yield*/, post("national/programme/deleteNdcDetailsPeriod", {
26653
+ id: selectedPeriod.key,
26654
+ })];
26655
+ case 7:
26656
+ actionResponse = _a.sent();
26657
+ _a.label = 8;
26658
+ case 8:
26659
+ if (actionResponse &&
26660
+ (actionInfo.action === "Delete" || actionInfo.action === "Finalize")) {
26661
+ fetchNdcDetailPeriods();
26662
+ }
26663
+ else if (actionResponse &&
26664
+ (actionInfo.action === "Approve" || actionInfo.action === "Reject")) {
26665
+ fetchNdcDetailActions();
26666
+ }
26667
+ setOpenConfirmationModal(false);
26668
+ setLoading(false);
26669
+ return [2 /*return*/];
26670
+ }
26671
+ });
26672
+ }); };
26673
+ var onActionCanceled = function () {
26674
+ setOpenConfirmationModal(false);
26456
26675
  };
26676
+ var fetchNdcDetailPeriods = function () { return __awaiter(void 0, void 0, void 0, function () {
26677
+ var periods, addNewTab, response;
26678
+ return __generator(this, function (_a) {
26679
+ switch (_a.label) {
26680
+ case 0:
26681
+ setLoading(true);
26682
+ periods = [];
26683
+ addNewTab = {
26684
+ key: "add_new",
26685
+ label: "Add New",
26686
+ startYear: 0,
26687
+ endYear: 0,
26688
+ finalized: false,
26689
+ deleted: false,
26690
+ };
26691
+ return [4 /*yield*/, get("national/programme/queryNdcDetailsPeriod")];
26692
+ case 1:
26693
+ response = _a.sent();
26694
+ if (response && response.data) {
26695
+ periods = response.data.map(function (period) {
26696
+ return __assign(__assign({}, period), { key: period.id, label: period.finalized ? (React.createElement("span", null,
26697
+ React.createElement(LockOutlined, null),
26698
+ " ",
26699
+ period.startYear,
26700
+ "-",
26701
+ period.endYear,
26702
+ " ")) : ("".concat(period.startYear, "-").concat(period.endYear)) });
26703
+ });
26704
+ }
26705
+ if (isGovernmentUser) {
26706
+ periods.unshift(addNewTab);
26707
+ }
26708
+ setPeriodItems(periods);
26709
+ if (isGovernmentUser) {
26710
+ setSelectedPeriod(addNewTab);
26711
+ }
26712
+ else {
26713
+ setSelectedPeriod(periods[0]);
26714
+ }
26715
+ setLoading(false);
26716
+ return [2 /*return*/];
26717
+ }
26718
+ });
26719
+ }); };
26720
+ var fetchNdcDetailActions = function () { return __awaiter(void 0, void 0, void 0, function () {
26721
+ var response, maxActionId;
26722
+ return __generator(this, function (_a) {
26723
+ switch (_a.label) {
26724
+ case 0:
26725
+ setLoading(true);
26726
+ return [4 /*yield*/, get("national/programme/queryNdcDetailsAction")];
26727
+ case 1:
26728
+ response = _a.sent();
26729
+ if (response && response.data) {
26730
+ maxActionId = Math.max.apply(Math, response.data.map(function (item) { return item.id; }));
26731
+ setNextAvailableActionId(maxActionId + 1);
26732
+ setNdcActionsList(response.data);
26733
+ }
26734
+ setLoading(false);
26735
+ return [2 /*return*/];
26736
+ }
26737
+ });
26738
+ }); };
26739
+ var fetchMinistries = function () { return __awaiter(void 0, void 0, void 0, function () {
26740
+ var response, ministryOrgDetails;
26741
+ return __generator(this, function (_a) {
26742
+ switch (_a.label) {
26743
+ case 0:
26744
+ setLoading(true);
26745
+ return [4 /*yield*/, get("national/organisation/getMinistries")];
26746
+ case 1:
26747
+ response = _a.sent();
26748
+ if (response && response.data) {
26749
+ ministryOrgDetails = response.data.map(function (value) {
26750
+ return {
26751
+ value: value.company_companyId,
26752
+ label: value.company_name,
26753
+ };
26754
+ });
26755
+ setMinistryOrgList(ministryOrgDetails);
26756
+ }
26757
+ setLoading(false);
26758
+ return [2 /*return*/];
26759
+ }
26760
+ });
26761
+ }); };
26457
26762
  useEffect(function () {
26458
- var defaultNdcDetails = [
26459
- {
26460
- key: 1,
26461
- type: NdcActionType.main,
26462
- startDate: new Date("2019-03-25"),
26463
- endDate: new Date("2020-03-25"),
26464
- nationalPlanObj: "Enhance value addition in key growth opportunities",
26465
- kpi: 25,
26466
- ministry: "Ministry of Environment",
26467
- subNdcDetails: [
26468
- {
26469
- key: 6,
26470
- ndcActionId: 1,
26471
- type: NdcActionType.sub,
26472
- startDate: new Date("2019-03-25"),
26473
- endDate: new Date("2020-03-25"),
26474
- nationalPlanObj: "Enhance value addition in key growth opportunities sub details",
26475
- kpi: 25,
26476
- ministry: "Ministry of Agriculture, Water and Forestry (MAWF)",
26477
- },
26478
- {
26479
- key: 7,
26480
- ndcActionId: 1,
26481
- type: NdcActionType.sub,
26482
- startDate: new Date("2019-03-25"),
26483
- endDate: new Date("2020-03-25"),
26484
- nationalPlanObj: "",
26485
- kpi: "",
26486
- ministry: "",
26487
- },
26488
- ],
26489
- },
26490
- {
26491
- key: 2,
26492
- type: NdcActionType.main,
26493
- startDate: new Date("2019-03-25"),
26494
- endDate: new Date("2019-08-25"),
26495
- nationalPlanObj: "Strengthen the private sector to create 10,000 jobs",
26496
- kpi: 10500,
26497
- ministry: "Ministry of Environment",
26498
- subNdcDetails: [
26499
- {
26500
- key: 8,
26501
- ndcActionId: 2,
26502
- type: NdcActionType.sub,
26503
- startDate: new Date("2019-03-25"),
26504
- endDate: new Date("2020-03-25"),
26505
- nationalPlanObj: "",
26506
- kpi: "",
26507
- ministry: "",
26508
- },
26509
- ],
26510
- },
26511
- {
26512
- key: 12,
26513
- type: NdcActionType.main,
26514
- startDate: new Date("2019-03-25"),
26515
- endDate: new Date("2019-08-25"),
26516
- nationalPlanObj: "Other",
26517
- kpi: 10500,
26518
- ministry: "Ministry of Environment",
26519
- subNdcDetails: [
26520
- {
26521
- key: 8,
26522
- ndcActionId: 12,
26523
- type: NdcActionType.sub,
26524
- startDate: new Date("2019-03-25"),
26525
- endDate: new Date("2020-03-25"),
26526
- nationalPlanObj: "",
26527
- kpi: "",
26528
- ministry: "",
26529
- },
26530
- ],
26531
- },
26532
- {
26533
- key: 3,
26534
- type: NdcActionType.main,
26535
- startDate: new Date("2021-03-25"),
26536
- endDate: new Date("2022-03-25"),
26537
- nationalPlanObj: "Consolidate and increase the stock and quality of productive infrastructure by 50%",
26538
- kpi: 48,
26539
- ministry: "Ministry of Environment",
26540
- subNdcDetails: [
26541
- {
26542
- key: 9,
26543
- ndcActionId: 3,
26544
- type: NdcActionType.sub,
26545
- startDate: new Date("2019-03-25"),
26546
- endDate: new Date("2020-03-25"),
26547
- nationalPlanObj: "",
26548
- kpi: "",
26549
- ministry: "",
26550
- },
26551
- ],
26552
- },
26553
- {
26554
- key: 4,
26555
- type: NdcActionType.main,
26556
- startDate: new Date("2022-03-25"),
26557
- endDate: new Date("2022-05-25"),
26558
- nationalPlanObj: "Enhance the productivity and social wellbeing of the population",
26559
- kpi: 20,
26560
- ministry: "Ministry of Environment",
26561
- subNdcDetails: [
26562
- {
26563
- key: 10,
26564
- ndcActionId: 4,
26565
- type: NdcActionType.sub,
26566
- startDate: new Date("2019-03-25"),
26567
- endDate: new Date("2020-03-25"),
26568
- nationalPlanObj: "",
26569
- kpi: "",
26570
- ministry: "",
26571
- },
26572
- ],
26573
- },
26574
- {
26575
- key: 5,
26576
- type: NdcActionType.main,
26577
- startDate: new Date("2022-03-25"),
26578
- endDate: new Date("2023-03-25"),
26579
- nationalPlanObj: "Strengthen the role of the state in guiding and facilitating development",
26580
- kpi: 10,
26581
- ministry: "Ministry of Environment",
26582
- subNdcDetails: [
26583
- {
26584
- key: 11,
26585
- ndcActionId: 5,
26586
- type: NdcActionType.sub,
26587
- startDate: new Date("2019-03-25"),
26588
- endDate: new Date("2020-03-25"),
26589
- nationalPlanObj: "",
26590
- kpi: "",
26591
- ministry: "",
26592
- },
26593
- ],
26594
- },
26595
- {
26596
- key: 13,
26597
- type: NdcActionType.main,
26598
- startDate: new Date("2022-03-25"),
26599
- endDate: new Date("2023-03-25"),
26600
- nationalPlanObj: "Convert to solar energy",
26601
- kpi: 50000,
26602
- ministry: "Ministry of Environment",
26603
- subNdcDetails: [
26604
- {
26605
- key: 11,
26606
- ndcActionId: 13,
26607
- type: NdcActionType.sub,
26608
- startDate: new Date("2019-03-25"),
26609
- endDate: new Date("2020-03-25"),
26610
- nationalPlanObj: "Convert to solar energy",
26611
- kpi: "3000",
26612
- ministry: "Ministry of Agriculture, Water and Forestry (MAWF)",
26613
- },
26614
- {
26615
- key: 14,
26616
- ndcActionId: 13,
26617
- type: NdcActionType.sub,
26618
- startDate: new Date("2019-03-25"),
26619
- endDate: new Date("2020-03-25"),
26620
- nationalPlanObj: "",
26621
- kpi: "",
26622
- ministry: "",
26623
- },
26624
- ],
26625
- },
26626
- {
26627
- key: 15,
26628
- type: NdcActionType.main,
26629
- startDate: new Date("2022-03-25"),
26630
- endDate: new Date("2023-03-25"),
26631
- nationalPlanObj: "Strengthen the private sector to create jobs",
26632
- kpi: 10000,
26633
- ministry: "Ministry of Environment",
26634
- subNdcDetails: [
26635
- {
26636
- key: 16,
26637
- ndcActionId: 15,
26638
- type: NdcActionType.sub,
26639
- startDate: new Date("2019-03-25"),
26640
- endDate: new Date("2020-03-25"),
26641
- nationalPlanObj: "Strengthen the private sector to create jobs",
26642
- kpi: "7200",
26643
- ministry: "Ministry of Tourism (MoT)",
26644
- },
26645
- {
26646
- key: 17,
26647
- ndcActionId: 15,
26648
- type: NdcActionType.sub,
26649
- startDate: new Date("2019-03-25"),
26650
- endDate: new Date("2020-03-25"),
26651
- nationalPlanObj: "",
26652
- kpi: "",
26653
- ministry: "",
26654
- },
26655
- ],
26656
- },
26657
- {
26658
- key: 18,
26659
- type: NdcActionType.main,
26660
- startDate: new Date("2022-03-25"),
26661
- endDate: new Date("2023-03-25"),
26662
- nationalPlanObj: "Other",
26663
- kpi: '',
26664
- ministry: "Ministry of Environment",
26665
- subNdcDetails: [
26666
- {
26667
- key: 19,
26668
- ndcActionId: 18,
26669
- type: NdcActionType.sub,
26670
- startDate: new Date("2019-03-25"),
26671
- endDate: new Date("2020-03-25"),
26672
- nationalPlanObj: "Strengthen the private sector to create jobs",
26673
- kpi: "",
26674
- ministry: "Ministry of Agriculture, Water and Forestry (MAWF)",
26675
- },
26676
- {
26677
- key: 20,
26678
- ndcActionId: 18,
26679
- type: NdcActionType.sub,
26680
- startDate: new Date("2019-03-25"),
26681
- endDate: new Date("2020-03-25"),
26682
- nationalPlanObj: "",
26683
- kpi: "",
26684
- ministry: "",
26685
- },
26686
- ],
26687
- },
26688
- ];
26689
- var initialPeriods = [
26690
- {
26691
- key: "2019-2020",
26692
- label: "2019-2020",
26693
- start: 2019,
26694
- end: 2020,
26695
- children: ndcDetailsTableContent(),
26696
- },
26697
- {
26698
- key: "2021-2023",
26699
- label: "2021-2023",
26700
- start: 2021,
26701
- end: 2021,
26702
- children: ndcDetailsTableContent(),
26703
- },
26704
- ];
26705
- if (isAddRangeVisible()) {
26706
- initialPeriods.unshift({
26707
- key: "add_new",
26708
- label: "Add New",
26709
- start: 0,
26710
- end: 0,
26711
- children: addNewPeriodContent(),
26712
- });
26713
- }
26714
- addedNdcDetailId.current = 20;
26715
- setPeriodItems(initialPeriods);
26716
- periodItemsRef.current = initialPeriods;
26717
- setNdcDetailsData(defaultNdcDetails);
26763
+ fetchNdcDetailPeriods();
26764
+ fetchNdcDetailActions();
26765
+ fetchMinistries();
26718
26766
  }, []);
26719
- return (React.createElement("div", { className: "ndc-management content-container" },
26767
+ return (React.createElement("div", { className: "ndc-details content-container" },
26720
26768
  React.createElement("div", { className: "title-bar" },
26721
26769
  React.createElement(Row, { justify: "space-between", align: "middle" },
26722
26770
  React.createElement(Col, { span: 20 },
26723
26771
  React.createElement("div", { className: "body-title" }, t("ndc:ndcTitle")),
26724
26772
  React.createElement("div", { className: "body-sub-title" }, t("ndc:ndcSubTitle"))))),
26725
26773
  React.createElement("div", null,
26726
- React.createElement(Tabs, { centered: false, defaultActiveKey: "1", items: periodItems, activeKey: selectedTab, onChange: onTabChange })),
26727
- selectedTab !== "add_new" && (React.createElement("div", null,
26728
- React.createElement("div", null,
26729
- React.createElement(Table, { key: tableKey, components: components, rowClassName: function () { return "editable-row"; }, bordered: true, dataSource: getNdcDetailsForPeriod(), columns: columns, expandable: {
26730
- expandedRowRender: function (record) { return getSubNdcActionContent(record); },
26731
- indentSize: 0,
26732
- defaultExpandedRowKeys: [selectedNdcDetail.current.key],
26733
- }, footer: function () {
26734
- return isAddNdcActionVisible() && (React.createElement(Row, { justify: "center" },
26735
- React.createElement(Button, { onClick: onAddNewNdcDetail, type: "default", style: {
26736
- marginBottom: 16,
26737
- width: "100%",
26738
- } }, t("ndc:addNdcAction"))));
26739
- } }))))));
26774
+ React.createElement(Tabs, { centered: false, defaultActiveKey: "1", items: periodItems, activeKey: selectedPeriod.key, onChange: onTabChange })),
26775
+ React.createElement("div", null, selectedPeriod.key === "add_new"
26776
+ ? addNewPeriodContent()
26777
+ : mainNdcActionTableContent()),
26778
+ React.createElement(UserActionConfirmationModel, { t: t, actionInfo: actionInfo, onActionConfirmed: onActionConfirmed, onActionCanceled: onActionCanceled, openModal: openConfirmationModal, errorMsg: "", loading: loading })));
26740
26779
  };
26741
26780
 
26742
26781
  var ImgWithFallback = function (_a) {
@@ -28338,5 +28377,5 @@ var TimelineBody = function (props) {
28338
28377
  React.createElement("div", { className: "remark-body" }, remark)))));
28339
28378
  };
28340
28379
 
28341
- export { Action, AddNdcActionComponent, AddNewCompanyComponent, AddNewUserComponent, AdminBGColor, AdminColor, BaseEntity, CarbonSystemType, CertBGColor, CertColor, CoBenifitsComponent, Company, CompanyManagementColumns, CompanyManagementComponent, CompanyProfileComponent, CompanyRole, CompanyState, ConfigurationSettingsType, CreditTransferComponent, CreditTransferStage, DevBGColor, DevColor, DocType, DocumentStatus, ESGType, EnergyGenerationUnits, FormElementType, GovBGColor, GovColor, ImgWithFallback, InfoView, Instrument, InvestmentBGColor, InvestmentBody, InvestmentColor, InvestmentCreationComponent, InvestmentCreationType, InvestmentLevel, InvestmentManagementComponent, InvestmentStatus, InvestmentStream, InvestmentType, LandAreaUnits, LegendItem, Loading, ManagerBGColor, ManagerColor, MapComponent, MapTypes, MapboxComponent, MinBGColor, MinColor, MitigationSubTypes, MitigationTypes, MrvDashboardComponent, MrvStatsCardsTypes, NdcActionBody, NdcActionManagementComponent, NdcActionStatus, NdcActionTypes, NdcActionViewComponent, NdcDetailsComponent, OrganisationStatus, ProfileIcon, ProgrammeCertify, ProgrammeCreationComponent, ProgrammeDocuments, ProgrammeEntity, ProgrammeIssueForm, ProgrammeManagementColumns, ProgrammeManagementComponent, ProgrammeRetireForm, ProgrammeRevokeForm, ProgrammeStageLegend, ProgrammeStageMRV, ProgrammeStageR, ProgrammeStageUnified, ProgrammeTransfer, ProgrammeTransferForm, RadioButtonStatus, RadioButtonStatus2, RegistryDashboardComponent, RejectDocumentationConfirmationModel, RetireType, Role, RoleIcon, RootBGColor, RootColor, SdgGoals$1 as SdgGoals, Sector, SectoralScope, StasticCard, StatsCardsTypes, SubTypeOfMitigation, SupportCreationComponent, SupportManagementComponent, SystemNames, TimelineBody, Titles, TooltipColor, TransferActionModel, TxType, TypeOfMitigation, UnitField, User, UserManagementColumns, UserManagementComponent, UserProfileComponent, UserRoleIcon, ViewBGColor, ViewColor, WidgetType, addCommSep, addCommSepRound, addNdcDesc, addRoundNumber, addSpaces, consumerGroupList, creditUnit, dateFormat, dateTimeFormat, energyGenerationUnitList, getBase64, getCompanyBgColor, getCreditStageVal, getFinancialFields, getGeneralFields, getInvestmentStatusEnumVal, getNdcActionStatusEnumVal, getNdcStatusTagType, getRetirementTypeString, getStageEnumVal, getStageTagType, getStageTagTypeMRV, getStageTransferEnumVal, getStatusTagType, getTransferStageTagType, getValidNdcActions, isBase64, landAreaUnitList, methodologyOptions, mitigationSubTypeList, mitigationSubTypesListMapped, mitigationTypeList, ndcActionTypeList, sectorMitigationTypesListMapped, sumArray, titleList };
28380
+ export { Action, AddNdcActionComponent, AddNewCompanyComponent, AddNewUserComponent, AdminBGColor, AdminColor, BaseEntity, CarbonSystemType, CertBGColor, CertColor, CoBenifitsComponent, Company, CompanyManagementColumns, CompanyManagementComponent, CompanyProfileComponent, CompanyRole, CompanyState, ConfigurationSettingsType, CreditTransferComponent, CreditTransferStage, DevBGColor, DevColor, DocType, DocumentStatus, ESGType, EnergyGenerationUnits, FormElementType, GovBGColor, GovColor, ImgWithFallback, InfoView, Instrument, InvestmentBGColor, InvestmentBody, InvestmentColor, InvestmentCreationComponent, InvestmentCreationType, InvestmentLevel, InvestmentManagementComponent, InvestmentStatus, InvestmentStream, InvestmentType, LandAreaUnits, LegendItem, Loading, ManagerBGColor, ManagerColor, MapComponent, MapTypes, MapboxComponent, MinBGColor, MinColor, MitigationSubTypes, MitigationTypes, MrvDashboardComponent, MrvStatsCardsTypes, NdcActionBody, NdcActionManagementComponent, NdcActionStatus, NdcActionTypes, NdcActionViewComponent, NdcDetailsComponent, OrganisationStatus, ProfileIcon, ProgrammeCertify, ProgrammeCreationComponent, ProgrammeDocuments, ProgrammeEntity, ProgrammeIssueForm, ProgrammeManagementColumns, ProgrammeManagementComponent, ProgrammeRetireForm, ProgrammeRevokeForm, ProgrammeStageLegend, ProgrammeStageMRV, ProgrammeStageR, ProgrammeStageUnified, ProgrammeTransfer, ProgrammeTransferForm, RadioButtonStatus, RadioButtonStatus2, RegistryDashboardComponent, RejectDocumentationConfirmationModel, RetireType, Role, RoleIcon, RootBGColor, RootColor, SdgGoals$1 as SdgGoals, Sector, SectoralScope, StasticCard, StatsCardsTypes, SubTypeOfMitigation, SupportCreationComponent, SupportManagementComponent, SystemNames, TimelineBody, Titles, TooltipColor, TransferActionModel, TxType, TypeOfMitigation, UnitField, User, UserManagementColumns, UserManagementComponent, UserProfileComponent, UserRoleIcon, ViewBGColor, ViewColor, WidgetType, addCommSep, addCommSepRound, addNdcDesc, addRoundNumber, addSpaces, consumerGroupList, creditUnit, dateFormat, dateTimeFormat, energyGenerationUnitList, getBase64, getCompanyBgColor, getCreditStageVal, getFinancialFields, getGeneralFields, getInvestmentStatusEnumVal, getNdcActionStatusEnumVal$1 as getNdcActionStatusEnumVal, getNdcStatusTagType, getRetirementTypeString, getStageEnumVal, getStageTagType, getStageTagTypeMRV, getStageTransferEnumVal, getStatusTagType, getTransferStageTagType, getValidNdcActions, isBase64, landAreaUnitList, methodologyOptions, mitigationSubTypeList, mitigationSubTypesListMapped, mitigationTypeList, ndcActionTypeList, sectorMitigationTypesListMapped, sumArray, titleList };
28342
28381
  //# sourceMappingURL=index.js.map