import { GridComponent, ColumnsDirective, ColumnDirective, Inject, Sort } from '@syncfusion/ej2-react-grids'; import React, { useEffect } from 'react'; import { Button, Popover, Menu, MenuItem, MenuDivider, Position, Checkbox } from '@blueprintjs/core'; import { useParams } from 'react-router-dom'; import useAsync from 'hooks/async'; import Icon from 'components/Icon'; import { handleBooleanChange, compose } from 'utils'; import AccountsConnect from 'connectors/Accounts.connector'; import DialogConnect from 'connectors/Dialog.connector'; import DashboardConnect from 'connectors/Dashboard.connector'; import ViewConnect from 'connectors/View.connector'; import LoadingIndicator from 'components/LoadingIndicator'; function AccountsDataTable({ filterConditions, accounts, onDeleteAccount, onInactiveAccount, openDialog, addBulkActionAccount, removeBulkActionAccount, fetchAccounts, changeCurrentView, changePageSubtitle, getViewItem, setTopbarEditView }) { const { custom_view_id: customViewId } = useParams(); // Fetch accounts list according to the given custom view id. const fetchHook = useAsync(async () => { await Promise.all([ fetchAccounts({ custom_view_id: customViewId, stringified_filter_roles: JSON.stringify(filterConditions) || '', }), ]); }); useEffect(() => { fetchHook.execute(); }, [filterConditions]); // Refetch accounts list after custom view id change. useEffect(() => { const viewMeta = getViewItem(customViewId); fetchHook.execute(); if (customViewId) { changeCurrentView(customViewId); setTopbarEditView(customViewId); } changePageSubtitle((customViewId && viewMeta) ? viewMeta.name : ''); }, [customViewId]); useEffect(() => () => { // Clear page subtitle when unmount the page. changePageSubtitle(''); }, []); const handleEditAccount = account => () => { openDialog('account-form', { action: 'edit', id: account.id }); }; const actionMenuList = account => (
); const handleClickCheckboxBulk = account => handleBooleanChange(value => { if (value) { addBulkActionAccount(account.id); } else { removeBulkActionAccount(account.id); } }); const columns = [ { field: '', headerText: '', template: account => (