import React from "react";

import { GD_VehicleBlockActionsProps } from "../../../utils/Component";
import VehicleBlockAction from "../VehicleBlockAction";
import VehicleBlockSectionHeader from "../VehicleBlockSectionHeader";

interface Props extends GD_VehicleBlockActionsProps {}
export default class VehicleBlockActions extends React.PureComponent<Props> {
  static defaultProps = {
    reactions: [],
    bonusActions: [],
    special: [],
  };

  render() {
    const { reactions, bonusActions, special } = this.props;

    if (
      reactions.length === 0 &&
      bonusActions.length === 0 &&
      special.length === 0
    ) {
      return null;
    }

    return (
      <>
        {reactions.length > 0 && (
          <>
            <VehicleBlockSectionHeader label="Reactions" />
            {reactions.map((action) => (
              <VehicleBlockAction action={action} key={action.key} />
            ))}
          </>
        )}
        {bonusActions.length > 0 && (
          <>
            <VehicleBlockSectionHeader label="Bonus Actions" />
            {bonusActions.map((action) => (
              <VehicleBlockAction action={action} key={action.key} />
            ))}
          </>
        )}
        {special.length > 0 && (
          <>
            <VehicleBlockSectionHeader label="Special Actions" />
            {special.map((action) => (
              <VehicleBlockAction action={action} key={action.key} />
            ))}
          </>
        )}
      </>
    );
  }
}
