MDK Logo
UI Kit@mdk/foundationReferenceHooks

Monitoring hooks

Hooks for equipment monitoring, alerts, and device management

Hooks for monitoring mining equipment, managing alerts, and handling device-specific logic.

import {
  useBeepSound,
  useChartDataCheck,
} from '@mdk/foundation'

useBeepSound

Play a repeating beep sound for critical alerts. Useful for overheating containers or equipment failures where audible notification is needed.

import { useBeepSound } from '@mdk/foundation'

Options

OptionTypeDefaultDescription
isAllowedbooleanfalseWhether the beep is allowed to play
volumenumber0.5Volume level from 0 to 1
delayMsnumber1000Delay in milliseconds between beeps
srcstringbundled beepCustom sound source URL

Example

function TemperatureMonitor({ temperature, criticalThreshold }) {
  const isCritical = temperature > criticalThreshold

  // Beep when temperature is critical
  useBeepSound({ isAllowed: isCritical })

  return (
    <div className={isCritical ? 'alert-critical' : ''}>
      Temperature: {temperature}°C
    </div>
  )
}
// Custom interval and volume
useBeepSound({ isAllowed: hasAlert, delayMs: 500, volume: 0.8 })

// Custom sound source
useBeepSound({ isAllowed: true, src: '/sounds/alarm.mp3' })

useChartDataCheck

Check if chart data is empty or unavailable. Returns true if empty (show empty state), false if data exists (show chart).

import { useChartDataCheck } from '@mdk/foundation'

Parameters

ParameterTypeDescription
datasetobject | arrayDirect dataset for BarChart
dataobjectData object with datasets (LineChart) or dataset property

Returns

TypeDescription
booleantrue if data is empty, false if data exists

Example

// BarChart with direct dataset
function HashrateChart({ dataset }) {
  const isEmpty = useChartDataCheck({ dataset })

  if (isEmpty) {
    return <EmptyState message="No hashrate data available" />
  }

  return <BarChart data={dataset} />
}
// LineChart with data.datasets
function TemperatureChart({ data }) {
  const isEmpty = useChartDataCheck({ data })

  return isEmpty ? (
    <EmptyState message="No temperature data" />
  ) : (
    <LineChart data={data} />
  )
}

On this page