@undp/carbon-library 1.0.17-CARBON-363.1 → 1.0.17-CARBON-363.18

Sign up to get free protection for your applications and to get access to all the features.
package/dist/cjs/index.js CHANGED
@@ -26219,10 +26219,15 @@ var NdcDetailsComponent = function (props) {
26219
26219
  var selectedNdcDetail = React.useRef({});
26220
26220
  var _e = React.useState(0), tableKey = _e[0], setTableKey = _e[1];
26221
26221
  var _f = useConnection(), get = _f.get, post = _f.post, put = _f.put;
26222
+ var _g = React.useState([]), ministryOrgList = _g[0], setMinistryOrgList = _g[1];
26222
26223
  var userInfoState = useUserContext().userInfoState;
26223
- var governmentMinistry = process.env.REACT_APP_GOVERNMENT_MINISTRY
26224
+ var loginMinistry = (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.GOVERNMENT
26224
26225
  ? process.env.REACT_APP_GOVERNMENT_MINISTRY
26225
- : "Test ministryName";
26226
+ ? process.env.REACT_APP_GOVERNMENT_MINISTRY
26227
+ : "Test ministryName"
26228
+ : (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.MINISTRY
26229
+ ? userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyName
26230
+ : undefined;
26226
26231
  var isAddRangeVisible = ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.MINISTRY ||
26227
26232
  (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.GOVERNMENT) &&
26228
26233
  (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== exports.Role.ViewOnly;
@@ -26232,7 +26237,16 @@ var NdcDetailsComponent = function (props) {
26232
26237
  ndcDetail.actionType === NdcActionType.mainAction);
26233
26238
  })
26234
26239
  : [];
26235
- !selectedPeriod.finalized;
26240
+ var isMainNdcActionsEditable = !selectedPeriod.finalized &&
26241
+ (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.GOVERNMENT &&
26242
+ (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== exports.Role.ViewOnly;
26243
+ var isSubNdcActionsEditable = function (record) {
26244
+ return (!selectedPeriod.finalized &&
26245
+ ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.GOVERNMENT ||
26246
+ ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.MINISTRY &&
26247
+ (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyName) === record.ministryName)) &&
26248
+ (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== exports.Role.ViewOnly);
26249
+ };
26236
26250
  var getSubNdcDetailsForPeriod = function (id) {
26237
26251
  var subNdcDetails = ndcDetailsData.filter(function (ndcDetail) {
26238
26252
  return (ndcDetail.parentActionId === id &&
@@ -26242,7 +26256,7 @@ var NdcDetailsComponent = function (props) {
26242
26256
  actionType: NdcActionType.subAction,
26243
26257
  nationalPlanObjective: "",
26244
26258
  kpi: 0,
26245
- ministryName: governmentMinistry,
26259
+ ministryName: loginMinistry,
26246
26260
  status: NdcDetailsActionStatus.pending,
26247
26261
  parentActionId: id,
26248
26262
  };
@@ -26282,8 +26296,8 @@ var NdcDetailsComponent = function (props) {
26282
26296
  dataIndex: "nationalPlanObjective",
26283
26297
  key: "nationalPlanObjective",
26284
26298
  align: "left",
26285
- editable: true,
26286
26299
  width: "50%",
26300
+ editable: true,
26287
26301
  render: function (_, record) { return (React.createElement(React.Fragment, null, record.nationalPlanObjective ? (React.createElement(antd.Space, { size: "middle" },
26288
26302
  React.createElement("span", null, record.nationalPlanObjective))) : (React.createElement("input", { placeholder: "Please add the National Plan Objective", className: "ant-input", type: "text" })))); },
26289
26303
  },
@@ -26292,8 +26306,8 @@ var NdcDetailsComponent = function (props) {
26292
26306
  dataIndex: "kpi",
26293
26307
  key: "kpi",
26294
26308
  align: "left",
26295
- editable: true,
26296
26309
  width: "10%",
26310
+ editable: true,
26297
26311
  render: function (_, record) { return (React.createElement(React.Fragment, null, record.kpi ? (React.createElement(antd.Space, { size: "middle" },
26298
26312
  React.createElement("span", null, record.kpi))) : (React.createElement("input", { placeholder: "Enter Kpi", className: "ant-input", type: "text" })))); },
26299
26313
  },
@@ -26302,10 +26316,10 @@ var NdcDetailsComponent = function (props) {
26302
26316
  dataIndex: "ministryName",
26303
26317
  key: "ministryName",
26304
26318
  align: "left",
26305
- editable: true,
26306
26319
  width: "40%",
26307
- render: function (_, record) { return (React.createElement(React.Fragment, null, record.ministryName ? (React.createElement(antd.Space, { size: "middle" },
26308
- React.createElement("span", null, record.ministryName))) : (React.createElement("input", { placeholder: "Please add the ministryName name", className: "ant-input", type: "text" })))); },
26320
+ editable: false,
26321
+ 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 }))); },
26309
26323
  },
26310
26324
  ];
26311
26325
  var columns = defaultColumns.map(function (col) {
@@ -26313,10 +26327,12 @@ var NdcDetailsComponent = function (props) {
26313
26327
  return col;
26314
26328
  }
26315
26329
  return __assign(__assign({}, col), { onCell: function (record) {
26316
- console.log('record', record);
26330
+ console.log("record", record);
26317
26331
  return {
26318
26332
  record: record,
26319
- editable: col.editable,
26333
+ editable: record.actionType === NdcActionType.mainAction
26334
+ ? isMainNdcActionsEditable
26335
+ : isSubNdcActionsEditable(record),
26320
26336
  dataIndex: col.dataIndex,
26321
26337
  title: col.title,
26322
26338
  handleSave: handleSave,
@@ -26335,7 +26351,7 @@ var NdcDetailsComponent = function (props) {
26335
26351
  actionType: NdcActionType.mainAction,
26336
26352
  nationalPlanObjective: "",
26337
26353
  kpi: 0,
26338
- ministryName: governmentMinistry,
26354
+ ministryName: loginMinistry,
26339
26355
  periodId: periodId,
26340
26356
  status: NdcDetailsActionStatus.pending,
26341
26357
  };
@@ -26507,9 +26523,31 @@ var NdcDetailsComponent = function (props) {
26507
26523
  }
26508
26524
  });
26509
26525
  }); };
26526
+ var fetchMinistries = function () { return __awaiter(void 0, void 0, void 0, function () {
26527
+ var response, ministryOrgDetails;
26528
+ return __generator(this, function (_a) {
26529
+ switch (_a.label) {
26530
+ case 0: return [4 /*yield*/, get("national/company/getMinistries")];
26531
+ case 1:
26532
+ response = _a.sent();
26533
+ console.log('fetchMinistries', response);
26534
+ if (response && response.data) {
26535
+ ministryOrgDetails = response.data.map(function (value) {
26536
+ return {
26537
+ value: value.user_id,
26538
+ label: value.user_name,
26539
+ };
26540
+ });
26541
+ setMinistryOrgList(ministryOrgDetails);
26542
+ }
26543
+ return [2 /*return*/];
26544
+ }
26545
+ });
26546
+ }); };
26510
26547
  React.useEffect(function () {
26511
26548
  fetchNdcDetailPeriods();
26512
26549
  fetchNdcDetailActions();
26550
+ fetchMinistries();
26513
26551
  }, []);
26514
26552
  return (React.createElement("div", { className: "ndc-management content-container" },
26515
26553
  React.createElement("div", { className: "title-bar" },