@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/cjs/index.js CHANGED
@@ -2047,7 +2047,7 @@ exports.NdcActionStatus = void 0;
2047
2047
  NdcActionStatus["PENDING"] = "Pending";
2048
2048
  NdcActionStatus["APPROVED"] = "Approved";
2049
2049
  })(exports.NdcActionStatus || (exports.NdcActionStatus = {}));
2050
- var getNdcActionStatusEnumVal = function (value) {
2050
+ var getNdcActionStatusEnumVal$1 = function (value) {
2051
2051
  var index = Object.keys(exports.NdcActionStatus).indexOf(value);
2052
2052
  if (index < 0) {
2053
2053
  return value;
@@ -2055,7 +2055,7 @@ var getNdcActionStatusEnumVal = function (value) {
2055
2055
  return Object.values(exports.NdcActionStatus)[index];
2056
2056
  };
2057
2057
  var getNdcStatusTagType = function (status) {
2058
- switch (getNdcActionStatusEnumVal(status)) {
2058
+ switch (getNdcActionStatusEnumVal$1(status)) {
2059
2059
  case exports.NdcActionStatus.PENDING:
2060
2060
  return "processing";
2061
2061
  case exports.NdcActionStatus.APPROVED:
@@ -26143,70 +26143,58 @@ var RegistryDashboardComponent = function (props) {
26143
26143
  lastUpdateTransferLocations))))))))) : ("")));
26144
26144
  };
26145
26145
 
26146
- var EditableContext = React.createContext(null);
26147
- var EditableRow = function (_a) {
26148
- _a.index; var props = __rest(_a, ["index"]);
26149
- var form = antd.Form.useForm()[0];
26150
- return (React.createElement(antd.Form, { form: form, component: false },
26151
- React.createElement(EditableContext.Provider, { value: form },
26152
- React.createElement("tr", __assign({}, props)))));
26153
- };
26146
+ React.createContext(null);
26154
26147
  var EditableCell = function (_a) {
26155
- _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"]);
26156
- var _b = React.useState(false), editing = _b[0], setEditing = _b[1];
26157
- var inputRef = React.useRef(null);
26158
- var form = React.useContext(EditableContext);
26159
- React.useEffect(function () {
26160
- if (editing) {
26161
- inputRef.current.focus();
26162
- }
26163
- }, [editing]);
26164
- var toggleEdit = function () {
26165
- var _a;
26166
- setEditing(!editing);
26167
- form.setFieldsValue((_a = {}, _a[dataIndex] = record[dataIndex], _a));
26168
- };
26169
- var save = function () { return __awaiter(void 0, void 0, void 0, function () {
26170
- var values, errInfo_1;
26171
- return __generator(this, function (_a) {
26172
- switch (_a.label) {
26173
- case 0:
26174
- _a.trys.push([0, 2, , 3]);
26175
- return [4 /*yield*/, form.validateFields()];
26176
- case 1:
26177
- values = _a.sent();
26178
- toggleEdit();
26179
- handleSave(__assign(__assign({}, record), values));
26180
- return [3 /*break*/, 3];
26181
- case 2:
26182
- errInfo_1 = _a.sent();
26183
- console.log("Save failed:", errInfo_1);
26184
- return [3 /*break*/, 3];
26185
- case 3: return [2 /*return*/];
26186
- }
26187
- });
26188
- }); };
26189
- var childNode = children;
26190
- if (editable) {
26191
- childNode = editing ? (React.createElement(antd.Form.Item, { style: { margin: 0 }, name: dataIndex },
26192
- React.createElement(antd.Input, { ref: inputRef, onPressEnter: save, onBlur: save }))) : (React.createElement("div", { className: "editable-cell-value-wrap", style: { paddingRight: 24, minWidth: "100px", minHeight: "20px" }, onClick: toggleEdit }, children));
26148
+ var editing = _a.editing, dataIndex = _a.dataIndex, title = _a.title; _a.inputType; _a.record; _a.index; var children = _a.children, restProps = __rest(_a, ["editing", "dataIndex", "title", "inputType", "record", "index", "children"]);
26149
+ var inputNode;
26150
+ if (dataIndex === "nationalPlanObjective") {
26151
+ inputNode = React.createElement(antd.Input, { placeholder: "Enter National Plan Objective" });
26193
26152
  }
26194
- return React.createElement("td", __assign({}, restProps), childNode);
26153
+ else if (dataIndex === "kpi") {
26154
+ inputNode = React.createElement(antd.InputNumber, { placeholder: "Enter Kpi" });
26155
+ }
26156
+ return (React.createElement("td", __assign({}, restProps), editing ? (React.createElement(antd.Form.Item, { name: dataIndex, style: { margin: 0 }, rules: [
26157
+ {
26158
+ required: true,
26159
+ message: "Please Input ".concat(title, "!"),
26160
+ },
26161
+ ] }, inputNode)) : (children)));
26195
26162
  };
26196
26163
 
26197
26164
  var css_248z$4 = ".ndc-steps-actions {\n display: flex;\n flex-direction: row-reverse;\n margin-right: 1rem;\n justify-content: center; }\n .ndc-steps-actions .action-btn {\n border: 1px solid #16b1ff;\n color: #16b1ff;\n margin-right: 1rem; }\n .ndc-steps-actions .back-btn {\n border: 1px solid rgba(140, 140, 140, 0.7);\n color: rgba(140, 140, 140, 0.7);\n margin-right: 1rem; }\n .ndc-steps-actions .mg-left-1 {\n margin-left: 1rem; }\n";
26198
26165
  styleInject(css_248z$4);
26199
26166
 
26200
- var NdcActionType;
26201
- (function (NdcActionType) {
26202
- NdcActionType[NdcActionType["mainAction"] = 0] = "mainAction";
26203
- NdcActionType[NdcActionType["subAction"] = 1] = "subAction";
26204
- })(NdcActionType || (NdcActionType = {}));
26167
+ var NdcDetailsActionType;
26168
+ (function (NdcDetailsActionType) {
26169
+ NdcDetailsActionType["MainAction"] = "MainAction";
26170
+ NdcDetailsActionType["SubAction"] = "SubAction";
26171
+ })(NdcDetailsActionType || (NdcDetailsActionType = {}));
26205
26172
  var NdcDetailsActionStatus;
26206
26173
  (function (NdcDetailsActionStatus) {
26207
- NdcDetailsActionStatus[NdcDetailsActionStatus["pending"] = 0] = "pending";
26208
- NdcDetailsActionStatus[NdcDetailsActionStatus["approved"] = 1] = "approved";
26174
+ NdcDetailsActionStatus["New"] = "New";
26175
+ NdcDetailsActionStatus["Pending"] = "Pending";
26176
+ NdcDetailsActionStatus["Approved"] = "Approved";
26177
+ NdcDetailsActionStatus["Rejected"] = "Rejected";
26209
26178
  })(NdcDetailsActionStatus || (NdcDetailsActionStatus = {}));
26179
+ var getNdcActionStatusEnumVal = function (value) {
26180
+ var index = Object.keys(NdcDetailsActionStatus).indexOf(value);
26181
+ if (index < 0) {
26182
+ return value;
26183
+ }
26184
+ return Object.values(NdcDetailsActionStatus)[index];
26185
+ };
26186
+ var getNdcActionStatusTagType = function (status) {
26187
+ switch (getNdcActionStatusEnumVal(status)) {
26188
+ case NdcDetailsActionStatus.Rejected:
26189
+ return "error";
26190
+ case NdcDetailsActionStatus.Pending:
26191
+ return "processing";
26192
+ case NdcDetailsActionStatus.Approved:
26193
+ return "success";
26194
+ default:
26195
+ return "default";
26196
+ }
26197
+ };
26210
26198
 
26211
26199
  var NdcDetailsComponent = function (props) {
26212
26200
  var t = props.t, useConnection = props.useConnection, useUserContext = props.useUserContext;
@@ -26220,6 +26208,14 @@ var NdcDetailsComponent = function (props) {
26220
26208
  var _e = React.useState(0), tableKey = _e[0], setTableKey = _e[1];
26221
26209
  var _f = useConnection(), get = _f.get, post = _f.post, put = _f.put;
26222
26210
  var _g = React.useState([]), ministryOrgList = _g[0], setMinistryOrgList = _g[1];
26211
+ var _h = React.useState({}), actionInfo = _h[0], setActionInfo = _h[1];
26212
+ var _j = React.useState(false), openConfirmationModal = _j[0], setOpenConfirmationModal = _j[1];
26213
+ var form = antd.Form.useForm()[0];
26214
+ var _k = React.useState(-1), editingKey = _k[0], setEditingKey = _k[1];
26215
+ var _l = React.useState(0), nextAvailableActionId = _l[0], setNextAvailableActionId = _l[1];
26216
+ var _m = React.useState([]), expandedRowKeys = _m[0], setExpandedRowKeys = _m[1];
26217
+ var _o = React.useState([]), subNdcDetailsForPeriod = _o[0], setSubNdcDetailsForPeriod = _o[1];
26218
+ var isEditing = function (record) { return record.id === editingKey; };
26223
26219
  var userInfoState = useUserContext().userInfoState;
26224
26220
  var loginMinistry = (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.GOVERNMENT
26225
26221
  ? process.env.REACT_APP_GOVERNMENT_MINISTRY
@@ -26228,13 +26224,12 @@ var NdcDetailsComponent = function (props) {
26228
26224
  : (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.MINISTRY
26229
26225
  ? userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyName
26230
26226
  : undefined;
26231
- var isAddRangeVisible = ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.MINISTRY ||
26232
- (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.GOVERNMENT) &&
26227
+ var isGovernmentUser = (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.GOVERNMENT &&
26233
26228
  (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== exports.Role.ViewOnly;
26234
26229
  var ndcMainDetailsForPeriod = selectedPeriod.key !== "add_new"
26235
26230
  ? ndcDetailsData.filter(function (ndcDetail) {
26236
26231
  return (ndcDetail.periodId === parseInt(selectedPeriod.key) &&
26237
- ndcDetail.actionType === NdcActionType.mainAction);
26232
+ ndcDetail.actionType === NdcDetailsActionType.MainAction);
26238
26233
  })
26239
26234
  : [];
26240
26235
  var isMainNdcActionsEditable = !selectedPeriod.finalized &&
@@ -26242,84 +26237,138 @@ var NdcDetailsComponent = function (props) {
26242
26237
  (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== exports.Role.ViewOnly;
26243
26238
  var isSubNdcActionsEditable = function (record) {
26244
26239
  return (!selectedPeriod.finalized &&
26240
+ record.status !== NdcDetailsActionStatus.Approved &&
26245
26241
  ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.GOVERNMENT ||
26246
26242
  ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.MINISTRY &&
26247
26243
  (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyName) === record.ministryName)) &&
26248
26244
  (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== exports.Role.ViewOnly);
26249
26245
  };
26250
- var getSubNdcDetailsForPeriod = function (id) {
26251
- var subNdcDetails = ndcDetailsData.filter(function (ndcDetail) {
26252
- return (ndcDetail.parentActionId === id &&
26253
- ndcDetail.actionType === NdcActionType.subAction);
26254
- });
26255
- var emptySubNdcRow = {
26256
- actionType: NdcActionType.subAction,
26257
- nationalPlanObjective: "",
26258
- kpi: 0,
26259
- ministryName: loginMinistry,
26260
- status: NdcDetailsActionStatus.pending,
26261
- parentActionId: id,
26262
- };
26263
- return __spreadArray(__spreadArray([], subNdcDetails, true), [emptySubNdcRow], false);
26264
- };
26265
- var isAddNdcActionVisible = function () {
26266
- return ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.GOVERNMENT &&
26267
- (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== exports.Role.ViewOnly);
26268
- };
26269
26246
  var inRange = function (num, min, max) {
26270
26247
  return num >= min && num <= max;
26271
26248
  };
26272
26249
  var handleSave = function (row) { return __awaiter(void 0, void 0, void 0, function () {
26273
- var updatedItemIndex;
26250
+ var updatedFields, updatedItem, exception_1;
26274
26251
  return __generator(this, function (_a) {
26275
26252
  switch (_a.label) {
26276
26253
  case 0:
26277
- updatedItemIndex = ndcDetailsData.findIndex(function (item) { return item.id === row.id; });
26278
- if (!(updatedItemIndex === -1)) return [3 /*break*/, 2];
26279
- return [4 /*yield*/, post("national/programme/addNdcDetailsAction", __assign(__assign({}, row), { kpi: parseInt(row.kpi) }))];
26254
+ _a.trys.push([0, 6, , 7]);
26255
+ return [4 /*yield*/, form.validateFields()];
26280
26256
  case 1:
26257
+ updatedFields = (_a.sent());
26258
+ updatedItem = __assign(__assign({}, row), updatedFields);
26259
+ if (!(updatedItem.status === NdcDetailsActionStatus.New)) return [3 /*break*/, 3];
26260
+ updatedItem.status = NdcDetailsActionStatus.Pending;
26261
+ return [4 /*yield*/, post("national/programme/addNdcDetailsAction", __assign(__assign({}, updatedItem), { kpi: parseInt(updatedItem.kpi) }))];
26262
+ case 2:
26281
26263
  _a.sent();
26282
- return [3 /*break*/, 4];
26283
- case 2: return [4 /*yield*/, put("national/programme/updateNdcDetailsAction", __assign(__assign({}, row), { kpi: parseInt(row.kpi) }))];
26264
+ return [3 /*break*/, 5];
26284
26265
  case 3:
26285
- _a.sent();
26286
- _a.label = 4;
26266
+ updatedItem.status = NdcDetailsActionStatus.Pending;
26267
+ return [4 /*yield*/, put("national/programme/updateNdcDetailsAction", __assign(__assign({}, updatedItem), { kpi: parseInt(updatedItem.kpi) }))];
26287
26268
  case 4:
26269
+ _a.sent();
26270
+ _a.label = 5;
26271
+ case 5:
26288
26272
  fetchNdcDetailActions();
26289
- return [2 /*return*/];
26273
+ setEditingKey(-1);
26274
+ return [3 /*break*/, 7];
26275
+ case 6:
26276
+ exception_1 = _a.sent();
26277
+ console.log("error", exception_1);
26278
+ return [3 /*break*/, 7];
26279
+ case 7: return [2 /*return*/];
26290
26280
  }
26291
26281
  });
26292
26282
  }); };
26283
+ var actionMenu = function (record) {
26284
+ if (record.status === NdcDetailsActionStatus.Pending && isGovernmentUser) {
26285
+ return (React.createElement(antd.List, { className: "action-menu", size: "small", dataSource: [
26286
+ {
26287
+ text: t("ndc:approve"),
26288
+ icon: React.createElement(Icon__namespace.BoxArrowInDown, null),
26289
+ click: function () {
26290
+ setActionInfo({
26291
+ action: "Approve",
26292
+ headerText: t("ndc:actionApproveTitle"),
26293
+ type: "primary",
26294
+ icon: React.createElement(Icon__namespace.BoxArrowInDown, null),
26295
+ recordId: record.id,
26296
+ });
26297
+ setOpenConfirmationModal(true);
26298
+ },
26299
+ },
26300
+ {
26301
+ text: t("ndc:reject"),
26302
+ icon: React.createElement(Icon__namespace.XOctagon, null),
26303
+ click: function () {
26304
+ setActionInfo({
26305
+ action: "Reject",
26306
+ headerText: t("ndc:rejectApproveTitle"),
26307
+ type: "danger",
26308
+ icon: React.createElement(Icon__namespace.BoxArrowInDown, null),
26309
+ recordId: record.id,
26310
+ });
26311
+ setOpenConfirmationModal(true);
26312
+ },
26313
+ },
26314
+ ], renderItem: function (item) { return (React.createElement(antd.List.Item, { onClick: item.click },
26315
+ React.createElement(antd.Typography.Text, { className: "action-icon color-error" }, item.icon),
26316
+ React.createElement("span", null, item.text))); } }));
26317
+ }
26318
+ else {
26319
+ return null;
26320
+ }
26321
+ };
26293
26322
  var defaultColumns = [
26294
26323
  {
26295
26324
  title: t("ndc:ndcColumnsNationalPlanObj"),
26296
26325
  dataIndex: "nationalPlanObjective",
26297
26326
  key: "nationalPlanObjective",
26298
26327
  align: "left",
26299
- width: "50%",
26328
+ width: "40%",
26300
26329
  editable: true,
26301
- render: function (_, record) { return (React.createElement(React.Fragment, null, record.nationalPlanObjective ? (React.createElement(antd.Space, { size: "middle" },
26302
- React.createElement("span", null, record.nationalPlanObjective))) : (React.createElement("input", { placeholder: "Please add the National Plan Objective", className: "ant-input", type: "text" })))); },
26303
26330
  },
26304
26331
  {
26305
26332
  title: t("ndc:ndcColumnsKpi"),
26306
26333
  dataIndex: "kpi",
26307
26334
  key: "kpi",
26308
26335
  align: "left",
26309
- width: "10%",
26336
+ width: "15%",
26310
26337
  editable: true,
26311
- render: function (_, record) { return (React.createElement(React.Fragment, null, record.kpi ? (React.createElement(antd.Space, { size: "middle" },
26312
- React.createElement("span", null, record.kpi))) : (React.createElement("input", { placeholder: "Enter Kpi", className: "ant-input", type: "text" })))); },
26313
26338
  },
26314
26339
  {
26315
- title: "ministryName",
26340
+ title: t("ndc:ndcColumnsMinistry"),
26316
26341
  dataIndex: "ministryName",
26317
26342
  key: "ministryName",
26318
26343
  align: "left",
26319
- width: "40%",
26344
+ width: "30%",
26320
26345
  editable: false,
26321
26346
  render: function (_, record) { return (React.createElement(React.Fragment, null,
26322
- React.createElement(antd.Select, { disabled: !isSubNdcActionsEditable(record), defaultValue: record.ministryName ? record.ministryName : loginMinistry, style: { width: 320 }, onChange: function () { }, options: ministryOrgList }))); },
26347
+ React.createElement(antd.Select, { disabled: !(isSubNdcActionsEditable(record) && isEditing(record)), defaultValue: record.ministryName ? record.ministryName : loginMinistry, style: { width: 320 }, onChange: function (value, option) {
26348
+ record.ministryName = option.label;
26349
+ handleSave(record);
26350
+ }, options: ministryOrgList }))); },
26351
+ },
26352
+ {
26353
+ title: t("ndc:ndcColumnsStatus"),
26354
+ dataIndex: "status",
26355
+ key: "status",
26356
+ align: "left",
26357
+ width: "15%",
26358
+ editable: false,
26359
+ render: function (_, record) {
26360
+ var menu = actionMenu(record);
26361
+ return (React.createElement(React.Fragment, null,
26362
+ record.actionType === NdcDetailsActionType.SubAction &&
26363
+ record.status !== NdcDetailsActionStatus.New ? (React.createElement(antd.Tooltip, { title: record.status, color: TooltipColor, key: TooltipColor },
26364
+ React.createElement(antd.Tag, { className: "clickable", color: getNdcActionStatusTagType(record.status) }, addSpaces(record.status)))) : (""),
26365
+ record.actionType === NdcDetailsActionType.SubAction && menu ? (React.createElement(antd.Popover, { placement: "bottomRight", content: menu, trigger: "click" },
26366
+ React.createElement(icons.EllipsisOutlined, { rotate: 90, style: {
26367
+ fontWeight: 600,
26368
+ fontSize: "1rem",
26369
+ cursor: "pointer",
26370
+ } }))) : (React.createElement("span", null))));
26371
+ },
26323
26372
  },
26324
26373
  ];
26325
26374
  var columns = defaultColumns.map(function (col) {
@@ -26327,93 +26376,137 @@ var NdcDetailsComponent = function (props) {
26327
26376
  return col;
26328
26377
  }
26329
26378
  return __assign(__assign({}, col), { onCell: function (record) {
26330
- console.log("record", record);
26331
26379
  return {
26332
26380
  record: record,
26333
- editable: record.actionType === NdcActionType.mainAction
26334
- ? isMainNdcActionsEditable
26335
- : isSubNdcActionsEditable(record),
26381
+ editing: isEditing(record),
26336
26382
  dataIndex: col.dataIndex,
26337
26383
  title: col.title,
26338
- handleSave: handleSave,
26339
26384
  };
26340
26385
  } });
26341
26386
  });
26342
26387
  function onClickedAddNewNdcDetail() {
26343
26388
  return __awaiter(this, void 0, void 0, function () {
26344
- var periodId, newData, response, newlyCreatedNdcAction_1;
26389
+ var periodId, newData_1;
26345
26390
  return __generator(this, function (_a) {
26346
- switch (_a.label) {
26347
- case 0:
26348
- if (!(selectedPeriod.key !== "add_new")) return [3 /*break*/, 2];
26349
- periodId = parseInt(selectedPeriod.key);
26350
- newData = {
26351
- actionType: NdcActionType.mainAction,
26352
- nationalPlanObjective: "",
26353
- kpi: 0,
26354
- ministryName: loginMinistry,
26355
- periodId: periodId,
26356
- status: NdcDetailsActionStatus.pending,
26357
- };
26358
- return [4 /*yield*/, post("national/programme/addNdcDetailsAction", __assign({}, newData))];
26359
- case 1:
26360
- response = _a.sent();
26361
- if (response && response.data) {
26362
- newlyCreatedNdcAction_1 = response.data;
26363
- setNdcDetailsData(function (ndcDetailsData) { return __spreadArray(__spreadArray([], ndcDetailsData, true), [
26364
- newlyCreatedNdcAction_1,
26365
- ], false); });
26366
- setTableKey(function (key) { return key + 1; });
26367
- }
26368
- _a.label = 2;
26369
- case 2: return [2 /*return*/];
26391
+ if (selectedPeriod.key !== "add_new") {
26392
+ form.setFieldsValue({
26393
+ nationalPlanObjective: "",
26394
+ kpi: "",
26395
+ });
26396
+ periodId = parseInt(selectedPeriod.key);
26397
+ newData_1 = {
26398
+ id: nextAvailableActionId,
26399
+ actionType: NdcDetailsActionType.MainAction,
26400
+ nationalPlanObjective: "",
26401
+ kpi: "",
26402
+ ministryName: loginMinistry,
26403
+ periodId: periodId,
26404
+ status: NdcDetailsActionStatus.New,
26405
+ };
26406
+ setEditingKey(nextAvailableActionId);
26407
+ setNextAvailableActionId(function (value) { return value + 1; });
26408
+ setNdcDetailsData(function (ndcDetailsData) { return __spreadArray(__spreadArray([], ndcDetailsData, true), [
26409
+ newData_1,
26410
+ ], false); });
26411
+ setTableKey(function (key) { return key + 1; });
26370
26412
  }
26413
+ return [2 /*return*/];
26371
26414
  });
26372
26415
  });
26373
26416
  }
26374
26417
  var components = {
26375
26418
  body: {
26376
- row: EditableRow,
26377
26419
  cell: EditableCell,
26378
26420
  },
26379
26421
  };
26380
- var onDeletePeriod = function () { return __awaiter(void 0, void 0, void 0, function () {
26381
- var result;
26422
+ var onClickedDeletePeriod = function () { return __awaiter(void 0, void 0, void 0, function () {
26382
26423
  return __generator(this, function (_a) {
26383
- switch (_a.label) {
26384
- case 0: return [4 /*yield*/, post("national/programme/deleteNdcDetailsPeriod", {
26385
- id: selectedPeriod.key,
26386
- })];
26387
- case 1:
26388
- result = _a.sent();
26389
- if (result) {
26390
- fetchNdcDetailPeriods();
26391
- }
26392
- return [2 /*return*/];
26393
- }
26424
+ setActionInfo({
26425
+ action: "Delete",
26426
+ headerText: t("ndc:periodDeleteConfirmTitle"),
26427
+ type: "danger",
26428
+ icon: React.createElement(Icon__namespace.XCircle, null),
26429
+ recordId: selectedPeriod.key,
26430
+ });
26431
+ setOpenConfirmationModal(true);
26432
+ return [2 /*return*/];
26394
26433
  });
26395
26434
  }); };
26396
- var onFinalizePeriod = function () {
26397
- //
26435
+ var onClickedFinalizePeriod = function () { return __awaiter(void 0, void 0, void 0, function () {
26436
+ return __generator(this, function (_a) {
26437
+ setActionInfo({
26438
+ action: "Finalize",
26439
+ headerText: t("ndc:finalizeApproveTitle"),
26440
+ text: t("ndc:finalizeApproveSubTitle"),
26441
+ type: "primary",
26442
+ icon: React.createElement(Icon__namespace.Clipboard2Check, null),
26443
+ recordId: selectedPeriod.key,
26444
+ });
26445
+ setOpenConfirmationModal(true);
26446
+ return [2 /*return*/];
26447
+ });
26448
+ }); };
26449
+ var onMainTableRowExpand = function (expanded, record) {
26450
+ var keys = [];
26451
+ if (expanded) {
26452
+ keys.push(record.id);
26453
+ }
26454
+ setExpandedRowKeys(keys);
26455
+ var subNdcDetails = ndcDetailsData.filter(function (ndcDetail) {
26456
+ return (ndcDetail.parentActionId === record.id &&
26457
+ ndcDetail.actionType === NdcDetailsActionType.SubAction);
26458
+ });
26459
+ var emptySubNdcRow = {
26460
+ id: nextAvailableActionId,
26461
+ actionType: NdcDetailsActionType.SubAction,
26462
+ nationalPlanObjective: "",
26463
+ kpi: "",
26464
+ ministryName: loginMinistry,
26465
+ status: NdcDetailsActionStatus.New,
26466
+ parentActionId: record.id,
26467
+ };
26468
+ setEditingKey(nextAvailableActionId);
26469
+ setNextAvailableActionId(function (value) { return value + 1; });
26470
+ form.setFieldsValue({
26471
+ nationalPlanObjective: "",
26472
+ kpi: "",
26473
+ });
26474
+ setSubNdcDetailsForPeriod(__spreadArray(__spreadArray([], subNdcDetails, true), [emptySubNdcRow], false));
26398
26475
  };
26399
26476
  function ndcDetailsTableContent() {
26400
26477
  return (React.createElement("div", null,
26401
26478
  React.createElement(antd.Row, null,
26402
26479
  React.createElement(antd.Col, { span: 24 },
26403
- React.createElement(antd.Table, { key: tableKey, rowKey: "id", components: components, rowClassName: function () { return "editable-row"; }, bordered: true, dataSource: ndcMainDetailsForPeriod, columns: columns, expandable: {
26404
- expandedRowRender: function (record) { return getSubNdcActionContent(record); },
26405
- indentSize: 0,
26406
- //defaultExpandedRowKeys: [parseInt(selectedNdcDetail.current.id)],
26407
- }, footer: function () {
26408
- return isAddNdcActionVisible() && (React.createElement(antd.Row, { justify: "center" },
26409
- React.createElement(antd.Button, { onClick: onClickedAddNewNdcDetail, type: "default", style: {
26410
- marginBottom: 16,
26411
- width: "100%",
26412
- } }, t("ndc:addNdcAction"))));
26413
- } }))),
26414
- React.createElement(antd.Row, { justify: "end" },
26415
- React.createElement(antd.Button, { className: "mg-left-1", type: "primary", onClick: onDeletePeriod, htmlType: "submit", loading: loading }, t("ndc:delete")),
26416
- React.createElement(antd.Button, { className: "mg-left-1", type: "primary", onClick: onFinalizePeriod, htmlType: "submit", loading: loading }, t("ndc:finalize")))));
26480
+ React.createElement(antd.Form, { form: form, component: false },
26481
+ React.createElement(antd.Table, { key: tableKey, rowKey: "id", components: components, rowClassName: function () { return "editable-row"; }, bordered: true, dataSource: ndcMainDetailsForPeriod, columns: columns, expandedRowKeys: expandedRowKeys, onExpand: onMainTableRowExpand, expandable: {
26482
+ expandedRowRender: function (record) { return getSubNdcActionContent(record); },
26483
+ indentSize: 0,
26484
+ //defaultExpandedRowKeys: [parseInt(selectedNdcDetail.current.id)],
26485
+ }, onRow: function (record, rowIndex) {
26486
+ return {
26487
+ onClick: function () {
26488
+ if (record.id && isMainNdcActionsEditable && !isEditing(record)) {
26489
+ form.setFieldsValue(__assign({}, record));
26490
+ setEditingKey(record.id);
26491
+ }
26492
+ },
26493
+ onMouseLeave: function () {
26494
+ if (isEditing(record)) {
26495
+ handleSave(record);
26496
+ }
26497
+ },
26498
+ };
26499
+ }, footer: function () {
26500
+ return isGovernmentUser &&
26501
+ !selectedPeriod.finalized && (React.createElement(antd.Row, { justify: "center" },
26502
+ React.createElement(antd.Button, { onClick: onClickedAddNewNdcDetail, type: "default", style: {
26503
+ marginBottom: 16,
26504
+ width: "100%",
26505
+ } }, t("ndc:addNdcAction"))));
26506
+ } })))),
26507
+ isGovernmentUser && !selectedPeriod.finalized ? (React.createElement(antd.Row, { justify: "end" },
26508
+ React.createElement(antd.Button, { className: "mg-left-1", type: "primary", onClick: onClickedDeletePeriod, htmlType: "submit", loading: loading }, t("ndc:delete")),
26509
+ React.createElement(antd.Button, { className: "mg-left-1", type: "primary", onClick: onClickedFinalizePeriod, htmlType: "submit", loading: loading }, t("ndc:finalize")))) : ("")));
26417
26510
  }
26418
26511
  var onAddNewPeriod = function () { return __awaiter(void 0, void 0, void 0, function () {
26419
26512
  var periodItem_1, existingIndex, response, addedPeriodItem, updatedPeriodItem_1;
@@ -26470,7 +26563,21 @@ var NdcDetailsComponent = function (props) {
26470
26563
  }
26471
26564
  function getSubNdcActionContent(record) {
26472
26565
  selectedNdcDetail.current = record;
26473
- return (React.createElement(antd.Table, { rowKey: "id", components: components, rowClassName: function () { return "editable-row"; }, bordered: true, dataSource: getSubNdcDetailsForPeriod(record.id), columns: columns, showHeader: false, pagination: false }));
26566
+ return (React.createElement(antd.Table, { rowKey: "id", components: components, rowClassName: function () { return "editable-row"; }, bordered: true, dataSource: subNdcDetailsForPeriod, onRow: function (record, rowIndex) {
26567
+ return {
26568
+ onClick: function () {
26569
+ if (record.id && isSubNdcActionsEditable(record) && !isEditing(record)) {
26570
+ form.setFieldsValue(__assign({}, record));
26571
+ setEditingKey(record.id);
26572
+ }
26573
+ },
26574
+ onMouseLeave: function () {
26575
+ if (isEditing(record)) {
26576
+ handleSave(record);
26577
+ }
26578
+ },
26579
+ };
26580
+ }, columns: columns, showHeader: false, pagination: false }));
26474
26581
  }
26475
26582
  var onTabChange = function (key) {
26476
26583
  var selectedPeriod = periodItems.find(function (item) { return item.key === key; });
@@ -26478,6 +26585,57 @@ var NdcDetailsComponent = function (props) {
26478
26585
  setSelectedPeriod(selectedPeriod);
26479
26586
  }
26480
26587
  };
26588
+ var onActionConfirmed = function () { return __awaiter(void 0, void 0, void 0, function () {
26589
+ var response, response, response, result;
26590
+ return __generator(this, function (_a) {
26591
+ switch (_a.label) {
26592
+ case 0:
26593
+ if (!(actionInfo.action === "Approve")) return [3 /*break*/, 2];
26594
+ return [4 /*yield*/, get("national/programme/approveNdcDetailsAction", {
26595
+ id: actionInfo.recordId,
26596
+ })];
26597
+ case 1:
26598
+ response = _a.sent();
26599
+ return [3 /*break*/, 8];
26600
+ case 2:
26601
+ if (!(actionInfo.action === "Reject")) return [3 /*break*/, 4];
26602
+ return [4 /*yield*/, get("national/programme/rejectNdcDetailsAction", {
26603
+ id: actionInfo.recordId,
26604
+ })];
26605
+ case 3:
26606
+ response = _a.sent();
26607
+ return [3 /*break*/, 8];
26608
+ case 4:
26609
+ if (!(actionInfo.action === "Finalize")) return [3 /*break*/, 6];
26610
+ return [4 /*yield*/, post("national/programme/finalizeNdcDetailsPeriod", {
26611
+ id: selectedPeriod.key,
26612
+ })];
26613
+ case 5:
26614
+ response = _a.sent();
26615
+ if (response) {
26616
+ fetchNdcDetailPeriods();
26617
+ }
26618
+ return [3 /*break*/, 8];
26619
+ case 6:
26620
+ if (!(actionInfo.action === "Delete")) return [3 /*break*/, 8];
26621
+ return [4 /*yield*/, post("national/programme/deleteNdcDetailsPeriod", {
26622
+ id: selectedPeriod.key,
26623
+ })];
26624
+ case 7:
26625
+ result = _a.sent();
26626
+ if (result) {
26627
+ fetchNdcDetailPeriods();
26628
+ }
26629
+ _a.label = 8;
26630
+ case 8:
26631
+ setOpenConfirmationModal(false);
26632
+ return [2 /*return*/];
26633
+ }
26634
+ });
26635
+ }); };
26636
+ var onActionCanceled = function () {
26637
+ setOpenConfirmationModal(false);
26638
+ };
26481
26639
  var fetchNdcDetailPeriods = function () { return __awaiter(void 0, void 0, void 0, function () {
26482
26640
  var periods, addNewTab, response;
26483
26641
  return __generator(this, function (_a) {
@@ -26497,10 +26655,16 @@ var NdcDetailsComponent = function (props) {
26497
26655
  response = _a.sent();
26498
26656
  if (response && response.data) {
26499
26657
  periods = response.data.map(function (period) {
26500
- return __assign(__assign({}, period), { key: period.id, label: "".concat(period.startYear, "-").concat(period.endYear) });
26658
+ return __assign(__assign({}, period), { key: period.id, label: period.finalized ? (React.createElement("span", null,
26659
+ React.createElement(icons.LockOutlined, null),
26660
+ " ",
26661
+ period.startYear,
26662
+ "-",
26663
+ period.endYear,
26664
+ " ")) : ("".concat(period.startYear, "-").concat(period.endYear)) });
26501
26665
  });
26502
26666
  }
26503
- if (isAddRangeVisible) {
26667
+ if (isGovernmentUser) {
26504
26668
  periods.unshift(addNewTab);
26505
26669
  }
26506
26670
  setPeriodItems(periods);
@@ -26510,13 +26674,15 @@ var NdcDetailsComponent = function (props) {
26510
26674
  });
26511
26675
  }); };
26512
26676
  var fetchNdcDetailActions = function () { return __awaiter(void 0, void 0, void 0, function () {
26513
- var response;
26677
+ var response, maxActionId;
26514
26678
  return __generator(this, function (_a) {
26515
26679
  switch (_a.label) {
26516
26680
  case 0: return [4 /*yield*/, get("national/programme/queryNdcDetailsAction")];
26517
26681
  case 1:
26518
26682
  response = _a.sent();
26519
26683
  if (response && response.data) {
26684
+ maxActionId = Math.max.apply(Math, response.data.map(function (item) { return item.id; }));
26685
+ setNextAvailableActionId(maxActionId + 1);
26520
26686
  setNdcDetailsData(response.data);
26521
26687
  }
26522
26688
  return [2 /*return*/];
@@ -26527,15 +26693,14 @@ var NdcDetailsComponent = function (props) {
26527
26693
  var response, ministryOrgDetails;
26528
26694
  return __generator(this, function (_a) {
26529
26695
  switch (_a.label) {
26530
- case 0: return [4 /*yield*/, get("national/company/getMinistries")];
26696
+ case 0: return [4 /*yield*/, get("national/organisation/getMinistries")];
26531
26697
  case 1:
26532
26698
  response = _a.sent();
26533
- console.log('fetchMinistries', response);
26534
26699
  if (response && response.data) {
26535
26700
  ministryOrgDetails = response.data.map(function (value) {
26536
26701
  return {
26537
- value: value.user_id,
26538
- label: value.user_name,
26702
+ value: value.company_companyId,
26703
+ label: value.company_name,
26539
26704
  };
26540
26705
  });
26541
26706
  setMinistryOrgList(ministryOrgDetails);
@@ -26559,7 +26724,8 @@ var NdcDetailsComponent = function (props) {
26559
26724
  React.createElement(antd.Tabs, { centered: false, defaultActiveKey: "1", items: periodItems, activeKey: selectedPeriod.key, onChange: onTabChange })),
26560
26725
  React.createElement("div", null, selectedPeriod.key === "add_new"
26561
26726
  ? addNewPeriodContent()
26562
- : ndcDetailsTableContent())));
26727
+ : ndcDetailsTableContent()),
26728
+ React.createElement(UserActionConfirmationModel, { t: t, actionInfo: actionInfo, onActionConfirmed: onActionConfirmed, onActionCanceled: onActionCanceled, openModal: openConfirmationModal, errorMsg: "", loading: false })));
26563
26729
  };
26564
26730
 
26565
26731
  var ImgWithFallback = function (_a) {
@@ -28243,7 +28409,7 @@ exports.getCreditStageVal = getCreditStageVal;
28243
28409
  exports.getFinancialFields = getFinancialFields;
28244
28410
  exports.getGeneralFields = getGeneralFields;
28245
28411
  exports.getInvestmentStatusEnumVal = getInvestmentStatusEnumVal;
28246
- exports.getNdcActionStatusEnumVal = getNdcActionStatusEnumVal;
28412
+ exports.getNdcActionStatusEnumVal = getNdcActionStatusEnumVal$1;
28247
28413
  exports.getNdcStatusTagType = getNdcStatusTagType;
28248
28414
  exports.getRetirementTypeString = getRetirementTypeString;
28249
28415
  exports.getStageEnumVal = getStageEnumVal;