@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/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,598 +26123,576 @@ 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; _a.record; _a.index; var children = _a.children, restProps = __rest(_a, ["editing", "dataIndex", "title", "inputType", "record", "index", "children"]);
26129
+ var inputNode;
26130
+ if (dataIndex === "nationalPlanObjective") {
26131
+ inputNode = React.createElement(Input, { placeholder: "Enter National Plan Objective" });
26178
26132
  }
26179
- return React.createElement("td", __assign({}, restProps), childNode);
26133
+ else if (dataIndex === "kpi") {
26134
+ inputNode = React.createElement(InputNumber, { placeholder: "Enter Kpi" });
26135
+ }
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
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";
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
26182
  var _a = useState([]), ndcDetailsData = _a[0], setNdcDetailsData = _a[1];
26194
26183
  var _b = useState(false), loading = _b[0]; _b[1];
26195
- var periodItemsRef = useRef([]);
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);
26185
+ var _d = useState({}), selectedPeriod = _d[0], setSelectedPeriod = _d[1];
26186
+ var selectedDateRangeRef = useRef({});
26200
26187
  var selectedNdcDetail = useRef({});
26201
26188
  var _e = useState(0), tableKey = _e[0], setTableKey = _e[1];
26189
+ var _f = useConnection(), get = _f.get, post = _f.post, put = _f.put;
26190
+ var _g = useState([]), ministryOrgList = _g[0], setMinistryOrgList = _g[1];
26191
+ var _h = useState({}), actionInfo = _h[0], setActionInfo = _h[1];
26192
+ var _j = useState(false), openConfirmationModal = _j[0], setOpenConfirmationModal = _j[1];
26193
+ var form = Form.useForm()[0];
26194
+ var _k = useState(-1), editingKey = _k[0], setEditingKey = _k[1];
26195
+ var _l = useState(0), nextAvailableActionId = _l[0], setNextAvailableActionId = _l[1];
26196
+ var _m = useState([]), expandedRowKeys = _m[0], setExpandedRowKeys = _m[1];
26197
+ var _o = useState([]), subNdcDetailsForPeriod = _o[0], setSubNdcDetailsForPeriod = _o[1];
26198
+ var isEditing = function (record) { return record.id === editingKey; };
26202
26199
  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) &&
26206
- (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== Role.ViewOnly);
26207
- };
26208
- var isAddNdcActionVisible = function () {
26209
- return ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.GOVERNMENT &&
26200
+ var loginMinistry = (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.GOVERNMENT
26201
+ ? process.env.REACT_APP_GOVERNMENT_MINISTRY
26202
+ ? process.env.REACT_APP_GOVERNMENT_MINISTRY
26203
+ : "Test ministryName"
26204
+ : (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.MINISTRY
26205
+ ? userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyName
26206
+ : undefined;
26207
+ var isGovernmentUser = (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.GOVERNMENT &&
26208
+ (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== Role.ViewOnly;
26209
+ var ndcMainDetailsForPeriod = selectedPeriod.key !== "add_new"
26210
+ ? ndcDetailsData.filter(function (ndcDetail) {
26211
+ return (ndcDetail.periodId === parseInt(selectedPeriod.key) &&
26212
+ ndcDetail.actionType === NdcDetailsActionType.MainAction);
26213
+ })
26214
+ : [];
26215
+ var isMainNdcActionsEditable = !selectedPeriod.finalized &&
26216
+ (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.GOVERNMENT &&
26217
+ (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== Role.ViewOnly;
26218
+ var isSubNdcActionsEditable = function (record) {
26219
+ return (!selectedPeriod.finalized &&
26220
+ record.status !== NdcDetailsActionStatus.Approved &&
26221
+ ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.GOVERNMENT ||
26222
+ ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.MINISTRY &&
26223
+ (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyName) === record.ministryName)) &&
26210
26224
  (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== Role.ViewOnly);
26211
26225
  };
26212
26226
  var inRange = function (num, min, max) {
26213
26227
  return num >= min && num <= max;
26214
26228
  };
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
- }
26260
- }
26261
- else {
26262
- parentItem.subNdcDetails = [row];
26263
- }
26264
- }
26265
- newData[parentIndex] = __assign({}, parentItem);
26266
- setTableKey(function (key) { return key + 1; });
26229
+ var handleSave = function (row) { return __awaiter(void 0, void 0, void 0, function () {
26230
+ var updatedFields, updatedItem, exception_1;
26231
+ return __generator(this, function (_a) {
26232
+ switch (_a.label) {
26233
+ case 0:
26234
+ _a.trys.push([0, 6, , 7]);
26235
+ return [4 /*yield*/, form.validateFields()];
26236
+ case 1:
26237
+ updatedFields = (_a.sent());
26238
+ updatedItem = __assign(__assign({}, row), updatedFields);
26239
+ if (!(updatedItem.status === NdcDetailsActionStatus.New)) return [3 /*break*/, 3];
26240
+ updatedItem.status = NdcDetailsActionStatus.Pending;
26241
+ return [4 /*yield*/, post("national/programme/addNdcDetailsAction", __assign(__assign({}, updatedItem), { kpi: parseInt(updatedItem.kpi) }))];
26242
+ case 2:
26243
+ _a.sent();
26244
+ return [3 /*break*/, 5];
26245
+ case 3:
26246
+ updatedItem.status = NdcDetailsActionStatus.Pending;
26247
+ return [4 /*yield*/, put("national/programme/updateNdcDetailsAction", __assign(__assign({}, updatedItem), { kpi: parseInt(updatedItem.kpi) }))];
26248
+ case 4:
26249
+ _a.sent();
26250
+ _a.label = 5;
26251
+ case 5:
26252
+ fetchNdcDetailActions();
26253
+ setEditingKey(-1);
26254
+ return [3 /*break*/, 7];
26255
+ case 6:
26256
+ exception_1 = _a.sent();
26257
+ console.log("error", exception_1);
26258
+ return [3 /*break*/, 7];
26259
+ case 7: return [2 /*return*/];
26267
26260
  }
26268
- return newData;
26269
26261
  });
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;
26262
+ }); };
26263
+ var actionMenu = function (record) {
26264
+ if (record.status === NdcDetailsActionStatus.Pending && isGovernmentUser) {
26265
+ return (React.createElement(List, { className: "action-menu", size: "small", dataSource: [
26266
+ {
26267
+ text: t("ndc:approve"),
26268
+ icon: React.createElement(Icon.BoxArrowInDown, null),
26269
+ click: function () {
26270
+ setActionInfo({
26271
+ action: "Approve",
26272
+ headerText: t("ndc:actionApproveTitle"),
26273
+ type: "primary",
26274
+ icon: React.createElement(Icon.BoxArrowInDown, null),
26275
+ recordId: record.id,
26276
+ });
26277
+ setOpenConfirmationModal(true);
26278
+ },
26279
+ },
26280
+ {
26281
+ text: t("ndc:reject"),
26282
+ icon: React.createElement(Icon.XOctagon, null),
26283
+ click: function () {
26284
+ setActionInfo({
26285
+ action: "Reject",
26286
+ headerText: t("ndc:rejectApproveTitle"),
26287
+ type: "danger",
26288
+ icon: React.createElement(Icon.BoxArrowInDown, null),
26289
+ recordId: record.id,
26290
+ });
26291
+ setOpenConfirmationModal(true);
26292
+ },
26293
+ },
26294
+ ], renderItem: function (item) { return (React.createElement(List.Item, { onClick: item.click },
26295
+ React.createElement(Typography.Text, { className: "action-icon color-error" }, item.icon),
26296
+ React.createElement("span", null, item.text))); } }));
26297
26297
  }
26298
26298
  else {
26299
- return [];
26299
+ return null;
26300
26300
  }
26301
26301
  };
26302
26302
  var defaultColumns = [
26303
26303
  {
26304
26304
  title: t("ndc:ndcColumnsNationalPlanObj"),
26305
- dataIndex: "nationalPlanObj",
26306
- key: "nationalPlanObj",
26305
+ dataIndex: "nationalPlanObjective",
26306
+ key: "nationalPlanObjective",
26307
26307
  align: "left",
26308
+ width: "40%",
26308
26309
  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" })))); },
26312
26310
  },
26313
26311
  {
26314
26312
  title: t("ndc:ndcColumnsKpi"),
26315
26313
  dataIndex: "kpi",
26316
26314
  key: "kpi",
26317
26315
  align: "left",
26316
+ width: "15%",
26318
26317
  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" })))); },
26322
26318
  },
26323
26319
  {
26324
- title: "Ministry",
26325
- dataIndex: "ministry",
26326
- key: "ministry",
26320
+ title: t("ndc:ndcColumnsMinistry"),
26321
+ dataIndex: "ministryName",
26322
+ key: "ministryName",
26327
26323
  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" })))); },
26324
+ width: "30%",
26325
+ editable: false,
26326
+ render: function (_, record) { return (React.createElement(React.Fragment, null,
26327
+ React.createElement(Select, { disabled: !(isSubNdcActionsEditable(record) && isEditing(record)), defaultValue: record.ministryName ? record.ministryName : loginMinistry, style: { width: 320 }, onChange: function (value, option) {
26328
+ record.ministryName = option.label;
26329
+ handleSave(record);
26330
+ }, options: ministryOrgList }))); },
26331
+ },
26332
+ {
26333
+ title: t("ndc:ndcColumnsStatus"),
26334
+ dataIndex: "status",
26335
+ key: "status",
26336
+ align: "left",
26337
+ width: "15%",
26338
+ editable: false,
26339
+ render: function (_, record) {
26340
+ var menu = actionMenu(record);
26341
+ return (React.createElement(React.Fragment, null,
26342
+ record.actionType === NdcDetailsActionType.SubAction &&
26343
+ record.status !== NdcDetailsActionStatus.New ? (React.createElement(Tooltip, { title: record.status, color: TooltipColor, key: TooltipColor },
26344
+ React.createElement(Tag, { className: "clickable", color: getNdcActionStatusTagType(record.status) }, addSpaces(record.status)))) : (""),
26345
+ record.actionType === NdcDetailsActionType.SubAction && menu ? (React.createElement(Popover, { placement: "bottomRight", content: menu, trigger: "click" },
26346
+ React.createElement(EllipsisOutlined, { rotate: 90, style: {
26347
+ fontWeight: 600,
26348
+ fontSize: "1rem",
26349
+ cursor: "pointer",
26350
+ } }))) : (React.createElement("span", null))));
26351
+ },
26332
26352
  },
26333
26353
  ];
26334
26354
  var columns = defaultColumns.map(function (col) {
26335
26355
  if (!col.editable) {
26336
26356
  return col;
26337
26357
  }
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
- }); } });
26358
+ return __assign(__assign({}, col), { onCell: function (record) {
26359
+ return {
26360
+ record: record,
26361
+ editing: isEditing(record),
26362
+ dataIndex: col.dataIndex,
26363
+ title: col.title,
26364
+ };
26365
+ } });
26345
26366
  });
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));
26367
+ function onClickedAddNewNdcDetail() {
26368
+ return __awaiter(this, void 0, void 0, function () {
26369
+ var periodId, newData_1;
26370
+ return __generator(this, function (_a) {
26371
+ if (selectedPeriod.key !== "add_new") {
26372
+ form.setFieldsValue({
26373
+ nationalPlanObjective: "",
26374
+ kpi: "",
26375
+ });
26376
+ periodId = parseInt(selectedPeriod.key);
26377
+ newData_1 = {
26378
+ id: nextAvailableActionId,
26379
+ actionType: NdcDetailsActionType.MainAction,
26380
+ nationalPlanObjective: "",
26381
+ kpi: "",
26382
+ ministryName: loginMinistry,
26383
+ periodId: periodId,
26384
+ status: NdcDetailsActionStatus.New,
26385
+ };
26386
+ setEditingKey(nextAvailableActionId);
26387
+ setNextAvailableActionId(function (value) { return value + 1; });
26388
+ setNdcDetailsData(function (ndcDetailsData) { return __spreadArray(__spreadArray([], ndcDetailsData, true), [
26389
+ newData_1,
26390
+ ], false); });
26391
+ setTableKey(function (key) { return key + 1; });
26392
+ }
26393
+ return [2 /*return*/];
26394
+ });
26395
+ });
26371
26396
  }
26372
26397
  var components = {
26373
26398
  body: {
26374
- row: EditableRow,
26375
26399
  cell: EditableCell,
26376
26400
  },
26377
26401
  };
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);
26402
+ var onClickedDeletePeriod = function () { return __awaiter(void 0, void 0, void 0, function () {
26403
+ return __generator(this, function (_a) {
26404
+ setActionInfo({
26405
+ action: "Delete",
26406
+ headerText: t("ndc:periodDeleteConfirmTitle"),
26407
+ type: "danger",
26408
+ icon: React.createElement(Icon.XCircle, null),
26409
+ recordId: selectedPeriod.key,
26414
26410
  });
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 {
26420
- message.open({
26421
- type: "error",
26422
- content: t("ndc:rangeAlreadyExists"),
26423
- duration: 3,
26424
- style: { textAlign: "right", marginRight: 15, marginTop: 10 },
26425
- });
26426
- }
26411
+ setOpenConfirmationModal(true);
26412
+ return [2 /*return*/];
26413
+ });
26414
+ }); };
26415
+ var onClickedFinalizePeriod = function () { return __awaiter(void 0, void 0, void 0, function () {
26416
+ return __generator(this, function (_a) {
26417
+ setActionInfo({
26418
+ action: "Finalize",
26419
+ headerText: t("ndc:finalizeApproveTitle"),
26420
+ text: t("ndc:finalizeApproveSubTitle"),
26421
+ type: "primary",
26422
+ icon: React.createElement(Icon.Clipboard2Check, null),
26423
+ recordId: selectedPeriod.key,
26424
+ });
26425
+ setOpenConfirmationModal(true);
26426
+ return [2 /*return*/];
26427
+ });
26428
+ }); };
26429
+ var onMainTableRowExpand = function (expanded, record) {
26430
+ var keys = [];
26431
+ if (expanded) {
26432
+ keys.push(record.id);
26427
26433
  }
26434
+ setExpandedRowKeys(keys);
26435
+ var subNdcDetails = ndcDetailsData.filter(function (ndcDetail) {
26436
+ return (ndcDetail.parentActionId === record.id &&
26437
+ ndcDetail.actionType === NdcDetailsActionType.SubAction);
26438
+ });
26439
+ var emptySubNdcRow = {
26440
+ id: nextAvailableActionId,
26441
+ actionType: NdcDetailsActionType.SubAction,
26442
+ nationalPlanObjective: "",
26443
+ kpi: "",
26444
+ ministryName: loginMinistry,
26445
+ status: NdcDetailsActionStatus.New,
26446
+ parentActionId: record.id,
26447
+ };
26448
+ setEditingKey(nextAvailableActionId);
26449
+ setNextAvailableActionId(function (value) { return value + 1; });
26450
+ form.setFieldsValue({
26451
+ nationalPlanObjective: "",
26452
+ kpi: "",
26453
+ });
26454
+ setSubNdcDetailsForPeriod(__spreadArray(__spreadArray([], subNdcDetails, true), [emptySubNdcRow], false));
26428
26455
  };
26429
- useEffect(function () {
26430
- if (periodItems && periodItems.length > 3) {
26431
- setSelectedTab(periodItems[periodItems.length - 1].key);
26432
- }
26433
- }, [periodItems]);
26456
+ function ndcDetailsTableContent() {
26457
+ return (React.createElement("div", null,
26458
+ React.createElement(Row, null,
26459
+ React.createElement(Col, { span: 24 },
26460
+ React.createElement(Form, { form: form, component: false },
26461
+ React.createElement(Table, { key: tableKey, rowKey: "id", components: components, rowClassName: function () { return "editable-row"; }, bordered: true, dataSource: ndcMainDetailsForPeriod, columns: columns, expandedRowKeys: expandedRowKeys, onExpand: onMainTableRowExpand, expandable: {
26462
+ expandedRowRender: function (record) { return getSubNdcActionContent(record); },
26463
+ indentSize: 0,
26464
+ //defaultExpandedRowKeys: [parseInt(selectedNdcDetail.current.id)],
26465
+ }, onRow: function (record, rowIndex) {
26466
+ return {
26467
+ onClick: function () {
26468
+ if (record.id && isMainNdcActionsEditable && !isEditing(record)) {
26469
+ form.setFieldsValue(__assign({}, record));
26470
+ setEditingKey(record.id);
26471
+ }
26472
+ },
26473
+ onMouseLeave: function () {
26474
+ if (isEditing(record)) {
26475
+ handleSave(record);
26476
+ }
26477
+ },
26478
+ };
26479
+ }, footer: function () {
26480
+ return isGovernmentUser &&
26481
+ !selectedPeriod.finalized && (React.createElement(Row, { justify: "center" },
26482
+ React.createElement(Button, { onClick: onClickedAddNewNdcDetail, type: "default", style: {
26483
+ marginBottom: 16,
26484
+ width: "100%",
26485
+ } }, t("ndc:addNdcAction"))));
26486
+ } })))),
26487
+ isGovernmentUser && !selectedPeriod.finalized ? (React.createElement(Row, { justify: "end" },
26488
+ React.createElement(Button, { className: "mg-left-1", type: "primary", onClick: onClickedDeletePeriod, htmlType: "submit", loading: loading }, t("ndc:delete")),
26489
+ React.createElement(Button, { className: "mg-left-1", type: "primary", onClick: onClickedFinalizePeriod, htmlType: "submit", loading: loading }, t("ndc:finalize")))) : ("")));
26490
+ }
26491
+ var onAddNewPeriod = function () { return __awaiter(void 0, void 0, void 0, function () {
26492
+ var periodItem_1, existingIndex, response, addedPeriodItem, updatedPeriodItem_1;
26493
+ return __generator(this, function (_a) {
26494
+ switch (_a.label) {
26495
+ case 0:
26496
+ if (!(selectedDateRangeRef && selectedDateRangeRef.current)) return [3 /*break*/, 3];
26497
+ periodItem_1 = {
26498
+ startYear: selectedDateRangeRef.current.startYear,
26499
+ endYear: selectedDateRangeRef.current.endYear,
26500
+ finalized: false,
26501
+ };
26502
+ existingIndex = periodItems.findIndex(function (item) {
26503
+ return inRange(periodItem_1.startYear, item.startYear, item.endYear) ||
26504
+ inRange(periodItem_1.endYear, item.startYear, item.endYear);
26505
+ });
26506
+ if (!(existingIndex === -1)) return [3 /*break*/, 2];
26507
+ return [4 /*yield*/, post("national/programme/addNdcDetailsPeriod", __assign({}, periodItem_1))];
26508
+ case 1:
26509
+ response = _a.sent();
26510
+ if (response && response.data) {
26511
+ addedPeriodItem = response.data;
26512
+ updatedPeriodItem_1 = __assign(__assign({}, addedPeriodItem), { key: addedPeriodItem.id, label: "".concat(addedPeriodItem.startYear, "-").concat(addedPeriodItem.endYear) });
26513
+ setPeriodItems(function (items) { return __spreadArray(__spreadArray([], items, true), [updatedPeriodItem_1], false); });
26514
+ setSelectedPeriod(updatedPeriodItem_1);
26515
+ }
26516
+ return [3 /*break*/, 3];
26517
+ case 2:
26518
+ message.open({
26519
+ type: "error",
26520
+ content: t("ndc:rangeAlreadyExists"),
26521
+ duration: 3,
26522
+ style: { textAlign: "right", marginRight: 15, marginTop: 10 },
26523
+ });
26524
+ _a.label = 3;
26525
+ case 3: return [2 /*return*/];
26526
+ }
26527
+ });
26528
+ }); };
26434
26529
  var onDateRangeChanged = function (range) {
26435
26530
  var period = {
26436
- start: Number(moment(range[0]).year()),
26437
- end: Number(moment(range[1]).year()),
26531
+ startYear: Number(moment(range[0]).year()),
26532
+ endYear: Number(moment(range[1]).year()),
26438
26533
  };
26439
- selectedPeriod.current = period;
26534
+ selectedDateRangeRef.current = period;
26440
26535
  };
26441
26536
  function addNewPeriodContent() {
26442
26537
  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"))))));
26538
+ React.createElement(Row, { justify: "start", align: "middle", gutter: [16, 16] },
26539
+ React.createElement(Col, { flex: "340px" },
26540
+ React.createElement(RangePicker, { onChange: onDateRangeChanged, picker: "year" })),
26541
+ React.createElement(Col, { flex: "auto" },
26542
+ React.createElement(Button, { type: "primary", onClick: onAddNewPeriod, htmlType: "submit", loading: loading }, t("ndc:submit"))))));
26449
26543
  }
26450
26544
  function getSubNdcActionContent(record) {
26451
26545
  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 }));
26546
+ return (React.createElement(Table, { rowKey: "id", components: components, rowClassName: function () { return "editable-row"; }, bordered: true, dataSource: subNdcDetailsForPeriod, onRow: function (record, rowIndex) {
26547
+ return {
26548
+ onClick: function () {
26549
+ if (record.id && isSubNdcActionsEditable(record) && !isEditing(record)) {
26550
+ form.setFieldsValue(__assign({}, record));
26551
+ setEditingKey(record.id);
26552
+ }
26553
+ },
26554
+ onMouseLeave: function () {
26555
+ if (isEditing(record)) {
26556
+ handleSave(record);
26557
+ }
26558
+ },
26559
+ };
26560
+ }, columns: columns, showHeader: false, pagination: false }));
26453
26561
  }
26454
26562
  var onTabChange = function (key) {
26455
- setSelectedTab(key);
26563
+ var selectedPeriod = periodItems.find(function (item) { return item.key === key; });
26564
+ if (selectedPeriod) {
26565
+ setSelectedPeriod(selectedPeriod);
26566
+ }
26456
26567
  };
26568
+ var onActionConfirmed = function () { return __awaiter(void 0, void 0, void 0, function () {
26569
+ var response, response, response, result;
26570
+ return __generator(this, function (_a) {
26571
+ switch (_a.label) {
26572
+ case 0:
26573
+ if (!(actionInfo.action === "Approve")) return [3 /*break*/, 2];
26574
+ return [4 /*yield*/, get("national/programme/approveNdcDetailsAction", {
26575
+ id: actionInfo.recordId,
26576
+ })];
26577
+ case 1:
26578
+ response = _a.sent();
26579
+ return [3 /*break*/, 8];
26580
+ case 2:
26581
+ if (!(actionInfo.action === "Reject")) return [3 /*break*/, 4];
26582
+ return [4 /*yield*/, get("national/programme/rejectNdcDetailsAction", {
26583
+ id: actionInfo.recordId,
26584
+ })];
26585
+ case 3:
26586
+ response = _a.sent();
26587
+ return [3 /*break*/, 8];
26588
+ case 4:
26589
+ if (!(actionInfo.action === "Finalize")) return [3 /*break*/, 6];
26590
+ return [4 /*yield*/, post("national/programme/finalizeNdcDetailsPeriod", {
26591
+ id: selectedPeriod.key,
26592
+ })];
26593
+ case 5:
26594
+ response = _a.sent();
26595
+ if (response) {
26596
+ fetchNdcDetailPeriods();
26597
+ }
26598
+ return [3 /*break*/, 8];
26599
+ case 6:
26600
+ if (!(actionInfo.action === "Delete")) return [3 /*break*/, 8];
26601
+ return [4 /*yield*/, post("national/programme/deleteNdcDetailsPeriod", {
26602
+ id: selectedPeriod.key,
26603
+ })];
26604
+ case 7:
26605
+ result = _a.sent();
26606
+ if (result) {
26607
+ fetchNdcDetailPeriods();
26608
+ }
26609
+ _a.label = 8;
26610
+ case 8:
26611
+ setOpenConfirmationModal(false);
26612
+ return [2 /*return*/];
26613
+ }
26614
+ });
26615
+ }); };
26616
+ var onActionCanceled = function () {
26617
+ setOpenConfirmationModal(false);
26618
+ };
26619
+ var fetchNdcDetailPeriods = function () { return __awaiter(void 0, void 0, void 0, function () {
26620
+ var periods, addNewTab, response;
26621
+ return __generator(this, function (_a) {
26622
+ switch (_a.label) {
26623
+ case 0:
26624
+ periods = [];
26625
+ addNewTab = {
26626
+ key: "add_new",
26627
+ label: "Add New",
26628
+ startYear: 0,
26629
+ endYear: 0,
26630
+ finalized: false,
26631
+ deleted: false,
26632
+ };
26633
+ return [4 /*yield*/, get("national/programme/queryNdcDetailsPeriod")];
26634
+ case 1:
26635
+ response = _a.sent();
26636
+ if (response && response.data) {
26637
+ periods = response.data.map(function (period) {
26638
+ return __assign(__assign({}, period), { key: period.id, label: period.finalized ? (React.createElement("span", null,
26639
+ React.createElement(LockOutlined, null),
26640
+ " ",
26641
+ period.startYear,
26642
+ "-",
26643
+ period.endYear,
26644
+ " ")) : ("".concat(period.startYear, "-").concat(period.endYear)) });
26645
+ });
26646
+ }
26647
+ if (isGovernmentUser) {
26648
+ periods.unshift(addNewTab);
26649
+ }
26650
+ setPeriodItems(periods);
26651
+ setSelectedPeriod(addNewTab);
26652
+ return [2 /*return*/];
26653
+ }
26654
+ });
26655
+ }); };
26656
+ var fetchNdcDetailActions = function () { return __awaiter(void 0, void 0, void 0, function () {
26657
+ var response, maxActionId;
26658
+ return __generator(this, function (_a) {
26659
+ switch (_a.label) {
26660
+ case 0: return [4 /*yield*/, get("national/programme/queryNdcDetailsAction")];
26661
+ case 1:
26662
+ response = _a.sent();
26663
+ if (response && response.data) {
26664
+ maxActionId = Math.max.apply(Math, response.data.map(function (item) { return item.id; }));
26665
+ setNextAvailableActionId(maxActionId + 1);
26666
+ setNdcDetailsData(response.data);
26667
+ }
26668
+ return [2 /*return*/];
26669
+ }
26670
+ });
26671
+ }); };
26672
+ var fetchMinistries = function () { return __awaiter(void 0, void 0, void 0, function () {
26673
+ var response, ministryOrgDetails;
26674
+ return __generator(this, function (_a) {
26675
+ switch (_a.label) {
26676
+ case 0: return [4 /*yield*/, get("national/organisation/getMinistries")];
26677
+ case 1:
26678
+ response = _a.sent();
26679
+ if (response && response.data) {
26680
+ ministryOrgDetails = response.data.map(function (value) {
26681
+ return {
26682
+ value: value.company_companyId,
26683
+ label: value.company_name,
26684
+ };
26685
+ });
26686
+ setMinistryOrgList(ministryOrgDetails);
26687
+ }
26688
+ return [2 /*return*/];
26689
+ }
26690
+ });
26691
+ }); };
26457
26692
  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);
26693
+ fetchNdcDetailPeriods();
26694
+ fetchNdcDetailActions();
26695
+ fetchMinistries();
26718
26696
  }, []);
26719
26697
  return (React.createElement("div", { className: "ndc-management content-container" },
26720
26698
  React.createElement("div", { className: "title-bar" },
@@ -26723,20 +26701,11 @@ var NdcDetailsComponent = function (props) {
26723
26701
  React.createElement("div", { className: "body-title" }, t("ndc:ndcTitle")),
26724
26702
  React.createElement("div", { className: "body-sub-title" }, t("ndc:ndcSubTitle"))))),
26725
26703
  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
- } }))))));
26704
+ React.createElement(Tabs, { centered: false, defaultActiveKey: "1", items: periodItems, activeKey: selectedPeriod.key, onChange: onTabChange })),
26705
+ React.createElement("div", null, selectedPeriod.key === "add_new"
26706
+ ? addNewPeriodContent()
26707
+ : ndcDetailsTableContent()),
26708
+ React.createElement(UserActionConfirmationModel, { t: t, actionInfo: actionInfo, onActionConfirmed: onActionConfirmed, onActionCanceled: onActionCanceled, openModal: openConfirmationModal, errorMsg: "", loading: false })));
26740
26709
  };
26741
26710
 
26742
26711
  var ImgWithFallback = function (_a) {
@@ -28338,5 +28307,5 @@ var TimelineBody = function (props) {
28338
28307
  React.createElement("div", { className: "remark-body" }, remark)))));
28339
28308
  };
28340
28309
 
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 };
28310
+ 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
28311
  //# sourceMappingURL=index.js.map