import React, { useCallback, useMemo } from 'react'; import { Button, Popover, Menu, Intent, MenuItem, MenuDivider, Position, } from '@blueprintjs/core'; import { FormattedMessage as T, useIntl } from 'react-intl'; import moment from 'moment'; import classNames from 'classnames'; import { DataTable, If, Money, Choose, Icon, LoadingIndicator, } from 'components'; import { CLASSES } from 'common/classes'; import { useIsValuePassed } from 'hooks'; import withDialogActions from 'containers/Dialog/withDialogActions'; // withInventoryAdjustments // withInventoryAdjustmentsActions import { compose, saveInvoke } from 'utils'; import { withRouter } from 'react-router-dom'; function InventoryAdjustmentDataTable({ // #ownProps onDeleteInventoryAdjustment, onSelectedRowsChange, }) { const { formatMessage } = useIntl(); const handleDeleteInventoryAdjustment = useCallback( (_inventory) => { saveInvoke(onDeleteInventoryAdjustment, _inventory); }, [onDeleteInventoryAdjustment], ); const actionMenuList = useCallback( (adjustment) => ( } text={formatMessage({ id: 'view_details' })} /> } intent={Intent.DANGER} onClick={handleDeleteInventoryAdjustment(adjustment)} /> ), [handleDeleteInventoryAdjustment, formatMessage], ); const onRowContextMenu = useCallback( (cell) => actionMenuList(cell.row.original), [actionMenuList], ); const columns = useMemo( () => [ { id: 'date', Header: formatMessage({ id: 'date' }), accessor: (r) => moment(r.date).format('YYYY MMM DD'), width: 115, className: 'date', }, { id: 'type', Header: formatMessage({ id: 'type' }), accessor: 'type', className: 'type', width: 100, }, { id: 'reason', Header: formatMessage({ id: 'reason' }), // accessor: (r) => ( // // // ), className: 'reason', width: 115, }, { id: 'reference', Header: formatMessage({ id: 'reference' }), accessor: (row) => `#${row.reference}`, className: 'reference', width: 100, }, { id: 'status', Header: formatMessage({ id: 'status' }), accessor: 'status', width: 95, className: 'status', }, { id: 'description', Header: formatMessage({ id: 'description' }), disableSorting: true, width: 85, className: 'description', }, { id: 'created_at', Header: formatMessage({ id: 'created_at' }), accessor: (r) => moment(r.created_at).format('YYYY MMM DD'), width: 125, className: 'created_at', }, { id: 'actions', Header: '', Cell: ({ cell }) => (