@undp/carbon-library 1.0.135-ghg-inventory.12.19 → 1.0.135-ghg-inventory.12.21
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/index.js +589 -154
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/Components/GhgInventory/emission.mappings.d.ts +1 -0
- package/dist/esm/index.js +589 -154
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/Components/GhgInventory/emission.mappings.d.ts +1 -0
- package/dist/locales/i18n/ghgInventory/en.json +8 -5
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
@@ -28889,6 +28889,48 @@ var totalProjectionFields = [
|
|
28889
28889
|
'Total National Emission and Removals - Conditional NDC',
|
28890
28890
|
'Total National Emission and Removals - Unconditional NDC',
|
28891
28891
|
];
|
28892
|
+
var excelFields = [
|
28893
|
+
"Energy",
|
28894
|
+
"Fuel Combustion Activities",
|
28895
|
+
"Energy Industries",
|
28896
|
+
"Manufacturing Industries and Construction",
|
28897
|
+
"Transport",
|
28898
|
+
"Other Sectors",
|
28899
|
+
"Non-Specified",
|
28900
|
+
"Fugitive emissions from fuels",
|
28901
|
+
"Solid Fuels",
|
28902
|
+
"Oil and Natural Gas",
|
28903
|
+
"Other emissions from Energy Production",
|
28904
|
+
"Carbon dioxide Transport and Storage",
|
28905
|
+
"Transport of CO2",
|
28906
|
+
"Injection and Storage",
|
28907
|
+
"Other (Carbon dioxide Transport and Storage)",
|
28908
|
+
"Industrial Processes & Product Use",
|
28909
|
+
"Mineral Industry",
|
28910
|
+
"Chemical Industry",
|
28911
|
+
"Metal Industry",
|
28912
|
+
"Non-Energy Products from Fuels and Solvent Use",
|
28913
|
+
"Electronics Industry",
|
28914
|
+
"Product Uses as Substitutes for Ozone Depleting Substances",
|
28915
|
+
"Other Product Manufacture and Use",
|
28916
|
+
"Other (Industrial Processes & Product Use)",
|
28917
|
+
"Agriculture, Forestry, and Other Land Use",
|
28918
|
+
"Livestock",
|
28919
|
+
"Land",
|
28920
|
+
"Aggregate sources and non-CO2 emissions sources on land",
|
28921
|
+
"Other (Agriculture, Forestry, and Other Land Use)",
|
28922
|
+
"Waste",
|
28923
|
+
"Solid Waste Disposal",
|
28924
|
+
"Biological Treatment of Solid Waste",
|
28925
|
+
"Incineration and Open Burning of Waste",
|
28926
|
+
"Wastewater Treatment and Discharge",
|
28927
|
+
"Other (Waste)",
|
28928
|
+
"Other",
|
28929
|
+
"Indirect N2O emissions from the atmospheric deposition of nitrogen in NOx and NH3",
|
28930
|
+
"Other",
|
28931
|
+
"Total CO2 equivalent emissions without land use, land-use change and forestry",
|
28932
|
+
"Total CO2 equivalent emissions with land use, land-use change and forestry",
|
28933
|
+
];
|
28892
28934
|
|
28893
28935
|
Input.TextArea;
|
28894
28936
|
var DiscardChangesConfirmationModel = function (props) {
|
@@ -29008,22 +29050,32 @@ var GHGEmissionsComponent = function (props) {
|
|
29008
29050
|
for (var category in energyEmissionsSub) {
|
29009
29051
|
var subcategory = energyEmissionsSub[category];
|
29010
29052
|
for (var gas in subcategory) {
|
29011
|
-
result["".concat(key, "_").concat(category, "_").concat(gas)] = subcategory[gas];
|
29053
|
+
result["".concat(key, "_").concat(category, "_").concat(gas)] = !isNaN(subcategory[gas]) ? subcategory[gas] : 0;
|
29012
29054
|
}
|
29013
29055
|
}
|
29014
29056
|
}
|
29015
29057
|
else {
|
29016
29058
|
for (var gas in energyEmissionsSub) {
|
29017
|
-
result["".concat(objName, "_").concat(key, "_").concat(gas)] = energyEmissionsSub[gas];
|
29059
|
+
result["".concat(objName, "_").concat(key, "_").concat(gas)] = !isNaN(energyEmissionsSub[gas]) ? energyEmissionsSub[gas] : 0;
|
29018
29060
|
}
|
29019
29061
|
}
|
29020
29062
|
}
|
29021
29063
|
}
|
29022
29064
|
return result;
|
29023
29065
|
};
|
29024
|
-
var validateExcelDataFormat = function (
|
29066
|
+
var validateExcelDataFormat = function (sheet, excelData) {
|
29067
|
+
var sheetHeadings = XLSX.utils.sheet_to_json(sheet, {
|
29068
|
+
header: 1,
|
29069
|
+
})[0];
|
29025
29070
|
var columnHeadings = ['Sector', 'CO2', 'CH4', 'N2O', 'CO2-eq'];
|
29026
|
-
|
29071
|
+
if (!columnHeadings.every(function (element) { return sheetHeadings.includes(element); })) {
|
29072
|
+
return false;
|
29073
|
+
}
|
29074
|
+
var sectorValues = excelData.map(function (excelDataObj) { return excelDataObj.Sector; });
|
29075
|
+
if (!excelFields.every(function (element) { return sectorValues.includes(element); })) {
|
29076
|
+
return false;
|
29077
|
+
}
|
29078
|
+
return true;
|
29027
29079
|
};
|
29028
29080
|
var populateFormWithUploadedFile = function (excelData, keyPrefix) {
|
29029
29081
|
var emissions = {};
|
@@ -29103,12 +29155,13 @@ var GHGEmissionsComponent = function (props) {
|
|
29103
29155
|
var sum = 0;
|
29104
29156
|
for (var key in obj) {
|
29105
29157
|
if (key === gasType) {
|
29106
|
-
sum += obj[key];
|
29158
|
+
sum += Number.isInteger(obj[key]) ? obj[key] : 0;
|
29107
29159
|
}
|
29108
29160
|
else if (typeof obj[key] === 'object' &&
|
29109
29161
|
key !== 'totalCo2WithLand' &&
|
29110
29162
|
key !== 'totalCo2WithoutLand') {
|
29111
|
-
|
29163
|
+
var calculatedSum = calculateSumEmissionView(obj[key], gasType);
|
29164
|
+
sum += Number.isInteger(calculatedSum) ? calculatedSum : 0;
|
29112
29165
|
}
|
29113
29166
|
}
|
29114
29167
|
return sum;
|
@@ -29426,19 +29479,6 @@ var GHGEmissionsComponent = function (props) {
|
|
29426
29479
|
setOpenResetFormModal(false);
|
29427
29480
|
};
|
29428
29481
|
var onOpenResetFormModel = function () {
|
29429
|
-
setActionInfo({
|
29430
|
-
action: "".concat(t('ghgInventory:proceed')),
|
29431
|
-
headerText: "".concat(t('ghgInventory:discardHeaderText')),
|
29432
|
-
type: 'danger',
|
29433
|
-
icon: React.createElement(CloseCircleOutlined, null),
|
29434
|
-
});
|
29435
|
-
setErrorMsg('');
|
29436
|
-
setOpenResetFormModal(true);
|
29437
|
-
};
|
29438
|
-
var onSaveFormCanceled = function () {
|
29439
|
-
setOpenSaveFormModal(false);
|
29440
|
-
};
|
29441
|
-
var onOpenSaveFormModel = function () {
|
29442
29482
|
if (!isFormChanged) {
|
29443
29483
|
message.open({
|
29444
29484
|
type: 'error',
|
@@ -29449,34 +29489,98 @@ var GHGEmissionsComponent = function (props) {
|
|
29449
29489
|
}
|
29450
29490
|
else {
|
29451
29491
|
setActionInfo({
|
29452
|
-
action: "".concat(t(
|
29453
|
-
headerText: "".concat(t(
|
29454
|
-
type:
|
29455
|
-
icon: React.createElement(
|
29492
|
+
action: "".concat(t('ghgInventory:proceed')),
|
29493
|
+
headerText: "".concat(t('ghgInventory:discardHeaderText')),
|
29494
|
+
type: 'danger',
|
29495
|
+
icon: React.createElement(CloseCircleOutlined, null),
|
29456
29496
|
});
|
29457
29497
|
setErrorMsg('');
|
29458
|
-
|
29498
|
+
setOpenResetFormModal(true);
|
29459
29499
|
}
|
29460
29500
|
};
|
29501
|
+
var onSaveFormCanceled = function () {
|
29502
|
+
setOpenSaveFormModal(false);
|
29503
|
+
};
|
29504
|
+
var onOpenSaveFormModel = function () {
|
29505
|
+
var _a = form.getFieldsValue(true); _a.year; var rest = __rest(_a, ["year"]);
|
29506
|
+
var otherFieldsNegativeValue = Object.values(rest).some(function (value) {
|
29507
|
+
return typeof value === 'number' && value < 0;
|
29508
|
+
});
|
29509
|
+
form
|
29510
|
+
.validateFields()
|
29511
|
+
.then(function (values) {
|
29512
|
+
if (!isFormChanged) {
|
29513
|
+
message.open({
|
29514
|
+
type: 'error',
|
29515
|
+
content: t('ghgInventory:formNotChanged'),
|
29516
|
+
duration: 4,
|
29517
|
+
style: { textAlign: 'right', marginRight: 15, marginTop: 10 },
|
29518
|
+
});
|
29519
|
+
}
|
29520
|
+
else {
|
29521
|
+
setActionInfo({
|
29522
|
+
action: "".concat(t("ghgInventory:submit")),
|
29523
|
+
headerText: "".concat(t("ghgInventory:submitModelHeader")),
|
29524
|
+
type: "primary",
|
29525
|
+
icon: React.createElement(CheckCircleOutlined, null),
|
29526
|
+
});
|
29527
|
+
setErrorMsg('');
|
29528
|
+
setOpenSaveFormModal(true);
|
29529
|
+
}
|
29530
|
+
})
|
29531
|
+
.catch(function (errorInfo) {
|
29532
|
+
if (otherFieldsNegativeValue) {
|
29533
|
+
message.open({
|
29534
|
+
type: 'error',
|
29535
|
+
content: t('ghgInventory:negativeValuesNotAllowed'),
|
29536
|
+
duration: 4,
|
29537
|
+
style: { textAlign: 'right', marginRight: 15, marginTop: 10 },
|
29538
|
+
});
|
29539
|
+
}
|
29540
|
+
});
|
29541
|
+
};
|
29461
29542
|
var onFinalizeFormCanceled = function () {
|
29462
29543
|
setOpenFinalizeFormModal(false);
|
29463
29544
|
};
|
29464
29545
|
var onOpenFinalizeFormModel = function () {
|
29546
|
+
var _a = form.getFieldsValue(true); _a.year; var rest = __rest(_a, ["year"]);
|
29547
|
+
var otherFieldsEmpty = Object.values(rest).every(function (value) { return !value; });
|
29548
|
+
var otherFieldsNegativeValue = Object.values(rest).some(function (value) {
|
29549
|
+
return typeof value === 'number' && value < 0;
|
29550
|
+
});
|
29465
29551
|
form
|
29466
29552
|
.validateFields()
|
29467
29553
|
.then(function (values) {
|
29468
29554
|
// Validation successful, set ActionInfo and open the form modal
|
29469
|
-
|
29470
|
-
|
29471
|
-
|
29472
|
-
|
29473
|
-
|
29474
|
-
|
29475
|
-
|
29476
|
-
|
29555
|
+
if (otherFieldsEmpty) {
|
29556
|
+
message.open({
|
29557
|
+
type: 'error',
|
29558
|
+
content: t('ghgInventory:cannotFinaliseEmpty'),
|
29559
|
+
duration: 4,
|
29560
|
+
style: { textAlign: 'right', marginRight: 15, marginTop: 10 },
|
29561
|
+
});
|
29562
|
+
}
|
29563
|
+
else {
|
29564
|
+
setActionInfo({
|
29565
|
+
action: "".concat(t("ghgInventory:finalize")),
|
29566
|
+
headerText: "".concat(t("ghgInventory:finalizeModelHeader")),
|
29567
|
+
type: "primary",
|
29568
|
+
icon: React.createElement(ClipboardCheck, null),
|
29569
|
+
});
|
29570
|
+
setErrorMsg('');
|
29571
|
+
setOpenFinalizeFormModal(true);
|
29572
|
+
}
|
29477
29573
|
})
|
29478
29574
|
.catch(function (errorInfo) {
|
29479
29575
|
// Validation failed
|
29576
|
+
if (otherFieldsNegativeValue) {
|
29577
|
+
message.open({
|
29578
|
+
type: 'error',
|
29579
|
+
content: t('ghgInventory:negativeValuesNotAllowed'),
|
29580
|
+
duration: 4,
|
29581
|
+
style: { textAlign: 'right', marginRight: 15, marginTop: 10 },
|
29582
|
+
});
|
29583
|
+
}
|
29480
29584
|
console.log('Validation failed:', errorInfo);
|
29481
29585
|
});
|
29482
29586
|
};
|
@@ -29492,7 +29596,7 @@ var GHGEmissionsComponent = function (props) {
|
|
29492
29596
|
setLoading(true);
|
29493
29597
|
_a.label = 2;
|
29494
29598
|
case 2:
|
29495
|
-
_a.trys.push([2, 6,
|
29599
|
+
_a.trys.push([2, 6, 11, 12]);
|
29496
29600
|
return [4 /*yield*/, post('national/emissions', payload)];
|
29497
29601
|
case 3:
|
29498
29602
|
response = _a.sent();
|
@@ -29519,7 +29623,7 @@ var GHGEmissionsComponent = function (props) {
|
|
29519
29623
|
case 4:
|
29520
29624
|
_a.sent();
|
29521
29625
|
_a.label = 5;
|
29522
|
-
case 5: return [3 /*break*/,
|
29626
|
+
case 5: return [3 /*break*/, 12];
|
29523
29627
|
case 6:
|
29524
29628
|
error_1 = _a.sent();
|
29525
29629
|
console.log('Error in emission creation - ', error_1);
|
@@ -29531,19 +29635,31 @@ var GHGEmissionsComponent = function (props) {
|
|
29531
29635
|
duration: 4,
|
29532
29636
|
style: { textAlign: 'right', marginRight: 15, marginTop: 10 },
|
29533
29637
|
});
|
29534
|
-
if (!(error_1.
|
29638
|
+
if (!(error_1.status === HttpStatusCode.Conflict.valueOf())) return [3 /*break*/, 8];
|
29535
29639
|
return [4 /*yield*/, getEmissionData()];
|
29536
29640
|
case 7:
|
29537
29641
|
_a.sent();
|
29642
|
+
setIsSavedFormDataSet(false);
|
29643
|
+
clearUploadDoc();
|
29644
|
+
if (!isPendingFinalization) {
|
29645
|
+
clearForm();
|
29646
|
+
}
|
29647
|
+
return [3 /*break*/, 10];
|
29648
|
+
case 8:
|
29649
|
+
if (!(error_1.status === HttpStatusCode.Forbidden.valueOf())) return [3 /*break*/, 10];
|
29538
29650
|
clearUploadDoc();
|
29539
|
-
|
29540
|
-
|
29651
|
+
clearForm();
|
29652
|
+
return [4 /*yield*/, getEmissionData()];
|
29541
29653
|
case 9:
|
29654
|
+
_a.sent();
|
29655
|
+
_a.label = 10;
|
29656
|
+
case 10: return [3 /*break*/, 12];
|
29657
|
+
case 11:
|
29542
29658
|
// eslint-disable-next-line no-use-before-define, @typescript-eslint/no-use-before-define
|
29543
29659
|
setIsFormChanged(false);
|
29544
29660
|
setLoading(false);
|
29545
29661
|
return [7 /*endfinally*/];
|
29546
|
-
case
|
29662
|
+
case 12: return [2 /*return*/];
|
29547
29663
|
}
|
29548
29664
|
});
|
29549
29665
|
}); };
|
@@ -29781,7 +29897,6 @@ var GHGEmissionsComponent = function (props) {
|
|
29781
29897
|
(formValues.fuelCombustionActivities_transport_co2 || 0) +
|
29782
29898
|
(formValues.fuelCombustionActivities_otherSectors_co2 || 0) +
|
29783
29899
|
(formValues.fuelCombustionActivities_nonSpecified_co2 || 0);
|
29784
|
-
console.log('sum triggered', sum);
|
29785
29900
|
setFuelCombustionActivitiesCo2(sum);
|
29786
29901
|
}
|
29787
29902
|
if (panelHeading === 'fugitiveEmissionsFromFuels') {
|
@@ -30113,17 +30228,61 @@ var GHGEmissionsComponent = function (props) {
|
|
30113
30228
|
React.createElement(Col, { xl: 9, md: 9 },
|
30114
30229
|
React.createElement(Row, { gutter: 16, className: "panel-content-input-box-row" },
|
30115
30230
|
React.createElement(Col, { xl: 6 },
|
30116
|
-
React.createElement(Form.Item, { name: panelHeading + '_' + item + '_co2'
|
30117
|
-
|
30231
|
+
React.createElement(Form.Item, { name: panelHeading + '_' + item + '_co2', rules: [
|
30232
|
+
{
|
30233
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
30234
|
+
return __generator(this, function (_a) {
|
30235
|
+
if (value && value < 0) {
|
30236
|
+
throw new Error();
|
30237
|
+
}
|
30238
|
+
return [2 /*return*/];
|
30239
|
+
});
|
30240
|
+
}); },
|
30241
|
+
},
|
30242
|
+
] },
|
30243
|
+
React.createElement(InputNumber, { onChange: function (event) { return calculateSumCo2(event, panelHeading); }, disabled: (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) === Role.ViewOnly }))),
|
30118
30244
|
React.createElement(Col, { xl: 6 },
|
30119
|
-
React.createElement(Form.Item, { name: panelHeading + '_' + item + '_ch4'
|
30120
|
-
|
30245
|
+
React.createElement(Form.Item, { name: panelHeading + '_' + item + '_ch4', rules: [
|
30246
|
+
{
|
30247
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
30248
|
+
return __generator(this, function (_a) {
|
30249
|
+
if (value && value < 0) {
|
30250
|
+
throw new Error();
|
30251
|
+
}
|
30252
|
+
return [2 /*return*/];
|
30253
|
+
});
|
30254
|
+
}); },
|
30255
|
+
},
|
30256
|
+
] },
|
30257
|
+
React.createElement(InputNumber, { onChange: function (event) { return calculateSumCh4(event, panelHeading); }, disabled: (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) === Role.ViewOnly }))),
|
30121
30258
|
React.createElement(Col, { xl: 6 },
|
30122
|
-
React.createElement(Form.Item, { name: panelHeading + '_' + item + '_n2o'
|
30123
|
-
|
30259
|
+
React.createElement(Form.Item, { name: panelHeading + '_' + item + '_n2o', rules: [
|
30260
|
+
{
|
30261
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
30262
|
+
return __generator(this, function (_a) {
|
30263
|
+
if (value && value < 0) {
|
30264
|
+
throw new Error();
|
30265
|
+
}
|
30266
|
+
return [2 /*return*/];
|
30267
|
+
});
|
30268
|
+
}); },
|
30269
|
+
},
|
30270
|
+
] },
|
30271
|
+
React.createElement(InputNumber, { onChange: function (event) { return calculateSumN2o(event, panelHeading); }, disabled: (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) === Role.ViewOnly }))),
|
30124
30272
|
React.createElement(Col, { xl: 6 },
|
30125
|
-
React.createElement(Form.Item, { name: panelHeading + '_' + item + '_co2eq'
|
30126
|
-
|
30273
|
+
React.createElement(Form.Item, { name: panelHeading + '_' + item + '_co2eq', rules: [
|
30274
|
+
{
|
30275
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
30276
|
+
return __generator(this, function (_a) {
|
30277
|
+
if (value && value < 0) {
|
30278
|
+
throw new Error();
|
30279
|
+
}
|
30280
|
+
return [2 /*return*/];
|
30281
|
+
});
|
30282
|
+
}); },
|
30283
|
+
},
|
30284
|
+
] },
|
30285
|
+
React.createElement(InputNumber, { onChange: function (event) { return calculateSumCo2Eq(event, panelHeading); }, disabled: (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) === Role.ViewOnly }))))))); };
|
30127
30286
|
var renderPanelContentView = function (co2, ch4, n2o, co2eq, item, index) {
|
30128
30287
|
return (React.createElement(Row, { gutter: 16, key: index, className: "panel-content-row" },
|
30129
30288
|
React.createElement(Col, { xl: 12, md: 12, className: "panel-content-title" },
|
@@ -30185,7 +30344,7 @@ var GHGEmissionsComponent = function (props) {
|
|
30185
30344
|
var encodedUri = encodeURI("data:text/csv;charset=utf-8,".concat(csvContent));
|
30186
30345
|
var link = document.createElement('a');
|
30187
30346
|
link.setAttribute('href', encodedUri);
|
30188
|
-
link.setAttribute('download', "GHG-Reporting
|
30347
|
+
link.setAttribute('download', "GHG-Reporting-Emissions_".concat(dataToDownload.year, "_V").concat(dataToDownload.version, ".csv"));
|
30189
30348
|
document.body.appendChild(link);
|
30190
30349
|
link.click();
|
30191
30350
|
};
|
@@ -30208,6 +30367,17 @@ var GHGEmissionsComponent = function (props) {
|
|
30208
30367
|
}
|
30209
30368
|
return false;
|
30210
30369
|
};
|
30370
|
+
var canViewForm = function () {
|
30371
|
+
if ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.GOVERNMENT || (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.MINISTRY) {
|
30372
|
+
if ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) === Role.ViewOnly && data.some(function (item) { return item.state === 'SAVED'; })) {
|
30373
|
+
return true;
|
30374
|
+
}
|
30375
|
+
else if ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== Role.ViewOnly) {
|
30376
|
+
return true;
|
30377
|
+
}
|
30378
|
+
}
|
30379
|
+
return false;
|
30380
|
+
};
|
30211
30381
|
return (React.createElement("div", null,
|
30212
30382
|
React.createElement("div", { className: "content-container emission-tab-container" },
|
30213
30383
|
React.createElement("div", { className: "emission-title-bar" },
|
@@ -30216,8 +30386,7 @@ var GHGEmissionsComponent = function (props) {
|
|
30216
30386
|
React.createElement("div", { className: "body-sub-title" }, t("ghgInventory:totalNationalEmissionSubTitle")))),
|
30217
30387
|
React.createElement("div", { className: "content-card add-emission" },
|
30218
30388
|
React.createElement(Tabs, { defaultActiveKey: "Add New", centered: true },
|
30219
|
-
((
|
30220
|
-
(userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.MINISTRY) && (React.createElement(Tabs.TabPane, { key: "Add New", tab: t("ghgInventory:addNew") },
|
30389
|
+
(canViewForm()) && (React.createElement(Tabs.TabPane, { key: "Add New", tab: t("ghgInventory:addNew") },
|
30221
30390
|
React.createElement("div", null,
|
30222
30391
|
React.createElement(Form, { labelCol: { span: 20 }, wrapperCol: { span: 24 }, name: "add-emission", className: "programme-details-form", layout: "vertical", requiredMark: true, form: form, onValuesChange: onValuesChange, onFinish: onOpenSaveFormModel },
|
30223
30392
|
React.createElement(Row, null,
|
@@ -30268,10 +30437,8 @@ var GHGEmissionsComponent = function (props) {
|
|
30268
30437
|
var workbook = XLSX.read(xldata, { type: 'array' });
|
30269
30438
|
var sheetName = workbook.SheetNames[0];
|
30270
30439
|
var sheet = workbook.Sheets[sheetName];
|
30271
|
-
var
|
30272
|
-
|
30273
|
-
})[0];
|
30274
|
-
if (!validateExcelDataFormat(firstRow)) {
|
30440
|
+
var excelData = XLSX.utils.sheet_to_json(sheet);
|
30441
|
+
if (!validateExcelDataFormat(sheet, excelData)) {
|
30275
30442
|
message.open({
|
30276
30443
|
type: 'error',
|
30277
30444
|
content: t('ghgInventory:invalidDataInExcel'),
|
@@ -30284,7 +30451,6 @@ var GHGEmissionsComponent = function (props) {
|
|
30284
30451
|
});
|
30285
30452
|
return false;
|
30286
30453
|
}
|
30287
|
-
var excelData = XLSX.utils.sheet_to_json(sheet);
|
30288
30454
|
handleFileUploadData(excelData);
|
30289
30455
|
setUploadedFileName(file.name);
|
30290
30456
|
}
|
@@ -30297,9 +30463,9 @@ var GHGEmissionsComponent = function (props) {
|
|
30297
30463
|
// Prevent upload
|
30298
30464
|
return false;
|
30299
30465
|
} },
|
30300
|
-
React.createElement(Button, { icon: React.createElement(UploadOutlined, null) }, t("ghgInventory:upload"))))),
|
30466
|
+
React.createElement(Button, { icon: React.createElement(UploadOutlined, null), disabled: (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) === Role.ViewOnly }, t("ghgInventory:upload"))))),
|
30301
30467
|
React.createElement(Col, { xl: 16, md: 16, className: "add-new-upload-file-name-input" },
|
30302
|
-
React.createElement(Input, { value: uploadedFileName, readOnly: true, suffix: uploadedFileName && (React.createElement(Button, { onClick: clearUploadDoc, icon: React.createElement(DeleteOutlined, null), style: { marginRight: '-10px', padding: '0px 6px' } })) }))))),
|
30468
|
+
React.createElement(Input, { value: uploadedFileName, disabled: (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) === Role.ViewOnly, readOnly: true, suffix: uploadedFileName && (React.createElement(Button, { onClick: clearUploadDoc, icon: React.createElement(DeleteOutlined, null), style: { marginRight: '-10px', padding: '0px 6px' } })) }))))),
|
30303
30469
|
React.createElement(Row, { gutter: 16 },
|
30304
30470
|
React.createElement(Col, { span: 9, offset: 12 },
|
30305
30471
|
React.createElement(Row, { gutter: 16, className: "table-heading-row" },
|
@@ -30354,39 +30520,129 @@ var GHGEmissionsComponent = function (props) {
|
|
30354
30520
|
React.createElement(Col, { xl: 9, md: 9 },
|
30355
30521
|
React.createElement(Row, { gutter: 16, className: "panel-content-input-box-row total-co2-land-input-box-row" },
|
30356
30522
|
React.createElement(Col, { xl: 6 },
|
30357
|
-
React.createElement(Form.Item, { name: "totalCo2WithoutLand_co2"
|
30358
|
-
|
30523
|
+
React.createElement(Form.Item, { name: "totalCo2WithoutLand_co2", rules: [
|
30524
|
+
{
|
30525
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
30526
|
+
return __generator(this, function (_a) {
|
30527
|
+
if (value && value < 0) {
|
30528
|
+
throw new Error();
|
30529
|
+
}
|
30530
|
+
return [2 /*return*/];
|
30531
|
+
});
|
30532
|
+
}); },
|
30533
|
+
},
|
30534
|
+
] },
|
30535
|
+
React.createElement(InputNumber, { disabled: (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) === Role.ViewOnly }))),
|
30359
30536
|
React.createElement(Col, { xl: 6 },
|
30360
|
-
React.createElement(Form.Item, { name: "totalCo2WithoutLand_ch4"
|
30361
|
-
|
30537
|
+
React.createElement(Form.Item, { name: "totalCo2WithoutLand_ch4", rules: [
|
30538
|
+
{
|
30539
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
30540
|
+
return __generator(this, function (_a) {
|
30541
|
+
if (value && value < 0) {
|
30542
|
+
throw new Error();
|
30543
|
+
}
|
30544
|
+
return [2 /*return*/];
|
30545
|
+
});
|
30546
|
+
}); },
|
30547
|
+
},
|
30548
|
+
] },
|
30549
|
+
React.createElement(InputNumber, { disabled: (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) === Role.ViewOnly }))),
|
30362
30550
|
React.createElement(Col, { xl: 6 },
|
30363
|
-
React.createElement(Form.Item, { name: "totalCo2WithoutLand_n2o"
|
30364
|
-
|
30551
|
+
React.createElement(Form.Item, { name: "totalCo2WithoutLand_n2o", rules: [
|
30552
|
+
{
|
30553
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
30554
|
+
return __generator(this, function (_a) {
|
30555
|
+
if (value && value < 0) {
|
30556
|
+
throw new Error();
|
30557
|
+
}
|
30558
|
+
return [2 /*return*/];
|
30559
|
+
});
|
30560
|
+
}); },
|
30561
|
+
},
|
30562
|
+
] },
|
30563
|
+
React.createElement(InputNumber, { disabled: (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) === Role.ViewOnly }))),
|
30365
30564
|
React.createElement(Col, { xl: 6 },
|
30366
|
-
React.createElement(Form.Item, { name: "totalCo2WithoutLand_co2eq"
|
30367
|
-
|
30565
|
+
React.createElement(Form.Item, { name: "totalCo2WithoutLand_co2eq", rules: [
|
30566
|
+
{
|
30567
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
30568
|
+
return __generator(this, function (_a) {
|
30569
|
+
if (value && value < 0) {
|
30570
|
+
throw new Error();
|
30571
|
+
}
|
30572
|
+
return [2 /*return*/];
|
30573
|
+
});
|
30574
|
+
}); },
|
30575
|
+
},
|
30576
|
+
] },
|
30577
|
+
React.createElement(InputNumber, { disabled: (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) === Role.ViewOnly })))))),
|
30368
30578
|
React.createElement(Row, { gutter: 16, key: 'totalCo2WithLand', className: "total-co2-with-land-row" },
|
30369
30579
|
React.createElement(Col, { xl: 12, md: 12, className: "total-co2-with-land-title" },
|
30370
30580
|
React.createElement("span", null, t("ghgInventory:totalCo2WithLand"))),
|
30371
30581
|
React.createElement(Col, { xl: 9, md: 9 },
|
30372
30582
|
React.createElement(Row, { gutter: 16, className: "panel-content-input-box-row total-co2-land-input-box-row" },
|
30373
30583
|
React.createElement(Col, { xl: 6 },
|
30374
|
-
React.createElement(Form.Item, { name: "totalCo2WithLand_co2"
|
30375
|
-
|
30584
|
+
React.createElement(Form.Item, { name: "totalCo2WithLand_co2", rules: [
|
30585
|
+
{
|
30586
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
30587
|
+
return __generator(this, function (_a) {
|
30588
|
+
if (value && value < 0) {
|
30589
|
+
throw new Error();
|
30590
|
+
}
|
30591
|
+
return [2 /*return*/];
|
30592
|
+
});
|
30593
|
+
}); },
|
30594
|
+
},
|
30595
|
+
] },
|
30596
|
+
React.createElement(InputNumber, { disabled: (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) === Role.ViewOnly }))),
|
30376
30597
|
React.createElement(Col, { xl: 6 },
|
30377
|
-
React.createElement(Form.Item, { name: "totalCo2WithLand_ch4"
|
30378
|
-
|
30598
|
+
React.createElement(Form.Item, { name: "totalCo2WithLand_ch4", rules: [
|
30599
|
+
{
|
30600
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
30601
|
+
return __generator(this, function (_a) {
|
30602
|
+
if (value && value < 0) {
|
30603
|
+
throw new Error();
|
30604
|
+
}
|
30605
|
+
return [2 /*return*/];
|
30606
|
+
});
|
30607
|
+
}); },
|
30608
|
+
},
|
30609
|
+
] },
|
30610
|
+
React.createElement(InputNumber, { disabled: (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) === Role.ViewOnly }))),
|
30379
30611
|
React.createElement(Col, { xl: 6 },
|
30380
|
-
React.createElement(Form.Item, { name: "totalCo2WithLand_n2o"
|
30381
|
-
|
30612
|
+
React.createElement(Form.Item, { name: "totalCo2WithLand_n2o", rules: [
|
30613
|
+
{
|
30614
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
30615
|
+
return __generator(this, function (_a) {
|
30616
|
+
if (value && value < 0) {
|
30617
|
+
throw new Error();
|
30618
|
+
}
|
30619
|
+
return [2 /*return*/];
|
30620
|
+
});
|
30621
|
+
}); },
|
30622
|
+
},
|
30623
|
+
] },
|
30624
|
+
React.createElement(InputNumber, { disabled: (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) === Role.ViewOnly }))),
|
30382
30625
|
React.createElement(Col, { xl: 6 },
|
30383
|
-
React.createElement(Form.Item, { name: "totalCo2WithLand_co2eq"
|
30384
|
-
|
30385
|
-
|
30386
|
-
|
30387
|
-
|
30388
|
-
|
30389
|
-
|
30626
|
+
React.createElement(Form.Item, { name: "totalCo2WithLand_co2eq", rules: [
|
30627
|
+
{
|
30628
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
30629
|
+
return __generator(this, function (_a) {
|
30630
|
+
if (value && value < 0) {
|
30631
|
+
throw new Error();
|
30632
|
+
}
|
30633
|
+
return [2 /*return*/];
|
30634
|
+
});
|
30635
|
+
}); },
|
30636
|
+
},
|
30637
|
+
] },
|
30638
|
+
React.createElement(InputNumber, { disabled: (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) === Role.ViewOnly })))))),
|
30639
|
+
(((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.GOVERNMENT || (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.MINISTRY)
|
30640
|
+
&& ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== Role.ViewOnly)) &&
|
30641
|
+
(React.createElement("div", { className: "steps-actions" },
|
30642
|
+
(userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.GOVERNMENT &&
|
30643
|
+
(React.createElement(Button, { className: "finalize-btn", type: "primary", loading: loading, onClick: onOpenFinalizeFormModel }, "Finalise")),
|
30644
|
+
React.createElement(Button, { className: "submit-btn", type: "primary", onClick: onOpenSaveFormModel, loading: loading }, "Submit"),
|
30645
|
+
React.createElement(Button, { className: "back-btn", onClick: onOpenResetFormModel, loading: loading }, "Cancel"))))))),
|
30390
30646
|
data.map(function (tabData) {
|
30391
30647
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
30392
30648
|
return tabData.state === 'FINALIZED' && (React.createElement(Tabs.TabPane, { className: 'view-data-panel', key: tabData.id.toString(), tab: React.createElement("span", null,
|
@@ -30402,7 +30658,7 @@ var GHGEmissionsComponent = function (props) {
|
|
30402
30658
|
React.createElement(Row, { className: "add-new-upload-file-label" }, t("ghgInventory:emissionRemovalDocument")),
|
30403
30659
|
React.createElement(Row, null,
|
30404
30660
|
React.createElement(Col, { xl: 15, md: 15, className: "view-download-file-name-input" },
|
30405
|
-
React.createElement(Input, { value: "GHG-Reporting
|
30661
|
+
React.createElement(Input, { value: "GHG-Reporting-Emissions_".concat(tabData.year, "_V").concat(tabData.version, ".csv"), disabled: true })),
|
30406
30662
|
React.createElement(Col, { xl: 5, md: 5, className: "view-download-file-inner-col" },
|
30407
30663
|
React.createElement(Button, { icon: React.createElement(DownloadOutlined, null), onClick: function () { downloadCSV(tabData); } }, t("ghgInventory:download")))))),
|
30408
30664
|
React.createElement(Row, { gutter: 16 },
|
@@ -30591,31 +30847,38 @@ var GHGProjectionsComponent = function (props) {
|
|
30591
30847
|
var createSetFieldObject = function (obj, objName) {
|
30592
30848
|
var result = {};
|
30593
30849
|
for (var key in obj) {
|
30594
|
-
console.log('key', key);
|
30595
30850
|
var energyEmissionsSub = obj[key];
|
30596
30851
|
for (var childKey in energyEmissionsSub) {
|
30597
30852
|
if (typeof energyEmissionsSub[childKey] === 'object') {
|
30598
|
-
console.log('energyEmissionsSub', energyEmissionsSub);
|
30599
30853
|
for (var category in energyEmissionsSub) {
|
30600
|
-
console.log('category', category);
|
30601
30854
|
var subcategory = energyEmissionsSub[category];
|
30602
30855
|
for (var gas in subcategory) {
|
30603
|
-
result["".concat(key, "_").concat(category, "_").concat(gas)] = subcategory[gas];
|
30856
|
+
result["".concat(key, "_").concat(category, "_").concat(gas)] = !isNaN(subcategory[gas]) ? subcategory[gas] : 0;
|
30604
30857
|
}
|
30605
30858
|
}
|
30606
30859
|
}
|
30607
30860
|
else {
|
30608
30861
|
for (var gas in energyEmissionsSub) {
|
30609
|
-
result["".concat(objName, "_").concat(key, "_").concat(gas)] = energyEmissionsSub[gas];
|
30862
|
+
result["".concat(objName, "_").concat(key, "_").concat(gas)] = !isNaN(energyEmissionsSub[gas]) ? energyEmissionsSub[gas] : 0;
|
30610
30863
|
}
|
30611
30864
|
}
|
30612
30865
|
}
|
30613
30866
|
}
|
30614
30867
|
return result;
|
30615
30868
|
};
|
30616
|
-
var validateExcelDataFormat = function (
|
30869
|
+
var validateExcelDataFormat = function (sheet, excelData) {
|
30870
|
+
var sheetHeadings = XLSX.utils.sheet_to_json(sheet, {
|
30871
|
+
header: 1,
|
30872
|
+
})[0];
|
30617
30873
|
var columnHeadings = ['Sector', 'Business As Usual', 'Conditional NDC', 'Unconditional NDC'];
|
30618
|
-
|
30874
|
+
if (!columnHeadings.every(function (element) { return sheetHeadings.includes(element); })) {
|
30875
|
+
return false;
|
30876
|
+
}
|
30877
|
+
var sectorValues = excelData.map(function (excelDataObj) { return excelDataObj.Sector; });
|
30878
|
+
if (!excelFields.every(function (element) { return sectorValues.includes(element); })) {
|
30879
|
+
return false;
|
30880
|
+
}
|
30881
|
+
return true;
|
30619
30882
|
};
|
30620
30883
|
var populateFormWithUploadedFile = function (excelData, keyPrefix) {
|
30621
30884
|
var emissions = {};
|
@@ -30692,12 +30955,13 @@ var GHGProjectionsComponent = function (props) {
|
|
30692
30955
|
var sum = 0;
|
30693
30956
|
for (var key in obj) {
|
30694
30957
|
if (key === conditionType) {
|
30695
|
-
sum += obj[key];
|
30958
|
+
sum += Number.isInteger(obj[key]) ? obj[key] : 0;
|
30696
30959
|
}
|
30697
30960
|
else if (typeof obj[key] === 'object' &&
|
30698
30961
|
key !== 'totalCo2WithLand' &&
|
30699
30962
|
key !== 'totalCo2WithoutLand') {
|
30700
|
-
|
30963
|
+
var calculatedSum = calculateSumEmissionView(obj[key], conditionType);
|
30964
|
+
sum += Number.isInteger(calculatedSum) ? calculatedSum : 0;
|
30701
30965
|
}
|
30702
30966
|
}
|
30703
30967
|
return sum;
|
@@ -30975,19 +31239,6 @@ var GHGProjectionsComponent = function (props) {
|
|
30975
31239
|
setOpenResetFormModal(false);
|
30976
31240
|
};
|
30977
31241
|
var onOpenResetFormModel = function () {
|
30978
|
-
setActionInfo({
|
30979
|
-
action: "".concat(t('ghgInventory:proceed')),
|
30980
|
-
headerText: "".concat(t('ghgInventory:discardHeaderText')),
|
30981
|
-
type: 'danger',
|
30982
|
-
icon: React.createElement(CloseCircleOutlined, null),
|
30983
|
-
});
|
30984
|
-
setErrorMsg('');
|
30985
|
-
setOpenResetFormModal(true);
|
30986
|
-
};
|
30987
|
-
var onSaveFormCanceled = function () {
|
30988
|
-
setOpenSaveFormModal(false);
|
30989
|
-
};
|
30990
|
-
var onOpenSaveFormModel = function () {
|
30991
31242
|
if (!isFormChanged) {
|
30992
31243
|
message.open({
|
30993
31244
|
type: 'error',
|
@@ -30998,34 +31249,98 @@ var GHGProjectionsComponent = function (props) {
|
|
30998
31249
|
}
|
30999
31250
|
else {
|
31000
31251
|
setActionInfo({
|
31001
|
-
action: "".concat(t(
|
31002
|
-
headerText: "".concat(t(
|
31003
|
-
type:
|
31004
|
-
icon: React.createElement(
|
31252
|
+
action: "".concat(t('ghgInventory:proceed')),
|
31253
|
+
headerText: "".concat(t('ghgInventory:discardHeaderText')),
|
31254
|
+
type: 'danger',
|
31255
|
+
icon: React.createElement(CloseCircleOutlined, null),
|
31005
31256
|
});
|
31006
31257
|
setErrorMsg('');
|
31007
|
-
|
31258
|
+
setOpenResetFormModal(true);
|
31008
31259
|
}
|
31009
31260
|
};
|
31261
|
+
var onSaveFormCanceled = function () {
|
31262
|
+
setOpenSaveFormModal(false);
|
31263
|
+
};
|
31264
|
+
var onOpenSaveFormModel = function () {
|
31265
|
+
var _a = form.getFieldsValue(true); _a.year; var rest = __rest(_a, ["year"]);
|
31266
|
+
var otherFieldsNegativeValue = Object.values(rest).some(function (value) {
|
31267
|
+
return typeof value === 'number' && value < 0;
|
31268
|
+
});
|
31269
|
+
form
|
31270
|
+
.validateFields()
|
31271
|
+
.then(function (values) {
|
31272
|
+
if (!isFormChanged) {
|
31273
|
+
message.open({
|
31274
|
+
type: 'error',
|
31275
|
+
content: t('ghgInventory:formNotChanged'),
|
31276
|
+
duration: 4,
|
31277
|
+
style: { textAlign: 'right', marginRight: 15, marginTop: 10 },
|
31278
|
+
});
|
31279
|
+
}
|
31280
|
+
else {
|
31281
|
+
setActionInfo({
|
31282
|
+
action: "".concat(t("ghgInventory:submit")),
|
31283
|
+
headerText: "".concat(t("ghgInventory:submitModelHeader")),
|
31284
|
+
type: "primary",
|
31285
|
+
icon: React.createElement(CheckCircleOutlined, null),
|
31286
|
+
});
|
31287
|
+
setErrorMsg('');
|
31288
|
+
setOpenSaveFormModal(true);
|
31289
|
+
}
|
31290
|
+
})
|
31291
|
+
.catch(function (errorInfo) {
|
31292
|
+
if (otherFieldsNegativeValue) {
|
31293
|
+
message.open({
|
31294
|
+
type: 'error',
|
31295
|
+
content: t('ghgInventory:negativeValuesNotAllowed'),
|
31296
|
+
duration: 4,
|
31297
|
+
style: { textAlign: 'right', marginRight: 15, marginTop: 10 },
|
31298
|
+
});
|
31299
|
+
}
|
31300
|
+
});
|
31301
|
+
};
|
31010
31302
|
var onFinalizeFormCanceled = function () {
|
31011
31303
|
setOpenFinalizeFormModal(false);
|
31012
31304
|
};
|
31013
31305
|
var onOpenFinalizeFormModel = function () {
|
31306
|
+
var _a = form.getFieldsValue(true); _a.year; var rest = __rest(_a, ["year"]);
|
31307
|
+
var otherFieldsEmpty = Object.values(rest).every(function (value) { return !value; });
|
31308
|
+
var otherFieldsNegativeValue = Object.values(rest).some(function (value) {
|
31309
|
+
return typeof value === 'number' && value < 0;
|
31310
|
+
});
|
31014
31311
|
form
|
31015
31312
|
.validateFields()
|
31016
31313
|
.then(function (values) {
|
31017
31314
|
// Validation successful, set ActionInfo and open the form modal
|
31018
|
-
|
31019
|
-
|
31020
|
-
|
31021
|
-
|
31022
|
-
|
31023
|
-
|
31024
|
-
|
31025
|
-
|
31315
|
+
if (otherFieldsEmpty) {
|
31316
|
+
message.open({
|
31317
|
+
type: 'error',
|
31318
|
+
content: t('ghgInventory:cannotFinaliseEmpty'),
|
31319
|
+
duration: 4,
|
31320
|
+
style: { textAlign: 'right', marginRight: 15, marginTop: 10 },
|
31321
|
+
});
|
31322
|
+
}
|
31323
|
+
else {
|
31324
|
+
setActionInfo({
|
31325
|
+
action: "".concat(t("ghgInventory:finalize")),
|
31326
|
+
headerText: "".concat(t("ghgInventory:finalizeModelHeader")),
|
31327
|
+
type: "primary",
|
31328
|
+
icon: React.createElement(ClipboardCheck, null),
|
31329
|
+
});
|
31330
|
+
setErrorMsg('');
|
31331
|
+
setOpenFinalizeFormModal(true);
|
31332
|
+
}
|
31026
31333
|
})
|
31027
31334
|
.catch(function (errorInfo) {
|
31028
31335
|
// Validation failed
|
31336
|
+
if (otherFieldsNegativeValue) {
|
31337
|
+
message.open({
|
31338
|
+
type: 'error',
|
31339
|
+
content: t('ghgInventory:negativeValuesNotAllowed'),
|
31340
|
+
duration: 4,
|
31341
|
+
style: { textAlign: 'right', marginRight: 15, marginTop: 10 },
|
31342
|
+
});
|
31343
|
+
}
|
31029
31344
|
console.log('Validation failed:', errorInfo);
|
31030
31345
|
});
|
31031
31346
|
};
|
@@ -31089,7 +31404,7 @@ var GHGProjectionsComponent = function (props) {
|
|
31089
31404
|
setLoading(true);
|
31090
31405
|
_a.label = 2;
|
31091
31406
|
case 2:
|
31092
|
-
_a.trys.push([2, 6,
|
31407
|
+
_a.trys.push([2, 6, 11, 12]);
|
31093
31408
|
return [4 /*yield*/, post('national/projections', payload)];
|
31094
31409
|
case 3:
|
31095
31410
|
response = _a.sent();
|
@@ -31116,7 +31431,7 @@ var GHGProjectionsComponent = function (props) {
|
|
31116
31431
|
case 4:
|
31117
31432
|
_a.sent();
|
31118
31433
|
_a.label = 5;
|
31119
|
-
case 5: return [3 /*break*/,
|
31434
|
+
case 5: return [3 /*break*/, 12];
|
31120
31435
|
case 6:
|
31121
31436
|
error_2 = _a.sent();
|
31122
31437
|
console.log('Error in projection creation - ', error_2);
|
@@ -31128,19 +31443,31 @@ var GHGProjectionsComponent = function (props) {
|
|
31128
31443
|
duration: 4,
|
31129
31444
|
style: { textAlign: 'right', marginRight: 15, marginTop: 10 },
|
31130
31445
|
});
|
31131
|
-
if (!(error_2.
|
31446
|
+
if (!(error_2.status === HttpStatusCode.Conflict.valueOf())) return [3 /*break*/, 8];
|
31132
31447
|
return [4 /*yield*/, getProjectionData()];
|
31133
31448
|
case 7:
|
31134
31449
|
_a.sent();
|
31450
|
+
setIsSavedFormDataSet(false);
|
31451
|
+
clearUploadDoc();
|
31452
|
+
if (!isPendingFinalization) {
|
31453
|
+
clearForm();
|
31454
|
+
}
|
31455
|
+
return [3 /*break*/, 10];
|
31456
|
+
case 8:
|
31457
|
+
if (!(error_2.status === HttpStatusCode.Forbidden.valueOf())) return [3 /*break*/, 10];
|
31135
31458
|
clearUploadDoc();
|
31136
|
-
|
31137
|
-
|
31459
|
+
clearForm();
|
31460
|
+
return [4 /*yield*/, getProjectionData()];
|
31138
31461
|
case 9:
|
31462
|
+
_a.sent();
|
31463
|
+
_a.label = 10;
|
31464
|
+
case 10: return [3 /*break*/, 12];
|
31465
|
+
case 11:
|
31139
31466
|
// eslint-disable-next-line no-use-before-define, @typescript-eslint/no-use-before-define
|
31140
31467
|
setIsFormChanged(false);
|
31141
31468
|
setLoading(false);
|
31142
31469
|
return [7 /*endfinally*/];
|
31143
|
-
case
|
31470
|
+
case 12: return [2 /*return*/];
|
31144
31471
|
}
|
31145
31472
|
});
|
31146
31473
|
}); };
|
@@ -31569,14 +31896,47 @@ var GHGProjectionsComponent = function (props) {
|
|
31569
31896
|
React.createElement(Col, { xl: 9, md: 9 },
|
31570
31897
|
React.createElement(Row, { gutter: 16, className: "panel-content-input-box-row" },
|
31571
31898
|
React.createElement(Col, { xl: 7 },
|
31572
|
-
React.createElement(Form.Item, { name: panelHeading + '_' + item + '_bau'
|
31573
|
-
|
31899
|
+
React.createElement(Form.Item, { name: panelHeading + '_' + item + '_bau', rules: [
|
31900
|
+
{
|
31901
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
31902
|
+
return __generator(this, function (_a) {
|
31903
|
+
if (value && value < 0) {
|
31904
|
+
throw new Error();
|
31905
|
+
}
|
31906
|
+
return [2 /*return*/];
|
31907
|
+
});
|
31908
|
+
}); },
|
31909
|
+
},
|
31910
|
+
] },
|
31911
|
+
React.createElement(InputNumber, { onChange: function (event) { return calculateSumBau(event, panelHeading); }, disabled: (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) === Role.ViewOnly }))),
|
31574
31912
|
React.createElement(Col, { xl: 7 },
|
31575
|
-
React.createElement(Form.Item, { name: panelHeading + '_' + item + '_conditionalNdc'
|
31576
|
-
|
31913
|
+
React.createElement(Form.Item, { name: panelHeading + '_' + item + '_conditionalNdc', rules: [
|
31914
|
+
{
|
31915
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
31916
|
+
return __generator(this, function (_a) {
|
31917
|
+
if (value && value < 0) {
|
31918
|
+
throw new Error();
|
31919
|
+
}
|
31920
|
+
return [2 /*return*/];
|
31921
|
+
});
|
31922
|
+
}); },
|
31923
|
+
},
|
31924
|
+
] },
|
31925
|
+
React.createElement(InputNumber, { onChange: function (event) { return calculateSumConditionalNdc(event, panelHeading); }, disabled: (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) === Role.ViewOnly }))),
|
31577
31926
|
React.createElement(Col, { xl: 7 },
|
31578
|
-
React.createElement(Form.Item, { name: panelHeading + '_' + item + '_unconditionalNdc'
|
31579
|
-
|
31927
|
+
React.createElement(Form.Item, { name: panelHeading + '_' + item + '_unconditionalNdc', rules: [
|
31928
|
+
{
|
31929
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
31930
|
+
return __generator(this, function (_a) {
|
31931
|
+
if (value && value < 0) {
|
31932
|
+
throw new Error();
|
31933
|
+
}
|
31934
|
+
return [2 /*return*/];
|
31935
|
+
});
|
31936
|
+
}); },
|
31937
|
+
},
|
31938
|
+
] },
|
31939
|
+
React.createElement(InputNumber, { onChange: function (event) { return calculateSumUnconditionalNdc(event, panelHeading); }, disabled: (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) === Role.ViewOnly }))))))); };
|
31580
31940
|
var renderPanelContentView = function (bau, conditionalNdc, unconditionalNdc, item, index) {
|
31581
31941
|
return (React.createElement(Row, { gutter: 16, key: index, className: "panel-content-row" },
|
31582
31942
|
React.createElement(Col, { xl: 12, md: 12, className: "panel-content-title" },
|
@@ -31635,7 +31995,7 @@ var GHGProjectionsComponent = function (props) {
|
|
31635
31995
|
var encodedUri = encodeURI("data:text/csv;charset=utf-8,".concat(csvContent));
|
31636
31996
|
var link = document.createElement('a');
|
31637
31997
|
link.setAttribute('href', encodedUri);
|
31638
|
-
link.setAttribute('download', "GHG-Reporting
|
31998
|
+
link.setAttribute('download', "GHG-Reporting-Projections_".concat(dataToDownload.year, "_V").concat(dataToDownload.version, ".csv"));
|
31639
31999
|
document.body.appendChild(link);
|
31640
32000
|
link.click();
|
31641
32001
|
};
|
@@ -31657,6 +32017,17 @@ var GHGProjectionsComponent = function (props) {
|
|
31657
32017
|
}
|
31658
32018
|
return false;
|
31659
32019
|
};
|
32020
|
+
var canViewForm = function () {
|
32021
|
+
if ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.GOVERNMENT || (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.MINISTRY) {
|
32022
|
+
if ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) === Role.ViewOnly && data.some(function (item) { return item.state === 'SAVED'; })) {
|
32023
|
+
return true;
|
32024
|
+
}
|
32025
|
+
else if ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== Role.ViewOnly) {
|
32026
|
+
return true;
|
32027
|
+
}
|
32028
|
+
}
|
32029
|
+
return false;
|
32030
|
+
};
|
31660
32031
|
return (React.createElement("div", null,
|
31661
32032
|
React.createElement("div", { className: "content-container projection-tab-container" },
|
31662
32033
|
React.createElement("div", { className: "projection-title-bar" },
|
@@ -31665,8 +32036,7 @@ var GHGProjectionsComponent = function (props) {
|
|
31665
32036
|
React.createElement("div", { className: "body-sub-title" }, t("ghgInventory:totalNationalEmissionSubTitle")))),
|
31666
32037
|
React.createElement("div", { className: "content-card add-projection" },
|
31667
32038
|
React.createElement(Tabs, { defaultActiveKey: "Add New", centered: true },
|
31668
|
-
((
|
31669
|
-
(userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.MINISTRY) && (React.createElement(Tabs.TabPane, { key: "Add New", tab: t("ghgInventory:addNew") },
|
32039
|
+
(canViewForm()) && (React.createElement(Tabs.TabPane, { key: "Add New", tab: t("ghgInventory:addNew") },
|
31670
32040
|
React.createElement("div", null,
|
31671
32041
|
React.createElement(Form, { labelCol: { span: 20 }, wrapperCol: { span: 24 }, name: "add-projection", className: "programme-details-form", layout: "vertical", requiredMark: true, form: form, onValuesChange: onValuesChange, onFinish: onOpenSaveFormModel },
|
31672
32042
|
React.createElement(Row, null,
|
@@ -31716,10 +32086,8 @@ var GHGProjectionsComponent = function (props) {
|
|
31716
32086
|
var workbook = XLSX.read(xldata, { type: 'array' });
|
31717
32087
|
var sheetName = workbook.SheetNames[0];
|
31718
32088
|
var sheet = workbook.Sheets[sheetName];
|
31719
|
-
var
|
31720
|
-
|
31721
|
-
})[0];
|
31722
|
-
if (!validateExcelDataFormat(firstRow)) {
|
32089
|
+
var excelData = XLSX.utils.sheet_to_json(sheet);
|
32090
|
+
if (!validateExcelDataFormat(sheet, excelData)) {
|
31723
32091
|
message.open({
|
31724
32092
|
type: 'error',
|
31725
32093
|
content: t('ghgInventory:invalidDataInExcel'),
|
@@ -31732,7 +32100,6 @@ var GHGProjectionsComponent = function (props) {
|
|
31732
32100
|
});
|
31733
32101
|
return false;
|
31734
32102
|
}
|
31735
|
-
var excelData = XLSX.utils.sheet_to_json(sheet);
|
31736
32103
|
handleFileUploadData(excelData);
|
31737
32104
|
setUploadedFileName(file.name);
|
31738
32105
|
}
|
@@ -31745,9 +32112,9 @@ var GHGProjectionsComponent = function (props) {
|
|
31745
32112
|
// Prevent upload
|
31746
32113
|
return false;
|
31747
32114
|
} },
|
31748
|
-
React.createElement(Button, { icon: React.createElement(UploadOutlined, null) }, t("ghgInventory:upload"))))),
|
32115
|
+
React.createElement(Button, { icon: React.createElement(UploadOutlined, null), disabled: (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) === Role.ViewOnly }, t("ghgInventory:upload"))))),
|
31749
32116
|
React.createElement(Col, { xl: 16, md: 16, className: "add-new-upload-file-name-input" },
|
31750
|
-
React.createElement(Input, { value: uploadedFileName, readOnly: true, suffix: uploadedFileName && (React.createElement(Button, { onClick: clearUploadDoc, icon: React.createElement(DeleteOutlined, null), style: { marginRight: '-10px', padding: '0px 6px' } })) }))))),
|
32117
|
+
React.createElement(Input, { value: uploadedFileName, disabled: (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) === Role.ViewOnly, readOnly: true, suffix: uploadedFileName && (React.createElement(Button, { onClick: clearUploadDoc, icon: React.createElement(DeleteOutlined, null), style: { marginRight: '-10px', padding: '0px 6px' } })) }))))),
|
31751
32118
|
React.createElement(Row, { gutter: 16 },
|
31752
32119
|
React.createElement(Col, { span: 9, offset: 12 },
|
31753
32120
|
React.createElement(Row, { gutter: 16, className: "table-heading-row" },
|
@@ -31791,33 +32158,101 @@ var GHGProjectionsComponent = function (props) {
|
|
31791
32158
|
React.createElement(Col, { xl: 9, md: 9 },
|
31792
32159
|
React.createElement(Row, { gutter: 16, className: "panel-content-input-box-row total-co2-land-input-box-row" },
|
31793
32160
|
React.createElement(Col, { xl: 7 },
|
31794
|
-
React.createElement(Form.Item, { name: "totalCo2WithoutLand_bau"
|
31795
|
-
|
32161
|
+
React.createElement(Form.Item, { name: "totalCo2WithoutLand_bau", rules: [
|
32162
|
+
{
|
32163
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
32164
|
+
return __generator(this, function (_a) {
|
32165
|
+
if (value && value < 0) {
|
32166
|
+
throw new Error();
|
32167
|
+
}
|
32168
|
+
return [2 /*return*/];
|
32169
|
+
});
|
32170
|
+
}); },
|
32171
|
+
},
|
32172
|
+
] },
|
32173
|
+
React.createElement(InputNumber, { disabled: (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) === Role.ViewOnly }))),
|
31796
32174
|
React.createElement(Col, { xl: 7 },
|
31797
|
-
React.createElement(Form.Item, { name: "totalCo2WithoutLand_conditionalNdc"
|
31798
|
-
|
32175
|
+
React.createElement(Form.Item, { name: "totalCo2WithoutLand_conditionalNdc", rules: [
|
32176
|
+
{
|
32177
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
32178
|
+
return __generator(this, function (_a) {
|
32179
|
+
if (value && value < 0) {
|
32180
|
+
throw new Error();
|
32181
|
+
}
|
32182
|
+
return [2 /*return*/];
|
32183
|
+
});
|
32184
|
+
}); },
|
32185
|
+
},
|
32186
|
+
] },
|
32187
|
+
React.createElement(InputNumber, { disabled: (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) === Role.ViewOnly }))),
|
31799
32188
|
React.createElement(Col, { xl: 7 },
|
31800
|
-
React.createElement(Form.Item, { name: "totalCo2WithoutLand_unconditionalNdc"
|
31801
|
-
|
32189
|
+
React.createElement(Form.Item, { name: "totalCo2WithoutLand_unconditionalNdc", rules: [
|
32190
|
+
{
|
32191
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
32192
|
+
return __generator(this, function (_a) {
|
32193
|
+
if (value && value < 0) {
|
32194
|
+
throw new Error();
|
32195
|
+
}
|
32196
|
+
return [2 /*return*/];
|
32197
|
+
});
|
32198
|
+
}); },
|
32199
|
+
},
|
32200
|
+
] },
|
32201
|
+
React.createElement(InputNumber, { disabled: (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) === Role.ViewOnly })))))),
|
31802
32202
|
React.createElement(Row, { gutter: 16, key: 'totalCo2WithLand', className: "total-co2-with-land-row" },
|
31803
32203
|
React.createElement(Col, { xl: 12, md: 12, className: "total-co2-with-land-title" },
|
31804
32204
|
React.createElement("span", null, t("ghgInventory:totalCo2WithLand"))),
|
31805
32205
|
React.createElement(Col, { xl: 9, md: 9 },
|
31806
32206
|
React.createElement(Row, { gutter: 16, className: "panel-content-input-box-row total-co2-land-input-box-row" },
|
31807
32207
|
React.createElement(Col, { xl: 7 },
|
31808
|
-
React.createElement(Form.Item, { name: "totalCo2WithLand_bau"
|
31809
|
-
|
32208
|
+
React.createElement(Form.Item, { name: "totalCo2WithLand_bau", rules: [
|
32209
|
+
{
|
32210
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
32211
|
+
return __generator(this, function (_a) {
|
32212
|
+
if (value && value < 0) {
|
32213
|
+
throw new Error();
|
32214
|
+
}
|
32215
|
+
return [2 /*return*/];
|
32216
|
+
});
|
32217
|
+
}); },
|
32218
|
+
},
|
32219
|
+
] },
|
32220
|
+
React.createElement(InputNumber, { disabled: (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) === Role.ViewOnly }))),
|
31810
32221
|
React.createElement(Col, { xl: 7 },
|
31811
|
-
React.createElement(Form.Item, { name: "totalCo2WithLand_conditionalNdc"
|
31812
|
-
|
32222
|
+
React.createElement(Form.Item, { name: "totalCo2WithLand_conditionalNdc", rules: [
|
32223
|
+
{
|
32224
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
32225
|
+
return __generator(this, function (_a) {
|
32226
|
+
if (value && value < 0) {
|
32227
|
+
throw new Error();
|
32228
|
+
}
|
32229
|
+
return [2 /*return*/];
|
32230
|
+
});
|
32231
|
+
}); },
|
32232
|
+
},
|
32233
|
+
] },
|
32234
|
+
React.createElement(InputNumber, { disabled: (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) === Role.ViewOnly }))),
|
31813
32235
|
React.createElement(Col, { xl: 7 },
|
31814
|
-
React.createElement(Form.Item, { name: "totalCo2WithLand_unconditionalNdc"
|
31815
|
-
|
31816
|
-
|
31817
|
-
|
31818
|
-
|
31819
|
-
|
31820
|
-
|
32236
|
+
React.createElement(Form.Item, { name: "totalCo2WithLand_unconditionalNdc", rules: [
|
32237
|
+
{
|
32238
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
32239
|
+
return __generator(this, function (_a) {
|
32240
|
+
if (value && value < 0) {
|
32241
|
+
throw new Error();
|
32242
|
+
}
|
32243
|
+
return [2 /*return*/];
|
32244
|
+
});
|
32245
|
+
}); },
|
32246
|
+
},
|
32247
|
+
] },
|
32248
|
+
React.createElement(InputNumber, { disabled: (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) === Role.ViewOnly })))))),
|
32249
|
+
(((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.GOVERNMENT || (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.MINISTRY)
|
32250
|
+
&& ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== Role.ViewOnly)) &&
|
32251
|
+
(React.createElement("div", { className: "steps-actions" },
|
32252
|
+
(userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.GOVERNMENT &&
|
32253
|
+
(React.createElement(Button, { className: "finalize-btn", type: "primary", loading: loading, onClick: onOpenFinalizeFormModel }, "Finalise")),
|
32254
|
+
React.createElement(Button, { className: "submit-btn", type: "primary", onClick: onOpenSaveFormModel, loading: loading }, "Submit"),
|
32255
|
+
React.createElement(Button, { className: "back-btn", onClick: onOpenResetFormModel, loading: loading }, "Cancel"))))))),
|
31821
32256
|
data.map(function (tabData) {
|
31822
32257
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
31823
32258
|
return tabData.state === 'FINALIZED' && (React.createElement(Tabs.TabPane, { className: 'view-data-panel', key: tabData.id.toString(), tab: React.createElement("span", null,
|
@@ -31837,7 +32272,7 @@ var GHGProjectionsComponent = function (props) {
|
|
31837
32272
|
React.createElement(Row, { className: "add-new-upload-file-label" }, t("ghgInventory:emissionRemovalDocument")),
|
31838
32273
|
React.createElement(Row, null,
|
31839
32274
|
React.createElement(Col, { xl: 15, md: 15, className: "view-download-file-name-input" },
|
31840
|
-
React.createElement(Input, { value: "GHG-Reporting
|
32275
|
+
React.createElement(Input, { value: "GHG-Reporting-Projections_".concat(tabData.year, "_V").concat(tabData.version, ".csv"), disabled: true })),
|
31841
32276
|
React.createElement(Col, { xl: 5, md: 5, className: "view-download-file-inner-col" },
|
31842
32277
|
React.createElement(Button, { icon: React.createElement(DownloadOutlined, null), onClick: function () { downloadCSV(tabData); } }, t("ghgInventory:download")))))),
|
31843
32278
|
React.createElement(Row, { gutter: 16 },
|