Skip to Content
Octopus Energy Packages
API ReferenceTransforms

Coral Compat

APIs exported from @octopus-energy/measurements/compat

getCardProps

Maps MeasurementsOverview plus preferences into props for <EnergyOverviewCard>.

import { getCardProps } from "@octopus-energy/measurements/compat";

const cardProps = getCardProps({
  overview: electricityOverview,
  utility: "electricity",
  preferences,
  preferencesActions,
});
getCardProps

Prop

Type

Input

GetCardPropsInput

Prop

Type

Output

CardProps

Prop

Type


getTimeframeProps

Maps Timeframe and TimeframeActions into props for Coral's timeframe controls.

import { getTimeframeProps } from "@octopus-energy/measurements/compat";

const tfProps = getTimeframeProps({ timeframe, timeframeActions });
getTimeframeProps

Prop

Type

The returned object contains three prop groups:

  • tfProps.timeframeControls: for <EnergyOverviewTimeframeControls>
  • tfProps.toggleButton: for <EnergyOverviewTimeframeToggleButton>
  • tfProps.navigation: for <EnergyOverviewTimeframeNavigation>

Input

GetTimeframePropsInput

Prop

Type

Output

TimeframeProps

Prop

Type


EnergySummary compat helpers

These helpers are a clear temporary bridge between future-facing summary role-helper outputs and Coral's current EnergySummary prop names. They do not select metrics; call the summary role helpers first, then adapt the role output at the Coral render point.

import {
  getSummaryChartBarProps,
  getSummaryChartLabelProps,
  getSummaryIndicatorsProps,
} from "@octopus-energy/measurements/compat";
import {
  getSummaryChartBars,
  getSummaryChartLabels,
  getSummaryIndicators,
} from "@octopus-energy/measurements/summary";

const indicators = getSummaryIndicators(summary);
const chartBars = getSummaryChartBars(summary);
const chartLabels = getSummaryChartLabels(summary);

const indicatorProps = getSummaryIndicatorsProps(indicators);
const weekBeforeBars = getSummaryChartBarProps(chartBars.weekBefore);
const weekBeforeLabel = getSummaryChartLabelProps(chartLabels.weekBefore);
getSummaryChartBarProps

Prop

Type

getSummaryChartBarProps

Maps SummaryChartBar[] to the current props for <EnergySummaryChart>. Current Coral expects both period totals for scaling. Summary chart bars already carry a single value plus a compatible-bucket maxValue, so the adapter passes maxValue as the opposite period total.

{
  getSummaryChartBarProps(chartBars.weekBefore).map(({ key, ...chart }) => (
    <EnergySummaryChart key={key} {...chart} />
  ));
}
SummaryChartBarProps<TFilters>

Prop

Type

getSummaryChartLabelProps

Maps a SummaryChartLabel to the current props for <EnergySummaryChartLabel>. The adapter maps the summary label string to Coral's current value prop.

<EnergySummaryChartLabel {...getSummaryChartLabelProps(chartLabels.weekBefore)} />
SummaryChartLabelProps

Prop

Type

getSummaryIndicatorsProps

Maps SummaryIndicator[] to the current props for <EnergySummaryIndicator> and app-owned indicator copy. Current Coral accepts only "up" | "down" for the indicator icon direction, so delta.trend === "stable" maps to the current down icon direction while the semantic trend remains available at indicator.delta.trend.

{
  getSummaryIndicatorsProps(indicators).map((indicator) => (
    <EnergySummaryIndicators key={indicator.key}>
      <EnergySummaryIndicator direction={indicator.direction} />
      <Typography textStyle="body2">{/* Render localized text from indicator.delta. */}</Typography>
    </EnergySummaryIndicators>
  ));
}
SummaryIndicatorProps<TFilters>

Prop

Type


getDateRangeDisplay

Formats the current timeframe into a human-readable date string for display in <EnergyOverviewDateDisplay>.

import { getDateRangeDisplay } from "@octopus-energy/measurements/compat";

const display = getDateRangeDisplay(timeframe, dateLocale);
getDateRangeDisplay

Prop

Type

Returns: string

Output formats

TimeframeOutput
Single dayThe formatted anchor date
Multi-dayThe formatted start and end dates

On this page