import * as React from 'react' import type { Action, ActionHash } from '@lastres/action' import PresentationItem from '@lastres/components/presentation-item' import Presentation from '@lastres/components/presentation' export interface BottomPanelProps { websocket: WebSocket | null actionHash: ActionHash | null } export interface Style { background?: string } export default function BottomPanel (props: BottomPanelProps): JSX.Element { const actionHash = props.actionHash function printListActions(): JSX.Element { if (actionHash === null) { return <> } const listOfActionKeys = Object.keys(actionHash).sort((a, b) => { const isDisabledComparisionValue: number = +actionHash[a].is_disabled - +actionHash[b].is_disabled if (isDisabledComparisionValue !== 0) { return isDisabledComparisionValue } if (actionHash[a].name < actionHash[b].name) { return -1 } if (actionHash[a].name > actionHash[b].name) { return 1 } return 0 }) function printDisabledReason (action: Action): JSX.Element { if (!action.is_disabled || action.disabled_reason === null) { return <> } return (

{action.disabled_reason}

) } return <>

Acciones disponibles.

{ listOfActionKeys.map((key) => { const style: Style = {} const action = actionHash[key] if (action.is_disabled) { style.background = 'lightgray' } return

{action.name}

{ printDisabledReason(action) }
}) } } return ( { printListActions() } ) }