@undp/carbon-library 1.0.17-CARBON-363.20 → 1.0.17-CARBON-363.97

Sign up to get free protection for your applications and to get access to all the features.
package/dist/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { PlusOutlined, FilterOutlined, BankOutlined, SafetyOutlined, AuditOutlined, ExperimentOutlined, UploadOutlined, UserOutlined, MinusCircleOutlined, StarOutlined, ToolOutlined, EyeOutlined, SearchOutlined, EllipsisOutlined, EditOutlined, DeleteOutlined, FileAddOutlined, CheckCircleOutlined, ExclamationCircleOutlined, BookOutlined, CaretDownOutlined, EyeInvisibleOutlined, GlobalOutlined, FlagOutlined, LineChartOutlined, LikeOutlined, DislikeOutlined } from '@ant-design/icons';
1
+ import { PlusOutlined, FilterOutlined, BankOutlined, SafetyOutlined, AuditOutlined, ExperimentOutlined, UploadOutlined, UserOutlined, MinusCircleOutlined, StarOutlined, ToolOutlined, EyeOutlined, SearchOutlined, EllipsisOutlined, EditOutlined, DeleteOutlined, FileAddOutlined, CheckCircleOutlined, ExclamationCircleOutlined, BookOutlined, CaretDownOutlined, LockOutlined, EyeInvisibleOutlined, GlobalOutlined, FlagOutlined, LineChartOutlined, LikeOutlined, DislikeOutlined } from '@ant-design/icons';
2
2
  import { Input, Radio, Space, Row, Col, Button, Dropdown, Table, Empty, message, Form, Steps, Upload, InputNumber, Tooltip, Select, Modal, Alert, Skeleton, Card, Tag, Checkbox, DatePicker, Popover, List, Typography, Spin, Tabs, Progress } from 'antd';
3
- import React, { useState, useEffect, useRef, useContext } from 'react';
3
+ import React, { useState, useEffect, useRef } from 'react';
4
4
  import { DateTime } from 'luxon';
5
5
  import { Buffer } from 'buffer';
6
6
  import PhoneInput, { formatPhoneNumberIntl, formatPhoneNumber } from 'react-phone-number-input';
@@ -2027,7 +2027,7 @@ var NdcActionStatus;
2027
2027
  NdcActionStatus["PENDING"] = "Pending";
2028
2028
  NdcActionStatus["APPROVED"] = "Approved";
2029
2029
  })(NdcActionStatus || (NdcActionStatus = {}));
2030
- var getNdcActionStatusEnumVal = function (value) {
2030
+ var getNdcActionStatusEnumVal$1 = function (value) {
2031
2031
  var index = Object.keys(NdcActionStatus).indexOf(value);
2032
2032
  if (index < 0) {
2033
2033
  return value;
@@ -2035,7 +2035,7 @@ var getNdcActionStatusEnumVal = function (value) {
2035
2035
  return Object.values(NdcActionStatus)[index];
2036
2036
  };
2037
2037
  var getNdcStatusTagType = function (status) {
2038
- switch (getNdcActionStatusEnumVal(status)) {
2038
+ switch (getNdcActionStatusEnumVal$1(status)) {
2039
2039
  case NdcActionStatus.PENDING:
2040
2040
  return "processing";
2041
2041
  case NdcActionStatus.APPROVED:
@@ -26123,70 +26123,58 @@ 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
- _a.title; var 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 },
26172
- 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" });
26173
26132
  }
26174
- 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)));
26175
26142
  };
26176
26143
 
26177
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";
26178
26145
  styleInject(css_248z$4);
26179
26146
 
26180
- var NdcActionType;
26181
- (function (NdcActionType) {
26182
- NdcActionType[NdcActionType["mainAction"] = 0] = "mainAction";
26183
- NdcActionType[NdcActionType["subAction"] = 1] = "subAction";
26184
- })(NdcActionType || (NdcActionType = {}));
26147
+ var NdcDetailsActionType;
26148
+ (function (NdcDetailsActionType) {
26149
+ NdcDetailsActionType["MainAction"] = "MainAction";
26150
+ NdcDetailsActionType["SubAction"] = "SubAction";
26151
+ })(NdcDetailsActionType || (NdcDetailsActionType = {}));
26185
26152
  var NdcDetailsActionStatus;
26186
26153
  (function (NdcDetailsActionStatus) {
26187
- NdcDetailsActionStatus[NdcDetailsActionStatus["pending"] = 0] = "pending";
26188
- NdcDetailsActionStatus[NdcDetailsActionStatus["approved"] = 1] = "approved";
26154
+ NdcDetailsActionStatus["New"] = "New";
26155
+ NdcDetailsActionStatus["Pending"] = "Pending";
26156
+ NdcDetailsActionStatus["Approved"] = "Approved";
26157
+ NdcDetailsActionStatus["Rejected"] = "Rejected";
26189
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
+ };
26190
26178
 
26191
26179
  var NdcDetailsComponent = function (props) {
26192
26180
  var t = props.t, useConnection = props.useConnection, useUserContext = props.useUserContext;
@@ -26200,6 +26188,14 @@ var NdcDetailsComponent = function (props) {
26200
26188
  var _e = useState(0), tableKey = _e[0], setTableKey = _e[1];
26201
26189
  var _f = useConnection(), get = _f.get, post = _f.post, put = _f.put;
26202
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; };
26203
26199
  var userInfoState = useUserContext().userInfoState;
26204
26200
  var loginMinistry = (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.GOVERNMENT
26205
26201
  ? process.env.REACT_APP_GOVERNMENT_MINISTRY
@@ -26208,13 +26204,12 @@ var NdcDetailsComponent = function (props) {
26208
26204
  : (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.MINISTRY
26209
26205
  ? userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyName
26210
26206
  : undefined;
26211
- var isAddRangeVisible = ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.MINISTRY ||
26212
- (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.GOVERNMENT) &&
26207
+ var isGovernmentUser = (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.GOVERNMENT &&
26213
26208
  (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== Role.ViewOnly;
26214
26209
  var ndcMainDetailsForPeriod = selectedPeriod.key !== "add_new"
26215
26210
  ? ndcDetailsData.filter(function (ndcDetail) {
26216
26211
  return (ndcDetail.periodId === parseInt(selectedPeriod.key) &&
26217
- ndcDetail.actionType === NdcActionType.mainAction);
26212
+ ndcDetail.actionType === NdcDetailsActionType.MainAction);
26218
26213
  })
26219
26214
  : [];
26220
26215
  var isMainNdcActionsEditable = !selectedPeriod.finalized &&
@@ -26222,84 +26217,138 @@ var NdcDetailsComponent = function (props) {
26222
26217
  (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== Role.ViewOnly;
26223
26218
  var isSubNdcActionsEditable = function (record) {
26224
26219
  return (!selectedPeriod.finalized &&
26220
+ record.status !== NdcDetailsActionStatus.Approved &&
26225
26221
  ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.GOVERNMENT ||
26226
26222
  ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.MINISTRY &&
26227
26223
  (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyName) === record.ministryName)) &&
26228
26224
  (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== Role.ViewOnly);
26229
26225
  };
26230
- var getSubNdcDetailsForPeriod = function (id) {
26231
- var subNdcDetails = ndcDetailsData.filter(function (ndcDetail) {
26232
- return (ndcDetail.parentActionId === id &&
26233
- ndcDetail.actionType === NdcActionType.subAction);
26234
- });
26235
- var emptySubNdcRow = {
26236
- actionType: NdcActionType.subAction,
26237
- nationalPlanObjective: "",
26238
- kpi: 0,
26239
- ministryName: loginMinistry,
26240
- status: NdcDetailsActionStatus.pending,
26241
- parentActionId: id,
26242
- };
26243
- return __spreadArray(__spreadArray([], subNdcDetails, true), [emptySubNdcRow], false);
26244
- };
26245
- var isAddNdcActionVisible = function () {
26246
- return ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.GOVERNMENT &&
26247
- (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== Role.ViewOnly);
26248
- };
26249
26226
  var inRange = function (num, min, max) {
26250
26227
  return num >= min && num <= max;
26251
26228
  };
26252
26229
  var handleSave = function (row) { return __awaiter(void 0, void 0, void 0, function () {
26253
- var updatedItemIndex;
26230
+ var updatedFields, updatedItem, exception_1;
26254
26231
  return __generator(this, function (_a) {
26255
26232
  switch (_a.label) {
26256
26233
  case 0:
26257
- updatedItemIndex = ndcDetailsData.findIndex(function (item) { return item.id === row.id; });
26258
- if (!(updatedItemIndex === -1)) return [3 /*break*/, 2];
26259
- return [4 /*yield*/, post("national/programme/addNdcDetailsAction", __assign(__assign({}, row), { kpi: parseInt(row.kpi) }))];
26234
+ _a.trys.push([0, 6, , 7]);
26235
+ return [4 /*yield*/, form.validateFields()];
26260
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:
26261
26243
  _a.sent();
26262
- return [3 /*break*/, 4];
26263
- case 2: return [4 /*yield*/, put("national/programme/updateNdcDetailsAction", __assign(__assign({}, row), { kpi: parseInt(row.kpi) }))];
26244
+ return [3 /*break*/, 5];
26264
26245
  case 3:
26265
- _a.sent();
26266
- _a.label = 4;
26246
+ updatedItem.status = NdcDetailsActionStatus.Pending;
26247
+ return [4 /*yield*/, put("national/programme/updateNdcDetailsAction", __assign(__assign({}, updatedItem), { kpi: parseInt(updatedItem.kpi) }))];
26267
26248
  case 4:
26249
+ _a.sent();
26250
+ _a.label = 5;
26251
+ case 5:
26268
26252
  fetchNdcDetailActions();
26269
- return [2 /*return*/];
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*/];
26270
26260
  }
26271
26261
  });
26272
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
+ }
26298
+ else {
26299
+ return null;
26300
+ }
26301
+ };
26273
26302
  var defaultColumns = [
26274
26303
  {
26275
26304
  title: t("ndc:ndcColumnsNationalPlanObj"),
26276
26305
  dataIndex: "nationalPlanObjective",
26277
26306
  key: "nationalPlanObjective",
26278
26307
  align: "left",
26279
- width: "50%",
26308
+ width: "40%",
26280
26309
  editable: true,
26281
- render: function (_, record) { return (React.createElement(React.Fragment, null, record.nationalPlanObjective ? (React.createElement(Space, { size: "middle" },
26282
- React.createElement("span", null, record.nationalPlanObjective))) : (React.createElement("input", { placeholder: "Please add the National Plan Objective", className: "ant-input", type: "text" })))); },
26283
26310
  },
26284
26311
  {
26285
26312
  title: t("ndc:ndcColumnsKpi"),
26286
26313
  dataIndex: "kpi",
26287
26314
  key: "kpi",
26288
26315
  align: "left",
26289
- width: "10%",
26316
+ width: "15%",
26290
26317
  editable: true,
26291
- render: function (_, record) { return (React.createElement(React.Fragment, null, record.kpi ? (React.createElement(Space, { size: "middle" },
26292
- React.createElement("span", null, record.kpi))) : (React.createElement("input", { placeholder: "Enter Kpi", className: "ant-input", type: "text" })))); },
26293
26318
  },
26294
26319
  {
26295
- title: "ministryName",
26320
+ title: t("ndc:ndcColumnsMinistry"),
26296
26321
  dataIndex: "ministryName",
26297
26322
  key: "ministryName",
26298
26323
  align: "left",
26299
- width: "40%",
26324
+ width: "30%",
26300
26325
  editable: false,
26301
26326
  render: function (_, record) { return (React.createElement(React.Fragment, null,
26302
- React.createElement(Select, { disabled: !isSubNdcActionsEditable(record), defaultValue: record.ministryName ? record.ministryName : loginMinistry, style: { width: 320 }, onChange: function () { }, options: ministryOrgList }))); },
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
+ },
26303
26352
  },
26304
26353
  ];
26305
26354
  var columns = defaultColumns.map(function (col) {
@@ -26307,93 +26356,137 @@ var NdcDetailsComponent = function (props) {
26307
26356
  return col;
26308
26357
  }
26309
26358
  return __assign(__assign({}, col), { onCell: function (record) {
26310
- console.log("record", record);
26311
26359
  return {
26312
26360
  record: record,
26313
- editable: record.actionType === NdcActionType.mainAction
26314
- ? isMainNdcActionsEditable
26315
- : isSubNdcActionsEditable(record),
26361
+ editing: isEditing(record),
26316
26362
  dataIndex: col.dataIndex,
26317
26363
  title: col.title,
26318
- handleSave: handleSave,
26319
26364
  };
26320
26365
  } });
26321
26366
  });
26322
26367
  function onClickedAddNewNdcDetail() {
26323
26368
  return __awaiter(this, void 0, void 0, function () {
26324
- var periodId, newData, response, newlyCreatedNdcAction_1;
26369
+ var periodId, newData_1;
26325
26370
  return __generator(this, function (_a) {
26326
- switch (_a.label) {
26327
- case 0:
26328
- if (!(selectedPeriod.key !== "add_new")) return [3 /*break*/, 2];
26329
- periodId = parseInt(selectedPeriod.key);
26330
- newData = {
26331
- actionType: NdcActionType.mainAction,
26332
- nationalPlanObjective: "",
26333
- kpi: 0,
26334
- ministryName: loginMinistry,
26335
- periodId: periodId,
26336
- status: NdcDetailsActionStatus.pending,
26337
- };
26338
- return [4 /*yield*/, post("national/programme/addNdcDetailsAction", __assign({}, newData))];
26339
- case 1:
26340
- response = _a.sent();
26341
- if (response && response.data) {
26342
- newlyCreatedNdcAction_1 = response.data;
26343
- setNdcDetailsData(function (ndcDetailsData) { return __spreadArray(__spreadArray([], ndcDetailsData, true), [
26344
- newlyCreatedNdcAction_1,
26345
- ], false); });
26346
- setTableKey(function (key) { return key + 1; });
26347
- }
26348
- _a.label = 2;
26349
- case 2: return [2 /*return*/];
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; });
26350
26392
  }
26393
+ return [2 /*return*/];
26351
26394
  });
26352
26395
  });
26353
26396
  }
26354
26397
  var components = {
26355
26398
  body: {
26356
- row: EditableRow,
26357
26399
  cell: EditableCell,
26358
26400
  },
26359
26401
  };
26360
- var onDeletePeriod = function () { return __awaiter(void 0, void 0, void 0, function () {
26361
- var result;
26402
+ var onClickedDeletePeriod = function () { return __awaiter(void 0, void 0, void 0, function () {
26362
26403
  return __generator(this, function (_a) {
26363
- switch (_a.label) {
26364
- case 0: return [4 /*yield*/, post("national/programme/deleteNdcDetailsPeriod", {
26365
- id: selectedPeriod.key,
26366
- })];
26367
- case 1:
26368
- result = _a.sent();
26369
- if (result) {
26370
- fetchNdcDetailPeriods();
26371
- }
26372
- return [2 /*return*/];
26373
- }
26404
+ setActionInfo({
26405
+ action: "Delete",
26406
+ headerText: t("ndc:periodDeleteConfirmTitle"),
26407
+ type: "danger",
26408
+ icon: React.createElement(Icon.XCircle, null),
26409
+ recordId: selectedPeriod.key,
26410
+ });
26411
+ setOpenConfirmationModal(true);
26412
+ return [2 /*return*/];
26374
26413
  });
26375
26414
  }); };
26376
- var onFinalizePeriod = function () {
26377
- //
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);
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));
26378
26455
  };
26379
26456
  function ndcDetailsTableContent() {
26380
26457
  return (React.createElement("div", null,
26381
26458
  React.createElement(Row, null,
26382
26459
  React.createElement(Col, { span: 24 },
26383
- React.createElement(Table, { key: tableKey, rowKey: "id", components: components, rowClassName: function () { return "editable-row"; }, bordered: true, dataSource: ndcMainDetailsForPeriod, columns: columns, expandable: {
26384
- expandedRowRender: function (record) { return getSubNdcActionContent(record); },
26385
- indentSize: 0,
26386
- //defaultExpandedRowKeys: [parseInt(selectedNdcDetail.current.id)],
26387
- }, footer: function () {
26388
- return isAddNdcActionVisible() && (React.createElement(Row, { justify: "center" },
26389
- React.createElement(Button, { onClick: onClickedAddNewNdcDetail, type: "default", style: {
26390
- marginBottom: 16,
26391
- width: "100%",
26392
- } }, t("ndc:addNdcAction"))));
26393
- } }))),
26394
- React.createElement(Row, { justify: "end" },
26395
- React.createElement(Button, { className: "mg-left-1", type: "primary", onClick: onDeletePeriod, htmlType: "submit", loading: loading }, t("ndc:delete")),
26396
- React.createElement(Button, { className: "mg-left-1", type: "primary", onClick: onFinalizePeriod, htmlType: "submit", loading: loading }, t("ndc:finalize")))));
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")))) : ("")));
26397
26490
  }
26398
26491
  var onAddNewPeriod = function () { return __awaiter(void 0, void 0, void 0, function () {
26399
26492
  var periodItem_1, existingIndex, response, addedPeriodItem, updatedPeriodItem_1;
@@ -26450,7 +26543,21 @@ var NdcDetailsComponent = function (props) {
26450
26543
  }
26451
26544
  function getSubNdcActionContent(record) {
26452
26545
  selectedNdcDetail.current = record;
26453
- return (React.createElement(Table, { rowKey: "id", components: components, rowClassName: function () { return "editable-row"; }, bordered: true, dataSource: getSubNdcDetailsForPeriod(record.id), 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 }));
26454
26561
  }
26455
26562
  var onTabChange = function (key) {
26456
26563
  var selectedPeriod = periodItems.find(function (item) { return item.key === key; });
@@ -26458,6 +26565,57 @@ var NdcDetailsComponent = function (props) {
26458
26565
  setSelectedPeriod(selectedPeriod);
26459
26566
  }
26460
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
+ };
26461
26619
  var fetchNdcDetailPeriods = function () { return __awaiter(void 0, void 0, void 0, function () {
26462
26620
  var periods, addNewTab, response;
26463
26621
  return __generator(this, function (_a) {
@@ -26477,10 +26635,16 @@ var NdcDetailsComponent = function (props) {
26477
26635
  response = _a.sent();
26478
26636
  if (response && response.data) {
26479
26637
  periods = response.data.map(function (period) {
26480
- return __assign(__assign({}, period), { key: period.id, label: "".concat(period.startYear, "-").concat(period.endYear) });
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)) });
26481
26645
  });
26482
26646
  }
26483
- if (isAddRangeVisible) {
26647
+ if (isGovernmentUser) {
26484
26648
  periods.unshift(addNewTab);
26485
26649
  }
26486
26650
  setPeriodItems(periods);
@@ -26490,13 +26654,15 @@ var NdcDetailsComponent = function (props) {
26490
26654
  });
26491
26655
  }); };
26492
26656
  var fetchNdcDetailActions = function () { return __awaiter(void 0, void 0, void 0, function () {
26493
- var response;
26657
+ var response, maxActionId;
26494
26658
  return __generator(this, function (_a) {
26495
26659
  switch (_a.label) {
26496
26660
  case 0: return [4 /*yield*/, get("national/programme/queryNdcDetailsAction")];
26497
26661
  case 1:
26498
26662
  response = _a.sent();
26499
26663
  if (response && response.data) {
26664
+ maxActionId = Math.max.apply(Math, response.data.map(function (item) { return item.id; }));
26665
+ setNextAvailableActionId(maxActionId + 1);
26500
26666
  setNdcDetailsData(response.data);
26501
26667
  }
26502
26668
  return [2 /*return*/];
@@ -26507,15 +26673,14 @@ var NdcDetailsComponent = function (props) {
26507
26673
  var response, ministryOrgDetails;
26508
26674
  return __generator(this, function (_a) {
26509
26675
  switch (_a.label) {
26510
- case 0: return [4 /*yield*/, get("national/company/getMinistries")];
26676
+ case 0: return [4 /*yield*/, get("national/organisation/getMinistries")];
26511
26677
  case 1:
26512
26678
  response = _a.sent();
26513
- console.log('fetchMinistries', response);
26514
26679
  if (response && response.data) {
26515
26680
  ministryOrgDetails = response.data.map(function (value) {
26516
26681
  return {
26517
- value: value.user_id,
26518
- label: value.user_name,
26682
+ value: value.company_companyId,
26683
+ label: value.company_name,
26519
26684
  };
26520
26685
  });
26521
26686
  setMinistryOrgList(ministryOrgDetails);
@@ -26539,7 +26704,8 @@ var NdcDetailsComponent = function (props) {
26539
26704
  React.createElement(Tabs, { centered: false, defaultActiveKey: "1", items: periodItems, activeKey: selectedPeriod.key, onChange: onTabChange })),
26540
26705
  React.createElement("div", null, selectedPeriod.key === "add_new"
26541
26706
  ? addNewPeriodContent()
26542
- : ndcDetailsTableContent())));
26707
+ : ndcDetailsTableContent()),
26708
+ React.createElement(UserActionConfirmationModel, { t: t, actionInfo: actionInfo, onActionConfirmed: onActionConfirmed, onActionCanceled: onActionCanceled, openModal: openConfirmationModal, errorMsg: "", loading: false })));
26543
26709
  };
26544
26710
 
26545
26711
  var ImgWithFallback = function (_a) {
@@ -28140,5 +28306,5 @@ var TimelineBody = function (props) {
28140
28306
  React.createElement("div", { className: "remark-body" }, remark)))));
28141
28307
  };
28142
28308
 
28143
- 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 };
28309
+ 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 };
28144
28310
  //# sourceMappingURL=index.js.map