// @flow import React, { Component } from 'react'; import { apiFetch, components, i18n } from '../../wp'; import TestPreview from './TestPreview'; import Loader from '../Loader/Loader'; import { decodeLink } from '../../helpers/wordpress'; import './EditWrapper.css'; const { Button } = components; const { __ } = i18n; type EditWrapperProps = { id: string; }; type EditWrapperState = { isLoading: boolean; html: string; editLink: string; }; class EditWrapper extends Component { state = { isLoading: true, html: '', editLink: '', }; componentDidMount() { const { id } = this.props; apiFetch({ path: `/ab-testing-for-wp/v1/get-test-content-by-post?id=${id}` }) .then((result) => { this.setState({ isLoading: false, html: result.html, editLink: decodeLink(result.editLink), }); }); } render() { const { isLoading, html, editLink } = this.state; return (
{isLoading && !html ? : }
); } } export default EditWrapper;