import type { Device } from '@seamapi/types/connect'
import { BatteryLevelCriticalIcon } from 'lib/icons/BatteryLevelCritical.js'
import { BatteryLevelFullIcon } from 'lib/icons/BatteryLevelFull.js'
import { BatteryLevelHighIcon } from 'lib/icons/BatteryLevelHigh.js'
import { BatteryLevelLowIcon } from 'lib/icons/BatteryLevelLow.js'
interface BatteryStatusIndicatorProps {
device: Device
}
// UPSTREAM: Missing BatteryStatusIndicator type in @seamapi/types/connect.
type BatteryStatus = 'low' | 'full' | 'critical' | 'good'
export function BatteryStatusIndicator(
props: BatteryStatusIndicatorProps
): JSX.Element {
return (
)
}
function Content(props: {
status: BatteryStatus | null | undefined
level: number | null | undefined
}): JSX.Element | null {
const { status, level } = props
if (status === 'full') {
return (
<>
{t.full}
>
)
}
if (status === 'good') {
return (
<>
{t.high}
>
)
}
if (status === 'low') {
return (
<>
{t.low}
>
)
}
if (status === 'critical') {
return (
<>
{t.critical}
>
)
}
return null
}
function Percentage(props: {
level: number | null | undefined
}): JSX.Element | null {
if (props.level == null) return null
return <> ({Math.floor(props.level * 100)}%)>
}
const t = {
full: 'Good',
high: 'Good',
low: 'Low',
critical: 'Low!',
}