import * as React from 'react' import type { Location } from '@lastres/location' import type { PJ } from '@lastres/pj' import type { LogLine } from '@lastres/log-line' import PJListItem from '@lastres/components/pj-list-item' import PresentationItem from '@lastres/components/presentation-item' import Presentation from '@lastres/components/presentation' import LogPanel from '@lastres/components/log-panel' import MoveToPacket from '@lastres/output-packet/move-to' interface UpperPanelProps { connectedLocations: Location[] | null teamPJs: PJ[] | null currentLocation: Location | null logLines: LogLine[] | null websocket: WebSocket | null logPresentationRef: React.RefObject movingTo: Location | null remainingFrames: number | null } export default function UpperPanel (props: UpperPanelProps): JSX.Element { const connectedLocations = props.connectedLocations const teamPJs = props.teamPJs const currentLocation = props.currentLocation const logLines = props.logLines const websocket = props.websocket const logPresentationRef = props.logPresentationRef if (!(teamPJs !== null && currentLocation !== null && connectedLocations !== null)) { return ( <>

Esperando datos...

) } function onClickLocation (item: Location): void { const moveToPacket = new MoveToPacket(item) if (websocket !== null) { moveToPacket.send(websocket) } } function availableLocationsToMove (): JSX.Element { if (connectedLocations === null || connectedLocations.length === 0) { return ( <> ) } return ( <>

Puedes ir a:

) } function showLocationMenuHeaderText (): JSX.Element { if (currentLocation === null) { return <> } if (props.movingTo === null) { return

Estás en {currentLocation.area.name} / {currentLocation.location.name}.

} return

Estás yendo a {props.movingTo.area.name} / {props.movingTo.location.name}.

} function showRemainingFrames (): JSX.Element { if (props.movingTo === null) { return <> } if (props.remainingFrames === null) { return <> } return (

Te quedan {props.remainingFrames} frames para terminar la acción.

) } return ( { teamPJs.map((item, i) => { return }) } { showLocationMenuHeaderText() } { showRemainingFrames() } { availableLocationsToMove() } ) }