@undp/carbon-library 1.0.175-CARBON-339.0 → 1.0.175-CARBON-363.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. package/dist/cjs/index.js +508 -539
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/types/Components/Common/AntComponents/antTableComponents.d.ts +7 -6
  4. package/dist/cjs/types/Definitions/Definitions/ndcDetails.definitions.d.ts +42 -0
  5. package/dist/esm/index.js +510 -541
  6. package/dist/esm/index.js.map +1 -1
  7. package/dist/esm/types/Components/Common/AntComponents/antTableComponents.d.ts +7 -6
  8. package/dist/esm/types/Definitions/Definitions/ndcDetails.definitions.d.ts +42 -0
  9. package/package.json +1 -3
  10. package/dist/locales/i18n/addCompany/en.json +0 -38
  11. package/dist/locales/i18n/addCompany/es.json +0 -36
  12. package/dist/locales/i18n/addCompany/fr.json +0 -36
  13. package/dist/locales/i18n/addProgramme/en.json +0 -45
  14. package/dist/locales/i18n/addUser/en.json +0 -24
  15. package/dist/locales/i18n/addUser/es.json +0 -24
  16. package/dist/locales/i18n/addUser/fr.json +0 -24
  17. package/dist/locales/i18n/coBenifits/en.json +0 -39
  18. package/dist/locales/i18n/common/en.json +0 -22
  19. package/dist/locales/i18n/common/es.json +0 -21
  20. package/dist/locales/i18n/common/fr.json +0 -21
  21. package/dist/locales/i18n/company/en.json +0 -23
  22. package/dist/locales/i18n/company/es.json +0 -23
  23. package/dist/locales/i18n/company/fr.json +0 -23
  24. package/dist/locales/i18n/companyProfile/en.json +0 -44
  25. package/dist/locales/i18n/companyProfile/es.json +0 -42
  26. package/dist/locales/i18n/companyProfile/fr.json +0 -42
  27. package/dist/locales/i18n/creditTransfer/en.json +0 -34
  28. package/dist/locales/i18n/creditTransfer/es.json +0 -34
  29. package/dist/locales/i18n/creditTransfer/fr.json +0 -34
  30. package/dist/locales/i18n/dashboard/en.json +0 -94
  31. package/dist/locales/i18n/dashboard/es.json +0 -71
  32. package/dist/locales/i18n/dashboard/fr.json +0 -71
  33. package/dist/locales/i18n/economic/en.json +0 -35
  34. package/dist/locales/i18n/environment/en.json +0 -41
  35. package/dist/locales/i18n/forgotPassword/en.json +0 -9
  36. package/dist/locales/i18n/forgotPassword/es.json +0 -9
  37. package/dist/locales/i18n/forgotPassword/fr.json +0 -9
  38. package/dist/locales/i18n/genderParity/en.json +0 -14
  39. package/dist/locales/i18n/homepage/en.json +0 -33
  40. package/dist/locales/i18n/homepage/es.json +0 -30
  41. package/dist/locales/i18n/homepage/fr.json +0 -30
  42. package/dist/locales/i18n/login/en.json +0 -11
  43. package/dist/locales/i18n/login/es.json +0 -10
  44. package/dist/locales/i18n/login/fr.json +0 -10
  45. package/dist/locales/i18n/mrvdashboard/en.json +0 -29
  46. package/dist/locales/i18n/mrvdashboard/es.json +0 -0
  47. package/dist/locales/i18n/mrvdashboard/fr.json +0 -0
  48. package/dist/locales/i18n/nav/en.json +0 -15
  49. package/dist/locales/i18n/nav/es.json +0 -9
  50. package/dist/locales/i18n/nav/fr.json +0 -9
  51. package/dist/locales/i18n/ndc/en.json +0 -12
  52. package/dist/locales/i18n/ndcAction/en.json +0 -89
  53. package/dist/locales/i18n/passwordReset/en.json +0 -10
  54. package/dist/locales/i18n/passwordReset/es.json +0 -10
  55. package/dist/locales/i18n/passwordReset/fr.json +0 -10
  56. package/dist/locales/i18n/programme/en.json +0 -87
  57. package/dist/locales/i18n/programme/es.json +0 -17
  58. package/dist/locales/i18n/programme/fr.json +0 -17
  59. package/dist/locales/i18n/resetPassword/en.json +0 -8
  60. package/dist/locales/i18n/resetPassword/es.json +0 -8
  61. package/dist/locales/i18n/resetPassword/fr.json +0 -8
  62. package/dist/locales/i18n/safeguards/en.json +0 -73
  63. package/dist/locales/i18n/social/en.json +0 -41
  64. package/dist/locales/i18n/user/en.json +0 -16
  65. package/dist/locales/i18n/user/es.json +0 -16
  66. package/dist/locales/i18n/user/fr.json +0 -16
  67. package/dist/locales/i18n/userProfile/en.json +0 -34
  68. package/dist/locales/i18n/userProfile/es.json +0 -34
  69. package/dist/locales/i18n/userProfile/fr.json +0 -34
  70. package/dist/locales/i18n/view/en.json +0 -144
  71. package/dist/locales/i18n/view/es.json +0 -128
  72. package/dist/locales/i18n/view/fr.json +0 -128
package/dist/cjs/index.js CHANGED
@@ -2047,7 +2047,7 @@ exports.NdcActionStatus = void 0;
2047
2047
  NdcActionStatus["PENDING"] = "Pending";
2048
2048
  NdcActionStatus["APPROVED"] = "Approved";
2049
2049
  })(exports.NdcActionStatus || (exports.NdcActionStatus = {}));
2050
- var getNdcActionStatusEnumVal = function (value) {
2050
+ var getNdcActionStatusEnumVal$1 = function (value) {
2051
2051
  var index = Object.keys(exports.NdcActionStatus).indexOf(value);
2052
2052
  if (index < 0) {
2053
2053
  return value;
@@ -2055,7 +2055,7 @@ var getNdcActionStatusEnumVal = function (value) {
2055
2055
  return Object.values(exports.NdcActionStatus)[index];
2056
2056
  };
2057
2057
  var getNdcStatusTagType = function (status) {
2058
- switch (getNdcActionStatusEnumVal(status)) {
2058
+ switch (getNdcActionStatusEnumVal$1(status)) {
2059
2059
  case exports.NdcActionStatus.PENDING:
2060
2060
  return "processing";
2061
2061
  case exports.NdcActionStatus.APPROVED:
@@ -26143,598 +26143,576 @@ var RegistryDashboardComponent = function (props) {
26143
26143
  lastUpdateTransferLocations))))))))) : ("")));
26144
26144
  };
26145
26145
 
26146
- var EditableContext = React.createContext(null);
26147
- var EditableRow = function (_a) {
26148
- _a.index; var props = __rest(_a, ["index"]);
26149
- var form = antd.Form.useForm()[0];
26150
- return (React.createElement(antd.Form, { form: form, component: false },
26151
- React.createElement(EditableContext.Provider, { value: form },
26152
- React.createElement("tr", __assign({}, props)))));
26153
- };
26146
+ React.createContext(null);
26154
26147
  var EditableCell = function (_a) {
26155
- 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"]);
26156
- var _b = React.useState(false), editing = _b[0], setEditing = _b[1];
26157
- var inputRef = React.useRef(null);
26158
- var form = React.useContext(EditableContext);
26159
- React.useEffect(function () {
26160
- if (editing) {
26161
- inputRef.current.focus();
26162
- }
26163
- }, [editing]);
26164
- var toggleEdit = function () {
26165
- var _a;
26166
- setEditing(!editing);
26167
- form.setFieldsValue((_a = {}, _a[dataIndex] = record[dataIndex], _a));
26168
- };
26169
- var save = function () { return __awaiter(void 0, void 0, void 0, function () {
26170
- var values, errInfo_1;
26171
- return __generator(this, function (_a) {
26172
- switch (_a.label) {
26173
- case 0:
26174
- _a.trys.push([0, 2, , 3]);
26175
- return [4 /*yield*/, form.validateFields()];
26176
- case 1:
26177
- values = _a.sent();
26178
- toggleEdit();
26179
- handleSave(__assign(__assign({}, record), values));
26180
- return [3 /*break*/, 3];
26181
- case 2:
26182
- errInfo_1 = _a.sent();
26183
- console.log("Save failed:", errInfo_1);
26184
- return [3 /*break*/, 3];
26185
- case 3: return [2 /*return*/];
26186
- }
26187
- });
26188
- }); };
26189
- var childNode = children;
26190
- if (editable) {
26191
- childNode = editing ? (React.createElement(antd.Form.Item, { style: { margin: 0 }, name: dataIndex, rules: [
26192
- {
26193
- required: true,
26194
- message: "".concat(title, " is required."),
26195
- },
26196
- ] },
26197
- React.createElement(antd.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));
26148
+ var editing = _a.editing, dataIndex = _a.dataIndex, title = _a.title; _a.inputType; _a.record; _a.index; var children = _a.children, restProps = __rest(_a, ["editing", "dataIndex", "title", "inputType", "record", "index", "children"]);
26149
+ var inputNode;
26150
+ if (dataIndex === "nationalPlanObjective") {
26151
+ inputNode = React.createElement(antd.Input, { placeholder: "Enter National Plan Objective" });
26198
26152
  }
26199
- return React.createElement("td", __assign({}, restProps), childNode);
26153
+ else if (dataIndex === "kpi") {
26154
+ inputNode = React.createElement(antd.InputNumber, { placeholder: "Enter Kpi" });
26155
+ }
26156
+ return (React.createElement("td", __assign({}, restProps), editing ? (React.createElement(antd.Form.Item, { name: dataIndex, style: { margin: 0 }, rules: [
26157
+ {
26158
+ required: true,
26159
+ message: "Please Input ".concat(title, "!"),
26160
+ },
26161
+ ] }, inputNode)) : (children)));
26200
26162
  };
26201
26163
 
26202
26164
  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";
26203
26165
  styleInject(css_248z$4);
26204
26166
 
26205
- var NdcActionType;
26206
- (function (NdcActionType) {
26207
- NdcActionType[NdcActionType["main"] = 0] = "main";
26208
- NdcActionType[NdcActionType["sub"] = 1] = "sub";
26209
- })(NdcActionType || (NdcActionType = {}));
26167
+ var NdcDetailsActionType;
26168
+ (function (NdcDetailsActionType) {
26169
+ NdcDetailsActionType["MainAction"] = "MainAction";
26170
+ NdcDetailsActionType["SubAction"] = "SubAction";
26171
+ })(NdcDetailsActionType || (NdcDetailsActionType = {}));
26172
+ var NdcDetailsActionStatus;
26173
+ (function (NdcDetailsActionStatus) {
26174
+ NdcDetailsActionStatus["New"] = "New";
26175
+ NdcDetailsActionStatus["Pending"] = "Pending";
26176
+ NdcDetailsActionStatus["Approved"] = "Approved";
26177
+ NdcDetailsActionStatus["Rejected"] = "Rejected";
26178
+ })(NdcDetailsActionStatus || (NdcDetailsActionStatus = {}));
26179
+ var getNdcActionStatusEnumVal = function (value) {
26180
+ var index = Object.keys(NdcDetailsActionStatus).indexOf(value);
26181
+ if (index < 0) {
26182
+ return value;
26183
+ }
26184
+ return Object.values(NdcDetailsActionStatus)[index];
26185
+ };
26186
+ var getNdcActionStatusTagType = function (status) {
26187
+ switch (getNdcActionStatusEnumVal(status)) {
26188
+ case NdcDetailsActionStatus.Rejected:
26189
+ return "error";
26190
+ case NdcDetailsActionStatus.Pending:
26191
+ return "processing";
26192
+ case NdcDetailsActionStatus.Approved:
26193
+ return "success";
26194
+ default:
26195
+ return "default";
26196
+ }
26197
+ };
26198
+
26210
26199
  var NdcDetailsComponent = function (props) {
26211
- var t = props.t; props.useConnection; var useUserContext = props.useUserContext;
26200
+ var t = props.t, useConnection = props.useConnection, useUserContext = props.useUserContext;
26212
26201
  var RangePicker = antd.DatePicker.RangePicker;
26213
26202
  var _a = React.useState([]), ndcDetailsData = _a[0], setNdcDetailsData = _a[1];
26214
26203
  var _b = React.useState(false), loading = _b[0]; _b[1];
26215
- var periodItemsRef = React.useRef([]);
26216
26204
  var _c = React.useState([]), periodItems = _c[0], setPeriodItems = _c[1];
26217
- var _d = React.useState("add_new"), selectedTab = _d[0], setSelectedTab = _d[1];
26218
- var selectedPeriod = React.useRef({});
26219
- var addedNdcDetailId = React.useRef(0);
26205
+ var _d = React.useState({}), selectedPeriod = _d[0], setSelectedPeriod = _d[1];
26206
+ var selectedDateRangeRef = React.useRef({});
26220
26207
  var selectedNdcDetail = React.useRef({});
26221
26208
  var _e = React.useState(0), tableKey = _e[0], setTableKey = _e[1];
26209
+ var _f = useConnection(), get = _f.get, post = _f.post, put = _f.put;
26210
+ var _g = React.useState([]), ministryOrgList = _g[0], setMinistryOrgList = _g[1];
26211
+ var _h = React.useState({}), actionInfo = _h[0], setActionInfo = _h[1];
26212
+ var _j = React.useState(false), openConfirmationModal = _j[0], setOpenConfirmationModal = _j[1];
26213
+ var form = antd.Form.useForm()[0];
26214
+ var _k = React.useState(-1), editingKey = _k[0], setEditingKey = _k[1];
26215
+ var _l = React.useState(0), nextAvailableActionId = _l[0], setNextAvailableActionId = _l[1];
26216
+ var _m = React.useState([]), expandedRowKeys = _m[0], setExpandedRowKeys = _m[1];
26217
+ var _o = React.useState([]), subNdcDetailsForPeriod = _o[0], setSubNdcDetailsForPeriod = _o[1];
26218
+ var isEditing = function (record) { return record.id === editingKey; };
26222
26219
  var userInfoState = useUserContext().userInfoState;
26223
- var isAddRangeVisible = function () {
26224
- return (((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.MINISTRY ||
26225
- (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.GOVERNMENT) &&
26226
- (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== exports.Role.ViewOnly);
26227
- };
26228
- var isAddNdcActionVisible = function () {
26229
- return ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.GOVERNMENT &&
26220
+ var loginMinistry = (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.GOVERNMENT
26221
+ ? process.env.REACT_APP_GOVERNMENT_MINISTRY
26222
+ ? process.env.REACT_APP_GOVERNMENT_MINISTRY
26223
+ : "Test ministryName"
26224
+ : (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.MINISTRY
26225
+ ? userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyName
26226
+ : undefined;
26227
+ var isGovernmentUser = (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.GOVERNMENT &&
26228
+ (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== exports.Role.ViewOnly;
26229
+ var ndcMainDetailsForPeriod = selectedPeriod.key !== "add_new"
26230
+ ? ndcDetailsData.filter(function (ndcDetail) {
26231
+ return (ndcDetail.periodId === parseInt(selectedPeriod.key) &&
26232
+ ndcDetail.actionType === NdcDetailsActionType.MainAction);
26233
+ })
26234
+ : [];
26235
+ var isMainNdcActionsEditable = !selectedPeriod.finalized &&
26236
+ (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.GOVERNMENT &&
26237
+ (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== exports.Role.ViewOnly;
26238
+ var isSubNdcActionsEditable = function (record) {
26239
+ return (!selectedPeriod.finalized &&
26240
+ record.status !== NdcDetailsActionStatus.Approved &&
26241
+ ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.GOVERNMENT ||
26242
+ ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.MINISTRY &&
26243
+ (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyName) === record.ministryName)) &&
26230
26244
  (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== exports.Role.ViewOnly);
26231
26245
  };
26232
26246
  var inRange = function (num, min, max) {
26233
26247
  return num >= min && num <= max;
26234
26248
  };
26235
- function onAddNewSubNdcDetail() {
26236
- var range = selectedTab.split('-');
26237
- var ndcDetail = ndcDetailsData.find(function (item) { return item.key === selectedNdcDetail.current.key; });
26238
- var ndcDetailItemIndex = ndcDetailsData.findIndex(function (item) { return item.key === selectedNdcDetail.current.key; });
26239
- if (ndcDetail) {
26240
- addedNdcDetailId.current = addedNdcDetailId.current + 1;
26241
- var newData = {
26242
- key: addedNdcDetailId.current,
26243
- startDate: new Date("".concat(Number(range[0]), "-01-24 23:12:00")),
26244
- endDate: new Date("".concat(Number(range[0]), "-12-24 23:12:00")),
26245
- ndcActionId: ndcDetail === null || ndcDetail === void 0 ? void 0 : ndcDetail.key,
26246
- nationalPlanObj: '',
26247
- kpi: '',
26248
- ministry: '',
26249
- };
26250
- if (!ndcDetail.subNdcDetails) {
26251
- ndcDetail.subNdcDetails = [];
26252
- }
26253
- ndcDetail.subNdcDetails.push(newData);
26254
- }
26255
- ndcDetailsData[ndcDetailItemIndex] = ndcDetail;
26256
- setNdcDetailsData(ndcDetailsData);
26257
- setTableKey(function (key) { return key + 1; });
26258
- }
26259
- var handleSave = function (row) {
26260
- setNdcDetailsData(function (prevData) {
26261
- var newData = JSON.parse(JSON.stringify(prevData));
26262
- if (row.type === NdcActionType.main) {
26263
- var index = newData.findIndex(function (item) { return row.key === item.key; });
26264
- if (index !== -1) {
26265
- newData[index] = __assign(__assign({}, newData[index]), row);
26266
- }
26267
- }
26268
- else {
26269
- var parentIndex = newData.findIndex(function (item) { return row.ndcActionId === item.key; });
26270
- var parentItem = newData[parentIndex];
26271
- if (parentItem) {
26272
- if (parentItem.subNdcDetails) {
26273
- var itemIndex = parentItem.subNdcDetails.findIndex(function (item) { return row.key === item.key; });
26274
- if (itemIndex === -1) {
26275
- parentItem.subNdcDetails.push(row);
26276
- }
26277
- else {
26278
- parentItem.subNdcDetails[itemIndex] = __assign({}, row);
26279
- }
26280
- }
26281
- else {
26282
- parentItem.subNdcDetails = [row];
26283
- }
26284
- }
26285
- newData[parentIndex] = __assign({}, parentItem);
26286
- setTableKey(function (key) { return key + 1; });
26249
+ var handleSave = function (row) { return __awaiter(void 0, void 0, void 0, function () {
26250
+ var updatedFields, updatedItem, exception_1;
26251
+ return __generator(this, function (_a) {
26252
+ switch (_a.label) {
26253
+ case 0:
26254
+ _a.trys.push([0, 6, , 7]);
26255
+ return [4 /*yield*/, form.validateFields()];
26256
+ case 1:
26257
+ updatedFields = (_a.sent());
26258
+ updatedItem = __assign(__assign({}, row), updatedFields);
26259
+ if (!(updatedItem.status === NdcDetailsActionStatus.New)) return [3 /*break*/, 3];
26260
+ updatedItem.status = NdcDetailsActionStatus.Pending;
26261
+ return [4 /*yield*/, post("national/programme/addNdcDetailsAction", __assign(__assign({}, updatedItem), { kpi: parseInt(updatedItem.kpi) }))];
26262
+ case 2:
26263
+ _a.sent();
26264
+ return [3 /*break*/, 5];
26265
+ case 3:
26266
+ updatedItem.status = NdcDetailsActionStatus.Pending;
26267
+ return [4 /*yield*/, put("national/programme/updateNdcDetailsAction", __assign(__assign({}, updatedItem), { kpi: parseInt(updatedItem.kpi) }))];
26268
+ case 4:
26269
+ _a.sent();
26270
+ _a.label = 5;
26271
+ case 5:
26272
+ fetchNdcDetailActions();
26273
+ setEditingKey(-1);
26274
+ return [3 /*break*/, 7];
26275
+ case 6:
26276
+ exception_1 = _a.sent();
26277
+ console.log("error", exception_1);
26278
+ return [3 /*break*/, 7];
26279
+ case 7: return [2 /*return*/];
26287
26280
  }
26288
- return newData;
26289
26281
  });
26290
- };
26291
- var getNdcDetailsForPeriod = function () {
26292
- var range = selectedTab.split("-");
26293
- if (range.length > 1) {
26294
- var filteredData = ndcDetailsData.filter(function (item) {
26295
- return inRange(Number(moment(item.startDate).year()), Number(range[0]), Number(range[1]));
26296
- });
26297
- return filteredData;
26298
- }
26299
- else {
26300
- return [];
26301
- }
26302
- };
26303
- var getSubNdcDetails = function (key) {
26304
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
26305
- var ndcDetail = ndcDetailsData.find(function (item) { return item.key === key; });
26306
- if (ndcDetail) {
26307
- 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()) !== '' &&
26308
- ((_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) &&
26309
- ((_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()) !==
26310
- '' &&
26311
- ((_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) &&
26312
- 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() !== '' &&
26313
- 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)) {
26314
- onAddNewSubNdcDetail();
26315
- }
26316
- return ndcDetail.subNdcDetails;
26282
+ }); };
26283
+ var actionMenu = function (record) {
26284
+ if (record.status === NdcDetailsActionStatus.Pending && isGovernmentUser) {
26285
+ return (React.createElement(antd.List, { className: "action-menu", size: "small", dataSource: [
26286
+ {
26287
+ text: t("ndc:approve"),
26288
+ icon: React.createElement(Icon__namespace.BoxArrowInDown, null),
26289
+ click: function () {
26290
+ setActionInfo({
26291
+ action: "Approve",
26292
+ headerText: t("ndc:actionApproveTitle"),
26293
+ type: "primary",
26294
+ icon: React.createElement(Icon__namespace.BoxArrowInDown, null),
26295
+ recordId: record.id,
26296
+ });
26297
+ setOpenConfirmationModal(true);
26298
+ },
26299
+ },
26300
+ {
26301
+ text: t("ndc:reject"),
26302
+ icon: React.createElement(Icon__namespace.XOctagon, null),
26303
+ click: function () {
26304
+ setActionInfo({
26305
+ action: "Reject",
26306
+ headerText: t("ndc:rejectApproveTitle"),
26307
+ type: "danger",
26308
+ icon: React.createElement(Icon__namespace.BoxArrowInDown, null),
26309
+ recordId: record.id,
26310
+ });
26311
+ setOpenConfirmationModal(true);
26312
+ },
26313
+ },
26314
+ ], renderItem: function (item) { return (React.createElement(antd.List.Item, { onClick: item.click },
26315
+ React.createElement(antd.Typography.Text, { className: "action-icon color-error" }, item.icon),
26316
+ React.createElement("span", null, item.text))); } }));
26317
26317
  }
26318
26318
  else {
26319
- return [];
26319
+ return null;
26320
26320
  }
26321
26321
  };
26322
26322
  var defaultColumns = [
26323
26323
  {
26324
26324
  title: t("ndc:ndcColumnsNationalPlanObj"),
26325
- dataIndex: "nationalPlanObj",
26326
- key: "nationalPlanObj",
26325
+ dataIndex: "nationalPlanObjective",
26326
+ key: "nationalPlanObjective",
26327
26327
  align: "left",
26328
+ width: "40%",
26328
26329
  editable: true,
26329
- width: "50%",
26330
- render: function (_, record) { return (React.createElement(React.Fragment, null, record.nationalPlanObj ? (React.createElement(antd.Space, { size: "middle" },
26331
- React.createElement("span", null, record.nationalPlanObj))) : (React.createElement("input", { placeholder: "Please add the National Plan Objective", className: "ant-input", type: "text" })))); },
26332
26330
  },
26333
26331
  {
26334
26332
  title: t("ndc:ndcColumnsKpi"),
26335
26333
  dataIndex: "kpi",
26336
26334
  key: "kpi",
26337
26335
  align: "left",
26336
+ width: "15%",
26338
26337
  editable: true,
26339
- width: "10%",
26340
- render: function (_, record) { return (React.createElement(React.Fragment, null, record.nationalPlanObj ? (React.createElement(antd.Space, { size: "middle" },
26341
- React.createElement("span", null, record.kpi))) : (React.createElement("input", { placeholder: "Enter Kpi", className: "ant-input", type: "text" })))); },
26342
26338
  },
26343
26339
  {
26344
- title: "Ministry",
26345
- dataIndex: "ministry",
26346
- key: "ministry",
26340
+ title: t("ndc:ndcColumnsMinistry"),
26341
+ dataIndex: "ministryName",
26342
+ key: "ministryName",
26347
26343
  align: "left",
26348
- editable: true,
26349
- width: "40%",
26350
- render: function (_, record) { return (React.createElement(React.Fragment, null, record.nationalPlanObj ? (React.createElement(antd.Space, { size: "middle" },
26351
- React.createElement("span", null, record.ministry))) : (React.createElement("input", { placeholder: "Please add the Ministry name", className: "ant-input", type: "text" })))); },
26344
+ width: "30%",
26345
+ editable: false,
26346
+ render: function (_, record) { return (React.createElement(React.Fragment, null,
26347
+ React.createElement(antd.Select, { disabled: !(isSubNdcActionsEditable(record) && isEditing(record)), defaultValue: record.ministryName ? record.ministryName : loginMinistry, style: { width: 320 }, onChange: function (value, option) {
26348
+ record.ministryName = option.label;
26349
+ handleSave(record);
26350
+ }, options: ministryOrgList }))); },
26351
+ },
26352
+ {
26353
+ title: t("ndc:ndcColumnsStatus"),
26354
+ dataIndex: "status",
26355
+ key: "status",
26356
+ align: "left",
26357
+ width: "15%",
26358
+ editable: false,
26359
+ render: function (_, record) {
26360
+ var menu = actionMenu(record);
26361
+ return (React.createElement(React.Fragment, null,
26362
+ record.actionType === NdcDetailsActionType.SubAction &&
26363
+ record.status !== NdcDetailsActionStatus.New ? (React.createElement(antd.Tooltip, { title: record.status, color: TooltipColor, key: TooltipColor },
26364
+ React.createElement(antd.Tag, { className: "clickable", color: getNdcActionStatusTagType(record.status) }, addSpaces(record.status)))) : (""),
26365
+ record.actionType === NdcDetailsActionType.SubAction && menu ? (React.createElement(antd.Popover, { placement: "bottomRight", content: menu, trigger: "click" },
26366
+ React.createElement(icons.EllipsisOutlined, { rotate: 90, style: {
26367
+ fontWeight: 600,
26368
+ fontSize: "1rem",
26369
+ cursor: "pointer",
26370
+ } }))) : (React.createElement("span", null))));
26371
+ },
26352
26372
  },
26353
26373
  ];
26354
26374
  var columns = defaultColumns.map(function (col) {
26355
26375
  if (!col.editable) {
26356
26376
  return col;
26357
26377
  }
26358
- return __assign(__assign({}, col), { onCell: function (record) { return ({
26359
- record: record,
26360
- editable: col.editable,
26361
- dataIndex: col.dataIndex,
26362
- title: col.title,
26363
- handleSave: handleSave,
26364
- }); } });
26378
+ return __assign(__assign({}, col), { onCell: function (record) {
26379
+ return {
26380
+ record: record,
26381
+ editing: isEditing(record),
26382
+ dataIndex: col.dataIndex,
26383
+ title: col.title,
26384
+ };
26385
+ } });
26365
26386
  });
26366
- function onAddNewNdcDetail() {
26367
- var range = selectedTab.split("-");
26368
- var ndcActionId = ++addedNdcDetailId.current;
26369
- var newData = {
26370
- key: ndcActionId,
26371
- type: NdcActionType.main,
26372
- startDate: new Date("".concat(Number(range[0]), "-01-24 23:12:00")),
26373
- endDate: new Date("".concat(Number(range[0]), "-12-24 23:12:00")),
26374
- nationalPlanObj: "",
26375
- kpi: "",
26376
- ministry: "",
26377
- subNdcDetails: [
26378
- {
26379
- key: ++addedNdcDetailId.current,
26380
- ndcActionId: ndcActionId,
26381
- type: NdcActionType.sub,
26382
- startDate: new Date("2019-03-25"),
26383
- endDate: new Date("2020-03-25"),
26384
- nationalPlanObj: "",
26385
- kpi: "",
26386
- ministry: "",
26387
- },
26388
- ],
26389
- };
26390
- setNdcDetailsData(__spreadArray(__spreadArray([], ndcDetailsData, true), [newData], false));
26387
+ function onClickedAddNewNdcDetail() {
26388
+ return __awaiter(this, void 0, void 0, function () {
26389
+ var periodId, newData_1;
26390
+ return __generator(this, function (_a) {
26391
+ if (selectedPeriod.key !== "add_new") {
26392
+ form.setFieldsValue({
26393
+ nationalPlanObjective: "",
26394
+ kpi: "",
26395
+ });
26396
+ periodId = parseInt(selectedPeriod.key);
26397
+ newData_1 = {
26398
+ id: nextAvailableActionId,
26399
+ actionType: NdcDetailsActionType.MainAction,
26400
+ nationalPlanObjective: "",
26401
+ kpi: "",
26402
+ ministryName: loginMinistry,
26403
+ periodId: periodId,
26404
+ status: NdcDetailsActionStatus.New,
26405
+ };
26406
+ setEditingKey(nextAvailableActionId);
26407
+ setNextAvailableActionId(function (value) { return value + 1; });
26408
+ setNdcDetailsData(function (ndcDetailsData) { return __spreadArray(__spreadArray([], ndcDetailsData, true), [
26409
+ newData_1,
26410
+ ], false); });
26411
+ setTableKey(function (key) { return key + 1; });
26412
+ }
26413
+ return [2 /*return*/];
26414
+ });
26415
+ });
26391
26416
  }
26392
26417
  var components = {
26393
26418
  body: {
26394
- row: EditableRow,
26395
26419
  cell: EditableCell,
26396
26420
  },
26397
26421
  };
26398
- //commented because rendering issue
26399
- function ndcDetailsTableContent() {
26400
- return (React.createElement("div", null)
26401
- // <div>
26402
- // <Button
26403
- // onClick={onAddNewNdcDetail}
26404
- // type="primary"
26405
- // style={{
26406
- // marginBottom: 16,
26407
- // }}
26408
- // >
26409
- // Add a row
26410
- // </Button>
26411
- // <Table
26412
- // components={components}
26413
- // rowClassName={() => 'editable-row'}
26414
- // bordered
26415
- // dataSource={ndcDetailsData}
26416
- // columns={columns}
26417
- // />
26418
- // </div>
26419
- );
26420
- }
26421
- var onCancelPeriod = function () { };
26422
- var onAddNewPeriod = function () {
26423
- if (selectedPeriod && selectedPeriod.current) {
26424
- var newPeriodItem_1 = {
26425
- key: "".concat(selectedPeriod.current.start, "-").concat(selectedPeriod.current.end),
26426
- label: "".concat(selectedPeriod.current.start, "-").concat(selectedPeriod.current.end),
26427
- start: selectedPeriod.current.start,
26428
- end: selectedPeriod.current.end,
26429
- children: ndcDetailsTableContent(),
26430
- };
26431
- var existingIndex = periodItemsRef.current.findIndex(function (item) {
26432
- return inRange(newPeriodItem_1.start, item.start, item.end) ||
26433
- inRange(newPeriodItem_1.end, item.start, item.end);
26422
+ var onClickedDeletePeriod = function () { return __awaiter(void 0, void 0, void 0, function () {
26423
+ return __generator(this, function (_a) {
26424
+ setActionInfo({
26425
+ action: "Delete",
26426
+ headerText: t("ndc:periodDeleteConfirmTitle"),
26427
+ type: "danger",
26428
+ icon: React.createElement(Icon__namespace.XCircle, null),
26429
+ recordId: selectedPeriod.key,
26434
26430
  });
26435
- if (existingIndex === -1) {
26436
- setPeriodItems(function (items) { return __spreadArray(__spreadArray([], items, true), [newPeriodItem_1], false); });
26437
- periodItemsRef.current = __spreadArray(__spreadArray([], periodItemsRef.current, true), [newPeriodItem_1], false);
26438
- }
26439
- else {
26440
- antd.message.open({
26441
- type: "error",
26442
- content: t("ndc:rangeAlreadyExists"),
26443
- duration: 3,
26444
- style: { textAlign: "right", marginRight: 15, marginTop: 10 },
26445
- });
26446
- }
26431
+ setOpenConfirmationModal(true);
26432
+ return [2 /*return*/];
26433
+ });
26434
+ }); };
26435
+ var onClickedFinalizePeriod = function () { return __awaiter(void 0, void 0, void 0, function () {
26436
+ return __generator(this, function (_a) {
26437
+ setActionInfo({
26438
+ action: "Finalize",
26439
+ headerText: t("ndc:finalizeApproveTitle"),
26440
+ text: t("ndc:finalizeApproveSubTitle"),
26441
+ type: "primary",
26442
+ icon: React.createElement(Icon__namespace.Clipboard2Check, null),
26443
+ recordId: selectedPeriod.key,
26444
+ });
26445
+ setOpenConfirmationModal(true);
26446
+ return [2 /*return*/];
26447
+ });
26448
+ }); };
26449
+ var onMainTableRowExpand = function (expanded, record) {
26450
+ var keys = [];
26451
+ if (expanded) {
26452
+ keys.push(record.id);
26447
26453
  }
26454
+ setExpandedRowKeys(keys);
26455
+ var subNdcDetails = ndcDetailsData.filter(function (ndcDetail) {
26456
+ return (ndcDetail.parentActionId === record.id &&
26457
+ ndcDetail.actionType === NdcDetailsActionType.SubAction);
26458
+ });
26459
+ var emptySubNdcRow = {
26460
+ id: nextAvailableActionId,
26461
+ actionType: NdcDetailsActionType.SubAction,
26462
+ nationalPlanObjective: "",
26463
+ kpi: "",
26464
+ ministryName: loginMinistry,
26465
+ status: NdcDetailsActionStatus.New,
26466
+ parentActionId: record.id,
26467
+ };
26468
+ setEditingKey(nextAvailableActionId);
26469
+ setNextAvailableActionId(function (value) { return value + 1; });
26470
+ form.setFieldsValue({
26471
+ nationalPlanObjective: "",
26472
+ kpi: "",
26473
+ });
26474
+ setSubNdcDetailsForPeriod(__spreadArray(__spreadArray([], subNdcDetails, true), [emptySubNdcRow], false));
26448
26475
  };
26449
- React.useEffect(function () {
26450
- if (periodItems && periodItems.length > 3) {
26451
- setSelectedTab(periodItems[periodItems.length - 1].key);
26452
- }
26453
- }, [periodItems]);
26476
+ function ndcDetailsTableContent() {
26477
+ return (React.createElement("div", null,
26478
+ React.createElement(antd.Row, null,
26479
+ React.createElement(antd.Col, { span: 24 },
26480
+ React.createElement(antd.Form, { form: form, component: false },
26481
+ React.createElement(antd.Table, { key: tableKey, rowKey: "id", components: components, rowClassName: function () { return "editable-row"; }, bordered: true, dataSource: ndcMainDetailsForPeriod, columns: columns, expandedRowKeys: expandedRowKeys, onExpand: onMainTableRowExpand, expandable: {
26482
+ expandedRowRender: function (record) { return getSubNdcActionContent(record); },
26483
+ indentSize: 0,
26484
+ //defaultExpandedRowKeys: [parseInt(selectedNdcDetail.current.id)],
26485
+ }, onRow: function (record, rowIndex) {
26486
+ return {
26487
+ onClick: function () {
26488
+ if (record.id && isMainNdcActionsEditable && !isEditing(record)) {
26489
+ form.setFieldsValue(__assign({}, record));
26490
+ setEditingKey(record.id);
26491
+ }
26492
+ },
26493
+ onMouseLeave: function () {
26494
+ if (isEditing(record)) {
26495
+ handleSave(record);
26496
+ }
26497
+ },
26498
+ };
26499
+ }, footer: function () {
26500
+ return isGovernmentUser &&
26501
+ !selectedPeriod.finalized && (React.createElement(antd.Row, { justify: "center" },
26502
+ React.createElement(antd.Button, { onClick: onClickedAddNewNdcDetail, type: "default", style: {
26503
+ marginBottom: 16,
26504
+ width: "100%",
26505
+ } }, t("ndc:addNdcAction"))));
26506
+ } })))),
26507
+ isGovernmentUser && !selectedPeriod.finalized ? (React.createElement(antd.Row, { justify: "end" },
26508
+ React.createElement(antd.Button, { className: "mg-left-1", type: "primary", onClick: onClickedDeletePeriod, htmlType: "submit", loading: loading }, t("ndc:delete")),
26509
+ React.createElement(antd.Button, { className: "mg-left-1", type: "primary", onClick: onClickedFinalizePeriod, htmlType: "submit", loading: loading }, t("ndc:finalize")))) : ("")));
26510
+ }
26511
+ var onAddNewPeriod = function () { return __awaiter(void 0, void 0, void 0, function () {
26512
+ var periodItem_1, existingIndex, response, addedPeriodItem, updatedPeriodItem_1;
26513
+ return __generator(this, function (_a) {
26514
+ switch (_a.label) {
26515
+ case 0:
26516
+ if (!(selectedDateRangeRef && selectedDateRangeRef.current)) return [3 /*break*/, 3];
26517
+ periodItem_1 = {
26518
+ startYear: selectedDateRangeRef.current.startYear,
26519
+ endYear: selectedDateRangeRef.current.endYear,
26520
+ finalized: false,
26521
+ };
26522
+ existingIndex = periodItems.findIndex(function (item) {
26523
+ return inRange(periodItem_1.startYear, item.startYear, item.endYear) ||
26524
+ inRange(periodItem_1.endYear, item.startYear, item.endYear);
26525
+ });
26526
+ if (!(existingIndex === -1)) return [3 /*break*/, 2];
26527
+ return [4 /*yield*/, post("national/programme/addNdcDetailsPeriod", __assign({}, periodItem_1))];
26528
+ case 1:
26529
+ response = _a.sent();
26530
+ if (response && response.data) {
26531
+ addedPeriodItem = response.data;
26532
+ updatedPeriodItem_1 = __assign(__assign({}, addedPeriodItem), { key: addedPeriodItem.id, label: "".concat(addedPeriodItem.startYear, "-").concat(addedPeriodItem.endYear) });
26533
+ setPeriodItems(function (items) { return __spreadArray(__spreadArray([], items, true), [updatedPeriodItem_1], false); });
26534
+ setSelectedPeriod(updatedPeriodItem_1);
26535
+ }
26536
+ return [3 /*break*/, 3];
26537
+ case 2:
26538
+ antd.message.open({
26539
+ type: "error",
26540
+ content: t("ndc:rangeAlreadyExists"),
26541
+ duration: 3,
26542
+ style: { textAlign: "right", marginRight: 15, marginTop: 10 },
26543
+ });
26544
+ _a.label = 3;
26545
+ case 3: return [2 /*return*/];
26546
+ }
26547
+ });
26548
+ }); };
26454
26549
  var onDateRangeChanged = function (range) {
26455
26550
  var period = {
26456
- start: Number(moment(range[0]).year()),
26457
- end: Number(moment(range[1]).year()),
26551
+ startYear: Number(moment(range[0]).year()),
26552
+ endYear: Number(moment(range[1]).year()),
26458
26553
  };
26459
- selectedPeriod.current = period;
26554
+ selectedDateRangeRef.current = period;
26460
26555
  };
26461
26556
  function addNewPeriodContent() {
26462
26557
  return (React.createElement("div", null,
26463
- React.createElement(antd.Row, null,
26464
- React.createElement(RangePicker, { onChange: onDateRangeChanged, picker: "year" })),
26465
- React.createElement(antd.Row, { className: "mg-top-1" },
26466
- React.createElement("div", { className: "ndc-steps-actions" },
26467
- React.createElement(antd.Button, { type: "primary", onClick: onAddNewPeriod, htmlType: "submit", loading: loading }, t("ndc:submit")),
26468
- React.createElement(antd.Button, { className: "back-btn", onClick: onCancelPeriod, loading: loading }, t("ndc:back"))))));
26558
+ React.createElement(antd.Row, { justify: "start", align: "middle", gutter: [16, 16] },
26559
+ React.createElement(antd.Col, { flex: "340px" },
26560
+ React.createElement(RangePicker, { onChange: onDateRangeChanged, picker: "year" })),
26561
+ React.createElement(antd.Col, { flex: "auto" },
26562
+ React.createElement(antd.Button, { type: "primary", onClick: onAddNewPeriod, htmlType: "submit", loading: loading }, t("ndc:submit"))))));
26469
26563
  }
26470
26564
  function getSubNdcActionContent(record) {
26471
26565
  selectedNdcDetail.current = record;
26472
- return (React.createElement(antd.Table, { components: components, rowClassName: function () { return "editable-row"; }, bordered: true, dataSource: getSubNdcDetails(record.key), columns: columns, showHeader: false, pagination: false }));
26566
+ return (React.createElement(antd.Table, { rowKey: "id", components: components, rowClassName: function () { return "editable-row"; }, bordered: true, dataSource: subNdcDetailsForPeriod, onRow: function (record, rowIndex) {
26567
+ return {
26568
+ onClick: function () {
26569
+ if (record.id && isSubNdcActionsEditable(record) && !isEditing(record)) {
26570
+ form.setFieldsValue(__assign({}, record));
26571
+ setEditingKey(record.id);
26572
+ }
26573
+ },
26574
+ onMouseLeave: function () {
26575
+ if (isEditing(record)) {
26576
+ handleSave(record);
26577
+ }
26578
+ },
26579
+ };
26580
+ }, columns: columns, showHeader: false, pagination: false }));
26473
26581
  }
26474
26582
  var onTabChange = function (key) {
26475
- setSelectedTab(key);
26583
+ var selectedPeriod = periodItems.find(function (item) { return item.key === key; });
26584
+ if (selectedPeriod) {
26585
+ setSelectedPeriod(selectedPeriod);
26586
+ }
26476
26587
  };
26588
+ var onActionConfirmed = function () { return __awaiter(void 0, void 0, void 0, function () {
26589
+ var response, response, response, result;
26590
+ return __generator(this, function (_a) {
26591
+ switch (_a.label) {
26592
+ case 0:
26593
+ if (!(actionInfo.action === "Approve")) return [3 /*break*/, 2];
26594
+ return [4 /*yield*/, get("national/programme/approveNdcDetailsAction", {
26595
+ id: actionInfo.recordId,
26596
+ })];
26597
+ case 1:
26598
+ response = _a.sent();
26599
+ return [3 /*break*/, 8];
26600
+ case 2:
26601
+ if (!(actionInfo.action === "Reject")) return [3 /*break*/, 4];
26602
+ return [4 /*yield*/, get("national/programme/rejectNdcDetailsAction", {
26603
+ id: actionInfo.recordId,
26604
+ })];
26605
+ case 3:
26606
+ response = _a.sent();
26607
+ return [3 /*break*/, 8];
26608
+ case 4:
26609
+ if (!(actionInfo.action === "Finalize")) return [3 /*break*/, 6];
26610
+ return [4 /*yield*/, post("national/programme/finalizeNdcDetailsPeriod", {
26611
+ id: selectedPeriod.key,
26612
+ })];
26613
+ case 5:
26614
+ response = _a.sent();
26615
+ if (response) {
26616
+ fetchNdcDetailPeriods();
26617
+ }
26618
+ return [3 /*break*/, 8];
26619
+ case 6:
26620
+ if (!(actionInfo.action === "Delete")) return [3 /*break*/, 8];
26621
+ return [4 /*yield*/, post("national/programme/deleteNdcDetailsPeriod", {
26622
+ id: selectedPeriod.key,
26623
+ })];
26624
+ case 7:
26625
+ result = _a.sent();
26626
+ if (result) {
26627
+ fetchNdcDetailPeriods();
26628
+ }
26629
+ _a.label = 8;
26630
+ case 8:
26631
+ setOpenConfirmationModal(false);
26632
+ return [2 /*return*/];
26633
+ }
26634
+ });
26635
+ }); };
26636
+ var onActionCanceled = function () {
26637
+ setOpenConfirmationModal(false);
26638
+ };
26639
+ var fetchNdcDetailPeriods = function () { return __awaiter(void 0, void 0, void 0, function () {
26640
+ var periods, addNewTab, response;
26641
+ return __generator(this, function (_a) {
26642
+ switch (_a.label) {
26643
+ case 0:
26644
+ periods = [];
26645
+ addNewTab = {
26646
+ key: "add_new",
26647
+ label: "Add New",
26648
+ startYear: 0,
26649
+ endYear: 0,
26650
+ finalized: false,
26651
+ deleted: false,
26652
+ };
26653
+ return [4 /*yield*/, get("national/programme/queryNdcDetailsPeriod")];
26654
+ case 1:
26655
+ response = _a.sent();
26656
+ if (response && response.data) {
26657
+ periods = response.data.map(function (period) {
26658
+ return __assign(__assign({}, period), { key: period.id, label: period.finalized ? (React.createElement("span", null,
26659
+ React.createElement(icons.LockOutlined, null),
26660
+ " ",
26661
+ period.startYear,
26662
+ "-",
26663
+ period.endYear,
26664
+ " ")) : ("".concat(period.startYear, "-").concat(period.endYear)) });
26665
+ });
26666
+ }
26667
+ if (isGovernmentUser) {
26668
+ periods.unshift(addNewTab);
26669
+ }
26670
+ setPeriodItems(periods);
26671
+ setSelectedPeriod(addNewTab);
26672
+ return [2 /*return*/];
26673
+ }
26674
+ });
26675
+ }); };
26676
+ var fetchNdcDetailActions = function () { return __awaiter(void 0, void 0, void 0, function () {
26677
+ var response, maxActionId;
26678
+ return __generator(this, function (_a) {
26679
+ switch (_a.label) {
26680
+ case 0: return [4 /*yield*/, get("national/programme/queryNdcDetailsAction")];
26681
+ case 1:
26682
+ response = _a.sent();
26683
+ if (response && response.data) {
26684
+ maxActionId = Math.max.apply(Math, response.data.map(function (item) { return item.id; }));
26685
+ setNextAvailableActionId(maxActionId + 1);
26686
+ setNdcDetailsData(response.data);
26687
+ }
26688
+ return [2 /*return*/];
26689
+ }
26690
+ });
26691
+ }); };
26692
+ var fetchMinistries = function () { return __awaiter(void 0, void 0, void 0, function () {
26693
+ var response, ministryOrgDetails;
26694
+ return __generator(this, function (_a) {
26695
+ switch (_a.label) {
26696
+ case 0: return [4 /*yield*/, get("national/organisation/getMinistries")];
26697
+ case 1:
26698
+ response = _a.sent();
26699
+ if (response && response.data) {
26700
+ ministryOrgDetails = response.data.map(function (value) {
26701
+ return {
26702
+ value: value.company_companyId,
26703
+ label: value.company_name,
26704
+ };
26705
+ });
26706
+ setMinistryOrgList(ministryOrgDetails);
26707
+ }
26708
+ return [2 /*return*/];
26709
+ }
26710
+ });
26711
+ }); };
26477
26712
  React.useEffect(function () {
26478
- var defaultNdcDetails = [
26479
- {
26480
- key: 1,
26481
- type: NdcActionType.main,
26482
- startDate: new Date("2019-03-25"),
26483
- endDate: new Date("2020-03-25"),
26484
- nationalPlanObj: "Enhance value addition in key growth opportunities",
26485
- kpi: 25,
26486
- ministry: "Ministry of Environment",
26487
- subNdcDetails: [
26488
- {
26489
- key: 6,
26490
- ndcActionId: 1,
26491
- type: NdcActionType.sub,
26492
- startDate: new Date("2019-03-25"),
26493
- endDate: new Date("2020-03-25"),
26494
- nationalPlanObj: "Enhance value addition in key growth opportunities sub details",
26495
- kpi: 25,
26496
- ministry: "Ministry of Agriculture, Water and Forestry (MAWF)",
26497
- },
26498
- {
26499
- key: 7,
26500
- ndcActionId: 1,
26501
- type: NdcActionType.sub,
26502
- startDate: new Date("2019-03-25"),
26503
- endDate: new Date("2020-03-25"),
26504
- nationalPlanObj: "",
26505
- kpi: "",
26506
- ministry: "",
26507
- },
26508
- ],
26509
- },
26510
- {
26511
- key: 2,
26512
- type: NdcActionType.main,
26513
- startDate: new Date("2019-03-25"),
26514
- endDate: new Date("2019-08-25"),
26515
- nationalPlanObj: "Strengthen the private sector to create 10,000 jobs",
26516
- kpi: 10500,
26517
- ministry: "Ministry of Environment",
26518
- subNdcDetails: [
26519
- {
26520
- key: 8,
26521
- ndcActionId: 2,
26522
- type: NdcActionType.sub,
26523
- startDate: new Date("2019-03-25"),
26524
- endDate: new Date("2020-03-25"),
26525
- nationalPlanObj: "",
26526
- kpi: "",
26527
- ministry: "",
26528
- },
26529
- ],
26530
- },
26531
- {
26532
- key: 12,
26533
- type: NdcActionType.main,
26534
- startDate: new Date("2019-03-25"),
26535
- endDate: new Date("2019-08-25"),
26536
- nationalPlanObj: "Other",
26537
- kpi: 10500,
26538
- ministry: "Ministry of Environment",
26539
- subNdcDetails: [
26540
- {
26541
- key: 8,
26542
- ndcActionId: 12,
26543
- type: NdcActionType.sub,
26544
- startDate: new Date("2019-03-25"),
26545
- endDate: new Date("2020-03-25"),
26546
- nationalPlanObj: "",
26547
- kpi: "",
26548
- ministry: "",
26549
- },
26550
- ],
26551
- },
26552
- {
26553
- key: 3,
26554
- type: NdcActionType.main,
26555
- startDate: new Date("2021-03-25"),
26556
- endDate: new Date("2022-03-25"),
26557
- nationalPlanObj: "Consolidate and increase the stock and quality of productive infrastructure by 50%",
26558
- kpi: 48,
26559
- ministry: "Ministry of Environment",
26560
- subNdcDetails: [
26561
- {
26562
- key: 9,
26563
- ndcActionId: 3,
26564
- type: NdcActionType.sub,
26565
- startDate: new Date("2019-03-25"),
26566
- endDate: new Date("2020-03-25"),
26567
- nationalPlanObj: "",
26568
- kpi: "",
26569
- ministry: "",
26570
- },
26571
- ],
26572
- },
26573
- {
26574
- key: 4,
26575
- type: NdcActionType.main,
26576
- startDate: new Date("2022-03-25"),
26577
- endDate: new Date("2022-05-25"),
26578
- nationalPlanObj: "Enhance the productivity and social wellbeing of the population",
26579
- kpi: 20,
26580
- ministry: "Ministry of Environment",
26581
- subNdcDetails: [
26582
- {
26583
- key: 10,
26584
- ndcActionId: 4,
26585
- type: NdcActionType.sub,
26586
- startDate: new Date("2019-03-25"),
26587
- endDate: new Date("2020-03-25"),
26588
- nationalPlanObj: "",
26589
- kpi: "",
26590
- ministry: "",
26591
- },
26592
- ],
26593
- },
26594
- {
26595
- key: 5,
26596
- type: NdcActionType.main,
26597
- startDate: new Date("2022-03-25"),
26598
- endDate: new Date("2023-03-25"),
26599
- nationalPlanObj: "Strengthen the role of the state in guiding and facilitating development",
26600
- kpi: 10,
26601
- ministry: "Ministry of Environment",
26602
- subNdcDetails: [
26603
- {
26604
- key: 11,
26605
- ndcActionId: 5,
26606
- type: NdcActionType.sub,
26607
- startDate: new Date("2019-03-25"),
26608
- endDate: new Date("2020-03-25"),
26609
- nationalPlanObj: "",
26610
- kpi: "",
26611
- ministry: "",
26612
- },
26613
- ],
26614
- },
26615
- {
26616
- key: 13,
26617
- type: NdcActionType.main,
26618
- startDate: new Date("2022-03-25"),
26619
- endDate: new Date("2023-03-25"),
26620
- nationalPlanObj: "Convert to solar energy",
26621
- kpi: 50000,
26622
- ministry: "Ministry of Environment",
26623
- subNdcDetails: [
26624
- {
26625
- key: 11,
26626
- ndcActionId: 13,
26627
- type: NdcActionType.sub,
26628
- startDate: new Date("2019-03-25"),
26629
- endDate: new Date("2020-03-25"),
26630
- nationalPlanObj: "Convert to solar energy",
26631
- kpi: "3000",
26632
- ministry: "Ministry of Agriculture, Water and Forestry (MAWF)",
26633
- },
26634
- {
26635
- key: 14,
26636
- ndcActionId: 13,
26637
- type: NdcActionType.sub,
26638
- startDate: new Date("2019-03-25"),
26639
- endDate: new Date("2020-03-25"),
26640
- nationalPlanObj: "",
26641
- kpi: "",
26642
- ministry: "",
26643
- },
26644
- ],
26645
- },
26646
- {
26647
- key: 15,
26648
- type: NdcActionType.main,
26649
- startDate: new Date("2022-03-25"),
26650
- endDate: new Date("2023-03-25"),
26651
- nationalPlanObj: "Strengthen the private sector to create jobs",
26652
- kpi: 10000,
26653
- ministry: "Ministry of Environment",
26654
- subNdcDetails: [
26655
- {
26656
- key: 16,
26657
- ndcActionId: 15,
26658
- type: NdcActionType.sub,
26659
- startDate: new Date("2019-03-25"),
26660
- endDate: new Date("2020-03-25"),
26661
- nationalPlanObj: "Strengthen the private sector to create jobs",
26662
- kpi: "7200",
26663
- ministry: "Ministry of Tourism (MoT)",
26664
- },
26665
- {
26666
- key: 17,
26667
- ndcActionId: 15,
26668
- type: NdcActionType.sub,
26669
- startDate: new Date("2019-03-25"),
26670
- endDate: new Date("2020-03-25"),
26671
- nationalPlanObj: "",
26672
- kpi: "",
26673
- ministry: "",
26674
- },
26675
- ],
26676
- },
26677
- {
26678
- key: 18,
26679
- type: NdcActionType.main,
26680
- startDate: new Date("2022-03-25"),
26681
- endDate: new Date("2023-03-25"),
26682
- nationalPlanObj: "Other",
26683
- kpi: '',
26684
- ministry: "Ministry of Environment",
26685
- subNdcDetails: [
26686
- {
26687
- key: 19,
26688
- ndcActionId: 18,
26689
- type: NdcActionType.sub,
26690
- startDate: new Date("2019-03-25"),
26691
- endDate: new Date("2020-03-25"),
26692
- nationalPlanObj: "Strengthen the private sector to create jobs",
26693
- kpi: "",
26694
- ministry: "Ministry of Agriculture, Water and Forestry (MAWF)",
26695
- },
26696
- {
26697
- key: 20,
26698
- ndcActionId: 18,
26699
- type: NdcActionType.sub,
26700
- startDate: new Date("2019-03-25"),
26701
- endDate: new Date("2020-03-25"),
26702
- nationalPlanObj: "",
26703
- kpi: "",
26704
- ministry: "",
26705
- },
26706
- ],
26707
- },
26708
- ];
26709
- var initialPeriods = [
26710
- {
26711
- key: "2019-2020",
26712
- label: "2019-2020",
26713
- start: 2019,
26714
- end: 2020,
26715
- children: ndcDetailsTableContent(),
26716
- },
26717
- {
26718
- key: "2021-2023",
26719
- label: "2021-2023",
26720
- start: 2021,
26721
- end: 2021,
26722
- children: ndcDetailsTableContent(),
26723
- },
26724
- ];
26725
- if (isAddRangeVisible()) {
26726
- initialPeriods.unshift({
26727
- key: "add_new",
26728
- label: "Add New",
26729
- start: 0,
26730
- end: 0,
26731
- children: addNewPeriodContent(),
26732
- });
26733
- }
26734
- addedNdcDetailId.current = 20;
26735
- setPeriodItems(initialPeriods);
26736
- periodItemsRef.current = initialPeriods;
26737
- setNdcDetailsData(defaultNdcDetails);
26713
+ fetchNdcDetailPeriods();
26714
+ fetchNdcDetailActions();
26715
+ fetchMinistries();
26738
26716
  }, []);
26739
26717
  return (React.createElement("div", { className: "ndc-management content-container" },
26740
26718
  React.createElement("div", { className: "title-bar" },
@@ -26743,20 +26721,11 @@ var NdcDetailsComponent = function (props) {
26743
26721
  React.createElement("div", { className: "body-title" }, t("ndc:ndcTitle")),
26744
26722
  React.createElement("div", { className: "body-sub-title" }, t("ndc:ndcSubTitle"))))),
26745
26723
  React.createElement("div", null,
26746
- React.createElement(antd.Tabs, { centered: false, defaultActiveKey: "1", items: periodItems, activeKey: selectedTab, onChange: onTabChange })),
26747
- selectedTab !== "add_new" && (React.createElement("div", null,
26748
- React.createElement("div", null,
26749
- React.createElement(antd.Table, { key: tableKey, components: components, rowClassName: function () { return "editable-row"; }, bordered: true, dataSource: getNdcDetailsForPeriod(), columns: columns, expandable: {
26750
- expandedRowRender: function (record) { return getSubNdcActionContent(record); },
26751
- indentSize: 0,
26752
- defaultExpandedRowKeys: [selectedNdcDetail.current.key],
26753
- }, footer: function () {
26754
- return isAddNdcActionVisible() && (React.createElement(antd.Row, { justify: "center" },
26755
- React.createElement(antd.Button, { onClick: onAddNewNdcDetail, type: "default", style: {
26756
- marginBottom: 16,
26757
- width: "100%",
26758
- } }, t("ndc:addNdcAction"))));
26759
- } }))))));
26724
+ React.createElement(antd.Tabs, { centered: false, defaultActiveKey: "1", items: periodItems, activeKey: selectedPeriod.key, onChange: onTabChange })),
26725
+ React.createElement("div", null, selectedPeriod.key === "add_new"
26726
+ ? addNewPeriodContent()
26727
+ : ndcDetailsTableContent()),
26728
+ React.createElement(UserActionConfirmationModel, { t: t, actionInfo: actionInfo, onActionConfirmed: onActionConfirmed, onActionCanceled: onActionCanceled, openModal: openConfirmationModal, errorMsg: "", loading: false })));
26760
26729
  };
26761
26730
 
26762
26731
  var ImgWithFallback = function (_a) {
@@ -28441,7 +28410,7 @@ exports.getCreditStageVal = getCreditStageVal;
28441
28410
  exports.getFinancialFields = getFinancialFields;
28442
28411
  exports.getGeneralFields = getGeneralFields;
28443
28412
  exports.getInvestmentStatusEnumVal = getInvestmentStatusEnumVal;
28444
- exports.getNdcActionStatusEnumVal = getNdcActionStatusEnumVal;
28413
+ exports.getNdcActionStatusEnumVal = getNdcActionStatusEnumVal$1;
28445
28414
  exports.getNdcStatusTagType = getNdcStatusTagType;
28446
28415
  exports.getRetirementTypeString = getRetirementTypeString;
28447
28416
  exports.getStageEnumVal = getStageEnumVal;