/**
 * @author Martin Karkowski
 * @email m.karkowski@zema.de
 * @create date 2021-04-20 19:04:57
 * @modify date 2021-04-20 19:04:57
 * @desc [description]
 */

import React from "react";
import { Modal } from "react-bootstrap";
import DynamicRenderer from "../dynamic/dynamicRenderer";
import { IModalSettings } from "./interfaces/IModalSettings";

export class StaticPopup extends React.Component<
  { withoutBorder?: boolean } & IModalSettings
> {
  /**
   * Create the Status to Render.
   * @param props
   */
  constructor(props) {
    super(props);
    this.state = { modalVisible: true };
  }

  render(): JSX.Element {
    return (
      <Modal
        show={true}
        backdrop={
          typeof this.props.backdrop !== undefined
            ? this.props.backdrop
            : "static"
        }
        keyboard={false}
        size={this.props.size}
        centered={this.props.centered || false}
        onHide={this.props.onHide}
        scrollable
      >
        {this.props.header ? (
          <Modal.Header closeButton={this.props.closeButton}>
            <Modal.Title>{this.props.header}</Modal.Title>
          </Modal.Header>
        ) : (
          ""
        )}

        {this.props.withoutBorder ? (
          <DynamicRenderer
            component={this.props.content.component}
            props={this.props.content.props}
          />
        ) : (
          <Modal.Body style={{ border: 0 }}>
            {/* Render the dynamic Component  */}
            <DynamicRenderer
              component={this.props.content.component}
              props={this.props.content.props}
            />
          </Modal.Body>
        )}

        {this.props.footer ? (
          <Modal.Footer>{this.props.footer}</Modal.Footer>
        ) : (
          ""
        )}
      </Modal>
    );
  }
}
