import { orderBy } from "lodash"; import React from "react"; import { BasicActionContract, CharacterTheme, } from "@dndbeyond/character-rules-engine/es"; interface Props { basicActions: Array; onActionClick?: (basicAction: BasicActionContract) => void; theme: CharacterTheme; } export default class BasicActions extends React.PureComponent { handleActionClick = ( basicAction: BasicActionContract, evt: React.MouseEvent ): void => { const { onActionClick } = this.props; if (onActionClick) { evt.stopPropagation(); evt.nativeEvent.stopImmediatePropagation(); onActionClick(basicAction); } }; render() { const { basicActions, theme } = this.props; if (!basicActions.length) { return null; } let orderedActions = orderBy( basicActions, [(basicAction) => basicAction.name], ["asc"] ); return (
{orderedActions.map((basicAction, idx) => ( {basicAction.name} {idx + 1 < orderedActions.length && ( , )} ))}
); } }