@undp/carbon-library 1.0.17-CARBON-363.0 → 1.0.17-CARBON-363.14

Sign up to get free protection for your applications and to get access to all the features.
package/dist/esm/index.js CHANGED
@@ -26199,10 +26199,15 @@ var NdcDetailsComponent = function (props) {
26199
26199
  var selectedNdcDetail = useRef({});
26200
26200
  var _e = useState(0), tableKey = _e[0], setTableKey = _e[1];
26201
26201
  var _f = useConnection(), get = _f.get, post = _f.post, put = _f.put;
26202
+ var _g = useState([]), ministryOrgList = _g[0], setMinistryOrgList = _g[1];
26202
26203
  var userInfoState = useUserContext().userInfoState;
26203
- var governmentMinistry = process.env.REACT_APP_GOVERNMENT_MINISTRY
26204
+ var loginMinistry = (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.GOVERNMENT
26204
26205
  ? process.env.REACT_APP_GOVERNMENT_MINISTRY
26205
- : "Test ministryName";
26206
+ ? process.env.REACT_APP_GOVERNMENT_MINISTRY
26207
+ : "Test ministryName"
26208
+ : (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.MINISTRY
26209
+ ? userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyName
26210
+ : undefined;
26206
26211
  var isAddRangeVisible = ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.MINISTRY ||
26207
26212
  (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.GOVERNMENT) &&
26208
26213
  (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== Role.ViewOnly;
@@ -26212,7 +26217,16 @@ var NdcDetailsComponent = function (props) {
26212
26217
  ndcDetail.actionType === NdcActionType.mainAction);
26213
26218
  })
26214
26219
  : [];
26215
- !selectedPeriod.finalized;
26220
+ var isMainNdcActionsEditable = !selectedPeriod.finalized &&
26221
+ (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.GOVERNMENT &&
26222
+ (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== Role.ViewOnly;
26223
+ var isSubNdcActionsEditable = function (record) {
26224
+ return (!selectedPeriod.finalized &&
26225
+ ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.GOVERNMENT ||
26226
+ ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.MINISTRY &&
26227
+ (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyName) === record.ministryName)) &&
26228
+ (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== Role.ViewOnly);
26229
+ };
26216
26230
  var getSubNdcDetailsForPeriod = function (id) {
26217
26231
  var subNdcDetails = ndcDetailsData.filter(function (ndcDetail) {
26218
26232
  return (ndcDetail.parentActionId === id &&
@@ -26222,7 +26236,7 @@ var NdcDetailsComponent = function (props) {
26222
26236
  actionType: NdcActionType.subAction,
26223
26237
  nationalPlanObjective: "",
26224
26238
  kpi: 0,
26225
- ministryName: governmentMinistry,
26239
+ ministryName: loginMinistry,
26226
26240
  status: NdcDetailsActionStatus.pending,
26227
26241
  parentActionId: id,
26228
26242
  };
@@ -26262,8 +26276,8 @@ var NdcDetailsComponent = function (props) {
26262
26276
  dataIndex: "nationalPlanObjective",
26263
26277
  key: "nationalPlanObjective",
26264
26278
  align: "left",
26265
- editable: true,
26266
26279
  width: "50%",
26280
+ editable: true,
26267
26281
  render: function (_, record) { return (React.createElement(React.Fragment, null, record.nationalPlanObjective ? (React.createElement(Space, { size: "middle" },
26268
26282
  React.createElement("span", null, record.nationalPlanObjective))) : (React.createElement("input", { placeholder: "Please add the National Plan Objective", className: "ant-input", type: "text" })))); },
26269
26283
  },
@@ -26272,8 +26286,8 @@ var NdcDetailsComponent = function (props) {
26272
26286
  dataIndex: "kpi",
26273
26287
  key: "kpi",
26274
26288
  align: "left",
26275
- editable: true,
26276
26289
  width: "10%",
26290
+ editable: true,
26277
26291
  render: function (_, record) { return (React.createElement(React.Fragment, null, record.kpi ? (React.createElement(Space, { size: "middle" },
26278
26292
  React.createElement("span", null, record.kpi))) : (React.createElement("input", { placeholder: "Enter Kpi", className: "ant-input", type: "text" })))); },
26279
26293
  },
@@ -26282,10 +26296,10 @@ var NdcDetailsComponent = function (props) {
26282
26296
  dataIndex: "ministryName",
26283
26297
  key: "ministryName",
26284
26298
  align: "left",
26285
- editable: true,
26286
26299
  width: "40%",
26287
- render: function (_, record) { return (React.createElement(React.Fragment, null, record.ministryName ? (React.createElement(Space, { size: "middle" },
26288
- React.createElement("span", null, record.ministryName))) : (React.createElement("input", { placeholder: "Please add the ministryName name", className: "ant-input", type: "text" })))); },
26300
+ editable: false,
26301
+ 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 }))); },
26289
26303
  },
26290
26304
  ];
26291
26305
  var columns = defaultColumns.map(function (col) {
@@ -26293,10 +26307,12 @@ var NdcDetailsComponent = function (props) {
26293
26307
  return col;
26294
26308
  }
26295
26309
  return __assign(__assign({}, col), { onCell: function (record) {
26296
- console.log('record', record);
26310
+ console.log("record", record);
26297
26311
  return {
26298
26312
  record: record,
26299
- editable: col.editable,
26313
+ editable: record.actionType === NdcActionType.mainAction
26314
+ ? isMainNdcActionsEditable
26315
+ : isSubNdcActionsEditable(record),
26300
26316
  dataIndex: col.dataIndex,
26301
26317
  title: col.title,
26302
26318
  handleSave: handleSave,
@@ -26315,7 +26331,7 @@ var NdcDetailsComponent = function (props) {
26315
26331
  actionType: NdcActionType.mainAction,
26316
26332
  nationalPlanObjective: "",
26317
26333
  kpi: 0,
26318
- ministryName: governmentMinistry,
26334
+ ministryName: loginMinistry,
26319
26335
  periodId: periodId,
26320
26336
  status: NdcDetailsActionStatus.pending,
26321
26337
  };
@@ -26487,9 +26503,31 @@ var NdcDetailsComponent = function (props) {
26487
26503
  }
26488
26504
  });
26489
26505
  }); };
26506
+ var fetchMinistries = function () { return __awaiter(void 0, void 0, void 0, function () {
26507
+ var response, ministryOrgDetails;
26508
+ return __generator(this, function (_a) {
26509
+ switch (_a.label) {
26510
+ case 0: return [4 /*yield*/, get("national/company/getMinistries")];
26511
+ case 1:
26512
+ response = _a.sent();
26513
+ console.log('fetchMinistries', response);
26514
+ if (response && response.data) {
26515
+ ministryOrgDetails = response.data.map(function (value) {
26516
+ return {
26517
+ value: value.user_id,
26518
+ label: value.user_name,
26519
+ };
26520
+ });
26521
+ setMinistryOrgList(ministryOrgDetails);
26522
+ }
26523
+ return [2 /*return*/];
26524
+ }
26525
+ });
26526
+ }); };
26490
26527
  useEffect(function () {
26491
26528
  fetchNdcDetailPeriods();
26492
26529
  fetchNdcDetailActions();
26530
+ fetchMinistries();
26493
26531
  }, []);
26494
26532
  return (React.createElement("div", { className: "ndc-management content-container" },
26495
26533
  React.createElement("div", { className: "title-bar" },