import React from 'react'; import classNames from 'classnames'; import { useHistory } from 'react-router-dom'; import CustomersEmptyStatus from './CustomersEmptyStatus'; import TableSkeletonRows from 'components/Datatable/TableSkeletonRows'; import TableSkeletonHeader from 'components/Datatable/TableHeaderSkeleton'; import { DataTable, Choose } from 'components'; import { CLASSES } from 'common/classes'; import withCustomersActions from './withCustomersActions'; import withAlertsActions from 'containers/Alert/withAlertActions'; import withDialogActions from 'containers/Dialog/withDialogActions'; import { useCustomersListContext } from './CustomersListProvider'; import { ActionsMenu, useCustomersTableColumns } from './components'; import { compose } from 'utils'; /** * Customers table. */ function CustomersTable({ // #withCustomersActions setCustomersTableState, // #withAlerts openAlert }) { const history = useHistory(); // Customers table columns. const columns = useCustomersTableColumns(); // Customers list context. const { isEmptyStatus, customers, pagination, isCustomersLoading, isCustomersFetching, } = useCustomersListContext(); // Handle fetch data once the page index, size or sort by of the table change. const handleFetchData = React.useCallback( ({ pageSize, pageIndex, sortBy }) => { setCustomersTableState({ pageIndex, pageSize, sortBy, }); }, [setCustomersTableState], ); // Handles the customer delete action. const handleCustomerDelete = (customer) => { openAlert('customer-delete', { customerId: customer.id }) }; // Handle the customer edit action. const handleCustomerEdit = (customer) => { history.push(`/customers/${customer.id}/edit`); }; return (
); }; export default compose( withAlertsActions, withDialogActions, withCustomersActions, )(CustomersTable);