import React, { useEffect, useCallback, useState, useMemo } from 'react'; import { Button, Popover, Menu, MenuItem, Position, Alert, Intent, } from '@blueprintjs/core'; import { useQuery } from 'react-query'; import Icon from 'components/Icon'; import { compose } from 'utils'; import DialogConnect from 'connectors/Dialog.connector'; import LoadingIndicator from 'components/LoadingIndicator'; import DataTable from 'components/DataTable'; import AppToaster from 'components/AppToaster'; import withDashboard from 'connectors/Dashboard.connector'; import withCurrencies from 'containers/Currencies/withCurrencies'; import withCurrenciesActions from 'containers/Currencies/withCurrenciesActions'; import { FormattedMessage as T, useIntl } from 'react-intl'; function CurrenciesList({ // #withCurrencies currenciesList, // #withCurrenciesActions requestDeleteCurrency, requestFetchCurrencies, // #withDialog openDialog, onFetchData, }) { const [deleteCurrencyState, setDeleteCurrencyState] = useState(false); const { formatMessage } = useIntl() const fetchCurrencies = useQuery(['currencies-table'], () => requestFetchCurrencies()); const handleEditCurrency = (currency) => { openDialog('currency-form', { action: 'edit', currencyCode: currency.currency_code, }); }; const onDeleteCurrency = (currency) => { setDeleteCurrencyState(currency); }; const handleCancelCurrencyDelete = () => { setDeleteCurrencyState(false); }; const handleConfirmCurrencyDelete = useCallback(() => { requestDeleteCurrency(deleteCurrencyState.currency_code).then( (response) => { setDeleteCurrencyState(false); AppToaster.show({ message: formatMessage({id:'the_currency_has_been_successfully_deleted'}), }); } ); }, [deleteCurrencyState]); const actionMenuList = useCallback((currency) => (
), []); const columns = useMemo(() => [ { Header: formatMessage({id:'currency_name'}), accessor: 'currency_name', width: 100, }, { Header: formatMessage({id:'currency_code'}), accessor: 'currency_code', className: 'currency_code', width: 100, }, { Header: 'Currency sign', width: 50, }, { id: 'actions', Header: '', Cell: ({ cell }) => (Are you sure you want to move filename to Trash? You will be able to restore it later, but it will become private to you.