import React, {useState} from "react" import {useDispatch, useSelector} from "react-redux" import styles from "./FeedsList.pcss" import {selectFeeds} from "spotlight/admin-common/stores/feeds/selectors" import {deleteFeed, duplicateFeed} from "spotlight/admin-common/stores/feeds/thunks" import {Dashicon} from "spotlight/common/components/Dashicon" import {Link} from "spotlight/admin-common/components/Link" import {Button, ButtonSize, ButtonType} from "spotlight/admin-common/components/Button" import Table, {TableStyleMap} from "spotlight/admin-common/components/Table/Table" import {SCREENS} from "spotlight/admin-common/stores/ScreensStore" import {MenuContent, MenuItem, MenuSeparator, StatefulMenu} from "spotlight/admin-common/components/Containers/Menu" import {Ellipsis} from "spotlight/admin-common/components/Ellipsis" import {CopyShortcode} from "spotlight/admin-common/components/Feeds/CopyShortcode" import WalletInfoModal from "spotlight/admin-common/components/WalletInfoModal" import {Responsive} from "spotlight/utils/responsive" import {Feed} from "spotlight/admin-common/stores/feeds" import {removeToast, showToast, ToastType} from "spotlight/admin-common/stores/toasts" import {gotoRoute} from "spotlight/admin-common/stores/router" import CopyToClipboard from "react-copy-to-clipboard" import {getErrorResponseMessage} from "spotlight/common/modules/rest-api/client" import {RestApi} from "spotlight/common/modules/rest-api" import {AdminRestApi} from "spotlight/admin-common/modules/rest-api" import {triggerError} from "spotlight/common/modules/errors/handlers" import {selectWalletList} from "spotlight/admin-common/stores/wallets/selectors" import {Wallet} from "spotlight/common/modules/wallets" export function FeedsList() { const dispatch = useDispatch() const feeds = useSelector(selectFeeds) const handleDelete = (feed) => { if (confirm("Are you sure you want to delete this gallery? This cannot be undone.")) { dispatch(deleteFeed(feed)) } } const handleUpdatePosts = async (feed) => { const response = await RestApi.tokens.import(feed.options) if (!response?.data?.batching) { dispatch(showToast({ key: "admin/feeds/import/done", message: `Finished importing NFTs for "${feed.name}".`, })) } } const editFeed = (feed: Feed) => { dispatch(gotoRoute({ screen: SCREENS.EDIT_FEED, id: feed.id.toString(), })) } const handleDuplicateFeed = (feed: Feed) => { dispatch(duplicateFeed(feed)) } const handleClearCache = async (feed) => { dispatch(showToast({ key: "admin/feeds/clear_cache/wait", message: `Clearing the cache for "${feed.name}". This could take a while. Please wait ...`, type: ToastType.STICKY, })) try { await AdminRestApi.cache.clearForFeed(feed) dispatch(showToast({ key: "admin/feeds/clear_cache/done", message: `Finished clearing the cache for "${feed.name}."`, })) } catch (error) { triggerError({ type: "feeds/clear_cache/error", message: getErrorResponseMessage(error), }) } finally { dispatch(removeToast("admin/feeds/clear_cache/wait")) } } function onExport() { dispatch(showToast({ key: "admin/feeds/export", message: "Copied export code to clipboard!", })) } const styleMap: TableStyleMap = { cols: { name: styles.nameCol, sources: styles.sourcesCol, usages: styles.usagesCol, actions: styles.actionsCol, }, cells: { name: styles.nameCell, sources: styles.sourcesCell, usages: styles.usagesCell, actions: styles.actionsCell, }, } return (