You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.2 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. /* eslint react/prop-types: 0 */
  2. import React, { Component } from "react";
  3. import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from "reactstrap";
  4. class ModalConfirm extends Component {
  5. constructor(props) {
  6. super(props);
  7. this.state = {
  8. modal: false
  9. };
  10. }
  11. toggle = () => {
  12. this.setState({
  13. modal: !this.state.modal
  14. });
  15. };
  16. getComponent = key => {
  17. return this.props.children.filter(comp => {
  18. return comp.key === key;
  19. });
  20. };
  21. render() {
  22. return (
  23. <Modal
  24. isOpen={this.state.modal}
  25. toggle={this.toggle}
  26. className={this.props.className + " modal-dialog-centered"}
  27. >
  28. <ModalHeader toggle={this.toggle}>
  29. {this.getComponent("title")}
  30. </ModalHeader>
  31. <ModalBody>{this.getComponent("body")}</ModalBody>
  32. <ModalFooter>
  33. <Button
  34. color="primary-outline"
  35. className="text-primary border-primary"
  36. onClick={this.toggle}
  37. >
  38. {this.getComponent("cancel")}
  39. </Button>
  40. <Button color="primary" onClick={this.toggle}>
  41. {this.getComponent("confirm")}
  42. </Button>
  43. </ModalFooter>
  44. </Modal>
  45. );
  46. }
  47. }
  48. export default ModalConfirm;