@undp/carbon-library 1.0.135-ghg-inventory.12.19 → 1.0.135-ghg-inventory.12.20
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/index.js +627 -129
- 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 +627 -129
- 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/cjs/index.js
CHANGED
@@ -28910,6 +28910,48 @@ var totalProjectionFields = [
|
|
28910
28910
|
'Total National Emission and Removals - Conditional NDC',
|
28911
28911
|
'Total National Emission and Removals - Unconditional NDC',
|
28912
28912
|
];
|
28913
|
+
var excelFields = [
|
28914
|
+
"Energy",
|
28915
|
+
"Fuel Combustion Activities",
|
28916
|
+
"Energy Industries",
|
28917
|
+
"Manufacturing Industries and Construction",
|
28918
|
+
"Transport",
|
28919
|
+
"Other Sectors",
|
28920
|
+
"Non-Specified",
|
28921
|
+
"Fugitive emissions from fuels",
|
28922
|
+
"Solid Fuels",
|
28923
|
+
"Oil and Natural Gas",
|
28924
|
+
"Other emissions from Energy Production",
|
28925
|
+
"Carbon dioxide Transport and Storage",
|
28926
|
+
"Transport of CO2",
|
28927
|
+
"Injection and Storage",
|
28928
|
+
"Other (Carbon dioxide Transport and Storage)",
|
28929
|
+
"Industrial Processes & Product Use",
|
28930
|
+
"Mineral Industry",
|
28931
|
+
"Chemical Industry",
|
28932
|
+
"Metal Industry",
|
28933
|
+
"Non-Energy Products from Fuels and Solvent Use",
|
28934
|
+
"Electronics Industry",
|
28935
|
+
"Product Uses as Substitutes for Ozone Depleting Substances",
|
28936
|
+
"Other Product Manufacture and Use",
|
28937
|
+
"Other (Industrial Processes & Product Use)",
|
28938
|
+
"Agriculture, Forestry, and Other Land Use",
|
28939
|
+
"Livestock",
|
28940
|
+
"Land",
|
28941
|
+
"Aggregate sources and non-CO2 emissions sources on land",
|
28942
|
+
"Other (Agriculture, Forestry, and Other Land Use)",
|
28943
|
+
"Waste",
|
28944
|
+
"Solid Waste Disposal",
|
28945
|
+
"Biological Treatment of Solid Waste",
|
28946
|
+
"Incineration and Open Burning of Waste",
|
28947
|
+
"Wastewater Treatment and Discharge",
|
28948
|
+
"Other (Waste)",
|
28949
|
+
"Other",
|
28950
|
+
"Indirect N2O emissions from the atmospheric deposition of nitrogen in NOx and NH3",
|
28951
|
+
"Other",
|
28952
|
+
"Total CO2 equivalent emissions without land use, land-use change and forestry",
|
28953
|
+
"Total CO2 equivalent emissions with land use, land-use change and forestry",
|
28954
|
+
];
|
28913
28955
|
|
28914
28956
|
antd.Input.TextArea;
|
28915
28957
|
var DiscardChangesConfirmationModel = function (props) {
|
@@ -29029,22 +29071,32 @@ var GHGEmissionsComponent = function (props) {
|
|
29029
29071
|
for (var category in energyEmissionsSub) {
|
29030
29072
|
var subcategory = energyEmissionsSub[category];
|
29031
29073
|
for (var gas in subcategory) {
|
29032
|
-
result["".concat(key, "_").concat(category, "_").concat(gas)] = subcategory[gas];
|
29074
|
+
result["".concat(key, "_").concat(category, "_").concat(gas)] = !isNaN(subcategory[gas]) ? subcategory[gas] : 0;
|
29033
29075
|
}
|
29034
29076
|
}
|
29035
29077
|
}
|
29036
29078
|
else {
|
29037
29079
|
for (var gas in energyEmissionsSub) {
|
29038
|
-
result["".concat(objName, "_").concat(key, "_").concat(gas)] = energyEmissionsSub[gas];
|
29080
|
+
result["".concat(objName, "_").concat(key, "_").concat(gas)] = !isNaN(energyEmissionsSub[gas]) ? energyEmissionsSub[gas] : 0;
|
29039
29081
|
}
|
29040
29082
|
}
|
29041
29083
|
}
|
29042
29084
|
}
|
29043
29085
|
return result;
|
29044
29086
|
};
|
29045
|
-
var validateExcelDataFormat = function (
|
29087
|
+
var validateExcelDataFormat = function (sheet, excelData) {
|
29088
|
+
var sheetHeadings = XLSX__namespace.utils.sheet_to_json(sheet, {
|
29089
|
+
header: 1,
|
29090
|
+
})[0];
|
29046
29091
|
var columnHeadings = ['Sector', 'CO2', 'CH4', 'N2O', 'CO2-eq'];
|
29047
|
-
|
29092
|
+
if (!columnHeadings.every(function (element) { return sheetHeadings.includes(element); })) {
|
29093
|
+
return false;
|
29094
|
+
}
|
29095
|
+
var sectorValues = excelData.map(function (excelDataObj) { return excelDataObj.Sector; });
|
29096
|
+
if (!excelFields.every(function (element) { return sectorValues.includes(element); })) {
|
29097
|
+
return false;
|
29098
|
+
}
|
29099
|
+
return true;
|
29048
29100
|
};
|
29049
29101
|
var populateFormWithUploadedFile = function (excelData, keyPrefix) {
|
29050
29102
|
var emissions = {};
|
@@ -29124,12 +29176,13 @@ var GHGEmissionsComponent = function (props) {
|
|
29124
29176
|
var sum = 0;
|
29125
29177
|
for (var key in obj) {
|
29126
29178
|
if (key === gasType) {
|
29127
|
-
sum += obj[key];
|
29179
|
+
sum += Number.isInteger(obj[key]) ? obj[key] : 0;
|
29128
29180
|
}
|
29129
29181
|
else if (typeof obj[key] === 'object' &&
|
29130
29182
|
key !== 'totalCo2WithLand' &&
|
29131
29183
|
key !== 'totalCo2WithoutLand') {
|
29132
|
-
|
29184
|
+
var calculatedSum = calculateSumEmissionView(obj[key], gasType);
|
29185
|
+
sum += Number.isInteger(calculatedSum) ? calculatedSum : 0;
|
29133
29186
|
}
|
29134
29187
|
}
|
29135
29188
|
return sum;
|
@@ -29447,19 +29500,6 @@ var GHGEmissionsComponent = function (props) {
|
|
29447
29500
|
setOpenResetFormModal(false);
|
29448
29501
|
};
|
29449
29502
|
var onOpenResetFormModel = function () {
|
29450
|
-
setActionInfo({
|
29451
|
-
action: "".concat(t('ghgInventory:proceed')),
|
29452
|
-
headerText: "".concat(t('ghgInventory:discardHeaderText')),
|
29453
|
-
type: 'danger',
|
29454
|
-
icon: React.createElement(icons.CloseCircleOutlined, null),
|
29455
|
-
});
|
29456
|
-
setErrorMsg('');
|
29457
|
-
setOpenResetFormModal(true);
|
29458
|
-
};
|
29459
|
-
var onSaveFormCanceled = function () {
|
29460
|
-
setOpenSaveFormModal(false);
|
29461
|
-
};
|
29462
|
-
var onOpenSaveFormModel = function () {
|
29463
29503
|
if (!isFormChanged) {
|
29464
29504
|
antd.message.open({
|
29465
29505
|
type: 'error',
|
@@ -29470,34 +29510,98 @@ var GHGEmissionsComponent = function (props) {
|
|
29470
29510
|
}
|
29471
29511
|
else {
|
29472
29512
|
setActionInfo({
|
29473
|
-
action: "".concat(t(
|
29474
|
-
headerText: "".concat(t(
|
29475
|
-
type:
|
29476
|
-
icon: React.createElement(icons.
|
29513
|
+
action: "".concat(t('ghgInventory:proceed')),
|
29514
|
+
headerText: "".concat(t('ghgInventory:discardHeaderText')),
|
29515
|
+
type: 'danger',
|
29516
|
+
icon: React.createElement(icons.CloseCircleOutlined, null),
|
29477
29517
|
});
|
29478
29518
|
setErrorMsg('');
|
29479
|
-
|
29519
|
+
setOpenResetFormModal(true);
|
29480
29520
|
}
|
29481
29521
|
};
|
29522
|
+
var onSaveFormCanceled = function () {
|
29523
|
+
setOpenSaveFormModal(false);
|
29524
|
+
};
|
29525
|
+
var onOpenSaveFormModel = function () {
|
29526
|
+
var _a = form.getFieldsValue(true); _a.year; var rest = __rest(_a, ["year"]);
|
29527
|
+
var otherFieldsNegativeValue = Object.values(rest).some(function (value) {
|
29528
|
+
return typeof value === 'number' && value < 0;
|
29529
|
+
});
|
29530
|
+
form
|
29531
|
+
.validateFields()
|
29532
|
+
.then(function (values) {
|
29533
|
+
if (!isFormChanged) {
|
29534
|
+
antd.message.open({
|
29535
|
+
type: 'error',
|
29536
|
+
content: t('ghgInventory:formNotChanged'),
|
29537
|
+
duration: 4,
|
29538
|
+
style: { textAlign: 'right', marginRight: 15, marginTop: 10 },
|
29539
|
+
});
|
29540
|
+
}
|
29541
|
+
else {
|
29542
|
+
setActionInfo({
|
29543
|
+
action: "".concat(t("ghgInventory:submit")),
|
29544
|
+
headerText: "".concat(t("ghgInventory:submitModelHeader")),
|
29545
|
+
type: "primary",
|
29546
|
+
icon: React.createElement(icons.CheckCircleOutlined, null),
|
29547
|
+
});
|
29548
|
+
setErrorMsg('');
|
29549
|
+
setOpenSaveFormModal(true);
|
29550
|
+
}
|
29551
|
+
})
|
29552
|
+
.catch(function (errorInfo) {
|
29553
|
+
if (otherFieldsNegativeValue) {
|
29554
|
+
antd.message.open({
|
29555
|
+
type: 'error',
|
29556
|
+
content: t('ghgInventory:negativeValuesNotAllowed'),
|
29557
|
+
duration: 4,
|
29558
|
+
style: { textAlign: 'right', marginRight: 15, marginTop: 10 },
|
29559
|
+
});
|
29560
|
+
}
|
29561
|
+
});
|
29562
|
+
};
|
29482
29563
|
var onFinalizeFormCanceled = function () {
|
29483
29564
|
setOpenFinalizeFormModal(false);
|
29484
29565
|
};
|
29485
29566
|
var onOpenFinalizeFormModel = function () {
|
29567
|
+
var _a = form.getFieldsValue(true); _a.year; var rest = __rest(_a, ["year"]);
|
29568
|
+
var otherFieldsEmpty = Object.values(rest).every(function (value) { return !value; });
|
29569
|
+
var otherFieldsNegativeValue = Object.values(rest).some(function (value) {
|
29570
|
+
return typeof value === 'number' && value < 0;
|
29571
|
+
});
|
29486
29572
|
form
|
29487
29573
|
.validateFields()
|
29488
29574
|
.then(function (values) {
|
29489
29575
|
// Validation successful, set ActionInfo and open the form modal
|
29490
|
-
|
29491
|
-
|
29492
|
-
|
29493
|
-
|
29494
|
-
|
29495
|
-
|
29496
|
-
|
29497
|
-
|
29576
|
+
if (otherFieldsEmpty) {
|
29577
|
+
antd.message.open({
|
29578
|
+
type: 'error',
|
29579
|
+
content: t('ghgInventory:cannotFinaliseEmpty'),
|
29580
|
+
duration: 4,
|
29581
|
+
style: { textAlign: 'right', marginRight: 15, marginTop: 10 },
|
29582
|
+
});
|
29583
|
+
}
|
29584
|
+
else {
|
29585
|
+
setActionInfo({
|
29586
|
+
action: "".concat(t("ghgInventory:finalize")),
|
29587
|
+
headerText: "".concat(t("ghgInventory:finalizeModelHeader")),
|
29588
|
+
type: "primary",
|
29589
|
+
icon: React.createElement(Icon.ClipboardCheck, null),
|
29590
|
+
});
|
29591
|
+
setErrorMsg('');
|
29592
|
+
setOpenFinalizeFormModal(true);
|
29593
|
+
}
|
29498
29594
|
})
|
29499
29595
|
.catch(function (errorInfo) {
|
29500
29596
|
// Validation failed
|
29597
|
+
if (otherFieldsNegativeValue) {
|
29598
|
+
antd.message.open({
|
29599
|
+
type: 'error',
|
29600
|
+
content: t('ghgInventory:negativeValuesNotAllowed'),
|
29601
|
+
duration: 4,
|
29602
|
+
style: { textAlign: 'right', marginRight: 15, marginTop: 10 },
|
29603
|
+
});
|
29604
|
+
}
|
29501
29605
|
console.log('Validation failed:', errorInfo);
|
29502
29606
|
});
|
29503
29607
|
};
|
@@ -29513,7 +29617,7 @@ var GHGEmissionsComponent = function (props) {
|
|
29513
29617
|
setLoading(true);
|
29514
29618
|
_a.label = 2;
|
29515
29619
|
case 2:
|
29516
|
-
_a.trys.push([2, 6,
|
29620
|
+
_a.trys.push([2, 6, 11, 12]);
|
29517
29621
|
return [4 /*yield*/, post('national/emissions', payload)];
|
29518
29622
|
case 3:
|
29519
29623
|
response = _a.sent();
|
@@ -29540,7 +29644,7 @@ var GHGEmissionsComponent = function (props) {
|
|
29540
29644
|
case 4:
|
29541
29645
|
_a.sent();
|
29542
29646
|
_a.label = 5;
|
29543
|
-
case 5: return [3 /*break*/,
|
29647
|
+
case 5: return [3 /*break*/, 12];
|
29544
29648
|
case 6:
|
29545
29649
|
error_1 = _a.sent();
|
29546
29650
|
console.log('Error in emission creation - ', error_1);
|
@@ -29552,19 +29656,31 @@ var GHGEmissionsComponent = function (props) {
|
|
29552
29656
|
duration: 4,
|
29553
29657
|
style: { textAlign: 'right', marginRight: 15, marginTop: 10 },
|
29554
29658
|
});
|
29555
|
-
if (!(error_1.
|
29659
|
+
if (!(error_1.status === axios.HttpStatusCode.Conflict.valueOf())) return [3 /*break*/, 8];
|
29556
29660
|
return [4 /*yield*/, getEmissionData()];
|
29557
29661
|
case 7:
|
29558
29662
|
_a.sent();
|
29663
|
+
setIsSavedFormDataSet(false);
|
29664
|
+
clearUploadDoc();
|
29665
|
+
if (!isPendingFinalization) {
|
29666
|
+
clearForm();
|
29667
|
+
}
|
29668
|
+
return [3 /*break*/, 10];
|
29669
|
+
case 8:
|
29670
|
+
if (!(error_1.status === axios.HttpStatusCode.Forbidden.valueOf())) return [3 /*break*/, 10];
|
29559
29671
|
clearUploadDoc();
|
29560
|
-
|
29561
|
-
|
29672
|
+
clearForm();
|
29673
|
+
return [4 /*yield*/, getEmissionData()];
|
29562
29674
|
case 9:
|
29675
|
+
_a.sent();
|
29676
|
+
_a.label = 10;
|
29677
|
+
case 10: return [3 /*break*/, 12];
|
29678
|
+
case 11:
|
29563
29679
|
// eslint-disable-next-line no-use-before-define, @typescript-eslint/no-use-before-define
|
29564
29680
|
setIsFormChanged(false);
|
29565
29681
|
setLoading(false);
|
29566
29682
|
return [7 /*endfinally*/];
|
29567
|
-
case
|
29683
|
+
case 12: return [2 /*return*/];
|
29568
29684
|
}
|
29569
29685
|
});
|
29570
29686
|
}); };
|
@@ -29802,7 +29918,6 @@ var GHGEmissionsComponent = function (props) {
|
|
29802
29918
|
(formValues.fuelCombustionActivities_transport_co2 || 0) +
|
29803
29919
|
(formValues.fuelCombustionActivities_otherSectors_co2 || 0) +
|
29804
29920
|
(formValues.fuelCombustionActivities_nonSpecified_co2 || 0);
|
29805
|
-
console.log('sum triggered', sum);
|
29806
29921
|
setFuelCombustionActivitiesCo2(sum);
|
29807
29922
|
}
|
29808
29923
|
if (panelHeading === 'fugitiveEmissionsFromFuels') {
|
@@ -30134,16 +30249,72 @@ var GHGEmissionsComponent = function (props) {
|
|
30134
30249
|
React.createElement(antd.Col, { xl: 9, md: 9 },
|
30135
30250
|
React.createElement(antd.Row, { gutter: 16, className: "panel-content-input-box-row" },
|
30136
30251
|
React.createElement(antd.Col, { xl: 6 },
|
30137
|
-
React.createElement(antd.Form.Item, { name: panelHeading + '_' + item + '_co2'
|
30252
|
+
React.createElement(antd.Form.Item, { name: panelHeading + '_' + item + '_co2', rules: [
|
30253
|
+
{
|
30254
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
30255
|
+
return __generator(this, function (_a) {
|
30256
|
+
if (value && value < 0) {
|
30257
|
+
throw new Error();
|
30258
|
+
}
|
30259
|
+
if (value && !Number.isInteger(value)) {
|
30260
|
+
throw new Error();
|
30261
|
+
}
|
30262
|
+
return [2 /*return*/];
|
30263
|
+
});
|
30264
|
+
}); },
|
30265
|
+
},
|
30266
|
+
] },
|
30138
30267
|
React.createElement(antd.InputNumber, { onChange: function (event) { return calculateSumCo2(event, panelHeading); } }))),
|
30139
30268
|
React.createElement(antd.Col, { xl: 6 },
|
30140
|
-
React.createElement(antd.Form.Item, { name: panelHeading + '_' + item + '_ch4'
|
30269
|
+
React.createElement(antd.Form.Item, { name: panelHeading + '_' + item + '_ch4', rules: [
|
30270
|
+
{
|
30271
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
30272
|
+
return __generator(this, function (_a) {
|
30273
|
+
if (value && value < 0) {
|
30274
|
+
throw new Error();
|
30275
|
+
}
|
30276
|
+
if (value && !Number.isInteger(value)) {
|
30277
|
+
throw new Error();
|
30278
|
+
}
|
30279
|
+
return [2 /*return*/];
|
30280
|
+
});
|
30281
|
+
}); },
|
30282
|
+
},
|
30283
|
+
] },
|
30141
30284
|
React.createElement(antd.InputNumber, { onChange: function (event) { return calculateSumCh4(event, panelHeading); } }))),
|
30142
30285
|
React.createElement(antd.Col, { xl: 6 },
|
30143
|
-
React.createElement(antd.Form.Item, { name: panelHeading + '_' + item + '_n2o'
|
30286
|
+
React.createElement(antd.Form.Item, { name: panelHeading + '_' + item + '_n2o', rules: [
|
30287
|
+
{
|
30288
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
30289
|
+
return __generator(this, function (_a) {
|
30290
|
+
if (value && value < 0) {
|
30291
|
+
throw new Error();
|
30292
|
+
}
|
30293
|
+
if (value && !Number.isInteger(value)) {
|
30294
|
+
throw new Error();
|
30295
|
+
}
|
30296
|
+
return [2 /*return*/];
|
30297
|
+
});
|
30298
|
+
}); },
|
30299
|
+
},
|
30300
|
+
] },
|
30144
30301
|
React.createElement(antd.InputNumber, { onChange: function (event) { return calculateSumN2o(event, panelHeading); } }))),
|
30145
30302
|
React.createElement(antd.Col, { xl: 6 },
|
30146
|
-
React.createElement(antd.Form.Item, { name: panelHeading + '_' + item + '_co2eq'
|
30303
|
+
React.createElement(antd.Form.Item, { name: panelHeading + '_' + item + '_co2eq', rules: [
|
30304
|
+
{
|
30305
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
30306
|
+
return __generator(this, function (_a) {
|
30307
|
+
if (value && value < 0) {
|
30308
|
+
throw new Error();
|
30309
|
+
}
|
30310
|
+
if (value && !Number.isInteger(value)) {
|
30311
|
+
throw new Error();
|
30312
|
+
}
|
30313
|
+
return [2 /*return*/];
|
30314
|
+
});
|
30315
|
+
}); },
|
30316
|
+
},
|
30317
|
+
] },
|
30147
30318
|
React.createElement(antd.InputNumber, { onChange: function (event) { return calculateSumCo2Eq(event, panelHeading); } }))))))); };
|
30148
30319
|
var renderPanelContentView = function (co2, ch4, n2o, co2eq, item, index) {
|
30149
30320
|
return (React.createElement(antd.Row, { gutter: 16, key: index, className: "panel-content-row" },
|
@@ -30206,7 +30377,7 @@ var GHGEmissionsComponent = function (props) {
|
|
30206
30377
|
var encodedUri = encodeURI("data:text/csv;charset=utf-8,".concat(csvContent));
|
30207
30378
|
var link = document.createElement('a');
|
30208
30379
|
link.setAttribute('href', encodedUri);
|
30209
|
-
link.setAttribute('download', "GHG-Reporting
|
30380
|
+
link.setAttribute('download', "GHG-Reporting-Emissions_".concat(dataToDownload.year, "_V").concat(dataToDownload.version, ".csv"));
|
30210
30381
|
document.body.appendChild(link);
|
30211
30382
|
link.click();
|
30212
30383
|
};
|
@@ -30229,6 +30400,17 @@ var GHGEmissionsComponent = function (props) {
|
|
30229
30400
|
}
|
30230
30401
|
return false;
|
30231
30402
|
};
|
30403
|
+
var canViewForm = function () {
|
30404
|
+
if ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.GOVERNMENT || (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.MINISTRY) {
|
30405
|
+
if ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) === exports.Role.ViewOnly && data.some(function (item) { return item.state === 'SAVED'; })) {
|
30406
|
+
return true;
|
30407
|
+
}
|
30408
|
+
else if ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== exports.Role.ViewOnly) {
|
30409
|
+
return true;
|
30410
|
+
}
|
30411
|
+
}
|
30412
|
+
return false;
|
30413
|
+
};
|
30232
30414
|
return (React.createElement("div", null,
|
30233
30415
|
React.createElement("div", { className: "content-container emission-tab-container" },
|
30234
30416
|
React.createElement("div", { className: "emission-title-bar" },
|
@@ -30237,8 +30419,7 @@ var GHGEmissionsComponent = function (props) {
|
|
30237
30419
|
React.createElement("div", { className: "body-sub-title" }, t("ghgInventory:totalNationalEmissionSubTitle")))),
|
30238
30420
|
React.createElement("div", { className: "content-card add-emission" },
|
30239
30421
|
React.createElement(antd.Tabs, { defaultActiveKey: "Add New", centered: true },
|
30240
|
-
((
|
30241
|
-
(userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.MINISTRY) && (React.createElement(antd.Tabs.TabPane, { key: "Add New", tab: t("ghgInventory:addNew") },
|
30422
|
+
(canViewForm()) && (React.createElement(antd.Tabs.TabPane, { key: "Add New", tab: t("ghgInventory:addNew") },
|
30242
30423
|
React.createElement("div", null,
|
30243
30424
|
React.createElement(antd.Form, { labelCol: { span: 20 }, wrapperCol: { span: 24 }, name: "add-emission", className: "programme-details-form", layout: "vertical", requiredMark: true, form: form, onValuesChange: onValuesChange, onFinish: onOpenSaveFormModel },
|
30244
30425
|
React.createElement(antd.Row, null,
|
@@ -30289,10 +30470,8 @@ var GHGEmissionsComponent = function (props) {
|
|
30289
30470
|
var workbook = XLSX__namespace.read(xldata, { type: 'array' });
|
30290
30471
|
var sheetName = workbook.SheetNames[0];
|
30291
30472
|
var sheet = workbook.Sheets[sheetName];
|
30292
|
-
var
|
30293
|
-
|
30294
|
-
})[0];
|
30295
|
-
if (!validateExcelDataFormat(firstRow)) {
|
30473
|
+
var excelData = XLSX__namespace.utils.sheet_to_json(sheet);
|
30474
|
+
if (!validateExcelDataFormat(sheet, excelData)) {
|
30296
30475
|
antd.message.open({
|
30297
30476
|
type: 'error',
|
30298
30477
|
content: t('ghgInventory:invalidDataInExcel'),
|
@@ -30305,7 +30484,6 @@ var GHGEmissionsComponent = function (props) {
|
|
30305
30484
|
});
|
30306
30485
|
return false;
|
30307
30486
|
}
|
30308
|
-
var excelData = XLSX__namespace.utils.sheet_to_json(sheet);
|
30309
30487
|
handleFileUploadData(excelData);
|
30310
30488
|
setUploadedFileName(file.name);
|
30311
30489
|
}
|
@@ -30375,16 +30553,72 @@ var GHGEmissionsComponent = function (props) {
|
|
30375
30553
|
React.createElement(antd.Col, { xl: 9, md: 9 },
|
30376
30554
|
React.createElement(antd.Row, { gutter: 16, className: "panel-content-input-box-row total-co2-land-input-box-row" },
|
30377
30555
|
React.createElement(antd.Col, { xl: 6 },
|
30378
|
-
React.createElement(antd.Form.Item, { name: "totalCo2WithoutLand_co2"
|
30556
|
+
React.createElement(antd.Form.Item, { name: "totalCo2WithoutLand_co2", rules: [
|
30557
|
+
{
|
30558
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
30559
|
+
return __generator(this, function (_a) {
|
30560
|
+
if (value && value < 0) {
|
30561
|
+
throw new Error();
|
30562
|
+
}
|
30563
|
+
if (value && !Number.isInteger(value)) {
|
30564
|
+
throw new Error();
|
30565
|
+
}
|
30566
|
+
return [2 /*return*/];
|
30567
|
+
});
|
30568
|
+
}); },
|
30569
|
+
},
|
30570
|
+
] },
|
30379
30571
|
React.createElement(antd.InputNumber, null))),
|
30380
30572
|
React.createElement(antd.Col, { xl: 6 },
|
30381
|
-
React.createElement(antd.Form.Item, { name: "totalCo2WithoutLand_ch4"
|
30573
|
+
React.createElement(antd.Form.Item, { name: "totalCo2WithoutLand_ch4", rules: [
|
30574
|
+
{
|
30575
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
30576
|
+
return __generator(this, function (_a) {
|
30577
|
+
if (value && value < 0) {
|
30578
|
+
throw new Error();
|
30579
|
+
}
|
30580
|
+
if (value && !Number.isInteger(value)) {
|
30581
|
+
throw new Error();
|
30582
|
+
}
|
30583
|
+
return [2 /*return*/];
|
30584
|
+
});
|
30585
|
+
}); },
|
30586
|
+
},
|
30587
|
+
] },
|
30382
30588
|
React.createElement(antd.InputNumber, null))),
|
30383
30589
|
React.createElement(antd.Col, { xl: 6 },
|
30384
|
-
React.createElement(antd.Form.Item, { name: "totalCo2WithoutLand_n2o"
|
30590
|
+
React.createElement(antd.Form.Item, { name: "totalCo2WithoutLand_n2o", rules: [
|
30591
|
+
{
|
30592
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
30593
|
+
return __generator(this, function (_a) {
|
30594
|
+
if (value && value < 0) {
|
30595
|
+
throw new Error();
|
30596
|
+
}
|
30597
|
+
if (value && !Number.isInteger(value)) {
|
30598
|
+
throw new Error();
|
30599
|
+
}
|
30600
|
+
return [2 /*return*/];
|
30601
|
+
});
|
30602
|
+
}); },
|
30603
|
+
},
|
30604
|
+
] },
|
30385
30605
|
React.createElement(antd.InputNumber, null))),
|
30386
30606
|
React.createElement(antd.Col, { xl: 6 },
|
30387
|
-
React.createElement(antd.Form.Item, { name: "totalCo2WithoutLand_co2eq"
|
30607
|
+
React.createElement(antd.Form.Item, { name: "totalCo2WithoutLand_co2eq", rules: [
|
30608
|
+
{
|
30609
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
30610
|
+
return __generator(this, function (_a) {
|
30611
|
+
if (value && value < 0) {
|
30612
|
+
throw new Error();
|
30613
|
+
}
|
30614
|
+
if (value && !Number.isInteger(value)) {
|
30615
|
+
throw new Error();
|
30616
|
+
}
|
30617
|
+
return [2 /*return*/];
|
30618
|
+
});
|
30619
|
+
}); },
|
30620
|
+
},
|
30621
|
+
] },
|
30388
30622
|
React.createElement(antd.InputNumber, null)))))),
|
30389
30623
|
React.createElement(antd.Row, { gutter: 16, key: 'totalCo2WithLand', className: "total-co2-with-land-row" },
|
30390
30624
|
React.createElement(antd.Col, { xl: 12, md: 12, className: "total-co2-with-land-title" },
|
@@ -30392,22 +30626,80 @@ var GHGEmissionsComponent = function (props) {
|
|
30392
30626
|
React.createElement(antd.Col, { xl: 9, md: 9 },
|
30393
30627
|
React.createElement(antd.Row, { gutter: 16, className: "panel-content-input-box-row total-co2-land-input-box-row" },
|
30394
30628
|
React.createElement(antd.Col, { xl: 6 },
|
30395
|
-
React.createElement(antd.Form.Item, { name: "totalCo2WithLand_co2"
|
30629
|
+
React.createElement(antd.Form.Item, { name: "totalCo2WithLand_co2", rules: [
|
30630
|
+
{
|
30631
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
30632
|
+
return __generator(this, function (_a) {
|
30633
|
+
if (value && value < 0) {
|
30634
|
+
throw new Error();
|
30635
|
+
}
|
30636
|
+
if (value && !Number.isInteger(value)) {
|
30637
|
+
throw new Error();
|
30638
|
+
}
|
30639
|
+
return [2 /*return*/];
|
30640
|
+
});
|
30641
|
+
}); },
|
30642
|
+
},
|
30643
|
+
] },
|
30396
30644
|
React.createElement(antd.InputNumber, null))),
|
30397
30645
|
React.createElement(antd.Col, { xl: 6 },
|
30398
|
-
React.createElement(antd.Form.Item, { name: "totalCo2WithLand_ch4"
|
30646
|
+
React.createElement(antd.Form.Item, { name: "totalCo2WithLand_ch4", rules: [
|
30647
|
+
{
|
30648
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
30649
|
+
return __generator(this, function (_a) {
|
30650
|
+
if (value && value < 0) {
|
30651
|
+
throw new Error();
|
30652
|
+
}
|
30653
|
+
if (value && !Number.isInteger(value)) {
|
30654
|
+
throw new Error();
|
30655
|
+
}
|
30656
|
+
return [2 /*return*/];
|
30657
|
+
});
|
30658
|
+
}); },
|
30659
|
+
},
|
30660
|
+
] },
|
30399
30661
|
React.createElement(antd.InputNumber, null))),
|
30400
30662
|
React.createElement(antd.Col, { xl: 6 },
|
30401
|
-
React.createElement(antd.Form.Item, { name: "totalCo2WithLand_n2o"
|
30663
|
+
React.createElement(antd.Form.Item, { name: "totalCo2WithLand_n2o", rules: [
|
30664
|
+
{
|
30665
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
30666
|
+
return __generator(this, function (_a) {
|
30667
|
+
if (value && value < 0) {
|
30668
|
+
throw new Error();
|
30669
|
+
}
|
30670
|
+
if (value && !Number.isInteger(value)) {
|
30671
|
+
throw new Error();
|
30672
|
+
}
|
30673
|
+
return [2 /*return*/];
|
30674
|
+
});
|
30675
|
+
}); },
|
30676
|
+
},
|
30677
|
+
] },
|
30402
30678
|
React.createElement(antd.InputNumber, null))),
|
30403
30679
|
React.createElement(antd.Col, { xl: 6 },
|
30404
|
-
React.createElement(antd.Form.Item, { name: "totalCo2WithLand_co2eq"
|
30680
|
+
React.createElement(antd.Form.Item, { name: "totalCo2WithLand_co2eq", rules: [
|
30681
|
+
{
|
30682
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
30683
|
+
return __generator(this, function (_a) {
|
30684
|
+
if (value && value < 0) {
|
30685
|
+
throw new Error();
|
30686
|
+
}
|
30687
|
+
if (value && !Number.isInteger(value)) {
|
30688
|
+
throw new Error();
|
30689
|
+
}
|
30690
|
+
return [2 /*return*/];
|
30691
|
+
});
|
30692
|
+
}); },
|
30693
|
+
},
|
30694
|
+
] },
|
30405
30695
|
React.createElement(antd.InputNumber, null)))))),
|
30406
|
-
|
30407
|
-
(userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.
|
30408
|
-
|
30409
|
-
|
30410
|
-
|
30696
|
+
(((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.GOVERNMENT || (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.MINISTRY)
|
30697
|
+
&& ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== exports.Role.ViewOnly)) &&
|
30698
|
+
(React.createElement("div", { className: "steps-actions" },
|
30699
|
+
(userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.GOVERNMENT &&
|
30700
|
+
(React.createElement(antd.Button, { className: "finalize-btn", type: "primary", loading: loading, onClick: onOpenFinalizeFormModel }, "Finalise")),
|
30701
|
+
React.createElement(antd.Button, { className: "submit-btn", type: "primary", onClick: onOpenSaveFormModel, loading: loading }, "Submit"),
|
30702
|
+
React.createElement(antd.Button, { className: "back-btn", onClick: onOpenResetFormModel, loading: loading }, "Cancel"))))))),
|
30411
30703
|
data.map(function (tabData) {
|
30412
30704
|
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;
|
30413
30705
|
return tabData.state === 'FINALIZED' && (React.createElement(antd.Tabs.TabPane, { className: 'view-data-panel', key: tabData.id.toString(), tab: React.createElement("span", null,
|
@@ -30423,7 +30715,7 @@ var GHGEmissionsComponent = function (props) {
|
|
30423
30715
|
React.createElement(antd.Row, { className: "add-new-upload-file-label" }, t("ghgInventory:emissionRemovalDocument")),
|
30424
30716
|
React.createElement(antd.Row, null,
|
30425
30717
|
React.createElement(antd.Col, { xl: 15, md: 15, className: "view-download-file-name-input" },
|
30426
|
-
React.createElement(antd.Input, { value: "GHG-Reporting
|
30718
|
+
React.createElement(antd.Input, { value: "GHG-Reporting-Emissions_".concat(tabData.year, "_V").concat(tabData.version, ".csv"), disabled: true })),
|
30427
30719
|
React.createElement(antd.Col, { xl: 5, md: 5, className: "view-download-file-inner-col" },
|
30428
30720
|
React.createElement(antd.Button, { icon: React.createElement(icons.DownloadOutlined, null), onClick: function () { downloadCSV(tabData); } }, t("ghgInventory:download")))))),
|
30429
30721
|
React.createElement(antd.Row, { gutter: 16 },
|
@@ -30612,31 +30904,38 @@ var GHGProjectionsComponent = function (props) {
|
|
30612
30904
|
var createSetFieldObject = function (obj, objName) {
|
30613
30905
|
var result = {};
|
30614
30906
|
for (var key in obj) {
|
30615
|
-
console.log('key', key);
|
30616
30907
|
var energyEmissionsSub = obj[key];
|
30617
30908
|
for (var childKey in energyEmissionsSub) {
|
30618
30909
|
if (typeof energyEmissionsSub[childKey] === 'object') {
|
30619
|
-
console.log('energyEmissionsSub', energyEmissionsSub);
|
30620
30910
|
for (var category in energyEmissionsSub) {
|
30621
|
-
console.log('category', category);
|
30622
30911
|
var subcategory = energyEmissionsSub[category];
|
30623
30912
|
for (var gas in subcategory) {
|
30624
|
-
result["".concat(key, "_").concat(category, "_").concat(gas)] = subcategory[gas];
|
30913
|
+
result["".concat(key, "_").concat(category, "_").concat(gas)] = !isNaN(subcategory[gas]) ? subcategory[gas] : 0;
|
30625
30914
|
}
|
30626
30915
|
}
|
30627
30916
|
}
|
30628
30917
|
else {
|
30629
30918
|
for (var gas in energyEmissionsSub) {
|
30630
|
-
result["".concat(objName, "_").concat(key, "_").concat(gas)] = energyEmissionsSub[gas];
|
30919
|
+
result["".concat(objName, "_").concat(key, "_").concat(gas)] = !isNaN(energyEmissionsSub[gas]) ? energyEmissionsSub[gas] : 0;
|
30631
30920
|
}
|
30632
30921
|
}
|
30633
30922
|
}
|
30634
30923
|
}
|
30635
30924
|
return result;
|
30636
30925
|
};
|
30637
|
-
var validateExcelDataFormat = function (
|
30926
|
+
var validateExcelDataFormat = function (sheet, excelData) {
|
30927
|
+
var sheetHeadings = XLSX__namespace.utils.sheet_to_json(sheet, {
|
30928
|
+
header: 1,
|
30929
|
+
})[0];
|
30638
30930
|
var columnHeadings = ['Sector', 'Business As Usual', 'Conditional NDC', 'Unconditional NDC'];
|
30639
|
-
|
30931
|
+
if (!columnHeadings.every(function (element) { return sheetHeadings.includes(element); })) {
|
30932
|
+
return false;
|
30933
|
+
}
|
30934
|
+
var sectorValues = excelData.map(function (excelDataObj) { return excelDataObj.Sector; });
|
30935
|
+
if (!excelFields.every(function (element) { return sectorValues.includes(element); })) {
|
30936
|
+
return false;
|
30937
|
+
}
|
30938
|
+
return true;
|
30640
30939
|
};
|
30641
30940
|
var populateFormWithUploadedFile = function (excelData, keyPrefix) {
|
30642
30941
|
var emissions = {};
|
@@ -30713,12 +31012,13 @@ var GHGProjectionsComponent = function (props) {
|
|
30713
31012
|
var sum = 0;
|
30714
31013
|
for (var key in obj) {
|
30715
31014
|
if (key === conditionType) {
|
30716
|
-
sum += obj[key];
|
31015
|
+
sum += Number.isInteger(obj[key]) ? obj[key] : 0;
|
30717
31016
|
}
|
30718
31017
|
else if (typeof obj[key] === 'object' &&
|
30719
31018
|
key !== 'totalCo2WithLand' &&
|
30720
31019
|
key !== 'totalCo2WithoutLand') {
|
30721
|
-
|
31020
|
+
var calculatedSum = calculateSumEmissionView(obj[key], conditionType);
|
31021
|
+
sum += Number.isInteger(calculatedSum) ? calculatedSum : 0;
|
30722
31022
|
}
|
30723
31023
|
}
|
30724
31024
|
return sum;
|
@@ -30996,19 +31296,6 @@ var GHGProjectionsComponent = function (props) {
|
|
30996
31296
|
setOpenResetFormModal(false);
|
30997
31297
|
};
|
30998
31298
|
var onOpenResetFormModel = function () {
|
30999
|
-
setActionInfo({
|
31000
|
-
action: "".concat(t('ghgInventory:proceed')),
|
31001
|
-
headerText: "".concat(t('ghgInventory:discardHeaderText')),
|
31002
|
-
type: 'danger',
|
31003
|
-
icon: React.createElement(icons.CloseCircleOutlined, null),
|
31004
|
-
});
|
31005
|
-
setErrorMsg('');
|
31006
|
-
setOpenResetFormModal(true);
|
31007
|
-
};
|
31008
|
-
var onSaveFormCanceled = function () {
|
31009
|
-
setOpenSaveFormModal(false);
|
31010
|
-
};
|
31011
|
-
var onOpenSaveFormModel = function () {
|
31012
31299
|
if (!isFormChanged) {
|
31013
31300
|
antd.message.open({
|
31014
31301
|
type: 'error',
|
@@ -31019,34 +31306,98 @@ var GHGProjectionsComponent = function (props) {
|
|
31019
31306
|
}
|
31020
31307
|
else {
|
31021
31308
|
setActionInfo({
|
31022
|
-
action: "".concat(t(
|
31023
|
-
headerText: "".concat(t(
|
31024
|
-
type:
|
31025
|
-
icon: React.createElement(icons.
|
31309
|
+
action: "".concat(t('ghgInventory:proceed')),
|
31310
|
+
headerText: "".concat(t('ghgInventory:discardHeaderText')),
|
31311
|
+
type: 'danger',
|
31312
|
+
icon: React.createElement(icons.CloseCircleOutlined, null),
|
31026
31313
|
});
|
31027
31314
|
setErrorMsg('');
|
31028
|
-
|
31315
|
+
setOpenResetFormModal(true);
|
31029
31316
|
}
|
31030
31317
|
};
|
31318
|
+
var onSaveFormCanceled = function () {
|
31319
|
+
setOpenSaveFormModal(false);
|
31320
|
+
};
|
31321
|
+
var onOpenSaveFormModel = function () {
|
31322
|
+
var _a = form.getFieldsValue(true); _a.year; var rest = __rest(_a, ["year"]);
|
31323
|
+
var otherFieldsNegativeValue = Object.values(rest).some(function (value) {
|
31324
|
+
return typeof value === 'number' && value < 0;
|
31325
|
+
});
|
31326
|
+
form
|
31327
|
+
.validateFields()
|
31328
|
+
.then(function (values) {
|
31329
|
+
if (!isFormChanged) {
|
31330
|
+
antd.message.open({
|
31331
|
+
type: 'error',
|
31332
|
+
content: t('ghgInventory:formNotChanged'),
|
31333
|
+
duration: 4,
|
31334
|
+
style: { textAlign: 'right', marginRight: 15, marginTop: 10 },
|
31335
|
+
});
|
31336
|
+
}
|
31337
|
+
else {
|
31338
|
+
setActionInfo({
|
31339
|
+
action: "".concat(t("ghgInventory:submit")),
|
31340
|
+
headerText: "".concat(t("ghgInventory:submitModelHeader")),
|
31341
|
+
type: "primary",
|
31342
|
+
icon: React.createElement(icons.CheckCircleOutlined, null),
|
31343
|
+
});
|
31344
|
+
setErrorMsg('');
|
31345
|
+
setOpenSaveFormModal(true);
|
31346
|
+
}
|
31347
|
+
})
|
31348
|
+
.catch(function (errorInfo) {
|
31349
|
+
if (otherFieldsNegativeValue) {
|
31350
|
+
antd.message.open({
|
31351
|
+
type: 'error',
|
31352
|
+
content: t('ghgInventory:negativeValuesNotAllowed'),
|
31353
|
+
duration: 4,
|
31354
|
+
style: { textAlign: 'right', marginRight: 15, marginTop: 10 },
|
31355
|
+
});
|
31356
|
+
}
|
31357
|
+
});
|
31358
|
+
};
|
31031
31359
|
var onFinalizeFormCanceled = function () {
|
31032
31360
|
setOpenFinalizeFormModal(false);
|
31033
31361
|
};
|
31034
31362
|
var onOpenFinalizeFormModel = function () {
|
31363
|
+
var _a = form.getFieldsValue(true); _a.year; var rest = __rest(_a, ["year"]);
|
31364
|
+
var otherFieldsEmpty = Object.values(rest).every(function (value) { return !value; });
|
31365
|
+
var otherFieldsNegativeValue = Object.values(rest).some(function (value) {
|
31366
|
+
return typeof value === 'number' && value < 0;
|
31367
|
+
});
|
31035
31368
|
form
|
31036
31369
|
.validateFields()
|
31037
31370
|
.then(function (values) {
|
31038
31371
|
// Validation successful, set ActionInfo and open the form modal
|
31039
|
-
|
31040
|
-
|
31041
|
-
|
31042
|
-
|
31043
|
-
|
31044
|
-
|
31045
|
-
|
31046
|
-
|
31372
|
+
if (otherFieldsEmpty) {
|
31373
|
+
antd.message.open({
|
31374
|
+
type: 'error',
|
31375
|
+
content: t('ghgInventory:cannotFinaliseEmpty'),
|
31376
|
+
duration: 4,
|
31377
|
+
style: { textAlign: 'right', marginRight: 15, marginTop: 10 },
|
31378
|
+
});
|
31379
|
+
}
|
31380
|
+
else {
|
31381
|
+
setActionInfo({
|
31382
|
+
action: "".concat(t("ghgInventory:finalize")),
|
31383
|
+
headerText: "".concat(t("ghgInventory:finalizeModelHeader")),
|
31384
|
+
type: "primary",
|
31385
|
+
icon: React.createElement(Icon.ClipboardCheck, null),
|
31386
|
+
});
|
31387
|
+
setErrorMsg('');
|
31388
|
+
setOpenFinalizeFormModal(true);
|
31389
|
+
}
|
31047
31390
|
})
|
31048
31391
|
.catch(function (errorInfo) {
|
31049
31392
|
// Validation failed
|
31393
|
+
if (otherFieldsNegativeValue) {
|
31394
|
+
antd.message.open({
|
31395
|
+
type: 'error',
|
31396
|
+
content: t('ghgInventory:negativeValuesNotAllowed'),
|
31397
|
+
duration: 4,
|
31398
|
+
style: { textAlign: 'right', marginRight: 15, marginTop: 10 },
|
31399
|
+
});
|
31400
|
+
}
|
31050
31401
|
console.log('Validation failed:', errorInfo);
|
31051
31402
|
});
|
31052
31403
|
};
|
@@ -31110,7 +31461,7 @@ var GHGProjectionsComponent = function (props) {
|
|
31110
31461
|
setLoading(true);
|
31111
31462
|
_a.label = 2;
|
31112
31463
|
case 2:
|
31113
|
-
_a.trys.push([2, 6,
|
31464
|
+
_a.trys.push([2, 6, 11, 12]);
|
31114
31465
|
return [4 /*yield*/, post('national/projections', payload)];
|
31115
31466
|
case 3:
|
31116
31467
|
response = _a.sent();
|
@@ -31137,7 +31488,7 @@ var GHGProjectionsComponent = function (props) {
|
|
31137
31488
|
case 4:
|
31138
31489
|
_a.sent();
|
31139
31490
|
_a.label = 5;
|
31140
|
-
case 5: return [3 /*break*/,
|
31491
|
+
case 5: return [3 /*break*/, 12];
|
31141
31492
|
case 6:
|
31142
31493
|
error_2 = _a.sent();
|
31143
31494
|
console.log('Error in projection creation - ', error_2);
|
@@ -31149,19 +31500,31 @@ var GHGProjectionsComponent = function (props) {
|
|
31149
31500
|
duration: 4,
|
31150
31501
|
style: { textAlign: 'right', marginRight: 15, marginTop: 10 },
|
31151
31502
|
});
|
31152
|
-
if (!(error_2.
|
31503
|
+
if (!(error_2.status === axios.HttpStatusCode.Conflict.valueOf())) return [3 /*break*/, 8];
|
31153
31504
|
return [4 /*yield*/, getProjectionData()];
|
31154
31505
|
case 7:
|
31155
31506
|
_a.sent();
|
31507
|
+
setIsSavedFormDataSet(false);
|
31508
|
+
clearUploadDoc();
|
31509
|
+
if (!isPendingFinalization) {
|
31510
|
+
clearForm();
|
31511
|
+
}
|
31512
|
+
return [3 /*break*/, 10];
|
31513
|
+
case 8:
|
31514
|
+
if (!(error_2.status === axios.HttpStatusCode.Forbidden.valueOf())) return [3 /*break*/, 10];
|
31156
31515
|
clearUploadDoc();
|
31157
|
-
|
31158
|
-
|
31516
|
+
clearForm();
|
31517
|
+
return [4 /*yield*/, getProjectionData()];
|
31159
31518
|
case 9:
|
31519
|
+
_a.sent();
|
31520
|
+
_a.label = 10;
|
31521
|
+
case 10: return [3 /*break*/, 12];
|
31522
|
+
case 11:
|
31160
31523
|
// eslint-disable-next-line no-use-before-define, @typescript-eslint/no-use-before-define
|
31161
31524
|
setIsFormChanged(false);
|
31162
31525
|
setLoading(false);
|
31163
31526
|
return [7 /*endfinally*/];
|
31164
|
-
case
|
31527
|
+
case 12: return [2 /*return*/];
|
31165
31528
|
}
|
31166
31529
|
});
|
31167
31530
|
}); };
|
@@ -31590,13 +31953,55 @@ var GHGProjectionsComponent = function (props) {
|
|
31590
31953
|
React.createElement(antd.Col, { xl: 9, md: 9 },
|
31591
31954
|
React.createElement(antd.Row, { gutter: 16, className: "panel-content-input-box-row" },
|
31592
31955
|
React.createElement(antd.Col, { xl: 7 },
|
31593
|
-
React.createElement(antd.Form.Item, { name: panelHeading + '_' + item + '_bau'
|
31956
|
+
React.createElement(antd.Form.Item, { name: panelHeading + '_' + item + '_bau', rules: [
|
31957
|
+
{
|
31958
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
31959
|
+
return __generator(this, function (_a) {
|
31960
|
+
if (value && value < 0) {
|
31961
|
+
throw new Error();
|
31962
|
+
}
|
31963
|
+
if (value && !Number.isInteger(value)) {
|
31964
|
+
throw new Error();
|
31965
|
+
}
|
31966
|
+
return [2 /*return*/];
|
31967
|
+
});
|
31968
|
+
}); },
|
31969
|
+
},
|
31970
|
+
] },
|
31594
31971
|
React.createElement(antd.InputNumber, { onChange: function (event) { return calculateSumBau(event, panelHeading); } }))),
|
31595
31972
|
React.createElement(antd.Col, { xl: 7 },
|
31596
|
-
React.createElement(antd.Form.Item, { name: panelHeading + '_' + item + '_conditionalNdc'
|
31973
|
+
React.createElement(antd.Form.Item, { name: panelHeading + '_' + item + '_conditionalNdc', rules: [
|
31974
|
+
{
|
31975
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
31976
|
+
return __generator(this, function (_a) {
|
31977
|
+
if (value && value < 0) {
|
31978
|
+
throw new Error();
|
31979
|
+
}
|
31980
|
+
if (value && !Number.isInteger(value)) {
|
31981
|
+
throw new Error();
|
31982
|
+
}
|
31983
|
+
return [2 /*return*/];
|
31984
|
+
});
|
31985
|
+
}); },
|
31986
|
+
},
|
31987
|
+
] },
|
31597
31988
|
React.createElement(antd.InputNumber, { onChange: function (event) { return calculateSumConditionalNdc(event, panelHeading); } }))),
|
31598
31989
|
React.createElement(antd.Col, { xl: 7 },
|
31599
|
-
React.createElement(antd.Form.Item, { name: panelHeading + '_' + item + '_unconditionalNdc'
|
31990
|
+
React.createElement(antd.Form.Item, { name: panelHeading + '_' + item + '_unconditionalNdc', rules: [
|
31991
|
+
{
|
31992
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
31993
|
+
return __generator(this, function (_a) {
|
31994
|
+
if (value && value < 0) {
|
31995
|
+
throw new Error();
|
31996
|
+
}
|
31997
|
+
if (value && !Number.isInteger(value)) {
|
31998
|
+
throw new Error();
|
31999
|
+
}
|
32000
|
+
return [2 /*return*/];
|
32001
|
+
});
|
32002
|
+
}); },
|
32003
|
+
},
|
32004
|
+
] },
|
31600
32005
|
React.createElement(antd.InputNumber, { onChange: function (event) { return calculateSumUnconditionalNdc(event, panelHeading); } }))))))); };
|
31601
32006
|
var renderPanelContentView = function (bau, conditionalNdc, unconditionalNdc, item, index) {
|
31602
32007
|
return (React.createElement(antd.Row, { gutter: 16, key: index, className: "panel-content-row" },
|
@@ -31656,7 +32061,7 @@ var GHGProjectionsComponent = function (props) {
|
|
31656
32061
|
var encodedUri = encodeURI("data:text/csv;charset=utf-8,".concat(csvContent));
|
31657
32062
|
var link = document.createElement('a');
|
31658
32063
|
link.setAttribute('href', encodedUri);
|
31659
|
-
link.setAttribute('download', "GHG-Reporting
|
32064
|
+
link.setAttribute('download', "GHG-Reporting-Projections_".concat(dataToDownload.year, "_V").concat(dataToDownload.version, ".csv"));
|
31660
32065
|
document.body.appendChild(link);
|
31661
32066
|
link.click();
|
31662
32067
|
};
|
@@ -31678,6 +32083,17 @@ var GHGProjectionsComponent = function (props) {
|
|
31678
32083
|
}
|
31679
32084
|
return false;
|
31680
32085
|
};
|
32086
|
+
var canViewForm = function () {
|
32087
|
+
if ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.GOVERNMENT || (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.MINISTRY) {
|
32088
|
+
if ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) === exports.Role.ViewOnly && data.some(function (item) { return item.state === 'SAVED'; })) {
|
32089
|
+
return true;
|
32090
|
+
}
|
32091
|
+
else if ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== exports.Role.ViewOnly) {
|
32092
|
+
return true;
|
32093
|
+
}
|
32094
|
+
}
|
32095
|
+
return false;
|
32096
|
+
};
|
31681
32097
|
return (React.createElement("div", null,
|
31682
32098
|
React.createElement("div", { className: "content-container projection-tab-container" },
|
31683
32099
|
React.createElement("div", { className: "projection-title-bar" },
|
@@ -31686,8 +32102,7 @@ var GHGProjectionsComponent = function (props) {
|
|
31686
32102
|
React.createElement("div", { className: "body-sub-title" }, t("ghgInventory:totalNationalEmissionSubTitle")))),
|
31687
32103
|
React.createElement("div", { className: "content-card add-projection" },
|
31688
32104
|
React.createElement(antd.Tabs, { defaultActiveKey: "Add New", centered: true },
|
31689
|
-
((
|
31690
|
-
(userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.MINISTRY) && (React.createElement(antd.Tabs.TabPane, { key: "Add New", tab: t("ghgInventory:addNew") },
|
32105
|
+
(canViewForm()) && (React.createElement(antd.Tabs.TabPane, { key: "Add New", tab: t("ghgInventory:addNew") },
|
31691
32106
|
React.createElement("div", null,
|
31692
32107
|
React.createElement(antd.Form, { labelCol: { span: 20 }, wrapperCol: { span: 24 }, name: "add-projection", className: "programme-details-form", layout: "vertical", requiredMark: true, form: form, onValuesChange: onValuesChange, onFinish: onOpenSaveFormModel },
|
31693
32108
|
React.createElement(antd.Row, null,
|
@@ -31737,10 +32152,8 @@ var GHGProjectionsComponent = function (props) {
|
|
31737
32152
|
var workbook = XLSX__namespace.read(xldata, { type: 'array' });
|
31738
32153
|
var sheetName = workbook.SheetNames[0];
|
31739
32154
|
var sheet = workbook.Sheets[sheetName];
|
31740
|
-
var
|
31741
|
-
|
31742
|
-
})[0];
|
31743
|
-
if (!validateExcelDataFormat(firstRow)) {
|
32155
|
+
var excelData = XLSX__namespace.utils.sheet_to_json(sheet);
|
32156
|
+
if (!validateExcelDataFormat(sheet, excelData)) {
|
31744
32157
|
antd.message.open({
|
31745
32158
|
type: 'error',
|
31746
32159
|
content: t('ghgInventory:invalidDataInExcel'),
|
@@ -31753,7 +32166,6 @@ var GHGProjectionsComponent = function (props) {
|
|
31753
32166
|
});
|
31754
32167
|
return false;
|
31755
32168
|
}
|
31756
|
-
var excelData = XLSX__namespace.utils.sheet_to_json(sheet);
|
31757
32169
|
handleFileUploadData(excelData);
|
31758
32170
|
setUploadedFileName(file.name);
|
31759
32171
|
}
|
@@ -31812,13 +32224,55 @@ var GHGProjectionsComponent = function (props) {
|
|
31812
32224
|
React.createElement(antd.Col, { xl: 9, md: 9 },
|
31813
32225
|
React.createElement(antd.Row, { gutter: 16, className: "panel-content-input-box-row total-co2-land-input-box-row" },
|
31814
32226
|
React.createElement(antd.Col, { xl: 7 },
|
31815
|
-
React.createElement(antd.Form.Item, { name: "totalCo2WithoutLand_bau"
|
32227
|
+
React.createElement(antd.Form.Item, { name: "totalCo2WithoutLand_bau", rules: [
|
32228
|
+
{
|
32229
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
32230
|
+
return __generator(this, function (_a) {
|
32231
|
+
if (value && value < 0) {
|
32232
|
+
throw new Error();
|
32233
|
+
}
|
32234
|
+
if (value && !Number.isInteger(value)) {
|
32235
|
+
throw new Error();
|
32236
|
+
}
|
32237
|
+
return [2 /*return*/];
|
32238
|
+
});
|
32239
|
+
}); },
|
32240
|
+
},
|
32241
|
+
] },
|
31816
32242
|
React.createElement(antd.InputNumber, null))),
|
31817
32243
|
React.createElement(antd.Col, { xl: 7 },
|
31818
|
-
React.createElement(antd.Form.Item, { name: "totalCo2WithoutLand_conditionalNdc"
|
32244
|
+
React.createElement(antd.Form.Item, { name: "totalCo2WithoutLand_conditionalNdc", rules: [
|
32245
|
+
{
|
32246
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
32247
|
+
return __generator(this, function (_a) {
|
32248
|
+
if (value && value < 0) {
|
32249
|
+
throw new Error();
|
32250
|
+
}
|
32251
|
+
if (value && !Number.isInteger(value)) {
|
32252
|
+
throw new Error();
|
32253
|
+
}
|
32254
|
+
return [2 /*return*/];
|
32255
|
+
});
|
32256
|
+
}); },
|
32257
|
+
},
|
32258
|
+
] },
|
31819
32259
|
React.createElement(antd.InputNumber, null))),
|
31820
32260
|
React.createElement(antd.Col, { xl: 7 },
|
31821
|
-
React.createElement(antd.Form.Item, { name: "totalCo2WithoutLand_unconditionalNdc"
|
32261
|
+
React.createElement(antd.Form.Item, { name: "totalCo2WithoutLand_unconditionalNdc", rules: [
|
32262
|
+
{
|
32263
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
32264
|
+
return __generator(this, function (_a) {
|
32265
|
+
if (value && value < 0) {
|
32266
|
+
throw new Error();
|
32267
|
+
}
|
32268
|
+
if (value && !Number.isInteger(value)) {
|
32269
|
+
throw new Error();
|
32270
|
+
}
|
32271
|
+
return [2 /*return*/];
|
32272
|
+
});
|
32273
|
+
}); },
|
32274
|
+
},
|
32275
|
+
] },
|
31822
32276
|
React.createElement(antd.InputNumber, null)))))),
|
31823
32277
|
React.createElement(antd.Row, { gutter: 16, key: 'totalCo2WithLand', className: "total-co2-with-land-row" },
|
31824
32278
|
React.createElement(antd.Col, { xl: 12, md: 12, className: "total-co2-with-land-title" },
|
@@ -31826,19 +32280,63 @@ var GHGProjectionsComponent = function (props) {
|
|
31826
32280
|
React.createElement(antd.Col, { xl: 9, md: 9 },
|
31827
32281
|
React.createElement(antd.Row, { gutter: 16, className: "panel-content-input-box-row total-co2-land-input-box-row" },
|
31828
32282
|
React.createElement(antd.Col, { xl: 7 },
|
31829
|
-
React.createElement(antd.Form.Item, { name: "totalCo2WithLand_bau"
|
32283
|
+
React.createElement(antd.Form.Item, { name: "totalCo2WithLand_bau", rules: [
|
32284
|
+
{
|
32285
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
32286
|
+
return __generator(this, function (_a) {
|
32287
|
+
if (value && value < 0) {
|
32288
|
+
throw new Error();
|
32289
|
+
}
|
32290
|
+
if (value && !Number.isInteger(value)) {
|
32291
|
+
throw new Error();
|
32292
|
+
}
|
32293
|
+
return [2 /*return*/];
|
32294
|
+
});
|
32295
|
+
}); },
|
32296
|
+
},
|
32297
|
+
] },
|
31830
32298
|
React.createElement(antd.InputNumber, null))),
|
31831
32299
|
React.createElement(antd.Col, { xl: 7 },
|
31832
|
-
React.createElement(antd.Form.Item, { name: "totalCo2WithLand_conditionalNdc"
|
32300
|
+
React.createElement(antd.Form.Item, { name: "totalCo2WithLand_conditionalNdc", rules: [
|
32301
|
+
{
|
32302
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
32303
|
+
return __generator(this, function (_a) {
|
32304
|
+
if (value && value < 0) {
|
32305
|
+
throw new Error();
|
32306
|
+
}
|
32307
|
+
if (value && !Number.isInteger(value)) {
|
32308
|
+
throw new Error();
|
32309
|
+
}
|
32310
|
+
return [2 /*return*/];
|
32311
|
+
});
|
32312
|
+
}); },
|
32313
|
+
},
|
32314
|
+
] },
|
31833
32315
|
React.createElement(antd.InputNumber, null))),
|
31834
32316
|
React.createElement(antd.Col, { xl: 7 },
|
31835
|
-
React.createElement(antd.Form.Item, { name: "totalCo2WithLand_unconditionalNdc"
|
32317
|
+
React.createElement(antd.Form.Item, { name: "totalCo2WithLand_unconditionalNdc", rules: [
|
32318
|
+
{
|
32319
|
+
validator: function (rule, value) { return __awaiter(void 0, void 0, void 0, function () {
|
32320
|
+
return __generator(this, function (_a) {
|
32321
|
+
if (value && value < 0) {
|
32322
|
+
throw new Error();
|
32323
|
+
}
|
32324
|
+
if (value && !Number.isInteger(value)) {
|
32325
|
+
throw new Error();
|
32326
|
+
}
|
32327
|
+
return [2 /*return*/];
|
32328
|
+
});
|
32329
|
+
}); },
|
32330
|
+
},
|
32331
|
+
] },
|
31836
32332
|
React.createElement(antd.InputNumber, null)))))),
|
31837
|
-
|
31838
|
-
(userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.
|
31839
|
-
|
31840
|
-
|
31841
|
-
|
32333
|
+
(((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.GOVERNMENT || (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.MINISTRY)
|
32334
|
+
&& ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== exports.Role.ViewOnly)) &&
|
32335
|
+
(React.createElement("div", { className: "steps-actions" },
|
32336
|
+
(userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.GOVERNMENT &&
|
32337
|
+
(React.createElement(antd.Button, { className: "finalize-btn", type: "primary", loading: loading, onClick: onOpenFinalizeFormModel }, "Finalise")),
|
32338
|
+
React.createElement(antd.Button, { className: "submit-btn", type: "primary", onClick: onOpenSaveFormModel, loading: loading }, "Submit"),
|
32339
|
+
React.createElement(antd.Button, { className: "back-btn", onClick: onOpenResetFormModel, loading: loading }, "Cancel"))))))),
|
31842
32340
|
data.map(function (tabData) {
|
31843
32341
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
31844
32342
|
return tabData.state === 'FINALIZED' && (React.createElement(antd.Tabs.TabPane, { className: 'view-data-panel', key: tabData.id.toString(), tab: React.createElement("span", null,
|
@@ -31858,7 +32356,7 @@ var GHGProjectionsComponent = function (props) {
|
|
31858
32356
|
React.createElement(antd.Row, { className: "add-new-upload-file-label" }, t("ghgInventory:emissionRemovalDocument")),
|
31859
32357
|
React.createElement(antd.Row, null,
|
31860
32358
|
React.createElement(antd.Col, { xl: 15, md: 15, className: "view-download-file-name-input" },
|
31861
|
-
React.createElement(antd.Input, { value: "GHG-Reporting
|
32359
|
+
React.createElement(antd.Input, { value: "GHG-Reporting-Projections_".concat(tabData.year, "_V").concat(tabData.version, ".csv"), disabled: true })),
|
31862
32360
|
React.createElement(antd.Col, { xl: 5, md: 5, className: "view-download-file-inner-col" },
|
31863
32361
|
React.createElement(antd.Button, { icon: React.createElement(icons.DownloadOutlined, null), onClick: function () { downloadCSV(tabData); } }, t("ghgInventory:download")))))),
|
31864
32362
|
React.createElement(antd.Row, { gutter: 16 },
|