import React, { useState } from 'react'; import { Button } from '@strapi/design-system/Button'; import { Dialog, DialogBody, DialogFooter } from '@strapi/design-system/Dialog'; import { Stack } from '@strapi/design-system/Stack'; import { Typography } from '@strapi/design-system/Typography'; import { Tooltip } from '@strapi/design-system/Tooltip'; import { request } from "@strapi/helper-plugin"; import PluginIcon from './PluginIcon'; import { currentCollection } from '../utils/urlHelper'; const FetchRetailers = () => { const [loading, setLoading] = useState(false); const [dialogVisible, setDialogVisible] = useState(false); const [result, setResult] = useState(null); const onFetch = async () => { if (!loading) { setLoading(true); const resp = await request("/dutchie-plus/sync_retailers", { method: 'POST' }) setResult(resp.message); setDialogVisible(true); setLoading(false); } } const collection = currentCollection(window.location.pathname); if (collection !== 'retailer') { return null; } const onDone = () => { setDialogVisible(false); window.location.reload(); } return ( <> setDialogVisible(false)} title="Success" isOpen={dialogVisible}> { result && result.map(msg => ( {msg} )) } {'Done & Refresh'} } /> ) } export default FetchRetailers;