Skip to Content
Octopus Energy Packages

Create the Shell

Create the route shell, client summary component, and fixed summary timeframe

An energy summary starts from a fixed comparison window. Unlike EnergyOverview, it does not need timeframe navigation, browser storage, or preference controls to decide what to fetch. The summary route can still start as a Client Component when TanStack Query owns the browser fetch lifecycle.

What you'll build

By the end of this guide, your summary route will render a client summary component with a stable two-week timeframe for the last complete ISO week and the week before it.

Create the route shell

Keep the route focused on routing concerns. It reads the route params and passes them to the client summary.

app/accounts/[accountNumber]/properties/[propertyId]/summary/page.tsx
import { EnergySummaryCard } from "./_components/energy-summary-card";

export default async function SummaryPage({
  params,
}: PageProps<"/accounts/[accountNumber]/properties/[propertyId]/summary">) {
  const { accountNumber, propertyId } = await params;

  return <EnergySummaryCard accountNumber={accountNumber} propertyId={propertyId} />;
}

The route does not fetch measurements yet. The client component will own the queries added in the next guide.

Create the client component

The client component receives serializable route params. It must not be an async component; browser data fetching happens through React Query in the next guide.

_components/energy-summary-card.tsx
"use client";

type Props = {
  accountNumber: string;
  propertyId: string;
};

export function EnergySummaryCard({ accountNumber, propertyId }: Props) {
  // Resolve the summary timeframe, fetch data, and render below.
}

Resolve the summary timeframe

Use resolveSummaryTimeframe to compute the two complete ISO weeks needed for the comparison. The returned timeframe carries the timezone used for fetching and summary derivation.

_components/energy-summary-card.tsx
import { resolveSummaryTimeframe } from "@octopus-energy/measurements/summary";

const timezone = "Europe/London";

export function EnergySummaryCard({ accountNumber, propertyId }: Props) {
  const timeframe = resolveSummaryTimeframe({ timezone });

  // Use accountNumber, propertyId, and timeframe in the next guide.
}

The same timeframe object is passed to the measurement query and summary transform in the next guide, keeping the fetched records and derived periods aligned.

Render a temporary shell

Render a small placeholder while the route and client boundary are being wired. The next guide replaces this with real query states and summary data.

_components/energy-summary-card.tsx
import { Typography } from "@octopus-energy/coral/atoms";
import { EnergySummary } from "@octopus-energy/coral/molecules";

return (
  <EnergySummary error={false} loading={false}>
    <Typography textStyle="body2">Energy summary data will load here.</Typography>
  </EnergySummary>
);

Implementation checkpoint

At this checkpoint, the route renders a client EnergySummaryCard and passes route params through. The client component resolves the fixed two-week summary timeframe but does not fetch measurements yet.

FAQ

On this page