Skip to Content
🎉 Coral x Panda has been released 🎉 Read the Migration Guide
DocumentationMoleculesEnergyOverviewuseEnergyOverviewTimeframe

useEnergyOverviewTimeframe

This hook is used to transform the data from the useMeasurementsFilters hook into an object that can be used to control the timeframe of the EnergyOverview compound component.

Basic Usage

import { useMeasurementFilters, useMeasurements, } from "@krakentech/blueprint-utils/client"; import { useEnergyOverviewTimeframe } from "@krakentech/coral-molecules"; const measurementFilters = useMeasurementFilters(); const electricityMeasurements = useMeasurements({ variables: { accountNumber, dateLocale, propertyId, utilityType: FuelType.Electricity, measurementFilters, }, }); const { anchorDate, setAnchorDate, toggleIntervalValue, setToggleIntervalValue, dateRangeIntervalValue, setDateRangeIntervalValue, dateRangeDisplay, dateRange, nextDateRangeIsFuture, DATE_RANGE_SET_ANCHOR_DATE_MAPPING, } = useEnergyOverviewTimeframe({ measurementFiltersData: measurementFilters, dateLocale: electricityMeasurements.dateLocale, });

Please see the EnergyOverview component for a full example of how to use this object within the compound component.

Full API

Arguments

NameDescriptiontypeDefault valueRequired
measurementFiltersDataThe initial data provided by the consumer from the useMeasurementsFilters hookEnergyOverviewFilterTypeundefinedtrue
dateLocaleThe dateLocale object provided by the useMeasurements hookobjectundefinedtrue

Return

NameDescriptiontype
anchorDateThe anchorDate object from useMeasurementsFilters, used to provide the starting date point for your current timeframeobject
setAnchorDateThe setAnchorDate function from useMeasurementsFilters, used to update the starting date point for your current timeframefunction
toggleIntervalValueA string returned from useMeasurementFilters, used to control the current interval valuestring
setToggleIntervalValueA function returned from useMeasurementFilters, used to set the current interval value and update the datafunction
dateRangeIntervalValueA string returned from useMeasurementFilters, used to control the custom date range value in the date pickerstring
setDateRangeIntervalValueA function returned from useMeasurementFilters, used to set the custom date range value in the date picker and update the datafunction
dateRangeDisplayA formatted string used to display the current date range in the UIstring
dateRangeUsed in conjunction with DATE_RANGE_SET_ANCHOR_DATE_MAPPING to set the anchorDatestring
nextDateRangeIsFutureIndicates whether the next date range is in the futureboolean
DATE_RANGE_SET_ANCHOR_DATE_MAPPINGUsed in conjunction with setAnchorDate to set the anchorDateobject
Last updated on