import React from 'react';

import {Button, Modal} from 'src/components';

export const WidgetSettingsModal = (props) => {
  if (!props.settingsView) {
    return null;
  }

  return (
    <Modal show={props.show} onHide={props.onClose}>
      <Modal.Body>
        {React.createElement(props.settingsView, props.settingsViewProps)}
      </Modal.Body>
      <Modal.Footer>
        {props.buttons || null}
        <Button
          _hint="Cancel"
          size="sm"
          variant="secondary"
          onClick={props.onCancelButtonClick}
        >
          Cancel
        </Button>
        <Button
          _hint="Save"
          size="sm"
          variant="primary"
          onClick={props.onSaveButtonClick}
        >
          Save
        </Button>
      </Modal.Footer>
    </Modal>
  );
};
