UNPKG

playball

Version:

Watch MLB games from the comfort of your terminal

42 lines 1.77 kB
import React from 'react'; import { useSelector } from "react-redux/lib/alternate-renderers.js"; import { selectCurrentPlay } from "../features/games.js"; function AtBat() { const currentPlay = useSelector(selectCurrentPlay); const playEvents = currentPlay.playEvents; const playResult = currentPlay.about.isComplete ? currentPlay.result.description : ''; let content = ''; if (playResult) { content += `${playResult}\n\n`; } if (playEvents && playEvents.length) { content += playEvents.slice().reverse().map(event => { let line = ''; if (event.isPitch) { var _event$pitchData, _event$details, _event$details2; line = `[${event.details.description}] `; if ((_event$pitchData = event.pitchData) !== null && _event$pitchData !== void 0 && _event$pitchData.startSpeed) { line += `${event.pitchData.startSpeed} MPH `; } if ((_event$details = event.details) !== null && _event$details !== void 0 && (_event$details = _event$details.type) !== null && _event$details !== void 0 && _event$details.description) { line += event.details.type.description; } if (!((_event$details2 = event.details) !== null && _event$details2 !== void 0 && _event$details2.isInPlay)) { line += `{|} ${event.count.balls}-${event.count.strikes}`; } } else { var _event$details3; if ((_event$details3 = event.details) !== null && _event$details3 !== void 0 && _event$details3.event) { line += `[${event.details.event}] `; } line += event.details.description; } return line; }).join('\n'); } return /*#__PURE__*/React.createElement("box", { content: content, tags: true }); } export default AtBat;