Skip to content

Commit

Permalink
Adapt request and response to new funtion get_tariff_prices
Browse files Browse the repository at this point in the history
  • Loading branch information
MariteSomEnergia committed Aug 8, 2023
1 parent cee6e72 commit 7d935ac
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 14 deletions.
31 changes: 17 additions & 14 deletions src/containers/Tariff.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const Tariff = (props) => {
i18n.changeLanguage(language)
}, [language, i18n])

useEffect(() => {
useEffect(() => {
const CITY_TAX_21 = 20
const CITY_TAX_10 = 37

Expand All @@ -26,7 +26,7 @@ const Tariff = (props) => {
city_id: taxType === 21 ? CITY_TAX_21 : CITY_TAX_10
})
.then((response) => {
const tariffPrices = response?.data
const tariffPrices = response?.data['current']
setPrices(tariffPrices)
setLoading(false)
})
Expand Down Expand Up @@ -72,15 +72,15 @@ const Tariff = (props) => {
<div className="tp">
<h4>{t('TERME_POTENCIA')}</h4>
<p className="titol">
{prices?.tp &&
Object.keys(prices?.tp)
{prices?.potencia &&
Object.keys(prices?.potencia)
.reverse()
.map((key) => (
<span key={key}>
{tariff === '2.0TD'
? t(`TERME_POTENCIA_${key}_${tariff}`)
: key}{' '}
{prices.tp[key]?.value} {prices.tp[key]?.uom}
{prices.potencia[key]?.value} {prices.potencia[key]?.unit}
<br />
</span>
))}
Expand All @@ -89,15 +89,15 @@ const Tariff = (props) => {
<div className="te">
<h4>{t('TERME_ENERGIA')}</h4>
<p className="titol">
{prices?.te &&
Object.keys(prices?.te)
{prices?.energia &&
Object.keys(prices?.energia)
.reverse()
.map((key) => (
<span key={key}>
{tariff === '2.0TD'
? t(`TERME_ENERGIA_${key}_${tariff}`)
: key}{' '}
{prices.te[key]?.value} {prices.te[key]?.uom}
{prices.energia[key]?.value} {prices.energia[key]?.unit}
<br />
</span>
))}
Expand All @@ -111,15 +111,15 @@ const Tariff = (props) => {
})
}}></h4>
<p className="titol">
{prices?.gkwh &&
Object.keys(prices?.gkwh)
{prices?.generation_kWh &&
Object.keys(prices?.generation_kWh)
.reverse()
.map((key) => (
<span key={key}>
{tariff === '2.0TD'
? t(`TERME_ENERGIA_${key}_${tariff}`)
: key}{' '}
{prices.gkwh[key]?.value} {prices.gkwh[key]?.uom}
{prices.generation_kWh[key]?.value} {prices.generation_kWh[key]?.unit}
<br />
</span>
))}
Expand All @@ -133,12 +133,15 @@ const Tariff = (props) => {
})
}}></h4>
<p className="titol">
{prices?.ac &&
Object.keys(prices?.ac)
{prices?.energia_autoconsumida &&
Object.keys(prices?.energia_autoconsumida)
.reverse()
.map((key) => (
<span key={key}>
{prices.ac[key]?.value} {prices.ac[key]?.uom}
{tariff === '2.0TD'
? t(`TERME_AUTOCONUNM_${key}_${tariff}`)
: key}{' '}
{prices.energia_autoconsumida[key]?.value} {prices.energia_autoconsumida[key]?.unit}
<br />
</span>
))}
Expand Down
9 changes: 9 additions & 0 deletions src/i18n/locale-ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,15 @@
"TERME_ENERGIA_P3_2": {
"0TD": "Període vall"
},
"TERME_AUTOCONSUM_P1_2": {
"0TD": "Període punta"
},
"TERME_AUTOCONSUM_P2_2": {
"0TD": "Període pla"
},
"TERME_AUTOCONSUM_P3_2": {
"0TD": "Període vall"
},
"TERME_ENERGIA_GENERATIONKWH": "Terme d’energia tarifa <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"{{url}}\">Generation kWh</a>",
"TERME_POTENCIA": "Terme de potència",
"TERME_POTENCIA_P1_2": {
Expand Down
9 changes: 9 additions & 0 deletions src/i18n/locale-es.json
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,15 @@
"TERME_ENERGIA_P3_2": {
"0TD": "Periodo valle"
},
"TERME_AUTOCONSUM_P1_2": {
"0TD": "Periodo punta"
},
"TERME_AUTOCONSUM_P2_2": {
"0TD": "Periodo llano"
},
"TERME_AUTOCONSUM_P3_2": {
"0TD": "Periodo valle"
},
"TERME_ENERGIA_GENERATIONKWH": "Término de energía tarifa <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"{{url}}\">Generation kWh</a>",
"TERME_POTENCIA": "Término de potencia",
"TERME_POTENCIA_P1_2": {
Expand Down
9 changes: 9 additions & 0 deletions src/i18n/locale-eu.json
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,15 @@
"TERME_ENERGIA_P3_2": {
"0TD": "Sakonune-aldia"
},
"TERME_AUTOCONSUM_P1_2": {
"0TD": "Puntako aldia"
},
"TERME_AUTOCONSUM_P2_2": {
"0TD": "Aldi arrunta"
},
"TERME_AUTOCONSUM_P3_2": {
"0TD": "Sakonune-aldia"
},
"TERME_ENERGIA_GENERATIONKWH": "Energia-tartea <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"{{url}}\">Generation kWh</a> tarifan",
"TERME_POTENCIA": "Potentzia-tartea",
"TERME_POTENCIA_P1_2": {
Expand Down
9 changes: 9 additions & 0 deletions src/i18n/locale-gl.json
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,15 @@
"TERME_ENERGIA_P3_2": {
"0TD": "Período val"
},
"TERME_AUTOCONSUM_P1_2": {
"0TD": "Período punta"
},
"TERME_AUTOCONSUM_P2_2": {
"0TD": "Período chan"
},
"TERME_AUTOCONSUM_P3_2": {
"0TD": "Período val"
},
"TERME_ENERGIA_GENERATIONKWH": "Termo de enerxía tarifa <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"{{url}}\">Generation kWh</a>",
"TERME_POTENCIA": "Termo de potencia",
"TERME_POTENCIA_P1_2": {
Expand Down

0 comments on commit 7d935ac

Please sign in to comment.