import React from 'react';
import { LoadingIndicatorPage, useGlobalContext, request } from 'strapi-helper-plugin';
import { Header } from '@buffetjs/custom';
import { useHistory } from 'react-router-dom';
import { useFetchPluginsFromMarketPlace } from '../../hooks';
import PageTitle from '../../components/PageTitle';
import PluginCard from './PluginCard';
import Wrapper from './Wrapper';
const MarketPlacePage = () => {
const history = useHistory();
const { autoReload, currentEnvironment, formatMessage, plugins } = useGlobalContext();
const { error, isLoading, data } = useFetchPluginsFromMarketPlace();
if (isLoading || error) {
return ;
}
const handleDownloadPlugin = async pluginId => {
// Force the Overlayblocker to be displayed
const overlayblockerParams = {
enabled: true,
title: 'app.components.InstallPluginPage.Download.title',
description: 'app.components.InstallPluginPage.Download.description',
};
// Lock the app
strapi.lockApp(overlayblockerParams);
try {
const opts = {
method: 'POST',
body: {
plugin: pluginId,
port: window.location.port,
},
};
const response = await request('/admin/plugins/install', opts, overlayblockerParams);
if (response.ok) {
// Reload the app
window.location.reload();
}
} catch (err) {
strapi.unlockApp();
strapi.notification.toggle({
type: 'warning',
message: { id: 'notification.error' },
});
}
};
return (
{data.map(plugin => {
return (
);
})}
);
};
export default MarketPlacePage;