import {Component} from "@wordpress/element"; import { __ } from '@wordpress/i18n'; import * as cmplz_api from "../utils/api"; import Icon from "../utils/Icon"; class Modal extends Component { constructor() { super( ...arguments ); this.state = { data:[], buttonsDisabled:false, }; } dismissModal(dropItem){ this.props.handleModal(false, null, dropItem); } componentDidMount() { this.setState({ data:this.props.data, buttonsDisabled:false, }); } handleFix(e){ //set to disabled let action = this.props.data.action; this.setState({ buttonsDisabled:true }); cmplz_api.doAction(action, 'refresh', this.props.data ).then( ( response ) => { this.props.data let { data, } = this.state; data.description = response.msg; data.subtitle = ''; this.setState({ data: data, }); let item = this.props.data; if (response.success) { this.dismissModal(this.props.data); } }); } render(){ const { data, buttonsDisabled, } = this.state; let disabled = buttonsDisabled ? 'disabled' : ''; let description = data.description; return (
this.dismissModal(e) }> 

{data.title}

{data.subtitle &&
{data.subtitle}
} { Array.isArray(description) && description.map( (s, i) =>
{s}
) }
{ data.edit && {__("Edit", "complianz-gdpr")}} { data.help && {__("Help", "complianz-gdpr")}} { (!data.ignored && data.action==='ignore_url') && } { data.action!=='ignore_url' && }
) } } export default Modal;