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
| Option | Type | Default | Description |
|---|---|---|---|
isAllowed | boolean | false | Whether the beep is allowed to play |
volume | number | 0.5 | Volume level from 0 to 1 |
delayMs | number | 1000 | Delay in milliseconds between beeps |
src | string | bundled beep | Custom 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
| Parameter | Type | Description |
|---|---|---|
dataset | object | array | Direct dataset for BarChart |
data | object | Data object with datasets (LineChart) or dataset property |
Returns
| Type | Description |
|---|---|
boolean | true 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} />
)
}
