import { PureComponent, PropsWithChildren } from "react";

import { Constants } from "@dndbeyond/character-rules-engine/es";

import { GD_VehicleBlockShellProps } from "../../../utils/Component";
import VehicleBlockShellCap from "../VehicleBlockShellCap";

interface Props extends GD_VehicleBlockShellProps, PropsWithChildren {}

export default class VehicleBlockShell extends PureComponent<Props> {
  render() {
    const { children, displayType } = this.props;

    let type: string | null = null;

    switch (displayType) {
      case Constants.VehicleConfigurationDisplayTypeEnum.INFERNAL_WAR_MACHINE:
        type = "infernal";
        break;
      case Constants.VehicleConfigurationDisplayTypeEnum.ELEMENTAL_AIRSHIP:
        type = "elemental-airship";
        break;
      case Constants.VehicleConfigurationDisplayTypeEnum.SPELLJAMMER:
        type = "spelljammer";
        break;
      case Constants.VehicleConfigurationDisplayTypeEnum.SHIP:
      default:
        type = "ship";
        break;
    }

    return (
      <div className={`ct-vehicle-block ct-vehicle-block--${type}`}>
        <VehicleBlockShellCap displayType={displayType} />
        <div
          className={`ct-vehicle-block__block ct-vehicle-block__block--${type}`}
        >
          {children}
        </div>
        <VehicleBlockShellCap displayType={displayType} invertY={true} />
      </div>
    );
  }
}
