@undp/carbon-library 1.0.135-ghg-inventory.9.8 → 1.0.135-ghg-inventory.9.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,10 +18,10 @@ export declare enum EmissionSector {
18
18
  'other' = "Other"
19
19
  }
20
20
  export declare enum EmissionGas {
21
- 'CO2' = "CO<sub>2</sub>",
22
- 'CH4' = "CH<sub>4</sub>",
23
- 'N2O' = "N<sub>2</sub>O",
24
- 'CO2eq' = "CO<sub>2</sub>-eq"
21
+ 'co2' = "CO<sub>2</sub>",
22
+ 'ch4' = "CH<sub>4</sub>",
23
+ 'n2o' = "N<sub>2</sub>O",
24
+ 'co2eq' = "CO<sub>2</sub>-eq"
25
25
  }
26
26
  export declare enum EmissionSubSectors {
27
27
  fuelCombustionActivities = "Fuel Combustion Activities",
package/dist/esm/index.js CHANGED
@@ -4384,10 +4384,10 @@ var EmissionSector;
4384
4384
  })(EmissionSector || (EmissionSector = {}));
4385
4385
  var EmissionGas;
4386
4386
  (function (EmissionGas) {
4387
- EmissionGas["CO2"] = "CO<sub>2</sub>";
4388
- EmissionGas["CH4"] = "CH<sub>4</sub>";
4389
- EmissionGas["N2O"] = "N<sub>2</sub>O";
4390
- EmissionGas["CO2eq"] = "CO<sub>2</sub>-eq";
4387
+ EmissionGas["co2"] = "CO<sub>2</sub>";
4388
+ EmissionGas["ch4"] = "CH<sub>4</sub>";
4389
+ EmissionGas["n2o"] = "N<sub>2</sub>O";
4390
+ EmissionGas["co2eq"] = "CO<sub>2</sub>-eq";
4391
4391
  })(EmissionGas || (EmissionGas = {}));
4392
4392
  var EmissionSubSectors;
4393
4393
  (function (EmissionSubSectors) {
@@ -28891,15 +28891,16 @@ var emissionComparisonOptionsSub = function (labels, chartColors) {
28891
28891
 
28892
28892
  var RangePicker = DatePicker.RangePicker;
28893
28893
  var GHGDashboardComponent = function (props) {
28894
- var t = props.t, useUserContext = props.useUserContext; props.useConnection; var Chart = props.Chart, ButtonGroup = props.ButtonGroup, Link = props.Link, isMultipleDashboardsVisible = props.isMultipleDashboardsVisible;
28894
+ var t = props.t, useUserContext = props.useUserContext, useConnection = props.useConnection, Chart = props.Chart, ButtonGroup = props.ButtonGroup, Link = props.Link, isMultipleDashboardsVisible = props.isMultipleDashboardsVisible;
28895
+ var _a = useConnection(); _a.get; var post = _a.post; _a.delete;
28895
28896
  var userInfoState = useUserContext().userInfoState;
28896
- var _a = useState(Date.parse(String(moment().endOf('year')))), endYear = _a[0], setEndYear = _a[1];
28897
- var _b = useState(Date.parse(String(moment().subtract('10', 'years')))), startYear = _b[0], setStartYear = _b[1];
28898
- var _c = useState(false), loadingCharts = _c[0]; _c[1];
28899
- var _e = useState({}), data = _e[0], setData = _e[1];
28900
- var _f = useState({}), estimateData = _f[0], setEstimateData = _f[1];
28901
- var _g = useState({}), actualData = _g[0], setActualData = _g[1];
28902
- var _h = useState(window.innerWidth), screenWidth = _h[0], setScreenWidth = _h[1];
28897
+ var _b = useState(moment().year()), endYear = _b[0], setEndYear = _b[1];
28898
+ var _c = useState(moment().subtract('10', 'years').year()), startYear = _c[0], setStartYear = _c[1];
28899
+ var _e = useState(false), loadingCharts = _e[0], setLoadingCharts = _e[1];
28900
+ var _f = useState({}), data = _f[0], setData = _f[1];
28901
+ var _g = useState({}), estimateData = _g[0], setEstimateData = _g[1];
28902
+ var _h = useState({}), actualData = _h[0], setActualData = _h[1];
28903
+ var _j = useState(window.innerWidth), screenWidth = _j[0], setScreenWidth = _j[1];
28903
28904
  var colors = ['#16B1FF', '#FF8183', '#7FEABF', '#FFB480', '#D8D8D8'];
28904
28905
  var colorsComparison = ['#7FEABF', '#FF8183', '#16B1FF'];
28905
28906
  var layout = [
@@ -28909,275 +28910,6 @@ var GHGDashboardComponent = function (props) {
28909
28910
  [GhgStatCardTypes.AGG_EMISSIONS_COMPARISON],
28910
28911
  ];
28911
28912
  var TTSuffix = (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.PROGRAMME_DEVELOPER ? 'My' : '';
28912
- var response = {
28913
- data: {
28914
- stats: {
28915
- AGG_EMISSIONS_BY_SECTOR: {
28916
- data: {
28917
- xLabels: ['2016', '2017', '2018', '2019', '2020', '2021', '2022', '2023'],
28918
- agricultureForestryOtherLandUse: [500, 230, 125, 689, 255, 361, 178, 388],
28919
- energyEmissions: [230, 548, 99, 100, 330, 105, 273, 225],
28920
- industrialProcessesProductUse: [601, 552, 85, 63, 500, 230, 125, 689],
28921
- other: [330, 105, 273, 225, 601, 552, 85, 63],
28922
- waste: [255, 361, 178, 388, 330, 105, 273, 225],
28923
- },
28924
- last: '1700786087613',
28925
- all: {
28926
- statusUpdateTime: '1700786087613',
28927
- creditUpdateTime: '1700785938783',
28928
- },
28929
- },
28930
- AGG_EMISSIONS_BY_GAS: {
28931
- data: {
28932
- xLabels: ['2020', '2021', '2022', '2023'],
28933
- CO2: [500, 230, 125, 689],
28934
- CH4: [230, 548, 99, 100],
28935
- N2O: [601, 552, 85, 63],
28936
- CO2eq: [330, 105, 273, 225],
28937
- },
28938
- last: '1700786087613',
28939
- all: {
28940
- statusUpdateTime: '1700786087613',
28941
- creditUpdateTime: '1700785938783',
28942
- },
28943
- },
28944
- AGG_EMISSIONS_MITIGATION_POTENTIAL_BY_SECTOR: {
28945
- data: {
28946
- xLabels: ['2016', '2017', '2018', '2019', '2020', '2021', '2022', '2023'],
28947
- agricultureForestryOtherLandUse: [500, 230, 125, 689, 255, 361, 178, 388],
28948
- energyEmissions: [230, 548, 99, 100, 330, 105, 273, 225],
28949
- industrialProcessesProductUse: [601, 552, 85, 63, 500, 230, 125, 689],
28950
- other: [330, 105, 273, 225, 601, 552, 85, 63],
28951
- waste: [255, 361, 178, 388, 330, 105, 273, 225],
28952
- },
28953
- last: '1700786087613',
28954
- all: {
28955
- statusUpdateTime: '1700786087613',
28956
- creditUpdateTime: '1700785938783',
28957
- },
28958
- },
28959
- AGG_EMISSIONS_COMPARISON: {
28960
- data: {
28961
- xLabels: ['2016', '2017', '2018', '2019', '2020', '2021', '2022', '2023'],
28962
- bau: [50, 23, 25, 69, 55, 31, 18, 38],
28963
- conditionalNdc: [23, 58, 99, 10, 30, 15, 27, 25],
28964
- unconditionalNdc: [61, 52, 85, 63, 50, 20, 15, 68],
28965
- actual: [25, 86, 46, 63, 57, 23, 25, 65],
28966
- },
28967
- last: '1700786087613',
28968
- all: {
28969
- statusUpdateTime: '1700786087613',
28970
- creditUpdateTime: '1700785938783',
28971
- },
28972
- },
28973
- AGG_REDUCTION_PERCENT_BAU_BY_SECTOR: {
28974
- data: {
28975
- estimate: {
28976
- data: {
28977
- xLabels: [
28978
- ['Fuel', 'Combustion', 'Activities'],
28979
- ['Fugitive', 'emissions', ' from', 'fuels'],
28980
- ['Carbon', 'dioxide', 'Transport', 'and', 'Storage'],
28981
- ['Mineral', 'Industry'],
28982
- ['Chemical', 'Industry'],
28983
- ['Metal', 'Industry'],
28984
- ['Non-Energy', 'Products', 'from', 'Fuels', 'and', 'Solvent', 'Use'],
28985
- ['Electronics', 'Industry'],
28986
- ['Product', 'Uses as', 'Substitutes', 'for', 'Ozone', 'Depleting', 'Substances'],
28987
- ['Other', 'Product', 'Manufacture', 'and', 'Use'],
28988
- ['Other', '(Other', 'Product', 'Manufacture', 'and', 'Use)'],
28989
- 'Livestock',
28990
- 'Land',
28991
- ['Aggregate', 'sources', 'and', 'non-CO2', 'emissions', 'sources', 'on land'],
28992
- ['Other', '(Agriculture,', 'Forestry,', 'and', 'Other', 'Land', 'Use)'],
28993
- ['Solid', 'Waste', 'Disposal'],
28994
- ['Biological', 'Treatment', 'of', 'Solid', 'Waste'],
28995
- ['Incineration', 'and', 'Open', 'Burning', 'of', 'Waste'],
28996
- ['Wastewater', 'Treatment', 'and', 'Discharge'],
28997
- ['Other', '(Waste)'],
28998
- [
28999
- 'Indirect',
29000
- 'N2O',
29001
- 'emissions',
29002
- 'from',
29003
- 'the',
29004
- 'atmospheric',
29005
- 'deposition',
29006
- 'of nitrogen',
29007
- 'in NOx',
29008
- 'and NH3',
29009
- ],
29010
- 'Other',
29011
- ],
29012
- fuelCombustionActivities: [
29013
- 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
29014
- ],
29015
- fugitiveEmissionsFromFuels: [
29016
- 0, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
29017
- ],
29018
- carbonDioxideTransportStorage: [
29019
- 0, 0, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
29020
- ],
29021
- mineralIndustry: [
29022
- 0, 0, 0, 45, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
29023
- ],
29024
- chemicalIndustry: [
29025
- 0, 0, 0, 0, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
29026
- ],
29027
- metalIndustry: [0, 0, 0, 0, 0, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
29028
- nonEnergyProductsFuelsSolventUse: [
29029
- 0, 0, 0, 0, 0, 0, 74, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
29030
- ],
29031
- electronicsIndustry: [
29032
- 0, 0, 0, 0, 0, 0, 0, 29, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
29033
- ],
29034
- productUsesSubstOzoneDepletingSubs: [
29035
- 0, 0, 0, 0, 0, 0, 0, 0, 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
29036
- ],
29037
- otherProductManufactureUse: [
29038
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
29039
- ],
29040
- otherIndustrialProcessesProductUse: [
29041
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
29042
- ],
29043
- livestock: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
29044
- land: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0],
29045
- aggregateNonCo2SourcesLand: [
29046
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 0, 0, 0,
29047
- ],
29048
- otherAgricultureForestryOtherLandUse: [
29049
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0,
29050
- ],
29051
- solidWasteDisposal: [
29052
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13.5, 0, 0, 0, 0, 0, 0,
29053
- ],
29054
- biologicalTreatmentSolidWaste: [
29055
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 0, 0, 0, 0, 0,
29056
- ],
29057
- incinerationOpenBurningWaste: [
29058
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 125, 0, 0, 0, 0,
29059
- ],
29060
- wastewaterTreatmentDischarge: [
29061
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 69, 0, 0, 0,
29062
- ],
29063
- otherWaste: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 0, 0],
29064
- indirectN2oEmissions: [
29065
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3.25, 0,
29066
- ],
29067
- other: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30],
29068
- },
29069
- last: '1700786087613',
29070
- all: {
29071
- statusUpdateTime: '1700786087613',
29072
- creditUpdateTime: '1700785938783',
29073
- },
29074
- },
29075
- actual: {
29076
- data: {
29077
- xLabels: [
29078
- ['Fuel', 'Combustion', 'Activities'],
29079
- ['Fugitive', 'emissions', ' from', 'fuels'],
29080
- ['Carbon', 'dioxide', 'Transport', 'and', 'Storage'],
29081
- ['Mineral', 'Industry'],
29082
- ['Chemical', 'Industry'],
29083
- ['Metal', 'Industry'],
29084
- ['Non-Energy', 'Products', 'from', 'Fuels', 'and', 'Solvent', 'Use'],
29085
- ['Electronics', 'Industry'],
29086
- ['Product', 'Uses as', 'Substitutes', 'for', 'Ozone', 'Depleting', 'Substances'],
29087
- ['Other', 'Product', 'Manufacture', 'and', 'Use'],
29088
- ['Other', '(Other', 'Product', 'Manufacture', 'and', 'Use)'],
29089
- 'Livestock',
29090
- 'Land',
29091
- ['Aggregate', 'sources', 'and', 'non-CO2', 'emissions', 'sources', 'on land'],
29092
- ['Other', '(Agriculture,', 'Forestry,', 'and', 'Other', 'Land', 'Use)'],
29093
- ['Solid', 'Waste', 'Disposal'],
29094
- ['Biological', 'Treatment', 'of', 'Solid', 'Waste'],
29095
- ['Incineration', 'and', 'Open', 'Burning', 'of', 'Waste'],
29096
- ['Wastewater', 'Treatment', 'and', 'Discharge'],
29097
- ['Other', '(Waste)'],
29098
- [
29099
- 'Indirect',
29100
- 'N2O',
29101
- 'emissions',
29102
- 'from',
29103
- 'the',
29104
- 'atmospheric',
29105
- 'deposition',
29106
- 'of nitrogen',
29107
- 'in NOx',
29108
- 'and NH3',
29109
- ],
29110
- 'Other',
29111
- ],
29112
- fuelCombustionActivities: [
29113
- 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
29114
- ],
29115
- fugitiveEmissionsFromFuels: [
29116
- 0, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
29117
- ],
29118
- carbonDioxideTransportStorage: [
29119
- 0, 0, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
29120
- ],
29121
- mineralIndustry: [
29122
- 0, 0, 0, 45, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
29123
- ],
29124
- chemicalIndustry: [
29125
- 0, 0, 0, 0, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
29126
- ],
29127
- metalIndustry: [0, 0, 0, 0, 0, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
29128
- nonEnergyProductsFuelsSolventUse: [
29129
- 0, 0, 0, 0, 0, 0, 74, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
29130
- ],
29131
- electronicsIndustry: [
29132
- 0, 0, 0, 0, 0, 0, 0, 29, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
29133
- ],
29134
- productUsesSubstOzoneDepletingSubs: [
29135
- 0, 0, 0, 0, 0, 0, 0, 0, 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
29136
- ],
29137
- otherProductManufactureUse: [
29138
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
29139
- ],
29140
- otherIndustrialProcessesProductUse: [
29141
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
29142
- ],
29143
- livestock: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
29144
- land: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0],
29145
- aggregateNonCo2SourcesLand: [
29146
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 0, 0, 0,
29147
- ],
29148
- otherAgricultureForestryOtherLandUse: [
29149
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0,
29150
- ],
29151
- solidWasteDisposal: [
29152
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13.5, 0, 0, 0, 0, 0, 0,
29153
- ],
29154
- biologicalTreatmentSolidWaste: [
29155
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 0, 0, 0, 0, 0,
29156
- ],
29157
- incinerationOpenBurningWaste: [
29158
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 125, 0, 0, 0, 0,
29159
- ],
29160
- wastewaterTreatmentDischarge: [
29161
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 69, 0, 0, 0,
29162
- ],
29163
- otherWaste: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 0, 0],
29164
- indirectN2oEmissions: [
29165
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3.25, 0,
29166
- ],
29167
- other: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30],
29168
- },
29169
- last: '1700786087613',
29170
- all: {
29171
- statusUpdateTime: '1700786087613',
29172
- creditUpdateTime: '1700785938783',
29173
- },
29174
- },
29175
- },
29176
- },
29177
- },
29178
- lastUpdate: 1700796691,
29179
- },
29180
- };
29181
28913
  var handleResize = function () {
29182
28914
  setScreenWidth(window.innerWidth);
29183
28915
  };
@@ -29214,6 +28946,7 @@ var GHGDashboardComponent = function (props) {
29214
28946
  });
29215
28947
  }); };
29216
28948
  useEffect(function () {
28949
+ getData();
29217
28950
  console.log('****************Date changed*******', startYear, endYear);
29218
28951
  }, [startYear, endYear]);
29219
28952
  var parseEmissionSectorData = function (statData) {
@@ -29304,7 +29037,6 @@ var GHGDashboardComponent = function (props) {
29304
29037
  var emissionsAggByComparison = statData === null || statData === void 0 ? void 0 : statData.data;
29305
29038
  projectionTypesArray === null || projectionTypesArray === void 0 ? void 0 : projectionTypesArray.map(function (projectionType) {
29306
29039
  if (emissionsAggByComparison[projectionType] !== undefined) {
29307
- console.log('------------parseEmissionComparisonData-----------------', projectionType);
29308
29040
  emissionComparisonSeriesData.push({
29309
29041
  name: ProjectionTypes$1[projectionType],
29310
29042
  data: emissionsAggByComparison[projectionType],
@@ -29390,31 +29122,113 @@ var GHGDashboardComponent = function (props) {
29390
29122
  },
29391
29123
  },
29392
29124
  };
29393
- useEffect(function () {
29125
+ var genPayload = function () {
29126
+ var stats = [];
29127
+ for (var item in GhgStatCardTypes) {
29128
+ stats.push({
29129
+ type: item,
29130
+ statFilter: {
29131
+ startTime: startYear !== 0 ? startYear : undefined,
29132
+ endTime: endYear !== 0 ? endYear : undefined,
29133
+ onlyMine: (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.PROGRAMME_DEVELOPER,
29134
+ },
29135
+ });
29136
+ }
29137
+ return {
29138
+ system: SystemNames.CARBON_TRANSPARENCY,
29139
+ stats: stats,
29140
+ };
29141
+ };
29142
+ var getData = function () { return __awaiter(void 0, void 0, void 0, function () {
29143
+ var response_1, newd, key, obj, config, dx, error_1;
29394
29144
  var _a, _b, _c, _e, _f, _g, _h, _j, _k;
29395
- console.log('Response', response);
29396
- var newd = {};
29397
- for (var key in (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.stats) {
29398
- if ((_b = response === null || response === void 0 ? void 0 : response.data) === null || _b === void 0 ? void 0 : _b.stats.hasOwnProperty(key)) {
29399
- if (key === GhgStatCardTypes.AGG_REDUCTION_PERCENT_BAU_BY_SECTOR) {
29400
- setActualData((_f = (_e = (_c = response === null || response === void 0 ? void 0 : response.data.stats.AGG_REDUCTION_PERCENT_BAU_BY_SECTOR) === null || _c === void 0 ? void 0 : _c.data) === null || _e === void 0 ? void 0 : _e.actual) === null || _f === void 0 ? void 0 : _f.data);
29401
- setEstimateData((_j = (_h = (_g = response === null || response === void 0 ? void 0 : response.data.stats.AGG_REDUCTION_PERCENT_BAU_BY_SECTOR) === null || _g === void 0 ? void 0 : _g.data) === null || _h === void 0 ? void 0 : _h.estimate) === null || _j === void 0 ? void 0 : _j.data);
29402
- }
29403
- var obj = (_k = response === null || response === void 0 ? void 0 : response.data) === null || _k === void 0 ? void 0 : _k.stats[key];
29404
- var config = supportedWidgetList[key];
29405
- if (config) {
29406
- var dx = config.callbacks.parseData(obj, config.configs.dataLabelField, config.configs.dataValField);
29407
- newd[key] = {
29408
- data: dx,
29409
- time: !obj.last || obj.last === '0' || obj.last === 0
29410
- ? '0'
29411
- : moment(parseInt(obj.last)).fromNow(),
29412
- };
29413
- }
29145
+ return __generator(this, function (_l) {
29146
+ switch (_l.label) {
29147
+ case 0:
29148
+ setLoadingCharts(true);
29149
+ _l.label = 1;
29150
+ case 1:
29151
+ _l.trys.push([1, 3, 4, 5]);
29152
+ return [4 /*yield*/, post("stats/ghg/agg", genPayload(), undefined,
29153
+ // process.env.REACT_APP_STAT_URL
29154
+ 'http://localhost:3100')];
29155
+ case 2:
29156
+ response_1 = _l.sent();
29157
+ console.log('Response', response_1);
29158
+ newd = {};
29159
+ for (key in (_a = response_1 === null || response_1 === void 0 ? void 0 : response_1.data) === null || _a === void 0 ? void 0 : _a.stats) {
29160
+ if ((_b = response_1 === null || response_1 === void 0 ? void 0 : response_1.data) === null || _b === void 0 ? void 0 : _b.stats.hasOwnProperty(key)) {
29161
+ if (key === GhgStatCardTypes.AGG_REDUCTION_PERCENT_BAU_BY_SECTOR) {
29162
+ setActualData((_f = (_e = (_c = response_1 === null || response_1 === void 0 ? void 0 : response_1.data.stats.AGG_REDUCTION_PERCENT_BAU_BY_SECTOR) === null || _c === void 0 ? void 0 : _c.data) === null || _e === void 0 ? void 0 : _e.actual) === null || _f === void 0 ? void 0 : _f.data);
29163
+ setEstimateData((_j = (_h = (_g = response_1 === null || response_1 === void 0 ? void 0 : response_1.data.stats.AGG_REDUCTION_PERCENT_BAU_BY_SECTOR) === null || _g === void 0 ? void 0 : _g.data) === null || _h === void 0 ? void 0 : _h.estimate) === null || _j === void 0 ? void 0 : _j.data);
29164
+ }
29165
+ obj = (_k = response_1 === null || response_1 === void 0 ? void 0 : response_1.data) === null || _k === void 0 ? void 0 : _k.stats[key];
29166
+ config = supportedWidgetList[key];
29167
+ if (config) {
29168
+ dx = config.callbacks.parseData(obj, config.configs.dataLabelField, config.configs.dataValField);
29169
+ newd[key] = {
29170
+ data: dx,
29171
+ time: !obj.last || obj.last === '0' || obj.last === 0
29172
+ ? '0'
29173
+ : moment(parseInt(obj.last)).fromNow(),
29174
+ };
29175
+ }
29176
+ }
29177
+ }
29178
+ console.log('newd', newd);
29179
+ setData(newd);
29180
+ return [3 /*break*/, 5];
29181
+ case 3:
29182
+ error_1 = _l.sent();
29183
+ console.log("Error in getting users", error_1);
29184
+ message.open({
29185
+ type: "error",
29186
+ content: error_1.message,
29187
+ duration: 3,
29188
+ style: { textAlign: "right", marginRight: 15, marginTop: 10 },
29189
+ });
29190
+ return [3 /*break*/, 5];
29191
+ case 4:
29192
+ setLoadingCharts(false);
29193
+ return [7 /*endfinally*/];
29194
+ case 5: return [2 /*return*/];
29414
29195
  }
29415
- }
29416
- console.log('newd', newd);
29417
- setData(newd);
29196
+ });
29197
+ }); };
29198
+ useEffect(function () {
29199
+ // console.log('Response', response);
29200
+ // const newd: any = {};
29201
+ // for (const key in response?.data?.stats) {
29202
+ // if (response?.data?.stats.hasOwnProperty(key)) {
29203
+ // if (key === GhgStatCardTypes.AGG_REDUCTION_PERCENT_BAU_BY_SECTOR) {
29204
+ // setActualData(
29205
+ // response?.data.stats.AGG_REDUCTION_PERCENT_BAU_BY_SECTOR?.data?.actual?.data
29206
+ // );
29207
+ // setEstimateData(
29208
+ // response?.data.stats.AGG_REDUCTION_PERCENT_BAU_BY_SECTOR?.data?.estimate?.data
29209
+ // );
29210
+ // }
29211
+ // const obj = response?.data?.stats[key];
29212
+ // const config = supportedWidgetList[key];
29213
+ // if (config) {
29214
+ // const dx = config.callbacks.parseData(
29215
+ // obj,
29216
+ // config.configs.dataLabelField,
29217
+ // config.configs.dataValField
29218
+ // );
29219
+ // newd[key] = {
29220
+ // data: dx,
29221
+ // time:
29222
+ // !obj.last || obj.last === '0' || obj.last === 0
29223
+ // ? '0'
29224
+ // : moment(parseInt(obj.last)).fromNow(),
29225
+ // };
29226
+ // }
29227
+ // }
29228
+ // }
29229
+ // console.log('newd', newd);
29230
+ // setData(newd);
29231
+ getData();
29418
29232
  }, []);
29419
29233
  var getColorsForPercentageCharts = function (percentageData) {
29420
29234
  if (percentageData === undefined || percentageData === null) {