import { createElement, Component, useState } from '@wordpress/element' import { __, sprintf } from 'ct-i18n' const SinglePremiumPlugin = ({ status, plugin, onPluginsSync }) => { const [isLoading, setIsLoading] = useState(false) const makeAction = async (plugin, actionName) => { const body = new FormData() body.append('plugin', plugin) body.append('action', actionName) setIsLoading(true) try { await fetch(ctDashboardLocalizations.ajax_url, { method: 'POST', body }) onPluginsSync() } catch (e) {} await new Promise(r => setTimeout(() => r(), 1000)) setIsLoading(false) } return (
  • {plugin.title}

    {plugin.author && ( ${ plugin.author }` ) }} /> )}
    {plugin.description &&

    {plugin.description}

    }
    {isLoading && } {!isLoading && status === 'activated' && ( makeAction( plugin.name, 'premium_plugin_deactivate' ) } className="ct-button"> {__('Deactivate', 'blocksy')} )} {!isLoading && status === 'deactivated' && ( makeAction( plugin.name, 'premium_plugin_activate' ) } className="ct-button-primary"> {__('Activate', 'blocksy')} )} {!isLoading && status === 'uninstalled' && !plugin.comingsoon && plugin.type !== 'link' && ( makeAction( plugin.name, 'premium_plugin_download' ) } className="ct-button"> {__('Install', 'blocksy')} )} {!isLoading && status === 'uninstalled' && !plugin.comingsoon && plugin.type === 'link' && ( {__('Download', 'blocksy')} )} {!isLoading && status === 'uninstalled' && plugin.comingsoon && ( {__('COMING SOON', 'blocksy')} )}
  • ) } export default SinglePremiumPlugin