@undp/carbon-library 1.0.274-CARBON-404.5 → 1.0.274-CARBON-363.56

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:
@@ -5707,188 +5707,6 @@ exports.SystemNames = void 0;
5707
5707
  SystemNames["CARBON_TRANSPARENCY"] = "CARBON_TRANSPARENCY_SYSTEM";
5708
5708
  })(exports.SystemNames || (exports.SystemNames = {}));
5709
5709
 
5710
- exports.GovDepartment = void 0;
5711
- (function (GovDepartment) {
5712
- GovDepartment["Cocoa Research Institute"] = "1";
5713
- GovDepartment["National Agricultural Extension, Research and Liaison Services"] = "2";
5714
- GovDepartment["National Veterinary Research Institute"] = "3";
5715
- GovDepartment["Agricultural Insurance Corporation"] = "4";
5716
- GovDepartment["National Root Crops Research Institute"] = "5";
5717
- GovDepartment["Agricultural Research Council"] = "6";
5718
- GovDepartment["Institute for Oceanography and Marine Research"] = "7";
5719
- GovDepartment["Institute for Oil Palm Research"] = "8";
5720
- GovDepartment["Agricultural Quarantine Service"] = "9";
5721
- GovDepartment["National Horticultural Research Institute"] = "10";
5722
- GovDepartment["Federal Airports Authority"] = "11";
5723
- GovDepartment["Airspace Management Agency"] = "12";
5724
- GovDepartment["Civil Aviation Authority"] = "13";
5725
- GovDepartment["Safety Investigation Bureau"] = "14";
5726
- GovDepartment["Meteorological Agency"] = "15";
5727
- GovDepartment["College of Aviation Technology"] = "16";
5728
- GovDepartment["National Information Technology Development Agency"] = "17";
5729
- GovDepartment["Satellite Limited"] = "18";
5730
- GovDepartment["Broadcasting Commission"] = "19";
5731
- GovDepartment["Commission"] = "20";
5732
- GovDepartment["Postal Service"] = "21";
5733
- GovDepartment["National Frequency Management Council"] = "22";
5734
- GovDepartment["Television Authority"] = "23";
5735
- GovDepartment["Galaxy Backbone"] = "24";
5736
- GovDepartment["Asset Management Corporation"] = "25";
5737
- GovDepartment["Social Security Administration"] = "26";
5738
- GovDepartment["Budget Office of the Federation"] = "27";
5739
- GovDepartment["Bureau of Public Enterprises"] = "28";
5740
- GovDepartment["Bureau of Public Procurement"] = "29";
5741
- GovDepartment["Central Bank"] = "30";
5742
- GovDepartment["Corporate Affairs Commission"] = "31";
5743
- GovDepartment["Debt Management Office"] = "32";
5744
- GovDepartment["Inland Revenue Service"] = "33";
5745
- GovDepartment["Mortgage Bank"] = "34";
5746
- GovDepartment["Fiscal Responsibility Commission"] = "35";
5747
- GovDepartment["Infrastructure Concession Regulatory Commission"] = "36";
5748
- GovDepartment["National Bureau of Statistics"] = "37";
5749
- GovDepartment["National Council on Privatisation"] = "38";
5750
- GovDepartment["National Insurance Commission"] = "39";
5751
- GovDepartment["National Pension Commission"] = "40";
5752
- GovDepartment["National Planning Commission"] = "41";
5753
- GovDepartment["National Sugar Development Council"] = "42";
5754
- GovDepartment["Niger Delta Development Commission"] = "43";
5755
- GovDepartment["Customs Service"] = "44";
5756
- GovDepartment["Deposit Insurance Corporation"] = "45";
5757
- GovDepartment["Investment Promotion Commission"] = "46";
5758
- GovDepartment["Export - Import Bank"] = "47";
5759
- GovDepartment["Export Promotion Council"] = "48";
5760
- GovDepartment["Oil and Gas Free Zones Authority"] = "49";
5761
- GovDepartment["Export Processing Zones Authority"] = "50";
5762
- GovDepartment["Revenue Mobilisation Allocation and Fiscal Commission"] = "51";
5763
- GovDepartment["Securities and Exchange Commission"] = "52";
5764
- GovDepartment["Standards Organisation"] = "53";
5765
- GovDepartment["Small and Medium Enterprise Development Agency"] = "54";
5766
- GovDepartment["National Board for Arabic And Islamic Studies"] = "55";
5767
- GovDepartment["Joint Admissions and Matriculation Board"] = "56";
5768
- GovDepartment["National Examination Council"] = "115";
5769
- GovDepartment["National Open University"] = "57";
5770
- GovDepartment["National Teachers Institute"] = "58";
5771
- GovDepartment["National Universities Commission"] = "59";
5772
- GovDepartment["Tertiary Education Trust Fund"] = "60";
5773
- GovDepartment["Teachers Registration Council"] = "61";
5774
- GovDepartment["National Business and Technical Examinations Board"] = "62";
5775
- GovDepartment["Universal Basic Education Commission"] = "63";
5776
- GovDepartment["West African Examination Council"] = "64";
5777
- GovDepartment["National Commission for Colleges of Education"] = "65";
5778
- GovDepartment["National Library"] = "66";
5779
- GovDepartment["Midstream and Downstream Petroleum Regulatory Authority"] = "67";
5780
- GovDepartment["Upstream Petroleum Regulatory Commission"] = "68";
5781
- GovDepartment["Electricity Management Services Limited"] = "69";
5782
- GovDepartment["Energy Commission"] = "70";
5783
- GovDepartment["National Power Training Institute"] = "71";
5784
- GovDepartment["Electricity Regulatory Commission"] = "72";
5785
- GovDepartment["Content Monitoring and Development Board"] = "73";
5786
- GovDepartment["National Petroleum Corporation"] = "74";
5787
- GovDepartment["Nuclear Regulatory Authority Science & Technology"] = "75";
5788
- GovDepartment["Petroleum Product Pricing Regulatory Agency"] = "76";
5789
- GovDepartment["Power Holding Company (defunct)"] = "77";
5790
- GovDepartment["Rural Electrification Agency"] = "78";
5791
- GovDepartment["Transmission Company"] = "79";
5792
- GovDepartment["Environmental Protection Agency (defunct)"] = "80";
5793
- GovDepartment["Forestry Research Institute"] = "81";
5794
- GovDepartment["National Biosafety Management Agency"] = "82";
5795
- GovDepartment["National Environmental Standards and Regulations Enforcement Agency"] = "83";
5796
- GovDepartment["National Oil Spill Detection and Response Agency"] = "84";
5797
- GovDepartment["Environmental Health Officers Registration Council"] = "85";
5798
- GovDepartment["National Health Insurance Scheme"] = "86";
5799
- GovDepartment["Institute for Pharmaceutical Research and Development"] = "87";
5800
- GovDepartment["Agency for the Control of AIDS"] = "88";
5801
- GovDepartment["Agency for Food and Drug Administration and Control"] = "89";
5802
- GovDepartment["Primary Health Care Development Agency"] = "90";
5803
- GovDepartment["Institute of Medical Research"] = "91";
5804
- GovDepartment["Centre for Disease Control"] = "92";
5805
- GovDepartment["Drug Law Enforcement Agency"] = "93";
5806
- GovDepartment["Defence Intelligence Agency"] = "94";
5807
- GovDepartment["State Security Service"] = "95";
5808
- GovDepartment["National Intelligence Agency"] = "96";
5809
- GovDepartment["Financial Intelligence Unit"] = "97";
5810
- GovDepartment["National Judicial Council"] = "98";
5811
- GovDepartment["Federal Judicial Service Commission"] = "99";
5812
- GovDepartment["National Judicial Institute"] = "100";
5813
- GovDepartment["Maritime Administration and Safety Agency"] = "101";
5814
- GovDepartment["Ports Authority"] = "102";
5815
- GovDepartment["Shippers' Council"] = "103";
5816
- GovDepartment["Broadcasting Organisation"] = "104";
5817
- GovDepartment["News Agency"] = "105";
5818
- GovDepartment["Press Council"] = "106";
5819
- GovDepartment["Television Authority Media"] = "107";
5820
- GovDepartment["Agency For Science and Engineering Infrastructure"] = "108";
5821
- GovDepartment["Biotechnology Development Agency"] = "109";
5822
- GovDepartment["Centre for Remote Sensing"] = "110";
5823
- GovDepartment["Science and Technology Complex"] = "111";
5824
- GovDepartment["Office for Technology Acquisition and Promotion"] = "112";
5825
- GovDepartment["Space Research and Development Agency"] = "113";
5826
- GovDepartment["Nuclear Regulatory Authority"] = "114";
5827
- GovDepartment["Raw Materials Research and Development Council"] = "116";
5828
- GovDepartment["Communications Satellite Ltd"] = "117";
5829
- GovDepartment["Centre for Technology Management"] = "118";
5830
- GovDepartment["Hydrological Services Agency"] = "119";
5831
- GovDepartment["Integrated Water Resources Commission"] = "120";
5832
- GovDepartment["Water Resources Institute"] = "121";
5833
- GovDepartment["River Basin Development Authorities"] = "122";
5834
- GovDepartment["Centre for Black and African Arts and Civilization"] = "123";
5835
- GovDepartment["Automotive Design and Development Council"] = "124";
5836
- GovDepartment["Code of Conduct Bureau"] = "125";
5837
- GovDepartment["Computer Professionals Registration Council"] = "126";
5838
- GovDepartment["Consumer Protection Council"] = "127";
5839
- GovDepartment["Economic and Financial Crimes Commission"] = "128";
5840
- GovDepartment["Federal Character Commission"] = "129";
5841
- GovDepartment["Federal Housing Authority"] = "130";
5842
- GovDepartment["Corrupt Practices and Other Related Offences Commission"] = "131";
5843
- GovDepartment["Independent National Electoral Commission"] = "132";
5844
- GovDepartment["Industrial Training Fund"] = "133";
5845
- GovDepartment["Legal Aid Council"] = "134";
5846
- GovDepartment["Agency for the Prohibition of Trafficking in Persons"] = "135";
5847
- GovDepartment["National Boundary Commission"] = "136";
5848
- GovDepartment["National Council of Arts and Culture"] = "137";
5849
- GovDepartment["Economic Reconstruction Fund"] = "138";
5850
- GovDepartment["Emergency Management Agency"] = "139";
5851
- GovDepartment["Hajj Commission"] = "140";
5852
- GovDepartment["Human Rights Commission"] = "141";
5853
- GovDepartment["Identity Management Commission"] = "142";
5854
- GovDepartment["Institute for Hospitality Tourism"] = "143";
5855
- GovDepartment["Lottery Regulatory Commission"] = "144";
5856
- GovDepartment["Orientation Agency"] = "145";
5857
- GovDepartment["Population Commission"] = "146";
5858
- GovDepartment["Poverty Eradication Programme (defunct)"] = "147";
5859
- GovDepartment["Salaries, Incomes and Wages Commission"] = "148";
5860
- GovDepartment["Sports Commission"] = "149";
5861
- GovDepartment["Extractive Industries Transparency Initiative"] = "150";
5862
- GovDepartment["Immigration Service"] = "151";
5863
- GovDepartment["Building and Road Research Institute"] = "152";
5864
- GovDepartment["Institute of Building"] = "153";
5865
- GovDepartment["Christian Pilgrim Commission"] = "154";
5866
- GovDepartment["Copyright Commission"] = "155";
5867
- GovDepartment["Tourism Development Corporation"] = "156";
5868
- GovDepartment["Public Complaints Commission"] = "157";
5869
- GovDepartment["Surveyors Council"] = "158";
5870
- GovDepartment["National Lottery Trust Fund"] = "159";
5871
- })(exports.GovDepartment || (exports.GovDepartment = {}));
5872
-
5873
- exports.Ministry = void 0;
5874
- (function (Ministry) {
5875
- Ministry["Agriculture"] = "Agriculture";
5876
- Ministry["Aviation"] = "Aviation";
5877
- Ministry["Communications"] = "Communications";
5878
- Ministry["Economy"] = "Economy";
5879
- Ministry["Education"] = "Education";
5880
- Ministry["Energy"] = "Energy";
5881
- Ministry["Environment"] = "Environment";
5882
- Ministry["Health"] = "Health";
5883
- Ministry["Intelligence"] = "Intelligence";
5884
- Ministry["Judiciary"] = "Judiciary";
5885
- Ministry["Maritime"] = "Maritime";
5886
- Ministry["Media"] = "Media";
5887
- Ministry["ScienceAndTechnology"] = "Science And Technology";
5888
- Ministry["WaterResources"] = "Water Resources";
5889
- Ministry["Other"] = "Other";
5890
- })(exports.Ministry || (exports.Ministry = {}));
5891
-
5892
5710
  exports.ConfigurationSettingsType = void 0;
5893
5711
  (function (ConfigurationSettingsType) {
5894
5712
  ConfigurationSettingsType[ConfigurationSettingsType["isTransferFrozen"] = 0] = "isTransferFrozen";
@@ -5934,197 +5752,6 @@ var ProgrammeCertify = /** @class */ (function () {
5934
5752
  return ProgrammeCertify;
5935
5753
  }());
5936
5754
 
5937
- var sectoralScopes$1 = {
5938
- Agriculture: [
5939
- "Cocoa Research Institute",
5940
- "National Agricultural Extension, Research and Liaison Services",
5941
- "National Veterinary Research Institute",
5942
- "Agricultural Insurance Corporation",
5943
- "National Root Crops Research Institute",
5944
- "Agricultural Research Council",
5945
- "Institute for Oceanography and Marine Research",
5946
- "Institute for Oil Palm Research",
5947
- "Agricultural Quarantine Service",
5948
- "National Horticultural Research Institute",
5949
- ],
5950
- Aviation: [
5951
- "Federal Airports Authority",
5952
- "Airspace Management Agency",
5953
- "Civil Aviation Authority",
5954
- "Safety Investigation Bureau",
5955
- "Meteorological Agency",
5956
- "College of Aviation Technology",
5957
- ],
5958
- Communications: [
5959
- "National Information Technology Development Agency",
5960
- "Communications Satellite Limited",
5961
- "Broadcasting Commission",
5962
- "Communications Commission",
5963
- "Postal Service",
5964
- "National Frequency Management Council",
5965
- "Television Authority",
5966
- "Galaxy Backbone",
5967
- ],
5968
- Economy: [
5969
- "Asset Management Corporation",
5970
- "Social Security Administration",
5971
- "Budget Office of the Federation",
5972
- "Bureau of Public Enterprises",
5973
- "Bureau of Public Procurement",
5974
- "Central Bank",
5975
- "Corporate Affairs Commission",
5976
- "Debt Management Office",
5977
- "Inland Revenue Service",
5978
- "Mortgage Bank",
5979
- "Fiscal Responsibility Commission",
5980
- "Infrastructure Concession Regulatory Commission",
5981
- "National Bureau of Statistics",
5982
- "National Council on Privatisation",
5983
- "National Insurance Commission",
5984
- "National Pension Commission",
5985
- "National Planning Commission",
5986
- "National Sugar Development Council",
5987
- "Niger Delta Development Commission",
5988
- "Customs Service",
5989
- "Deposit Insurance Corporation",
5990
- "Investment Promotion Commission",
5991
- "Export - Import Bank",
5992
- "Export Promotion Council",
5993
- "Oil and Gas Free Zones Authority",
5994
- "Export Processing Zones Authority",
5995
- "Revenue Mobilisation Allocation and Fiscal Commission",
5996
- "Securities and Exchange Commission",
5997
- "Standards Organisation",
5998
- "Small and Medium Enterprise Development Agency",
5999
- ],
6000
- Education: [
6001
- "National Board for Arabic And Islamic Studies",
6002
- "Joint Admissions and Matriculation Board",
6003
- "National Examination Council",
6004
- "National Open University",
6005
- "National Teachers Institute",
6006
- "National Universities Commission",
6007
- "Tertiary Education Trust Fund",
6008
- "Teachers Registration Council",
6009
- "National Business and Technical Examinations Board",
6010
- "Universal Basic Education Commission",
6011
- "West African Examination Council",
6012
- "National Commission for Colleges of Education",
6013
- "National Library",
6014
- ],
6015
- Energy: [
6016
- "Midstream and Downstream Petroleum Regulatory Authority",
6017
- "Upstream Petroleum Regulatory Commission",
6018
- "Electricity Management Services Limited",
6019
- "Energy Commission",
6020
- "National Power Training Institute",
6021
- "Electricity Regulatory Commission",
6022
- "Content Monitoring and Development Board",
6023
- "National Petroleum Corporation",
6024
- "Nuclear Regulatory Authority",
6025
- "Petroleum Product Pricing Regulatory Agency",
6026
- "Power Holding Company (defunct)",
6027
- "Rural Electrification Agency",
6028
- "Transmission Company",
6029
- ],
6030
- Environment: [
6031
- "Environmental Protection Agency (defunct)",
6032
- "Forestry Research Institute",
6033
- "National Biosafety Management Agency",
6034
- "National Environmental Standards and Regulations Enforcement Agency",
6035
- "National Oil Spill Detection and Response Agency",
6036
- "Environmental Health Officers Registration Council",
6037
- ],
6038
- Health: [
6039
- "National Health Insurance Scheme",
6040
- "Institute for Pharmaceutical Research and Development",
6041
- "Agency for the Control of AIDS",
6042
- "Agency for Food and Drug Administration and Control",
6043
- "Primary Health Care Development Agency",
6044
- "Institute of Medical Research",
6045
- "Centre for Disease Control",
6046
- "Drug Law Enforcement Agency",
6047
- ],
6048
- Intelligence: [
6049
- "Defence Intelligence Agency",
6050
- "State Security Service",
6051
- "National Intelligence Agency",
6052
- "Financial Intelligence Unit",
6053
- ],
6054
- Judiciary: [
6055
- "National Judicial Council",
6056
- "Federal Judicial Service Commission",
6057
- "National Judicial Institute",
6058
- ],
6059
- Maritime: [
6060
- "Maritime Administration and Safety Agency",
6061
- "Ports Authority",
6062
- "Shippers' Council",
6063
- ],
6064
- Media: [
6065
- "Broadcasting Organisation",
6066
- "News Agency",
6067
- "Press Council",
6068
- "Television Authority",
6069
- ],
6070
- ScienceAndTechnology: [
6071
- "Agency For Science and Engineering Infrastructure",
6072
- "Biotechnology Development Agency",
6073
- "Centre for Remote Sensing",
6074
- "Science and Technology Complex",
6075
- "Office for Technology Acquisition and Promotion",
6076
- "Space Research and Development Agency",
6077
- "Nuclear Regulatory Authority",
6078
- "Raw Materials Research and Development Council",
6079
- "Communications Satellite Ltd",
6080
- "Centre for Technology Management",
6081
- ],
6082
- WaterResources: [
6083
- "Hydrological Services Agency",
6084
- "Integrated Water Resources Commission",
6085
- "Water Resources Institute",
6086
- "River Basin Development Authorities",
6087
- ],
6088
- Other: [
6089
- "Centre for Black and African Arts and Civilization",
6090
- "Automotive Design and Development Council",
6091
- "Code of Conduct Bureau",
6092
- "Computer Professionals Registration Council",
6093
- "Consumer Protection Council",
6094
- "Economic and Financial Crimes Commission",
6095
- "Federal Character Commission",
6096
- "Federal Housing Authority",
6097
- "Corrupt Practices and Other Related Offences Commission",
6098
- "Independent National Electoral Commission",
6099
- "Industrial Training Fund",
6100
- "Legal Aid Council",
6101
- "Agency for the Prohibition of Trafficking in Persons",
6102
- "National Boundary Commission",
6103
- "National Council of Arts and Culture",
6104
- "Economic Reconstruction Fund",
6105
- "Emergency Management Agency",
6106
- "Hajj Commission",
6107
- "Human Rights Commission",
6108
- "Identity Management Commission",
6109
- "Institute for Hospitality Tourism",
6110
- "Lottery Regulatory Commission",
6111
- "Orientation Agency",
6112
- "Population Commission",
6113
- "Poverty Eradication Programme (defunct)",
6114
- "Salaries, Incomes and Wages Commission",
6115
- "Sports Commission",
6116
- "Extractive Industries Transparency Initiative",
6117
- "Immigration Service",
6118
- "Building and Road Research Institute",
6119
- "Institute of Building",
6120
- "Christian Pilgrim Commission",
6121
- "Copyright Commission",
6122
- "Tourism Development Corporation",
6123
- "Public Complaints Commission",
6124
- "Surveyors Council",
6125
- "National Lottery Trust Fund",
6126
- ],
6127
- };
6128
5755
  var AddNewCompanyComponent = function (props) {
6129
5756
  var _a;
6130
5757
  var t = props.t, onNavigateToCompanyManagement = props.onNavigateToCompanyManagement, maximumImageSize = props.maximumImageSize, useConnection = props.useConnection, useUserContext = props.useUserContext, useLocation = props.useLocation, regionField = props.regionField, isGuest = props.isGuest, onNavigateToHome = props.onNavigateToHome, systemType = props.systemType;
@@ -6143,53 +5770,6 @@ var AddNewCompanyComponent = function (props) {
6143
5770
  var _k = React.useState(false), loadingList = _k[0], setLoadingList = _k[1];
6144
5771
  var _l = React.useState([]), regionsList = _l[0], setRegionsList = _l[1];
6145
5772
  var _m = React.useState((_a = state === null || state === void 0 ? void 0 : state.record) === null || _a === void 0 ? void 0 : _a.companyRole), companyRole = _m[0], setCompanyRole = _m[1];
6146
- var _o = React.useState(""), selectedMinistry = _o[0], setSelectedMinistry = _o[1];
6147
- var _p = React.useState([]), existgovDep = _p[0], setexistGovdep = _p[1];
6148
- var selectedGovDepatments = sectoralScopes$1[selectedMinistry];
6149
- if (existgovDep && existgovDep.length > 0) {
6150
- selectedGovDepatments = selectedGovDepatments.filter(function (x) { return !existgovDep.includes(x); });
6151
- }
6152
- var onChangeMinistry = function (val) { return __awaiter(void 0, void 0, void 0, function () {
6153
- var key, response, existDep, i, departName;
6154
- return __generator(this, function (_a) {
6155
- switch (_a.label) {
6156
- case 0:
6157
- formOne.resetFields(["govDep"]);
6158
- key = Object.keys(exports.Ministry)[Object.values(exports.Ministry).indexOf(val)];
6159
- setSelectedMinistry(String(key));
6160
- return [4 /*yield*/, post("national/organisation/query", {
6161
- page: 1,
6162
- size: 10,
6163
- filterAnd: [
6164
- {
6165
- key: "companyRole",
6166
- operation: "=",
6167
- value: "Ministry",
6168
- },
6169
- {
6170
- key: "ministry",
6171
- operation: "=",
6172
- value: val,
6173
- },
6174
- ],
6175
- })];
6176
- case 1:
6177
- response = _a.sent();
6178
- if (response && response.data) {
6179
- existDep = [];
6180
- for (i in response.data) {
6181
- console.log("existdata", response.data[i]);
6182
- if (response.data[i].govDep && response.data[i].govDep.length > 0) {
6183
- departName = Object.keys(exports.GovDepartment)[Object.values(exports.GovDepartment).indexOf(response.data[i].govDep)];
6184
- existDep.push(departName);
6185
- }
6186
- }
6187
- setexistGovdep(existDep);
6188
- }
6189
- return [2 /*return*/];
6190
- }
6191
- });
6192
- }); };
6193
5773
  var getCountryList = function () { return __awaiter(void 0, void 0, void 0, function () {
6194
5774
  var response, alpha2Names;
6195
5775
  return __generator(this, function (_a) {
@@ -6314,10 +5894,6 @@ var AddNewCompanyComponent = function (props) {
6314
5894
  logoBase64 = _c.sent();
6315
5895
  logoUrls = logoBase64.split(",");
6316
5896
  requestData.company.logo = logoUrls[1];
6317
- if (companyRole === exports.CompanyRole.MINISTRY) {
6318
- requestData.company.name =
6319
- "Ministry of " + requestData.company.ministry;
6320
- }
6321
5897
  if (!isGuest) return [3 /*break*/, 4];
6322
5898
  return [4 /*yield*/, post("national/user/register", requestData)];
6323
5899
  case 3:
@@ -6370,7 +5946,7 @@ var AddNewCompanyComponent = function (props) {
6370
5946
  });
6371
5947
  }); };
6372
5948
  var onUpdateCompany = function () { return __awaiter(void 0, void 0, void 0, function () {
6373
- var formOneValues, values, key, logoBase64, logoUrls, response, error_3;
5949
+ var formOneValues, values, logoBase64, logoUrls, response, error_3;
6374
5950
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
6375
5951
  return __generator(this, function (_l) {
6376
5952
  switch (_l.label) {
@@ -6411,15 +5987,6 @@ var AddNewCompanyComponent = function (props) {
6411
5987
  if (((_g = state === null || state === void 0 ? void 0 : state.record) === null || _g === void 0 ? void 0 : _g.companyRole) === exports.CompanyRole.MINISTRY) {
6412
5988
  values.sectoralScope = formOneValues.sectoralScope;
6413
5989
  values.nameOfMinister = formOneValues.nameOfMinister;
6414
- values.ministry = formOneValues.ministry;
6415
- if (formOneValues.govDep in exports.GovDepartment) {
6416
- key = formOneValues.govDep;
6417
- values.govDep = exports.GovDepartment[key];
6418
- }
6419
- else {
6420
- values.govDep = formOneValues.govDep;
6421
- }
6422
- values.name = "Ministry of " + formOneValues.ministry;
6423
5990
  }
6424
5991
  if (((_h = state === null || state === void 0 ? void 0 : state.record) === null || _h === void 0 ? void 0 : _h.companyRole) === exports.CompanyRole.GOVERNMENT) {
6425
5992
  values.omgePercentage = Math.round(Number(formOneValues.omgePercentage));
@@ -6480,7 +6047,7 @@ var AddNewCompanyComponent = function (props) {
6480
6047
  setCompanyRole(value);
6481
6048
  };
6482
6049
  var CompanyDetailsForm = function () {
6483
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
6050
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
6484
6051
  var companyRoleClassName = companyRole === exports.CompanyRole.CERTIFIER
6485
6052
  ? "certifier"
6486
6053
  : companyRole === exports.CompanyRole.PROGRAMME_DEVELOPER
@@ -6494,7 +6061,7 @@ var AddNewCompanyComponent = function (props) {
6494
6061
  React.createElement(antd.Row, { className: "row", gutter: [16, 16] },
6495
6062
  React.createElement(antd.Col, { xl: 12, md: 24 },
6496
6063
  React.createElement("div", { className: "details-part-one" },
6497
- companyRole !== exports.CompanyRole.MINISTRY && (React.createElement(antd.Form.Item, { label: "Name", name: "name", initialValue: (_a = state === null || state === void 0 ? void 0 : state.record) === null || _a === void 0 ? void 0 : _a.name, rules: [
6064
+ React.createElement(antd.Form.Item, { label: "Name", name: "name", initialValue: (_a = state === null || state === void 0 ? void 0 : state.record) === null || _a === void 0 ? void 0 : _a.name, rules: [
6498
6065
  {
6499
6066
  required: true,
6500
6067
  message: "",
@@ -6513,7 +6080,7 @@ var AddNewCompanyComponent = function (props) {
6513
6080
  }); },
6514
6081
  },
6515
6082
  ] },
6516
- React.createElement(antd.Input, { size: "large" }))),
6083
+ React.createElement(antd.Input, { size: "large" })),
6517
6084
  companyRole !== exports.CompanyRole.MINISTRY
6518
6085
  ? (!isUpdate ||
6519
6086
  (isUpdate &&
@@ -6593,31 +6160,7 @@ var AddNewCompanyComponent = function (props) {
6593
6160
  },
6594
6161
  ] },
6595
6162
  React.createElement(antd.Input, { size: "large" })),
6596
- companyRole === exports.CompanyRole.MINISTRY && (React.createElement("div", { className: "space-container", style: { width: "100%" } },
6597
- React.createElement(antd.Form.Item, { label: "Ministry Name", name: "ministry", initialValue: (_e = state === null || state === void 0 ? void 0 : state.record) === null || _e === void 0 ? void 0 : _e.ministry, rules: [
6598
- {
6599
- required: true,
6600
- message: "Ministry Name is required",
6601
- },
6602
- ] },
6603
- React.createElement(antd.Select, { size: "large", onChange: onChangeMinistry }, Object.values(exports.Ministry).map(function (ministry) { return (React.createElement(antd.Select.Option, { value: ministry }, ministry)); }))),
6604
- React.createElement(antd.Form.Item, { label: "Name of the Minister", name: "nameOfMinister", initialValue: (_f = state === null || state === void 0 ? void 0 : state.record) === null || _f === void 0 ? void 0 : _f.nameOfMinister, rules: [
6605
- {
6606
- validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
6607
- return __generator(this, function (_a) {
6608
- if (String(value).trim() === "" ||
6609
- String(value).trim() === undefined ||
6610
- value === null ||
6611
- value === undefined) {
6612
- throw new Error("Name of the Minister ".concat(t("isRequired")));
6613
- }
6614
- return [2 /*return*/];
6615
- });
6616
- }); },
6617
- },
6618
- ] },
6619
- React.createElement(antd.Input, { size: "large" })))),
6620
- React.createElement(antd.Form.Item, { className: "website", label: "Website", initialValue: (_h = (_g = state === null || state === void 0 ? void 0 : state.record) === null || _g === void 0 ? void 0 : _g.website) === null || _h === void 0 ? void 0 : _h.split("://")[1], name: "website", rules: [
6163
+ React.createElement(antd.Form.Item, { className: "website", label: "Website", initialValue: (_f = (_e = state === null || state === void 0 ? void 0 : state.record) === null || _e === void 0 ? void 0 : _e.website) === null || _f === void 0 ? void 0 : _f.split("://")[1], name: "website", rules: [
6621
6164
  {
6622
6165
  required: false,
6623
6166
  validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
@@ -6635,23 +6178,6 @@ var AddNewCompanyComponent = function (props) {
6635
6178
  },
6636
6179
  ], getValueFromEvent: function (event) { var _a; return (_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.value.trim(); } },
6637
6180
  React.createElement(antd.Input, { addonBefore: "https://", size: "large" })),
6638
- companyRole === exports.CompanyRole.MINISTRY && (React.createElement(antd.Form.Item, { name: "address", label: "Address", initialValue: (_j = state === null || state === void 0 ? void 0 : state.record) === null || _j === void 0 ? void 0 : _j.address, rules: [
6639
- { required: true, message: "" },
6640
- {
6641
- validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
6642
- return __generator(this, function (_a) {
6643
- if (String(value).trim() === "" ||
6644
- String(value).trim() === undefined ||
6645
- value === null ||
6646
- value === undefined) {
6647
- throw new Error("Address ".concat(t("isRequired")));
6648
- }
6649
- return [2 /*return*/];
6650
- });
6651
- }); },
6652
- },
6653
- ] },
6654
- React.createElement(antd.Input.TextArea, { rows: 3, maxLength: 100 }))),
6655
6181
  React.createElement(antd.Form.Item, { name: "logo", label: "Organisation Logo (File Type : JPEG , PNG)", valuePropName: "fileList", getValueFromEvent: normFile, required: true, rules: [
6656
6182
  {
6657
6183
  validator: function (rule, file) { return __awaiter(void 0, void 0, void 0, function () {
@@ -6695,12 +6221,29 @@ var AddNewCompanyComponent = function (props) {
6695
6221
  return false;
6696
6222
  }, className: "logo-upload-section", name: "logo", action: "/upload.do", listType: "picture", multiple: false, defaultFileList: fileList, maxCount: 1 },
6697
6223
  React.createElement(antd.Button, { size: "large", icon: React.createElement(icons.UploadOutlined, null) }, "Upload"))),
6224
+ companyRole === exports.CompanyRole.MINISTRY && (React.createElement(antd.Form.Item, { name: "address", label: "Address", initialValue: (_g = state === null || state === void 0 ? void 0 : state.record) === null || _g === void 0 ? void 0 : _g.address, rules: [
6225
+ { required: true, message: "" },
6226
+ {
6227
+ validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
6228
+ return __generator(this, function (_a) {
6229
+ if (String(value).trim() === "" ||
6230
+ String(value).trim() === undefined ||
6231
+ value === null ||
6232
+ value === undefined) {
6233
+ throw new Error("Address ".concat(t("isRequired")));
6234
+ }
6235
+ return [2 /*return*/];
6236
+ });
6237
+ }); },
6238
+ },
6239
+ ] },
6240
+ React.createElement(antd.Input.TextArea, { rows: 3, maxLength: 100 }))),
6698
6241
  companyRole === exports.CompanyRole.GOVERNMENT && (React.createElement("div", { className: "space-container", style: { width: "100%" } },
6699
6242
  React.createElement(antd.Space, { wrap: true, style: {
6700
6243
  display: "flex",
6701
6244
  marginBottom: 8,
6702
6245
  }, align: "center", size: "large" },
6703
- React.createElement(antd.Form.Item, { style: { width: "100%" }, name: "nationalSopValue", label: "National Share of Proceeds", initialValue: (_k = state === null || state === void 0 ? void 0 : state.record) === null || _k === void 0 ? void 0 : _k.nationalSopValue, rules: [
6246
+ React.createElement(antd.Form.Item, { style: { width: "100%" }, name: "nationalSopValue", label: "National Share of Proceeds", initialValue: (_h = state === null || state === void 0 ? void 0 : state.record) === null || _h === void 0 ? void 0 : _h.nationalSopValue, rules: [
6704
6247
  { required: true, message: "" },
6705
6248
  {
6706
6249
  validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
@@ -6758,45 +6301,37 @@ var AddNewCompanyComponent = function (props) {
6758
6301
  React.createElement(antd.Radio.Button, { className: "minister", value: "Ministry" },
6759
6302
  React.createElement(icons.AuditOutlined, { className: "role-icons" }),
6760
6303
  "Ministry")))))))),
6761
- companyRole === exports.CompanyRole.MINISTRY && (React.createElement(antd.Form.Item, { label: "Government Department", name: "govDep", initialValue: Object.keys(exports.GovDepartment)[Object.values(exports.GovDepartment).indexOf((_l = state === null || state === void 0 ? void 0 : state.record) === null || _l === void 0 ? void 0 : _l.govDep)], rules: [
6304
+ companyRole === exports.CompanyRole.MINISTRY && (React.createElement(antd.Form.Item, { label: "Name of the Minister", name: "nameOfMinister", initialValue: (_j = state === null || state === void 0 ? void 0 : state.record) === null || _j === void 0 ? void 0 : _j.nameOfMinister, rules: [
6762
6305
  {
6763
6306
  required: true,
6764
- message: "Government Department is required",
6307
+ message: "",
6765
6308
  },
6766
6309
  {
6767
6310
  validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
6768
- var val;
6769
6311
  return __generator(this, function (_a) {
6770
- val = Object.keys(exports.GovDepartment)[Object.values(exports.GovDepartment).indexOf(value)];
6771
- if (val &&
6772
- val.length > 0 &&
6773
- selectedGovDepatments &&
6774
- !selectedGovDepatments.includes(val)) {
6775
- throw new Error("Department not exist in Ministry");
6312
+ if (String(value).trim() === "" ||
6313
+ String(value).trim() === undefined ||
6314
+ value === null ||
6315
+ value === undefined) {
6316
+ throw new Error("Name of the Minister ".concat(t("isRequired")));
6776
6317
  }
6777
6318
  return [2 /*return*/];
6778
6319
  });
6779
6320
  }); },
6780
6321
  },
6781
6322
  ] },
6782
- React.createElement(antd.Select, { size: "large" }, selectedGovDepatments === null || selectedGovDepatments === void 0 ? void 0 : selectedGovDepatments.map(function (val) {
6783
- if (val in exports.GovDepartment) {
6784
- var key = val;
6785
- return (React.createElement(antd.Select.Option, { key: exports.GovDepartment[key], value: exports.GovDepartment[key] }, val));
6786
- }
6787
- return null;
6788
- })))),
6323
+ React.createElement(antd.Input, { size: "large" }))),
6789
6324
  companyRole === exports.CompanyRole.MINISTRY && (React.createElement(antd.Form.Item, { label: "Sectoral Scope", name: "sectoralScope", rules: [
6790
6325
  {
6791
6326
  required: true,
6792
6327
  message: "Sectoral Scope ".concat(t("isRequired")),
6793
6328
  },
6794
- ], initialValue: (_m = state === null || state === void 0 ? void 0 : state.record) === null || _m === void 0 ? void 0 : _m.sectoralScope },
6329
+ ], initialValue: (_k = state === null || state === void 0 ? void 0 : state.record) === null || _k === void 0 ? void 0 : _k.sectoralScope },
6795
6330
  React.createElement(antd.Select, { mode: "multiple", size: "large", maxTagCount: 2, allowClear: true }, Object.entries(exports.SectoralScope).map(function (_a) {
6796
6331
  var key = _a[0], value = _a[1];
6797
6332
  return (React.createElement(antd.Select.Option, { key: value, value: value }, key));
6798
6333
  })))),
6799
- React.createElement(antd.Form.Item, { name: "phoneNo", label: "Phone Number", initialValue: (_o = state === null || state === void 0 ? void 0 : state.record) === null || _o === void 0 ? void 0 : _o.phoneNo, rules: [
6334
+ React.createElement(antd.Form.Item, { name: "phoneNo", label: "Phone Number", initialValue: (_l = state === null || state === void 0 ? void 0 : state.record) === null || _l === void 0 ? void 0 : _l.phoneNo, rules: [
6800
6335
  {
6801
6336
  required: true,
6802
6337
  message: "",
@@ -6827,14 +6362,14 @@ var AddNewCompanyComponent = function (props) {
6827
6362
  },
6828
6363
  ] },
6829
6364
  React.createElement(PhoneInput, { placeholder: "Phone number", international: true, value: PhoneInput.formatPhoneNumberIntl(contactNoInput), defaultCountry: "LK", countryCallingCodeEditable: false, onChange: function (v) { }, countries: countries })),
6830
- regionField && (React.createElement(antd.Form.Item, { label: t("region"), name: "regions", initialValue: (_p = state === null || state === void 0 ? void 0 : state.record) === null || _p === void 0 ? void 0 : _p.regions, rules: [
6365
+ regionField && (React.createElement(antd.Form.Item, { label: t("region"), name: "regions", initialValue: (_m = state === null || state === void 0 ? void 0 : state.record) === null || _m === void 0 ? void 0 : _m.regions, rules: [
6831
6366
  {
6832
6367
  required: true,
6833
6368
  message: "".concat(t("region"), " ").concat(t("isRequired")),
6834
6369
  },
6835
6370
  ] },
6836
6371
  React.createElement(antd.Select, { mode: "multiple", size: "large", maxTagCount: 2, onChange: onChangeRegion, loading: loadingList, allowClear: true }, regionsList.map(function (region) { return (React.createElement(antd.Select.Option, { value: region }, region)); })))),
6837
- companyRole !== exports.CompanyRole.MINISTRY && (React.createElement(antd.Form.Item, { name: "address", label: "Address", initialValue: (_q = state === null || state === void 0 ? void 0 : state.record) === null || _q === void 0 ? void 0 : _q.address, rules: [
6372
+ companyRole !== exports.CompanyRole.MINISTRY && (React.createElement(antd.Form.Item, { name: "address", label: "Address", initialValue: (_o = state === null || state === void 0 ? void 0 : state.record) === null || _o === void 0 ? void 0 : _o.address, rules: [
6838
6373
  { required: true, message: "" },
6839
6374
  {
6840
6375
  validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
@@ -6857,7 +6392,7 @@ var AddNewCompanyComponent = function (props) {
6857
6392
  display: "flex",
6858
6393
  marginBottom: 8,
6859
6394
  }, align: "center", size: "large" },
6860
- React.createElement(antd.Form.Item, { style: { width: "100%" }, name: "omgePercentage", label: "Overall Mitigation in Global Emissions (OMGE) Account", initialValue: (_r = state === null || state === void 0 ? void 0 : state.record) === null || _r === void 0 ? void 0 : _r.omgePercentage, rules: [
6395
+ React.createElement(antd.Form.Item, { style: { width: "100%" }, name: "omgePercentage", label: "Overall Mitigation in Global Emissions (OMGE) Account", initialValue: (_p = state === null || state === void 0 ? void 0 : state.record) === null || _p === void 0 ? void 0 : _p.omgePercentage, rules: [
6861
6396
  { required: true, message: "" },
6862
6397
  {
6863
6398
  validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
@@ -7364,16 +6899,6 @@ var CompanyProfileComponent = function (props) {
7364
6899
  React.createElement(antd.Col, { span: 12, className: "field-value" }, companyDetails.nameOfMinister
7365
6900
  ? companyDetails.nameOfMinister
7366
6901
  : "-")),
7367
- React.createElement(antd.Row, { className: "field" },
7368
- React.createElement(antd.Col, { span: 12, className: "field-key" }, t("companyProfile:ministryName")),
7369
- React.createElement(antd.Col, { span: 12, className: "field-value" }, companyDetails.ministry
7370
- ? companyDetails.ministry
7371
- : "-")),
7372
- React.createElement(antd.Row, { className: "field" },
7373
- React.createElement(antd.Col, { span: 12, className: "field-key" }, t("companyProfile:govDepName")),
7374
- React.createElement(antd.Col, { span: 12, className: "field-value" }, companyDetails.govDep
7375
- ? Object.keys(exports.GovDepartment)[Object.values(exports.GovDepartment).indexOf(companyDetails.govDep)]
7376
- : "-")),
7377
6902
  React.createElement(antd.Row, { className: "field" },
7378
6903
  React.createElement(antd.Col, { span: 12, className: "field-key" }, t("companyProfile:sectoralScope")),
7379
6904
  React.createElement(antd.Col, { span: 12, className: "field-value" }, companyDetails.sectoralScope
@@ -27150,622 +26675,891 @@ var RegistryDashboardComponent = function (props) {
27150
26675
  lastUpdateTransferLocations))))))))) : ("")));
27151
26676
  };
27152
26677
 
27153
- var EditableContext = React.createContext(null);
27154
- var EditableRow = function (_a) {
27155
- _a.index; var props = __rest(_a, ["index"]);
27156
- var form = antd.Form.useForm()[0];
27157
- return (React.createElement(antd.Form, { form: form, component: false },
27158
- React.createElement(EditableContext.Provider, { value: form },
27159
- React.createElement("tr", __assign({}, props)))));
27160
- };
26678
+ React.createContext(null);
27161
26679
  var EditableCell = function (_a) {
27162
- 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"]);
27163
- var _b = React.useState(false), editing = _b[0], setEditing = _b[1];
27164
- var inputRef = React.useRef(null);
27165
- var form = React.useContext(EditableContext);
27166
- React.useEffect(function () {
27167
- if (editing) {
27168
- inputRef.current.focus();
27169
- }
27170
- }, [editing]);
27171
- var toggleEdit = function () {
27172
- var _a;
27173
- setEditing(!editing);
27174
- form.setFieldsValue((_a = {}, _a[dataIndex] = record[dataIndex], _a));
27175
- };
27176
- var save = function () { return __awaiter(void 0, void 0, void 0, function () {
27177
- var values, errInfo_1;
27178
- return __generator(this, function (_a) {
27179
- switch (_a.label) {
27180
- case 0:
27181
- _a.trys.push([0, 2, , 3]);
27182
- return [4 /*yield*/, form.validateFields()];
27183
- case 1:
27184
- values = _a.sent();
27185
- toggleEdit();
27186
- handleSave(__assign(__assign({}, record), values));
27187
- return [3 /*break*/, 3];
27188
- case 2:
27189
- errInfo_1 = _a.sent();
27190
- console.log("Save failed:", errInfo_1);
27191
- return [3 /*break*/, 3];
27192
- case 3: return [2 /*return*/];
27193
- }
27194
- });
27195
- }); };
27196
- var childNode = children;
27197
- if (editable) {
27198
- childNode = editing ? (React.createElement(antd.Form.Item, { style: { margin: 0 }, name: dataIndex, rules: [
27199
- {
27200
- required: true,
27201
- message: "".concat(title, " is required."),
27202
- },
27203
- ] },
27204
- 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));
27205
- }
27206
- return React.createElement("td", __assign({}, restProps), childNode);
26680
+ var editing = _a.editing, dataIndex = _a.dataIndex, title = _a.title; _a.inputType; var record = _a.record; _a.index; var children = _a.children, onBlurHandler = _a.onBlurHandler, t = _a.t, restProps = __rest(_a, ["editing", "dataIndex", "title", "inputType", "record", "index", "children", "onBlurHandler", "t"]);
26681
+ return (React.createElement("td", __assign({}, restProps), editing && dataIndex === "nationalPlanObjective" ? (React.createElement(antd.Form.Item, { name: dataIndex, style: { margin: 0 }, rules: [
26682
+ {
26683
+ validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
26684
+ var trimValue;
26685
+ return __generator(this, function (_a) {
26686
+ trimValue = typeof value === "string" ? value.trim() : value;
26687
+ if (!trimValue) {
26688
+ throw new Error("".concat(title, " ").concat(t("ndc:isRequired")));
26689
+ }
26690
+ return [2 /*return*/];
26691
+ });
26692
+ }); },
26693
+ },
26694
+ ] },
26695
+ React.createElement(antd.Input, { onBlur: function () { return onBlurHandler(record); }, placeholder: t("ndc:nationalPlanObjectivePlaceHolder") }))) : editing && dataIndex === "kpi" ? (React.createElement(antd.Form.Item, { name: dataIndex, style: { margin: 0 }, rules: [
26696
+ {
26697
+ validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
26698
+ var trimValue;
26699
+ return __generator(this, function (_a) {
26700
+ trimValue = typeof value === "string" ? value.trim() : value;
26701
+ if (trimValue) {
26702
+ if (isNaN(+trimValue)) {
26703
+ throw new Error(t("ndc:kpiInvalidFormat"));
26704
+ }
26705
+ else if (+trimValue <= 0) {
26706
+ throw new Error(t("ndc:kpiGreaterThanZero"));
26707
+ }
26708
+ else if (trimValue.toString().length > 7) {
26709
+ throw new Error(t("ndc:kpiMaxLength"));
26710
+ }
26711
+ }
26712
+ else {
26713
+ throw new Error("".concat(title, " ").concat(t("ndc:isRequired")));
26714
+ }
26715
+ return [2 /*return*/];
26716
+ });
26717
+ }); },
26718
+ },
26719
+ ] },
26720
+ React.createElement(antd.Input, { onBlur: function () { return onBlurHandler(record); }, placeholder: t("ndc:kpiPlaceHolder") }))) : (children)));
27207
26721
  };
27208
26722
 
27209
- 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";
26723
+ 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\n.ndc-details .ant-input-number-input-wrap {\n margin-right: 10px; }\n\n.ndc-details tbody {\n vertical-align: top; }\n\n.ndc-details td .ant-space-item {\n margin-top: 5px; }\n\n.ndc-details .btn-danger {\n color: #ff4d4f !important;\n border-color: #ff8183 !important; }\n";
27210
26724
  styleInject(css_248z$4);
27211
26725
 
27212
- var NdcActionType;
27213
- (function (NdcActionType) {
27214
- NdcActionType[NdcActionType["main"] = 0] = "main";
27215
- NdcActionType[NdcActionType["sub"] = 1] = "sub";
27216
- })(NdcActionType || (NdcActionType = {}));
26726
+ var NdcDetailsActionType;
26727
+ (function (NdcDetailsActionType) {
26728
+ NdcDetailsActionType["MainAction"] = "MainAction";
26729
+ NdcDetailsActionType["SubAction"] = "SubAction";
26730
+ })(NdcDetailsActionType || (NdcDetailsActionType = {}));
26731
+ var NdcDetailsActionStatus;
26732
+ (function (NdcDetailsActionStatus) {
26733
+ NdcDetailsActionStatus["New"] = "New";
26734
+ NdcDetailsActionStatus["Pending"] = "Pending";
26735
+ NdcDetailsActionStatus["Approved"] = "Approved";
26736
+ NdcDetailsActionStatus["Rejected"] = "Rejected";
26737
+ })(NdcDetailsActionStatus || (NdcDetailsActionStatus = {}));
26738
+ var getNdcActionStatusEnumVal = function (value) {
26739
+ var index = Object.keys(NdcDetailsActionStatus).indexOf(value);
26740
+ if (index < 0) {
26741
+ return value;
26742
+ }
26743
+ return Object.values(NdcDetailsActionStatus)[index];
26744
+ };
26745
+ var getNdcActionStatusTagType = function (status) {
26746
+ switch (getNdcActionStatusEnumVal(status)) {
26747
+ case NdcDetailsActionStatus.Rejected:
26748
+ return "error";
26749
+ case NdcDetailsActionStatus.Pending:
26750
+ return "processing";
26751
+ case NdcDetailsActionStatus.Approved:
26752
+ return "success";
26753
+ default:
26754
+ return "default";
26755
+ }
26756
+ };
26757
+
27217
26758
  var NdcDetailsComponent = function (props) {
27218
- var t = props.t; props.useConnection; var useUserContext = props.useUserContext;
26759
+ var t = props.t, useConnection = props.useConnection, useUserContext = props.useUserContext;
27219
26760
  var RangePicker = antd.DatePicker.RangePicker;
27220
- var _a = React.useState([]), ndcDetailsData = _a[0], setNdcDetailsData = _a[1];
27221
- var _b = React.useState(false), loading = _b[0]; _b[1];
27222
- var periodItemsRef = React.useRef([]);
26761
+ var _a = React.useState([]), ndcActionsList = _a[0], setNdcActionsList = _a[1];
26762
+ var _b = React.useState(false), loading = _b[0], setLoading = _b[1];
27223
26763
  var _c = React.useState([]), periodItems = _c[0], setPeriodItems = _c[1];
27224
- var _d = React.useState("add_new"), selectedTab = _d[0], setSelectedTab = _d[1];
27225
- var selectedPeriod = React.useRef({});
27226
- var addedNdcDetailId = React.useRef(0);
27227
- var selectedNdcDetail = React.useRef({});
26764
+ var _d = React.useState({}), selectedPeriod = _d[0], setSelectedPeriod = _d[1];
26765
+ var selectedDateRangeRef = React.useRef({});
27228
26766
  var _e = React.useState(0), tableKey = _e[0], setTableKey = _e[1];
26767
+ var _f = useConnection(), get = _f.get, post = _f.post, put = _f.put;
26768
+ var _g = React.useState([]), ministryOrgList = _g[0], setMinistryOrgList = _g[1];
26769
+ var _h = React.useState({}), actionInfo = _h[0], setActionInfo = _h[1];
26770
+ var _j = React.useState(false), openConfirmationModal = _j[0], setOpenConfirmationModal = _j[1];
26771
+ var form = antd.Form.useForm()[0];
26772
+ var _k = React.useState(null), editingKey = _k[0], setEditingKey = _k[1];
26773
+ var _l = React.useState(0), nextAvailableActionId = _l[0], setNextAvailableActionId = _l[1];
26774
+ var _m = React.useState([]), expandedRowKeys = _m[0], setExpandedRowKeys = _m[1];
26775
+ var _o = React.useState([]), subNdcActionsForPeriod = _o[0], setSubNdcActionsForPeriod = _o[1];
26776
+ var _p = React.useState(1), currentPage = _p[0], setCurrentPage = _p[1];
26777
+ var _q = React.useState(10), pageSize = _q[0], setPageSize = _q[1];
26778
+ var isEditing = function (record) { return record.id === editingKey; };
26779
+ var isMainActionInEditMode = function () {
26780
+ if (editingKey) {
26781
+ var action = ndcActionsList.find(function (item) { return item.id === editingKey; });
26782
+ if (action && action.actionType === NdcDetailsActionType.MainAction) {
26783
+ return true;
26784
+ }
26785
+ }
26786
+ return false;
26787
+ };
27229
26788
  var userInfoState = useUserContext().userInfoState;
27230
- var isAddRangeVisible = function () {
27231
- return (((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.MINISTRY ||
27232
- (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.GOVERNMENT) &&
26789
+ React.useEffect(function () {
26790
+ if (expandedRowKeys && expandedRowKeys.length > 0) {
26791
+ var expandedKey = expandedRowKeys[0];
26792
+ setNdcSubActionsForMainAction(expandedKey);
26793
+ }
26794
+ }, ndcActionsList);
26795
+ var loginMinistry = (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.GOVERNMENT
26796
+ ? process.env.REACT_APP_GOVERNMENT_MINISTRY
26797
+ ? process.env.REACT_APP_GOVERNMENT_MINISTRY
26798
+ : "Ministry Of Environment"
26799
+ : (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.MINISTRY
26800
+ ? userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyName
26801
+ : undefined;
26802
+ var isGovernmentUser = (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.GOVERNMENT &&
26803
+ (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== exports.Role.ViewOnly;
26804
+ var isMainNdcActionsEditable = !selectedPeriod.finalized &&
26805
+ (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.GOVERNMENT &&
26806
+ (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== exports.Role.ViewOnly;
26807
+ var isSubNdcActionsEditable = function (record) {
26808
+ return (!selectedPeriod.finalized &&
26809
+ record.status !== NdcDetailsActionStatus.Approved &&
26810
+ ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.GOVERNMENT ||
26811
+ ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.MINISTRY &&
26812
+ (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyName) === record.ministryName)) &&
27233
26813
  (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== exports.Role.ViewOnly);
27234
26814
  };
27235
- var isAddNdcActionVisible = function () {
27236
- return ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.GOVERNMENT &&
26815
+ var checkSubNdcActionCreatePermission = function () {
26816
+ return (!selectedPeriod.finalized &&
26817
+ ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.GOVERNMENT ||
26818
+ (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.MINISTRY) &&
27237
26819
  (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== exports.Role.ViewOnly);
27238
26820
  };
26821
+ var isNdcActionEditable = function (record) {
26822
+ if (record.actionType === NdcDetailsActionType.MainAction) {
26823
+ return isMainNdcActionsEditable;
26824
+ }
26825
+ else if (record.actionType === NdcDetailsActionType.SubAction) {
26826
+ return isSubNdcActionsEditable(record);
26827
+ }
26828
+ };
26829
+ var ndcMainDetailsForPeriod = selectedPeriod.key !== "add_new"
26830
+ ? ndcActionsList.filter(function (ndcDetail) {
26831
+ return (ndcDetail.periodId === parseInt(selectedPeriod.key) &&
26832
+ ndcDetail.actionType === NdcDetailsActionType.MainAction);
26833
+ })
26834
+ : [];
26835
+ var setNdcSubActionsForMainAction = function (mainActionId) {
26836
+ var subNdcDetails = ndcActionsList.filter(function (ndcDetail) {
26837
+ return (ndcDetail.parentActionId === mainActionId &&
26838
+ ndcDetail.actionType === NdcDetailsActionType.SubAction);
26839
+ });
26840
+ var emptySubNdcRow = {
26841
+ id: nextAvailableActionId,
26842
+ actionType: NdcDetailsActionType.SubAction,
26843
+ nationalPlanObjective: "",
26844
+ kpi: "",
26845
+ ministryName: loginMinistry,
26846
+ status: NdcDetailsActionStatus.New,
26847
+ parentActionId: mainActionId,
26848
+ };
26849
+ if (checkSubNdcActionCreatePermission()) {
26850
+ subNdcDetails = __spreadArray(__spreadArray([], subNdcDetails, true), [emptySubNdcRow], false);
26851
+ setEditingKey(nextAvailableActionId);
26852
+ setNextAvailableActionId(function (value) { return value + 1; });
26853
+ form.setFieldsValue({
26854
+ nationalPlanObjective: "",
26855
+ kpi: "",
26856
+ });
26857
+ }
26858
+ setSubNdcActionsForPeriod(subNdcDetails);
26859
+ };
27239
26860
  var inRange = function (num, min, max) {
27240
26861
  return num >= min && num <= max;
27241
26862
  };
27242
- function onAddNewSubNdcDetail() {
27243
- var range = selectedTab.split("-");
27244
- var ndcDetail = ndcDetailsData.find(function (item) { return item.key === selectedNdcDetail.current.key; });
27245
- var ndcDetailItemIndex = ndcDetailsData.findIndex(function (item) { return item.key === selectedNdcDetail.current.key; });
27246
- if (ndcDetail) {
27247
- addedNdcDetailId.current = addedNdcDetailId.current + 1;
27248
- var newData = {
27249
- key: addedNdcDetailId.current,
27250
- startDate: new Date("".concat(Number(range[0]), "-01-24 23:12:00")),
27251
- endDate: new Date("".concat(Number(range[0]), "-12-24 23:12:00")),
27252
- ndcActionId: ndcDetail === null || ndcDetail === void 0 ? void 0 : ndcDetail.key,
27253
- nationalPlanObj: "",
27254
- kpi: "",
27255
- ministry: "",
27256
- };
27257
- if (!ndcDetail.subNdcDetails) {
27258
- ndcDetail.subNdcDetails = [];
27259
- }
27260
- ndcDetail.subNdcDetails.push(newData);
27261
- }
27262
- ndcDetailsData[ndcDetailItemIndex] = ndcDetail;
27263
- setNdcDetailsData(ndcDetailsData);
27264
- setTableKey(function (key) { return key + 1; });
27265
- }
27266
- var handleSave = function (row) {
27267
- setNdcDetailsData(function (prevData) {
27268
- var newData = JSON.parse(JSON.stringify(prevData));
27269
- if (row.type === NdcActionType.main) {
27270
- var index = newData.findIndex(function (item) { return row.key === item.key; });
27271
- if (index !== -1) {
27272
- newData[index] = __assign(__assign({}, newData[index]), row);
27273
- }
27274
- }
27275
- else {
27276
- var parentIndex = newData.findIndex(function (item) { return row.ndcActionId === item.key; });
27277
- var parentItem = newData[parentIndex];
27278
- if (parentItem) {
27279
- if (parentItem.subNdcDetails) {
27280
- var itemIndex = parentItem.subNdcDetails.findIndex(function (item) { return row.key === item.key; });
27281
- if (itemIndex === -1) {
27282
- parentItem.subNdcDetails.push(row);
27283
- }
27284
- else {
27285
- parentItem.subNdcDetails[itemIndex] = __assign({}, row);
27286
- }
26863
+ var ClearEditMode = function () {
26864
+ var unsavedMainActions = ndcActionsList.filter(function (item) {
26865
+ return item.status === NdcDetailsActionStatus.New &&
26866
+ item.actionType === NdcDetailsActionType.MainAction;
26867
+ });
26868
+ if (unsavedMainActions && unsavedMainActions.length) {
26869
+ var updatedActions = ndcActionsList.filter(function (item) { return !unsavedMainActions.includes(item); });
26870
+ setNdcActionsList(updatedActions);
26871
+ }
26872
+ setEditingKey(null);
26873
+ };
26874
+ var handleSave = function (row) { return __awaiter(void 0, void 0, void 0, function () {
26875
+ var updatedFields, updatedItem, exception_2;
26876
+ return __generator(this, function (_a) {
26877
+ switch (_a.label) {
26878
+ case 0:
26879
+ _a.trys.push([0, 9, , 10]);
26880
+ updatedFields = void 0;
26881
+ _a.label = 1;
26882
+ case 1:
26883
+ _a.trys.push([1, 3, , 4]);
26884
+ return [4 /*yield*/, form.validateFields()];
26885
+ case 2:
26886
+ updatedFields = (_a.sent());
26887
+ return [3 /*break*/, 4];
26888
+ case 3:
26889
+ _a.sent();
26890
+ return [2 /*return*/];
26891
+ case 4:
26892
+ if (!updatedFields) {
26893
+ ClearEditMode();
26894
+ return [2 /*return*/];
26895
+ }
26896
+ else if (updatedFields.kpi === row.kpi &&
26897
+ updatedFields.nationalPlanObjective === row.nationalPlanObjective) {
26898
+ ClearEditMode();
26899
+ return [2 /*return*/];
26900
+ }
26901
+ updatedItem = __assign(__assign({}, row), updatedFields);
26902
+ if (!(updatedItem.status === NdcDetailsActionStatus.New)) return [3 /*break*/, 6];
26903
+ if (isGovernmentUser &&
26904
+ updatedItem.actionType === NdcDetailsActionType.SubAction) {
26905
+ updatedItem.status = NdcDetailsActionStatus.Approved;
27287
26906
  }
27288
26907
  else {
27289
- parentItem.subNdcDetails = [row];
26908
+ updatedItem.status = NdcDetailsActionStatus.Pending;
27290
26909
  }
27291
- }
27292
- newData[parentIndex] = __assign({}, parentItem);
27293
- setTableKey(function (key) { return key + 1; });
26910
+ return [4 /*yield*/, post("national/programme/addNdcDetailsAction", __assign(__assign({}, updatedItem), { kpi: parseInt(updatedItem.kpi.toString()) }))];
26911
+ case 5:
26912
+ _a.sent();
26913
+ return [3 /*break*/, 8];
26914
+ case 6:
26915
+ updatedItem.status = NdcDetailsActionStatus.Pending;
26916
+ return [4 /*yield*/, put("national/programme/updateNdcDetailsAction", __assign(__assign({}, updatedItem), { kpi: parseInt(updatedItem.kpi.toString()) }))];
26917
+ case 7:
26918
+ _a.sent();
26919
+ _a.label = 8;
26920
+ case 8:
26921
+ fetchNdcDetailActions();
26922
+ ClearEditMode();
26923
+ return [3 /*break*/, 10];
26924
+ case 9:
26925
+ exception_2 = _a.sent();
26926
+ ClearEditMode();
26927
+ antd.message.open({
26928
+ type: "error",
26929
+ content: exception_2.message,
26930
+ duration: 3,
26931
+ style: { textAlign: "right", marginRight: 15, marginTop: 10 },
26932
+ });
26933
+ return [3 /*break*/, 10];
26934
+ case 10: return [2 /*return*/];
27294
26935
  }
27295
- return newData;
27296
26936
  });
27297
- };
27298
- var getNdcDetailsForPeriod = function () {
27299
- var range = selectedTab.split("-");
27300
- if (range.length > 1) {
27301
- var filteredData = ndcDetailsData.filter(function (item) {
27302
- return inRange(Number(moment(item.startDate).year()), Number(range[0]), Number(range[1]));
27303
- });
27304
- return filteredData;
26937
+ }); };
26938
+ var actionMenu = function (record) {
26939
+ if (record.status === NdcDetailsActionStatus.Pending &&
26940
+ isGovernmentUser &&
26941
+ !selectedPeriod.finalized) {
26942
+ return (React.createElement(antd.List, { className: "action-menu", size: "small", dataSource: [
26943
+ {
26944
+ text: t("ndc:approve"),
26945
+ icon: React.createElement(Icon__namespace.BoxArrowInDown, null),
26946
+ style: "color-primary",
26947
+ click: function () {
26948
+ setActionInfo({
26949
+ action: "Approve",
26950
+ headerText: t("ndc:actionApproveTitle"),
26951
+ type: "primary",
26952
+ icon: React.createElement(Icon__namespace.BoxArrowInDown, null),
26953
+ recordId: record.id,
26954
+ });
26955
+ setOpenConfirmationModal(true);
26956
+ },
26957
+ },
26958
+ {
26959
+ text: t("ndc:reject"),
26960
+ icon: React.createElement(Icon__namespace.XOctagon, null),
26961
+ style: "color-error",
26962
+ click: function () {
26963
+ setActionInfo({
26964
+ action: "Reject",
26965
+ headerText: t("ndc:rejectApproveTitle"),
26966
+ type: "danger",
26967
+ icon: React.createElement(Icon__namespace.XOctagon, null),
26968
+ recordId: record.id,
26969
+ });
26970
+ setOpenConfirmationModal(true);
26971
+ },
26972
+ },
26973
+ ], renderItem: function (item) { return (React.createElement(antd.List.Item, { onClick: item.click },
26974
+ React.createElement(antd.Typography.Text, { className: "action-icon ".concat(item.style) }, item.icon),
26975
+ React.createElement("span", null, item.text))); } }));
27305
26976
  }
27306
26977
  else {
27307
- return [];
27308
- }
27309
- };
27310
- var getSubNdcDetails = function (key) {
27311
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
27312
- var ndcDetail = ndcDetailsData.find(function (item) { return item.key === key; });
27313
- if (ndcDetail) {
27314
- 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()) !== "" &&
27315
- ((_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) &&
27316
- ((_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()) !== "" &&
27317
- ((_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) &&
27318
- 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() !== "" &&
27319
- 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)) {
27320
- onAddNewSubNdcDetail();
27321
- }
27322
- return ndcDetail.subNdcDetails;
27323
- }
27324
- else {
27325
- return [];
26978
+ return null;
27326
26979
  }
27327
26980
  };
27328
26981
  var defaultColumns = [
27329
26982
  {
27330
26983
  title: t("ndc:ndcColumnsNationalPlanObj"),
27331
- dataIndex: "nationalPlanObj",
27332
- key: "nationalPlanObj",
26984
+ dataIndex: "nationalPlanObjective",
26985
+ key: "nationalPlanObjective",
27333
26986
  align: "left",
26987
+ width: 400,
27334
26988
  editable: true,
27335
- width: "50%",
27336
- render: function (_, record) { return (React.createElement(React.Fragment, null, record.nationalPlanObj ? (React.createElement(antd.Space, { size: "middle" },
27337
- React.createElement("span", null, record.nationalPlanObj))) : (React.createElement("input", { placeholder: "Please add Programmes", className: "ant-input", type: "text" })))); },
26989
+ render: function (_, record) { return (React.createElement(antd.Space, { size: "middle" }, record.nationalPlanObjective ? (React.createElement(antd.Tooltip, { title: isNdcActionEditable(record) ? "" : t("ndc:ndcUnauthorisedMsg") },
26990
+ React.createElement("span", null, record.nationalPlanObjective))) : (React.createElement(antd.Input, { placeholder: t("ndc:nationalPlanObjectivePlaceHolder") })))); },
27338
26991
  },
27339
26992
  {
27340
26993
  title: t("ndc:ndcColumnsKpi"),
27341
26994
  dataIndex: "kpi",
27342
26995
  key: "kpi",
27343
26996
  align: "left",
26997
+ width: 100,
27344
26998
  editable: true,
27345
- width: "10%",
27346
- render: function (_, record) { return (React.createElement(React.Fragment, null, record.nationalPlanObj ? (React.createElement(antd.Space, { size: "middle" },
27347
- React.createElement("span", null, record.kpi))) : (React.createElement("input", { placeholder: "Enter Kpi", className: "ant-input", type: "text" })))); },
26999
+ render: function (_, record) { return (React.createElement(antd.Space, { size: "middle" }, record.kpi ? (React.createElement(antd.Tooltip, { title: isNdcActionEditable(record) ? "" : t("ndc:ndcUnauthorisedMsg") },
27000
+ React.createElement("span", null, record.kpi))) : (React.createElement(antd.Input, { placeholder: "Enter Kpi" })))); },
27348
27001
  },
27349
27002
  {
27350
- title: "Government Department",
27351
- dataIndex: "ministry",
27352
- key: "ministry",
27003
+ title: t("ndc:ndcColumnsMinistry"),
27004
+ dataIndex: "ministryName",
27005
+ key: "ministryName",
27353
27006
  align: "left",
27354
- editable: true,
27355
- width: "40%",
27356
- render: function (_, record) { return (React.createElement(React.Fragment, null, record.nationalPlanObj ? (React.createElement(antd.Space, { size: "middle" },
27357
- React.createElement("span", null, record.ministry))) : (React.createElement("input", { placeholder: "Please add the Government Department", className: "ant-input", type: "text" })))); },
27007
+ width: 300,
27008
+ editable: false,
27009
+ render: function (_, record) { return (React.createElement(antd.Tooltip, { title: isSubNdcActionsEditable(record) ? "" : t("ndc:ndcUnauthorisedMsg") },
27010
+ React.createElement(antd.Select, { disabled: !(isSubNdcActionsEditable(record) && isEditing(record)), defaultValue: record.ministryName ? record.ministryName : loginMinistry, style: { width: 220 }, onChange: function (value, option) {
27011
+ record.ministryName = option.label;
27012
+ handleSave(record);
27013
+ }, options: ministryOrgList }))); },
27014
+ },
27015
+ {
27016
+ title: t("ndc:ndcColumnsStatus"),
27017
+ dataIndex: "status",
27018
+ key: "status",
27019
+ align: "left",
27020
+ width: 200,
27021
+ editable: false,
27022
+ render: function (_, record) {
27023
+ var menu = actionMenu(record);
27024
+ return (React.createElement("div", { onClick: function (event) { return event.stopPropagation(); } },
27025
+ record.actionType === NdcDetailsActionType.SubAction &&
27026
+ record.status !== NdcDetailsActionStatus.New ? (React.createElement(antd.Tooltip, { title: record.status, color: TooltipColor, key: TooltipColor },
27027
+ React.createElement(antd.Tag, { className: "clickable", color: getNdcActionStatusTagType(record.status) }, addSpaces(record.status)))) : (""),
27028
+ record.actionType === NdcDetailsActionType.SubAction && menu ? (React.createElement(antd.Popover, { placement: "bottomRight", content: menu, trigger: "click" },
27029
+ React.createElement(icons.EllipsisOutlined, { rotate: 90, style: {
27030
+ fontWeight: 600,
27031
+ fontSize: "1rem",
27032
+ cursor: "pointer",
27033
+ } }))) : (React.createElement("span", null))));
27034
+ },
27358
27035
  },
27359
27036
  ];
27360
27037
  var columns = defaultColumns.map(function (col) {
27361
27038
  if (!col.editable) {
27362
27039
  return col;
27363
27040
  }
27364
- return __assign(__assign({}, col), { onCell: function (record) { return ({
27365
- record: record,
27366
- editable: col.editable,
27367
- dataIndex: col.dataIndex,
27368
- title: col.title,
27369
- handleSave: handleSave,
27370
- }); } });
27041
+ return __assign(__assign({}, col), { onCell: function (record) {
27042
+ return {
27043
+ record: record,
27044
+ editing: isEditing(record),
27045
+ dataIndex: col.dataIndex,
27046
+ title: col.title,
27047
+ onBlurHandler: function (record) {
27048
+ if (isEditing(record)) {
27049
+ handleSave(record);
27050
+ }
27051
+ },
27052
+ t: t,
27053
+ };
27054
+ } });
27371
27055
  });
27372
- function onAddNewNdcDetail() {
27373
- var range = selectedTab.split("-");
27374
- var ndcActionId = ++addedNdcDetailId.current;
27375
- var newData = {
27376
- key: ndcActionId,
27377
- type: NdcActionType.main,
27378
- startDate: new Date("".concat(Number(range[0]), "-01-24 23:12:00")),
27379
- endDate: new Date("".concat(Number(range[0]), "-12-24 23:12:00")),
27380
- nationalPlanObj: "",
27381
- kpi: "",
27382
- ministry: "",
27383
- subNdcDetails: [
27384
- {
27385
- key: ++addedNdcDetailId.current,
27386
- ndcActionId: ndcActionId,
27387
- type: NdcActionType.sub,
27388
- startDate: new Date("2019-03-25"),
27389
- endDate: new Date("2020-03-25"),
27390
- nationalPlanObj: "",
27391
- kpi: "",
27392
- ministry: "",
27393
- },
27394
- ],
27395
- };
27396
- setNdcDetailsData(__spreadArray(__spreadArray([], ndcDetailsData, true), [newData], false));
27056
+ function onClickedAddNewNdcDetail() {
27057
+ return __awaiter(this, void 0, void 0, function () {
27058
+ var periodId, newData_1, lastPage;
27059
+ return __generator(this, function (_a) {
27060
+ if (selectedPeriod.key !== "add_new") {
27061
+ form.setFieldsValue({
27062
+ nationalPlanObjective: "",
27063
+ kpi: "",
27064
+ });
27065
+ periodId = parseInt(selectedPeriod.key);
27066
+ newData_1 = {
27067
+ id: nextAvailableActionId,
27068
+ actionType: NdcDetailsActionType.MainAction,
27069
+ nationalPlanObjective: "",
27070
+ kpi: "",
27071
+ ministryName: loginMinistry,
27072
+ periodId: periodId,
27073
+ status: NdcDetailsActionStatus.New,
27074
+ };
27075
+ setEditingKey(nextAvailableActionId);
27076
+ setNextAvailableActionId(function (value) { return value + 1; });
27077
+ setNdcActionsList(function (ndcActionsList) { return __spreadArray(__spreadArray([], ndcActionsList, true), [
27078
+ newData_1,
27079
+ ], false); });
27080
+ setTableKey(function (key) { return key + 1; });
27081
+ if (ndcMainDetailsForPeriod.length + 1 > pageSize) {
27082
+ lastPage = Math.ceil(ndcMainDetailsForPeriod.length / pageSize);
27083
+ setCurrentPage(lastPage);
27084
+ }
27085
+ }
27086
+ return [2 /*return*/];
27087
+ });
27088
+ });
27397
27089
  }
27398
27090
  var components = {
27399
27091
  body: {
27400
- row: EditableRow,
27401
27092
  cell: EditableCell,
27402
27093
  },
27403
27094
  };
27404
- //commented because rendering issue
27405
- function ndcDetailsTableContent() {
27406
- return (React.createElement("div", null)
27407
- // <div>
27408
- // <Button
27409
- // onClick={onAddNewNdcDetail}
27410
- // type="primary"
27411
- // style={{
27412
- // marginBottom: 16,
27413
- // }}
27414
- // >
27415
- // Add a row
27416
- // </Button>
27417
- // <Table
27418
- // components={components}
27419
- // rowClassName={() => 'editable-row'}
27420
- // bordered
27421
- // dataSource={ndcDetailsData}
27422
- // columns={columns}
27423
- // />
27424
- // </div>
27425
- );
27426
- }
27427
- var onCancelPeriod = function () { };
27428
- var onAddNewPeriod = function () {
27429
- if (selectedPeriod &&
27430
- selectedPeriod.current &&
27431
- selectedPeriod.current.start &&
27432
- selectedPeriod.current.end) {
27433
- var newPeriodItem_1 = {
27434
- key: "".concat(selectedPeriod.current.start, "-").concat(selectedPeriod.current.end),
27435
- label: "".concat(selectedPeriod.current.start, "-").concat(selectedPeriod.current.end),
27436
- start: selectedPeriod.current.start,
27437
- end: selectedPeriod.current.end,
27438
- children: ndcDetailsTableContent(),
27439
- };
27440
- var existingIndex = periodItemsRef.current.findIndex(function (item) {
27441
- return inRange(newPeriodItem_1.start, item.start, item.end) ||
27442
- inRange(newPeriodItem_1.end, item.start, item.end);
27095
+ var onClickedDeletePeriod = function () { return __awaiter(void 0, void 0, void 0, function () {
27096
+ return __generator(this, function (_a) {
27097
+ setActionInfo({
27098
+ action: "Delete",
27099
+ headerText: t("ndc:periodDeleteConfirmTitle"),
27100
+ type: "danger",
27101
+ icon: React.createElement(Icon__namespace.XCircle, null),
27102
+ recordId: selectedPeriod.key,
27443
27103
  });
27444
- if (existingIndex === -1) {
27445
- setPeriodItems(function (items) { return __spreadArray(__spreadArray([], items, true), [newPeriodItem_1], false); });
27446
- periodItemsRef.current = __spreadArray(__spreadArray([], periodItemsRef.current, true), [newPeriodItem_1], false);
27104
+ setOpenConfirmationModal(true);
27105
+ return [2 /*return*/];
27106
+ });
27107
+ }); };
27108
+ var onClickedFinalizePeriod = function () { return __awaiter(void 0, void 0, void 0, function () {
27109
+ var isPendingActionAvailable;
27110
+ return __generator(this, function (_a) {
27111
+ if (ndcMainDetailsForPeriod.length === 0) {
27112
+ antd.message.open({
27113
+ type: "error",
27114
+ content: t("ndc:finalizeNdcEmptyErrorText"),
27115
+ duration: 3,
27116
+ style: { textAlign: "right", marginRight: 15, marginTop: 10 },
27117
+ });
27118
+ return [2 /*return*/];
27447
27119
  }
27448
- else {
27120
+ isPendingActionAvailable = false;
27121
+ ndcMainDetailsForPeriod.forEach(function (mainAction) {
27122
+ var pendingActions = ndcActionsList.filter(function (action) {
27123
+ return (action.status === NdcDetailsActionStatus.Pending &&
27124
+ action.actionType === NdcDetailsActionType.SubAction &&
27125
+ action.parentActionId === mainAction.id);
27126
+ });
27127
+ if (pendingActions && pendingActions.length > 0) {
27128
+ isPendingActionAvailable = true;
27129
+ return;
27130
+ }
27131
+ });
27132
+ if (isPendingActionAvailable) {
27449
27133
  antd.message.open({
27450
27134
  type: "error",
27451
- content: t("ndc:rangeAlreadyExists"),
27135
+ content: t("ndc:finalizeErrorText"),
27452
27136
  duration: 3,
27453
27137
  style: { textAlign: "right", marginRight: 15, marginTop: 10 },
27454
27138
  });
27455
27139
  }
27140
+ else {
27141
+ setActionInfo({
27142
+ action: "Finalize",
27143
+ headerText: t("ndc:finalizeApproveTitle"),
27144
+ text: t("ndc:finalizeApproveSubTitle"),
27145
+ type: "primary",
27146
+ icon: React.createElement(Icon__namespace.Clipboard2Check, null),
27147
+ recordId: selectedPeriod.key,
27148
+ });
27149
+ setOpenConfirmationModal(true);
27150
+ }
27151
+ return [2 /*return*/];
27152
+ });
27153
+ }); };
27154
+ var onMainTableRowExpand = function (expanded, record) {
27155
+ var keys = [];
27156
+ if (expanded) {
27157
+ keys.push(record.id);
27456
27158
  }
27457
- };
27458
- React.useEffect(function () {
27459
- if (periodItems && periodItems.length > 3) {
27460
- setSelectedTab(periodItems[periodItems.length - 1].key);
27461
- }
27462
- }, [periodItems]);
27463
- var onDateRangeChanged = function (range) {
27464
- var period = {
27465
- start: Number(moment(range[0]).year()),
27466
- end: Number(moment(range[1]).year()),
27467
- };
27468
- selectedPeriod.current = period;
27159
+ setExpandedRowKeys(keys);
27160
+ setNdcSubActionsForMainAction(record.id);
27469
27161
  };
27470
27162
  function addNewPeriodContent() {
27471
27163
  return (React.createElement("div", null,
27472
- React.createElement(antd.Row, null,
27473
- React.createElement(RangePicker, { onChange: onDateRangeChanged, picker: "year" })),
27474
- React.createElement(antd.Row, { className: "mg-top-1" },
27475
- React.createElement("div", { className: "ndc-steps-actions" },
27476
- React.createElement(antd.Button, { type: "primary", onClick: onAddNewPeriod, htmlType: "submit", loading: loading }, t("ndc:submit")),
27477
- React.createElement(antd.Button, { className: "back-btn", onClick: onCancelPeriod, loading: loading }, t("ndc:back"))))));
27478
- }
27479
- function getSubNdcActionContent(record) {
27480
- selectedNdcDetail.current = record;
27481
- return (React.createElement(antd.Table, { components: components, rowClassName: function () { return "editable-row"; }, bordered: true, dataSource: getSubNdcDetails(record.key), columns: columns, showHeader: false, pagination: false }));
27164
+ React.createElement(antd.Row, { justify: "start", align: "middle", gutter: [16, 16] },
27165
+ React.createElement(antd.Col, { flex: "340px" },
27166
+ React.createElement(RangePicker, { disabledDate: function (current) { return moment(current).year() < 1900; }, onChange: onDateRangeChanged, picker: "year" })),
27167
+ React.createElement(antd.Col, { flex: "auto" },
27168
+ React.createElement(antd.Button, { type: "primary", onClick: onAddNewPeriod, htmlType: "submit", loading: loading }, t("ndc:submit"))))));
27482
27169
  }
27483
- var onTabChange = function (key) {
27484
- setSelectedTab(key);
27170
+ var onChange = function (page, size) {
27171
+ setCurrentPage(page);
27172
+ setPageSize(size);
27485
27173
  };
27486
- React.useEffect(function () {
27487
- var defaultNdcDetails = [
27488
- {
27489
- key: 1,
27490
- type: NdcActionType.main,
27491
- startDate: new Date("2019-03-25"),
27492
- endDate: new Date("2020-03-25"),
27493
- nationalPlanObj: "Enhance value addition in key growth opportunities",
27494
- kpi: 25,
27495
- ministry: "Ministry of Environment",
27496
- subNdcDetails: [
27497
- {
27498
- key: 6,
27499
- ndcActionId: 1,
27500
- type: NdcActionType.sub,
27501
- startDate: new Date("2019-03-25"),
27502
- endDate: new Date("2020-03-25"),
27503
- nationalPlanObj: "Enhance value addition in key growth opportunities sub details",
27504
- kpi: 25,
27505
- ministry: "Ministry of Agriculture, Water and Forestry (MAWF)",
27506
- },
27507
- {
27508
- key: 7,
27509
- ndcActionId: 1,
27510
- type: NdcActionType.sub,
27511
- startDate: new Date("2019-03-25"),
27512
- endDate: new Date("2020-03-25"),
27513
- nationalPlanObj: "",
27514
- kpi: "",
27515
- ministry: "",
27516
- },
27517
- ],
27518
- },
27519
- {
27520
- key: 2,
27521
- type: NdcActionType.main,
27522
- startDate: new Date("2019-03-25"),
27523
- endDate: new Date("2019-08-25"),
27524
- nationalPlanObj: "Strengthen the private sector to create 10,000 jobs",
27525
- kpi: 10500,
27526
- ministry: "Ministry of Environment",
27527
- subNdcDetails: [
27528
- {
27529
- key: 8,
27530
- ndcActionId: 2,
27531
- type: NdcActionType.sub,
27532
- startDate: new Date("2019-03-25"),
27533
- endDate: new Date("2020-03-25"),
27534
- nationalPlanObj: "",
27535
- kpi: "",
27536
- ministry: "",
27537
- },
27538
- ],
27539
- },
27540
- {
27541
- key: 12,
27542
- type: NdcActionType.main,
27543
- startDate: new Date("2019-03-25"),
27544
- endDate: new Date("2019-08-25"),
27545
- nationalPlanObj: "Other",
27546
- kpi: 10500,
27547
- ministry: "Ministry of Environment",
27548
- subNdcDetails: [
27549
- {
27550
- key: 8,
27551
- ndcActionId: 12,
27552
- type: NdcActionType.sub,
27553
- startDate: new Date("2019-03-25"),
27554
- endDate: new Date("2020-03-25"),
27555
- nationalPlanObj: "",
27556
- kpi: "",
27557
- ministry: "",
27558
- },
27559
- ],
27560
- },
27561
- {
27562
- key: 3,
27563
- type: NdcActionType.main,
27564
- startDate: new Date("2021-03-25"),
27565
- endDate: new Date("2022-03-25"),
27566
- nationalPlanObj: "Consolidate and increase the stock and quality of productive infrastructure by 50%",
27567
- kpi: 48,
27568
- ministry: "Ministry of Environment",
27569
- subNdcDetails: [
27570
- {
27571
- key: 9,
27572
- ndcActionId: 3,
27573
- type: NdcActionType.sub,
27574
- startDate: new Date("2019-03-25"),
27575
- endDate: new Date("2020-03-25"),
27576
- nationalPlanObj: "",
27577
- kpi: "",
27578
- ministry: "",
27579
- },
27580
- ],
27581
- },
27582
- {
27583
- key: 4,
27584
- type: NdcActionType.main,
27585
- startDate: new Date("2022-03-25"),
27586
- endDate: new Date("2022-05-25"),
27587
- nationalPlanObj: "Enhance the productivity and social wellbeing of the population",
27588
- kpi: 20,
27589
- ministry: "Ministry of Environment",
27590
- subNdcDetails: [
27591
- {
27592
- key: 10,
27593
- ndcActionId: 4,
27594
- type: NdcActionType.sub,
27595
- startDate: new Date("2019-03-25"),
27596
- endDate: new Date("2020-03-25"),
27597
- nationalPlanObj: "",
27598
- kpi: "",
27599
- ministry: "",
27600
- },
27601
- ],
27602
- },
27603
- {
27604
- key: 5,
27605
- type: NdcActionType.main,
27606
- startDate: new Date("2022-03-25"),
27607
- endDate: new Date("2023-03-25"),
27608
- nationalPlanObj: "Strengthen the role of the state in guiding and facilitating development",
27609
- kpi: 10,
27610
- ministry: "Ministry of Environment",
27611
- subNdcDetails: [
27612
- {
27613
- key: 11,
27614
- ndcActionId: 5,
27615
- type: NdcActionType.sub,
27616
- startDate: new Date("2019-03-25"),
27617
- endDate: new Date("2020-03-25"),
27618
- nationalPlanObj: "",
27619
- kpi: "",
27620
- ministry: "",
27621
- },
27622
- ],
27623
- },
27624
- {
27625
- key: 13,
27626
- type: NdcActionType.main,
27627
- startDate: new Date("2022-03-25"),
27628
- endDate: new Date("2023-03-25"),
27629
- nationalPlanObj: "Convert to solar energy",
27630
- kpi: 50000,
27631
- ministry: "Ministry of Environment",
27632
- subNdcDetails: [
27633
- {
27634
- key: 11,
27635
- ndcActionId: 13,
27636
- type: NdcActionType.sub,
27637
- startDate: new Date("2019-03-25"),
27638
- endDate: new Date("2020-03-25"),
27639
- nationalPlanObj: "Convert to solar energy",
27640
- kpi: "3000",
27641
- ministry: "Ministry of Agriculture, Water and Forestry (MAWF)",
27642
- },
27643
- {
27644
- key: 14,
27645
- ndcActionId: 13,
27646
- type: NdcActionType.sub,
27647
- startDate: new Date("2019-03-25"),
27648
- endDate: new Date("2020-03-25"),
27649
- nationalPlanObj: "",
27650
- kpi: "",
27651
- ministry: "",
27652
- },
27653
- ],
27654
- },
27655
- {
27656
- key: 15,
27657
- type: NdcActionType.main,
27658
- startDate: new Date("2022-03-25"),
27659
- endDate: new Date("2023-03-25"),
27660
- nationalPlanObj: "Strengthen the private sector to create jobs",
27661
- kpi: 10000,
27662
- ministry: "Ministry of Environment",
27663
- subNdcDetails: [
27664
- {
27665
- key: 16,
27666
- ndcActionId: 15,
27667
- type: NdcActionType.sub,
27668
- startDate: new Date("2019-03-25"),
27669
- endDate: new Date("2020-03-25"),
27670
- nationalPlanObj: "Strengthen the private sector to create jobs",
27671
- kpi: "7200",
27672
- ministry: "Ministry of Tourism (MoT)",
27673
- },
27674
- {
27675
- key: 17,
27676
- ndcActionId: 15,
27677
- type: NdcActionType.sub,
27678
- startDate: new Date("2019-03-25"),
27679
- endDate: new Date("2020-03-25"),
27680
- nationalPlanObj: "",
27681
- kpi: "",
27682
- ministry: "",
27683
- },
27684
- ],
27685
- },
27686
- {
27687
- key: 18,
27688
- type: NdcActionType.main,
27689
- startDate: new Date("2022-03-25"),
27690
- endDate: new Date("2023-03-25"),
27691
- nationalPlanObj: "Other",
27692
- kpi: "",
27693
- ministry: "Ministry of Environment",
27694
- subNdcDetails: [
27695
- {
27696
- key: 19,
27697
- ndcActionId: 18,
27698
- type: NdcActionType.sub,
27699
- startDate: new Date("2019-03-25"),
27700
- endDate: new Date("2020-03-25"),
27701
- nationalPlanObj: "Strengthen the private sector to create jobs",
27702
- kpi: "",
27703
- ministry: "Ministry of Agriculture, Water and Forestry (MAWF)",
27174
+ function mainNdcActionTableContent() {
27175
+ return (React.createElement("div", null,
27176
+ React.createElement(antd.Row, null,
27177
+ React.createElement(antd.Col, { span: 24 },
27178
+ React.createElement(antd.Form, { form: form, component: false },
27179
+ React.createElement(antd.Table, { tableLayout: "fixed", key: tableKey, className: "common-table-class", rowKey: "id", pagination: {
27180
+ current: currentPage,
27181
+ pageSize: pageSize,
27182
+ total: ndcMainDetailsForPeriod.length,
27183
+ showQuickJumper: true,
27184
+ showSizeChanger: true,
27185
+ onChange: onChange,
27186
+ }, components: components, rowClassName: function () { return "editable-row"; }, bordered: true, loading: loading, dataSource: ndcMainDetailsForPeriod, columns: columns, expandedRowKeys: expandedRowKeys, onExpand: onMainTableRowExpand, expandable: {
27187
+ expandedRowRender: function (record) {
27188
+ return subNdcActionTableContent();
27189
+ },
27190
+ columnWidth: 40,
27191
+ }, onRow: function (record, rowIndex) {
27192
+ return {
27193
+ onClick: function (event) {
27194
+ if (record.id &&
27195
+ isNdcActionEditable(record) &&
27196
+ !isEditing(record)) {
27197
+ form.setFieldsValue(__assign({}, record));
27198
+ setEditingKey(record.id);
27199
+ }
27200
+ },
27201
+ onMouseLeave: function () {
27202
+ if (isEditing(record)) {
27203
+ handleSave(record);
27204
+ }
27205
+ },
27206
+ };
27207
+ }, footer: function () {
27208
+ return isGovernmentUser &&
27209
+ !selectedPeriod.finalized && (React.createElement(antd.Row, { justify: "center" },
27210
+ React.createElement(antd.Button, { className: "btnAddNewMainAct", disabled: isMainActionInEditMode(), onClick: onClickedAddNewNdcDetail, type: "default" }, t("ndc:addNdcAction"))));
27211
+ } })))),
27212
+ isGovernmentUser && !selectedPeriod.finalized ? (React.createElement(antd.Row, { justify: "end" },
27213
+ React.createElement(antd.Button, { className: "mg-left-1 btn-danger", onClick: onClickedDeletePeriod, htmlType: "submit", disabled: isMainActionInEditMode(), loading: loading }, t("ndc:delete")),
27214
+ React.createElement(antd.Button, { className: "mg-left-1 footer-btns", type: "primary", onClick: onClickedFinalizePeriod, disabled: isMainActionInEditMode(), htmlType: "submit", loading: loading }, t("ndc:finalize")))) : ("")));
27215
+ }
27216
+ function subNdcActionTableContent(record) {
27217
+ return (React.createElement(antd.Table, { tableLayout: "fixed", rowKey: "id", components: components, rowClassName: function () { return "editable-row"; }, className: "common-table-class", bordered: true, dataSource: subNdcActionsForPeriod, loading: loading, onRow: function (record, rowIndex) {
27218
+ return {
27219
+ onClick: function (event) {
27220
+ if (record.id &&
27221
+ isNdcActionEditable(record) &&
27222
+ !isEditing(record)) {
27223
+ form.setFieldsValue(__assign({}, record));
27224
+ setEditingKey(record.id);
27225
+ }
27704
27226
  },
27705
- {
27706
- key: 20,
27707
- ndcActionId: 18,
27708
- type: NdcActionType.sub,
27709
- startDate: new Date("2019-03-25"),
27710
- endDate: new Date("2020-03-25"),
27711
- nationalPlanObj: "",
27712
- kpi: "",
27713
- ministry: "",
27227
+ onMouseLeave: function () {
27228
+ if (isEditing(record)) {
27229
+ handleSave(record);
27230
+ }
27714
27231
  },
27715
- ],
27716
- },
27717
- ];
27718
- var initialPeriods = [
27719
- {
27720
- key: "2019-2020",
27721
- label: "2019-2020",
27722
- start: 2019,
27723
- end: 2020,
27724
- children: ndcDetailsTableContent(),
27725
- },
27726
- {
27727
- key: "2021-2023",
27728
- label: "2021-2023",
27729
- start: 2021,
27730
- end: 2021,
27731
- children: ndcDetailsTableContent(),
27732
- },
27733
- ];
27734
- if (isAddRangeVisible()) {
27735
- initialPeriods.unshift({
27736
- key: "add_new",
27737
- label: "Add New",
27738
- start: 0,
27739
- end: 0,
27740
- children: addNewPeriodContent(),
27741
- });
27232
+ };
27233
+ }, columns: columns, showHeader: false, pagination: false }));
27234
+ }
27235
+ var onAddNewPeriod = function () { return __awaiter(void 0, void 0, void 0, function () {
27236
+ var periodItem_1, existingIndex, response, addedPeriodItem, updatedPeriodItem_1, exception_3;
27237
+ return __generator(this, function (_a) {
27238
+ switch (_a.label) {
27239
+ case 0:
27240
+ _a.trys.push([0, 4, , 5]);
27241
+ if (!(selectedDateRangeRef &&
27242
+ selectedDateRangeRef.current &&
27243
+ selectedDateRangeRef.current.startYear &&
27244
+ selectedDateRangeRef.current.endYear)) return [3 /*break*/, 3];
27245
+ periodItem_1 = {
27246
+ startYear: selectedDateRangeRef.current.startYear,
27247
+ endYear: selectedDateRangeRef.current.endYear,
27248
+ finalized: false,
27249
+ };
27250
+ existingIndex = periodItems.findIndex(function (item) {
27251
+ return inRange(periodItem_1.startYear, item.startYear, item.endYear) ||
27252
+ inRange(periodItem_1.endYear, item.startYear, item.endYear);
27253
+ });
27254
+ if (!(existingIndex === -1)) return [3 /*break*/, 2];
27255
+ return [4 /*yield*/, post("national/programme/addNdcDetailsPeriod", __assign({}, periodItem_1))];
27256
+ case 1:
27257
+ response = _a.sent();
27258
+ if (response && response.data) {
27259
+ addedPeriodItem = response.data;
27260
+ updatedPeriodItem_1 = __assign(__assign({}, addedPeriodItem), { key: addedPeriodItem.id, label: "".concat(addedPeriodItem.startYear, "-").concat(addedPeriodItem.endYear) });
27261
+ setPeriodItems(function (items) { return __spreadArray(__spreadArray([], items, true), [updatedPeriodItem_1], false); });
27262
+ setSelectedPeriod(updatedPeriodItem_1);
27263
+ }
27264
+ return [3 /*break*/, 3];
27265
+ case 2:
27266
+ antd.message.open({
27267
+ type: "error",
27268
+ content: t("ndc:rangeAlreadyExists"),
27269
+ duration: 3,
27270
+ style: { textAlign: "right", marginRight: 15, marginTop: 10 },
27271
+ });
27272
+ _a.label = 3;
27273
+ case 3: return [3 /*break*/, 5];
27274
+ case 4:
27275
+ exception_3 = _a.sent();
27276
+ antd.message.open({
27277
+ type: "error",
27278
+ content: exception_3.message,
27279
+ duration: 3,
27280
+ style: { textAlign: "right", marginRight: 15, marginTop: 10 },
27281
+ });
27282
+ return [3 /*break*/, 5];
27283
+ case 5: return [2 /*return*/];
27284
+ }
27285
+ });
27286
+ }); };
27287
+ var onDateRangeChanged = function (range) {
27288
+ if (range) {
27289
+ var period = {
27290
+ startYear: Number(moment(range[0]).year()),
27291
+ endYear: Number(moment(range[1]).year()),
27292
+ };
27293
+ if (period.startYear === period.endYear) {
27294
+ antd.message.open({
27295
+ type: "error",
27296
+ content: t("ndc:sameStartEndDates"),
27297
+ duration: 3,
27298
+ style: { textAlign: "right", marginRight: 15, marginTop: 10 },
27299
+ });
27300
+ }
27301
+ else {
27302
+ selectedDateRangeRef.current = period;
27303
+ }
27304
+ }
27305
+ };
27306
+ var onTabChange = function (key) {
27307
+ var selectedPeriod = periodItems.find(function (item) { return item.key === key; });
27308
+ if (selectedPeriod) {
27309
+ setSelectedPeriod(selectedPeriod);
27742
27310
  }
27743
- addedNdcDetailId.current = 20;
27744
- setPeriodItems(initialPeriods);
27745
- periodItemsRef.current = initialPeriods;
27746
- setNdcDetailsData(defaultNdcDetails);
27311
+ };
27312
+ var onActionConfirmed = function () { return __awaiter(void 0, void 0, void 0, function () {
27313
+ var actionResponse, exception_4;
27314
+ return __generator(this, function (_a) {
27315
+ switch (_a.label) {
27316
+ case 0:
27317
+ setLoading(true);
27318
+ _a.label = 1;
27319
+ case 1:
27320
+ _a.trys.push([1, 10, , 11]);
27321
+ if (!(actionInfo.action === "Approve")) return [3 /*break*/, 3];
27322
+ return [4 /*yield*/, post("national/programme/approveNdcDetailsAction", {
27323
+ id: actionInfo.recordId,
27324
+ })];
27325
+ case 2:
27326
+ actionResponse = _a.sent();
27327
+ return [3 /*break*/, 9];
27328
+ case 3:
27329
+ if (!(actionInfo.action === "Reject")) return [3 /*break*/, 5];
27330
+ return [4 /*yield*/, post("national/programme/rejectNdcDetailsAction", {
27331
+ id: actionInfo.recordId,
27332
+ })];
27333
+ case 4:
27334
+ actionResponse = _a.sent();
27335
+ return [3 /*break*/, 9];
27336
+ case 5:
27337
+ if (!(actionInfo.action === "Finalize")) return [3 /*break*/, 7];
27338
+ return [4 /*yield*/, post("national/programme/finalizeNdcDetailsPeriod", {
27339
+ id: selectedPeriod.key,
27340
+ })];
27341
+ case 6:
27342
+ actionResponse = _a.sent();
27343
+ return [3 /*break*/, 9];
27344
+ case 7:
27345
+ if (!(actionInfo.action === "Delete")) return [3 /*break*/, 9];
27346
+ return [4 /*yield*/, post("national/programme/deleteNdcDetailsPeriod", {
27347
+ id: selectedPeriod.key,
27348
+ })];
27349
+ case 8:
27350
+ actionResponse = _a.sent();
27351
+ _a.label = 9;
27352
+ case 9: return [3 /*break*/, 11];
27353
+ case 10:
27354
+ exception_4 = _a.sent();
27355
+ antd.message.open({
27356
+ type: "error",
27357
+ content: exception_4.message,
27358
+ duration: 3,
27359
+ style: { textAlign: "right", marginRight: 15, marginTop: 10 },
27360
+ });
27361
+ return [3 /*break*/, 11];
27362
+ case 11:
27363
+ if (actionResponse) {
27364
+ if (actionInfo.action === "Delete") {
27365
+ antd.message.open({
27366
+ type: "success",
27367
+ content: t("ndc:deletePeriodSuccessMsg"),
27368
+ duration: 3,
27369
+ style: { textAlign: "right", marginRight: 15, marginTop: 10 },
27370
+ });
27371
+ fetchNdcDetailPeriods();
27372
+ }
27373
+ else if (actionInfo.action === "Finalize") {
27374
+ antd.message.open({
27375
+ type: "success",
27376
+ content: t("ndc:finalizeSuccessMsg"),
27377
+ duration: 3,
27378
+ style: { textAlign: "right", marginRight: 15, marginTop: 10 },
27379
+ });
27380
+ fetchNdcDetailPeriods();
27381
+ setExpandedRowKeys([]);
27382
+ ClearEditMode();
27383
+ }
27384
+ else if (actionInfo.action === "Approve") {
27385
+ antd.message.open({
27386
+ type: "success",
27387
+ content: t("ndc:approveSuccessMsg"),
27388
+ duration: 3,
27389
+ style: { textAlign: "right", marginRight: 15, marginTop: 10 },
27390
+ });
27391
+ fetchNdcDetailActions();
27392
+ }
27393
+ else if (actionInfo.action === "Reject") {
27394
+ antd.message.open({
27395
+ type: "success",
27396
+ content: t("ndc:rejectSuccessMsg"),
27397
+ duration: 3,
27398
+ style: { textAlign: "right", marginRight: 15, marginTop: 10 },
27399
+ });
27400
+ fetchNdcDetailActions();
27401
+ }
27402
+ }
27403
+ setOpenConfirmationModal(false);
27404
+ setLoading(false);
27405
+ return [2 /*return*/];
27406
+ }
27407
+ });
27408
+ }); };
27409
+ var onActionCanceled = function () {
27410
+ setOpenConfirmationModal(false);
27411
+ };
27412
+ var fetchNdcDetailPeriods = function () { return __awaiter(void 0, void 0, void 0, function () {
27413
+ var periods, addNewTab, response, exception_5;
27414
+ return __generator(this, function (_a) {
27415
+ switch (_a.label) {
27416
+ case 0:
27417
+ setLoading(true);
27418
+ _a.label = 1;
27419
+ case 1:
27420
+ _a.trys.push([1, 3, 4, 5]);
27421
+ periods = [];
27422
+ addNewTab = {
27423
+ key: "add_new",
27424
+ label: "Add New",
27425
+ startYear: 0,
27426
+ endYear: 0,
27427
+ finalized: false,
27428
+ deleted: false,
27429
+ };
27430
+ return [4 /*yield*/, get("national/programme/queryNdcDetailsPeriod")];
27431
+ case 2:
27432
+ response = _a.sent();
27433
+ if (response && response.data) {
27434
+ periods = response.data.map(function (period) {
27435
+ return __assign(__assign({}, period), { key: period.id, label: period.finalized ? (React.createElement("span", null,
27436
+ React.createElement(icons.LockOutlined, null),
27437
+ " ",
27438
+ period.startYear,
27439
+ "-",
27440
+ period.endYear,
27441
+ " ")) : ("".concat(period.startYear, "-").concat(period.endYear)) });
27442
+ });
27443
+ }
27444
+ if (isGovernmentUser) {
27445
+ periods.unshift(addNewTab);
27446
+ }
27447
+ setPeriodItems(periods);
27448
+ if (isGovernmentUser) {
27449
+ setSelectedPeriod(addNewTab);
27450
+ }
27451
+ else {
27452
+ setSelectedPeriod(periods[0]);
27453
+ }
27454
+ setLoading(false);
27455
+ return [3 /*break*/, 5];
27456
+ case 3:
27457
+ exception_5 = _a.sent();
27458
+ antd.message.open({
27459
+ type: "error",
27460
+ content: exception_5.message,
27461
+ duration: 3,
27462
+ style: { textAlign: "right", marginRight: 15, marginTop: 10 },
27463
+ });
27464
+ return [3 /*break*/, 5];
27465
+ case 4:
27466
+ setLoading(false);
27467
+ return [7 /*endfinally*/];
27468
+ case 5: return [2 /*return*/];
27469
+ }
27470
+ });
27471
+ }); };
27472
+ var fetchNdcDetailActions = function () { return __awaiter(void 0, void 0, void 0, function () {
27473
+ var response, maxActionId, exception_6;
27474
+ return __generator(this, function (_a) {
27475
+ switch (_a.label) {
27476
+ case 0:
27477
+ setLoading(true);
27478
+ _a.label = 1;
27479
+ case 1:
27480
+ _a.trys.push([1, 3, 4, 5]);
27481
+ return [4 /*yield*/, get("national/programme/queryNdcDetailsAction")];
27482
+ case 2:
27483
+ response = _a.sent();
27484
+ if (response && response.data) {
27485
+ maxActionId = Math.max.apply(Math, response.data.map(function (item) { return item.id; }));
27486
+ setNextAvailableActionId(maxActionId + 1);
27487
+ setNdcActionsList(response.data);
27488
+ }
27489
+ setLoading(false);
27490
+ return [3 /*break*/, 5];
27491
+ case 3:
27492
+ exception_6 = _a.sent();
27493
+ antd.message.open({
27494
+ type: "error",
27495
+ content: exception_6.message,
27496
+ duration: 3,
27497
+ style: { textAlign: "right", marginRight: 15, marginTop: 10 },
27498
+ });
27499
+ return [3 /*break*/, 5];
27500
+ case 4:
27501
+ setLoading(false);
27502
+ return [7 /*endfinally*/];
27503
+ case 5: return [2 /*return*/];
27504
+ }
27505
+ });
27506
+ }); };
27507
+ var fetchMinistries = function () { return __awaiter(void 0, void 0, void 0, function () {
27508
+ var response, ministryOrgDetails, exception_7;
27509
+ return __generator(this, function (_a) {
27510
+ switch (_a.label) {
27511
+ case 0:
27512
+ setLoading(true);
27513
+ _a.label = 1;
27514
+ case 1:
27515
+ _a.trys.push([1, 3, 4, 5]);
27516
+ return [4 /*yield*/, get("national/organisation/getMinistries")];
27517
+ case 2:
27518
+ response = _a.sent();
27519
+ if (response && response.data) {
27520
+ ministryOrgDetails = response.data.map(function (value) {
27521
+ return {
27522
+ value: value.company_companyId,
27523
+ label: value.company_name,
27524
+ };
27525
+ });
27526
+ setMinistryOrgList(ministryOrgDetails);
27527
+ }
27528
+ setLoading(false);
27529
+ return [3 /*break*/, 5];
27530
+ case 3:
27531
+ exception_7 = _a.sent();
27532
+ antd.message.open({
27533
+ type: "error",
27534
+ content: exception_7.message,
27535
+ duration: 3,
27536
+ style: { textAlign: "right", marginRight: 15, marginTop: 10 },
27537
+ });
27538
+ return [3 /*break*/, 5];
27539
+ case 4:
27540
+ setLoading(false);
27541
+ return [7 /*endfinally*/];
27542
+ case 5: return [2 /*return*/];
27543
+ }
27544
+ });
27545
+ }); };
27546
+ React.useEffect(function () {
27547
+ fetchNdcDetailPeriods();
27548
+ fetchNdcDetailActions();
27549
+ fetchMinistries();
27747
27550
  }, []);
27748
- return (React.createElement("div", { className: "ndc-management content-container" },
27551
+ return (React.createElement("div", { className: "ndc-details content-container" },
27749
27552
  React.createElement("div", { className: "title-bar" },
27750
27553
  React.createElement(antd.Row, { justify: "space-between", align: "middle" },
27751
27554
  React.createElement(antd.Col, { span: 20 },
27752
27555
  React.createElement("div", { className: "body-title" }, t("ndc:ndcTitle")),
27753
27556
  React.createElement("div", { className: "body-sub-title" }, t("ndc:ndcSubTitle"))))),
27754
27557
  React.createElement("div", null,
27755
- React.createElement(antd.Tabs, { centered: false, defaultActiveKey: "1", items: periodItems, activeKey: selectedTab, onChange: onTabChange })),
27756
- selectedTab !== "add_new" && (React.createElement("div", null,
27757
- React.createElement("div", null,
27758
- React.createElement(antd.Table, { key: tableKey, components: components, rowClassName: function () { return "editable-row"; }, bordered: true, dataSource: getNdcDetailsForPeriod(), columns: columns, expandable: {
27759
- expandedRowRender: function (record) { return getSubNdcActionContent(record); },
27760
- indentSize: 0,
27761
- defaultExpandedRowKeys: [selectedNdcDetail.current.key],
27762
- }, footer: function () {
27763
- return isAddNdcActionVisible() && (React.createElement(antd.Row, { justify: "center" },
27764
- React.createElement(antd.Button, { onClick: onAddNewNdcDetail, type: "default", style: {
27765
- marginBottom: 16,
27766
- width: "100%",
27767
- } }, t("ndc:addNdcAction"))));
27768
- } }))))));
27558
+ React.createElement(antd.Tabs, { centered: false, defaultActiveKey: "1", items: periodItems, activeKey: selectedPeriod.key, onChange: onTabChange })),
27559
+ React.createElement("div", null, selectedPeriod.key === "add_new"
27560
+ ? addNewPeriodContent()
27561
+ : mainNdcActionTableContent()),
27562
+ React.createElement(UserActionConfirmationModel, { t: t, actionInfo: actionInfo, onActionConfirmed: onActionConfirmed, onActionCanceled: onActionCanceled, openModal: openConfirmationModal, errorMsg: "", loading: loading })));
27769
27563
  };
27770
27564
 
27771
27565
  var ImgWithFallback = function (_a) {
@@ -29558,7 +29352,7 @@ exports.getCreditStageVal = getCreditStageVal;
29558
29352
  exports.getFinancialFields = getFinancialFields;
29559
29353
  exports.getGeneralFields = getGeneralFields;
29560
29354
  exports.getInvestmentStatusEnumVal = getInvestmentStatusEnumVal;
29561
- exports.getNdcActionStatusEnumVal = getNdcActionStatusEnumVal;
29355
+ exports.getNdcActionStatusEnumVal = getNdcActionStatusEnumVal$1;
29562
29356
  exports.getNdcStatusTagType = getNdcStatusTagType;
29563
29357
  exports.getRetirementTypeString = getRetirementTypeString;
29564
29358
  exports.getStageEnumVal = getStageEnumVal;