Utility Hooks
General utility and helper hooks
General-purpose utility hooks.
From @tetherto/mdk-react-adapter
@tetherto/mdk-react-adapter
Import the public APIs on this page from @tetherto/mdk-react-adapter.
useBeepSound
Plays a repeating beep sound at a configurable interval.
({ isAllowed = DEFAULTS.IS_ALLOWED, volume = DEFAULTS.VOLUME, delayMs = DEFAULTS.DELAY_MS, }: UseBeepSoundOptions = {}) => voiduseContextualModal
Headless open/close state for a modal that needs to remember the subject it was opened against (the row being edited, the device being inspected, etc.).
({ onOpen, onClose, }: UseContextualModalParams = {}) => { modalOpen: boolean; handleClose: () => void; handleOpen: (sub: T | null) => void; subject: T | null; setSubject: React.Dispatch<React.SetSta…useDeviceResolution
Hook to detect current device resolution/viewport size
() => DeviceResolutionuseKeyDown
Tracks whether a specific keyboard key is currently held down.
(keyName: string) => booleanuseLocalStorage
Custom hook for type-safe localStorage access with cross-tab sync.
(key: string, defaultValue: T) => [T, (value: T | ((prev: T) => T)) => void, VoidFunction]usePagination
Custom hook for managing pagination state
(args: PaginationArgs = {}) => UsePaginationReturnusePlatform
SSR-safe React hook returning the detected client OS.
() => PlatformResultuseSubtractedTime
Returns Date.now() - diff, refreshing on a fixed interval (default 5s).
(diff: number, interval = DEFAULT_INTERVAL) => numberuseTimezoneFormatter
Timezone-aware date formatting hook.
() => UseTimezoneFormatterReturnuseWindowSize
Hook to track window size changes
() => WindowSizeFrom @tetherto/mdk-react-devkit
@tetherto/mdk-react-devkit
Import the public APIs on this page from @tetherto/mdk-react-devkit.
useCostSummary
Base hook for the cost-summary reporting page (single-site mode).
Owns the date-range / period UI state and the pure transform from a v2 /auth/finance/cost-summary response into headline metrics and time-series. Consumers wire their own fetch (RTK Query, TanStack Query, fixtures, ...) and pass the result through query - the hook never fetches itself.
Multi-site mode is composed at the page level (T-13) by feeding a different response shape to the same view-model primitives; this base hook stays single-site to keep the input contract narrow.
({ query, ...dateRangeOptions }?: UseCostSummaryOptions) => { queryParams: CostSummaryQueryParams | null; isLoading: boolean; error: {} | null; metrics: CostSummaryDisplayMetrics | null; costLog: readonly CostTimeSeriesEntry[]; btcPriceLog:… /* see source */