Skip to content

Commit

Permalink
feature(client): also display per year info
Browse files Browse the repository at this point in the history
  • Loading branch information
djey47 committed Nov 28, 2023
1 parent 6340409 commit eca51ae
Show file tree
Hide file tree
Showing 4 changed files with 185 additions and 17 deletions.
2 changes: 2 additions & 0 deletions src/client/components/Teleinfo/Teleinfo.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe('Teleinfo component', () => {
estimatedPrices:{
currentDay: 5.567,
currentMonth: 55,
currentYear: 475,
total: 500
},
instantIntensity: 1,
Expand All @@ -40,6 +41,7 @@ describe('Teleinfo component', () => {
suppliedPower: {
currentDay: [1, 2],
currentMonth: [10, 20],
currentYear: [90, 150],
total: [100, 200],
},
},
Expand Down
22 changes: 19 additions & 3 deletions src/client/components/Teleinfo/Teleinfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const Teleinfo: FunctionComponent<Record<string, never>> = () => {
<span className="teleinfo__power-unit">W</span>
</p>
<p className="teleinfo__power-stats">
{renderPowerStats('min', 'Min (today/month/overall):')}
{renderPowerStats('min', 'Min (d/m/y/o):')}
{renderPowerStats('max', 'Max:')}
</p>
</>
Expand All @@ -79,6 +79,10 @@ const Teleinfo: FunctionComponent<Record<string, never>> = () => {
{(data_TELEINFO.statistics.instantPower?.currentMonth && data_TELEINFO.statistics.instantPower?.currentMonth[statItemKey]) || '...'}
</span>
/
<span className="teleinfo__power-stats-value">
{(data_TELEINFO.statistics.instantPower?.currentYear && data_TELEINFO.statistics.instantPower?.currentYear[statItemKey]) || '...'}
</span>
/
<span className="teleinfo__power-stats-value">
{(data_TELEINFO.statistics.instantPower?.overall && data_TELEINFO.statistics.instantPower?.overall[statItemKey]) || '...'}
</span>
Expand Down Expand Up @@ -125,12 +129,14 @@ const Teleinfo: FunctionComponent<Record<string, never>> = () => {
<>
<p className="teleinfo__supplied">
<span className="teleinfo__supplied-label">
Supplied (today/month/total):
Supplied (d/m/y/t):
</span>
{renderSuppliedValue('currentDay')}
/
{renderSuppliedValue('currentMonth')}
/
{renderSuppliedValue('currentYear')}
/
{renderSuppliedValue('total')}
<span className="teleinfo__supplied-unit">Wh</span>
</p>
Expand Down Expand Up @@ -173,6 +179,12 @@ const Teleinfo: FunctionComponent<Record<string, never>> = () => {
'...'}
</span>
/
<span className="teleinfo__supplied-value">
{(data_TELEINFO.suppliedPower?.currentYear &&
data_TELEINFO.suppliedPower?.currentYear[rank]) ||
'...'}
</span>
/
<span className="teleinfo__supplied-value">
{(data_TELEINFO.suppliedPower?.total &&
data_TELEINFO.suppliedPower?.total[rank]) ||
Expand Down Expand Up @@ -224,7 +236,7 @@ const Teleinfo: FunctionComponent<Record<string, never>> = () => {
<section className="teleinfo__costs-section">
<p className="teleinfo__costs">
<span className="teleinfo__costs-label">
Costs (today/month/total):
Costs (d/m/y/t):
</span>
<span className="teleinfo__costs-value">
~{displayPriceWithTwoDecimals(data_TELEINFO.estimatedPrices?.currentDay)}
Expand All @@ -234,6 +246,10 @@ const Teleinfo: FunctionComponent<Record<string, never>> = () => {
{data_TELEINFO.estimatedPrices?.currentMonth || '...'}
</span>
/
<span className="teleinfo__costs-value">
{data_TELEINFO.estimatedPrices?.currentYear || '...'}
</span>
/
<span className="teleinfo__costs-value">
{data_TELEINFO.estimatedPrices?.total || '...'}
</span>
Expand Down
Loading

0 comments on commit eca51ae

Please sign in to comment.