diff --git a/client/src/containers/Alerts/AccountActivateAlert.js b/client/src/containers/Alerts/AccountActivateAlert.js index fd6dbe2f0..777af9dfa 100644 --- a/client/src/containers/Alerts/AccountActivateAlert.js +++ b/client/src/containers/Alerts/AccountActivateAlert.js @@ -8,6 +8,7 @@ import withAlertActions from 'containers/Alert/withAlertActions'; import { useActivateAccount } from 'hooks/query'; import { compose } from 'utils'; + /** * Account activate alert. */ diff --git a/client/src/containers/Alerts/AccountBulkActivateAlert.js b/client/src/containers/Alerts/AccountBulkActivateAlert.js index 3cb367b67..da2672003 100644 --- a/client/src/containers/Alerts/AccountBulkActivateAlert.js +++ b/client/src/containers/Alerts/AccountBulkActivateAlert.js @@ -1,9 +1,5 @@ import React, { useState } from 'react'; -import { - FormattedMessage as T, - FormattedHTMLMessage, - useIntl, -} from 'react-intl'; +import { FormattedMessage as T, useIntl } from 'react-intl'; import { Intent, Alert } from '@blueprintjs/core'; import { queryCache } from 'react-query'; import { AppToaster } from 'components'; diff --git a/client/src/containers/Alerts/AccountBulkDeleteAlert.js b/client/src/containers/Alerts/AccountBulkDeleteAlert.js index 663d1858e..dd18667a1 100644 --- a/client/src/containers/Alerts/AccountBulkDeleteAlert.js +++ b/client/src/containers/Alerts/AccountBulkDeleteAlert.js @@ -12,6 +12,9 @@ import withAlertActions from 'containers/Alert/withAlertActions'; import { compose } from 'utils'; +/** + * Account bulk delete alert. + */ function AccountBulkDeleteAlert({ // #ownProps name, diff --git a/client/src/containers/Alerts/AccountDeleteAlert.js b/client/src/containers/Alerts/AccountDeleteAlert.js index ddfbcf0e3..15014af68 100644 --- a/client/src/containers/Alerts/AccountDeleteAlert.js +++ b/client/src/containers/Alerts/AccountDeleteAlert.js @@ -13,7 +13,6 @@ import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect'; import withAlertActions from 'containers/Alert/withAlertActions'; import { useDeleteAccount } from 'hooks/query'; - import { compose } from 'utils'; /** @@ -48,12 +47,7 @@ function AccountDeleteAlert({ }); closeAlert(name); }) - .catch((error) => { - const { - response: { - data: { errors }, - }, - } = error; + .catch(({ response: { data: { errors } } }) => { handleDeleteErrors(errors); closeAlert(name); }); diff --git a/client/src/containers/Alerts/Bills/BillDeleteAlert.js b/client/src/containers/Alerts/Bills/BillDeleteAlert.js index 348c0e736..05c0076bf 100644 --- a/client/src/containers/Alerts/Bills/BillDeleteAlert.js +++ b/client/src/containers/Alerts/Bills/BillDeleteAlert.js @@ -10,7 +10,6 @@ import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect'; import withAlertActions from 'containers/Alert/withAlertActions'; import { useDeleteBill } from 'hooks/query'; - import { compose } from 'utils'; /** @@ -29,12 +28,12 @@ function BillDeleteAlert({ const { formatMessage } = useIntl(); const { isLoading, mutateAsync: deleteBillMutate } = useDeleteBill(); - // handle cancel Bill + // Handle cancel Bill const handleCancel = () => { closeAlert(name); }; - // handleConfirm delete invoice + // Handle confirm delete invoice const handleConfirmBillDelete = () => { deleteBillMutate(billId).then(() => { AppToaster.show({ diff --git a/client/src/containers/Alerts/Bills/BillOpenAlert.js b/client/src/containers/Alerts/Bills/BillOpenAlert.js index 828f75703..0093b4bb7 100644 --- a/client/src/containers/Alerts/Bills/BillOpenAlert.js +++ b/client/src/containers/Alerts/Bills/BillOpenAlert.js @@ -40,8 +40,9 @@ function BillOpenAlert({ }), intent: Intent.SUCCESS, }); + closeAlert(name); }) - .finally((error) => { + .catch((error) => { closeAlert(name); }); }; diff --git a/client/src/containers/Alerts/Estimates/EstimateDeleteAlert.js b/client/src/containers/Alerts/Estimates/EstimateDeleteAlert.js index b07c2833c..491a97ce9 100644 --- a/client/src/containers/Alerts/Estimates/EstimateDeleteAlert.js +++ b/client/src/containers/Alerts/Estimates/EstimateDeleteAlert.js @@ -1,4 +1,4 @@ -import React, { useCallback, useState } from 'react'; +import React, { useCallback } from 'react'; import { FormattedMessage as T, FormattedHTMLMessage, diff --git a/client/src/containers/Alerts/Estimates/EstimateRejectAlert.js b/client/src/containers/Alerts/Estimates/EstimateRejectAlert.js index a56ee3bd1..2a013ede2 100644 --- a/client/src/containers/Alerts/Estimates/EstimateRejectAlert.js +++ b/client/src/containers/Alerts/Estimates/EstimateRejectAlert.js @@ -1,14 +1,12 @@ -import React, { useCallback } from 'react'; +import React from 'react'; import { FormattedMessage as T, useIntl } from 'react-intl'; import { Intent, Alert } from '@blueprintjs/core'; -import { queryCache } from 'react-query'; import { AppToaster } from 'components'; import { useRejectEstimate } from 'hooks/query'; import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect'; import withAlertActions from 'containers/Alert/withAlertActions'; -import withEstimateActions from 'containers/Sales/Estimate/withEstimateActions'; import { compose } from 'utils'; @@ -22,9 +20,6 @@ function EstimateRejectAlert({ isOpen, payload: { estimateId }, - // #withEstimateActions - requestRejectEstimate, - // #withAlertActions closeAlert, }) { @@ -40,8 +35,8 @@ function EstimateRejectAlert({ }; // Handle confirm estimate reject. - const handleConfirmEstimateReject = useCallback(() => { - requestRejectEstimate(estimateId) + const handleConfirmEstimateReject = () => { + rejectEstimateMutate(estimateId) .then(() => { AppToaster.show({ message: formatMessage({ @@ -49,13 +44,12 @@ function EstimateRejectAlert({ }), intent: Intent.SUCCESS, }); - queryCache.invalidateQueries('estimates-table'); }) .catch((error) => {}) .finally(() => { closeAlert(name); }); - }, [estimateId, rejectEstimateMutate, formatMessage]); + }; return ( { closeAlert(name); }; @@ -84,5 +78,4 @@ function InvoiceDeleteAlert({ export default compose( withAlertStoreConnect(), withAlertActions, - withInvoiceActions, )(InvoiceDeleteAlert); diff --git a/client/src/containers/Alerts/Invoices/InvoiceDeliverAlert.js b/client/src/containers/Alerts/Invoices/InvoiceDeliverAlert.js index 96cc5c5f3..5badf9335 100644 --- a/client/src/containers/Alerts/Invoices/InvoiceDeliverAlert.js +++ b/client/src/containers/Alerts/Invoices/InvoiceDeliverAlert.js @@ -7,7 +7,6 @@ import { AppToaster } from 'components'; import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect'; import withAlertActions from 'containers/Alert/withAlertActions'; -import withInvoiceActions from 'containers/Sales/Invoice/withInvoiceActions'; import { compose } from 'utils'; @@ -72,5 +71,4 @@ function InvoiceDeliverAlert({ export default compose( withAlertStoreConnect(), withAlertActions, - withInvoiceActions, )(InvoiceDeliverAlert); diff --git a/client/src/containers/Dialogs/EstimateNumberDialog/EstimateNumberDialogContent.js b/client/src/containers/Dialogs/EstimateNumberDialog/EstimateNumberDialogContent.js index fda4a8d68..42a8267a0 100644 --- a/client/src/containers/Dialogs/EstimateNumberDialog/EstimateNumberDialogContent.js +++ b/client/src/containers/Dialogs/EstimateNumberDialog/EstimateNumberDialogContent.js @@ -6,7 +6,6 @@ import ReferenceNumberForm from 'containers/JournalNumber/ReferenceNumberForm'; import withDialogActions from 'containers/Dialog/withDialogActions'; import withSettings from 'containers/Settings/withSettings'; import withSettingsActions from 'containers/Settings/withSettingsActions'; -import withEstimateActions from 'containers/Sales/Estimate/withEstimateActions'; import { compose, optionsMapToArray } from 'utils'; @@ -18,15 +17,13 @@ function EstimateNumberDialogContent({ // #withSettings nextNumber, numberPrefix, + // #withSettingsActions requestFetchOptions, requestSubmitOptions, // #withDialogActions closeDialog, - - // #withEstimateActions - setEstimateNumberChanged, }) { const fetchSettings = useQuery(['settings'], () => requestFetchOptions({})); @@ -41,7 +38,7 @@ function EstimateNumberDialogContent({ setTimeout(() => { queryCache.invalidateQueries('settings'); - setEstimateNumberChanged(true); + // setEstimateNumberChanged(true); }, 250); }) .catch(() => { @@ -72,5 +69,4 @@ export default compose( nextNumber: estimatesSettings?.nextNumber, numberPrefix: estimatesSettings?.numberPrefix, })), - withEstimateActions, )(EstimateNumberDialogContent); diff --git a/client/src/containers/Dialogs/InvoiceNumberDialog/InvoiceNumberDialogContent.js b/client/src/containers/Dialogs/InvoiceNumberDialog/InvoiceNumberDialogContent.js index 33783df40..a9aa09cb5 100644 --- a/client/src/containers/Dialogs/InvoiceNumberDialog/InvoiceNumberDialogContent.js +++ b/client/src/containers/Dialogs/InvoiceNumberDialog/InvoiceNumberDialogContent.js @@ -7,7 +7,7 @@ import ReferenceNumberForm from 'containers/JournalNumber/ReferenceNumberForm'; import withDialogActions from 'containers/Dialog/withDialogActions'; import withSettings from 'containers/Settings/withSettings'; import withSettingsActions from 'containers/Settings/withSettingsActions'; -import withInvoicesActions from 'containers/Sales/Invoice/withInvoiceActions'; +// import withInvoicesActions from 'containers/Sales/Invoice/withInvoiceActions'; import { compose, optionsMapToArray } from 'utils'; @@ -28,7 +28,7 @@ function InvoiceNumberDialogContent({ closeDialog, // #withInvoicesActions - setInvoiceNumberChanged, + // setInvoiceNumberChanged, }) { const fetchSettings = useQuery(['settings'], () => requestFetchOptions({})); @@ -44,7 +44,7 @@ function InvoiceNumberDialogContent({ setTimeout(() => { queryCache.invalidateQueries('settings'); - setInvoiceNumberChanged(true); + // setInvoiceNumberChanged(true); }, 250); }) .catch(() => { @@ -75,5 +75,5 @@ export default compose( nextNumber: invoiceSettings?.nextNumber, numberPrefix: invoiceSettings?.numberPrefix, })), - withInvoicesActions, + // withInvoicesActions, )(InvoiceNumberDialogContent); diff --git a/client/src/containers/Dialogs/PaymentReceiveNumberDialog/PaymentReceiveNumberDialogContent.js b/client/src/containers/Dialogs/PaymentReceiveNumberDialog/PaymentReceiveNumberDialogContent.js index 302b08cad..b0fa75c2e 100644 --- a/client/src/containers/Dialogs/PaymentReceiveNumberDialog/PaymentReceiveNumberDialogContent.js +++ b/client/src/containers/Dialogs/PaymentReceiveNumberDialog/PaymentReceiveNumberDialogContent.js @@ -1,13 +1,13 @@ import React, { useCallback } from 'react'; import { DialogContent } from 'components'; -import { useQuery, queryCache } from 'react-query'; +import { useQuery } from 'react-query'; import ReferenceNumberForm from 'containers/JournalNumber/ReferenceNumberForm'; import withDialogActions from 'containers/Dialog/withDialogActions'; import withSettingsActions from 'containers/Settings/withSettingsActions'; import withSettings from 'containers/Settings/withSettings'; -import withPaymentReceivesActions from 'containers/Sales/PaymentReceive/withPaymentReceivesActions'; +// import withPaymentReceivesActions from 'containers/Sales/PaymentReceive/withPaymentReceivesActions'; import { compose, optionsMapToArray } from 'utils'; @@ -28,7 +28,7 @@ function PaymentNumberDialogContent({ closeDialog, // #withPaymentReceivesActions - setPaymentReceiveNumberChanged, + // setPaymentReceiveNumberChanged, }) { const fetchSettings = useQuery(['settings'], () => requestFetchOptions({})); @@ -43,8 +43,7 @@ function PaymentNumberDialogContent({ closeDialog('payment-receive-number-form'); setTimeout(() => { - queryCache.invalidateQueries('settings'); - setPaymentReceiveNumberChanged(true); + // setPaymentReceiveNumberChanged(true); }, 250); }) .catch(() => { @@ -76,5 +75,5 @@ export default compose( nextNumber: paymentReceiveSettings?.nextNumber, numberPrefix: paymentReceiveSettings?.numberPrefix, })), - withPaymentReceivesActions, + // withPaymentReceivesActions, )(PaymentNumberDialogContent); diff --git a/client/src/containers/Dialogs/ReceiptNumberDialog/ReceiptNumberDialogContent.js b/client/src/containers/Dialogs/ReceiptNumberDialog/ReceiptNumberDialogContent.js index 39eee1f0d..76c9100ce 100644 --- a/client/src/containers/Dialogs/ReceiptNumberDialog/ReceiptNumberDialogContent.js +++ b/client/src/containers/Dialogs/ReceiptNumberDialog/ReceiptNumberDialogContent.js @@ -1,13 +1,12 @@ import React, { useCallback } from 'react'; import { DialogContent } from 'components'; -import { useQuery, queryCache } from 'react-query'; +import { useQuery } from 'react-query'; import ReferenceNumberForm from 'containers/JournalNumber/ReferenceNumberForm'; import withDialogActions from 'containers/Dialog/withDialogActions'; import withSettings from 'containers/Settings/withSettings'; import withSettingsActions from 'containers/Settings/withSettingsActions'; -import withReceiptActions from 'containers/Sales/Receipt/withReceiptActions'; import { compose, optionsMapToArray } from 'utils'; @@ -43,7 +42,6 @@ function ReceiptNumberDialogContent({ closeDialog('receipt-number-form'); setTimeout(() => { - queryCache.invalidateQueries('settings'); setReceiptNumberChanged(true); }, 250); }) @@ -75,5 +73,4 @@ export default compose( nextNumber: receiptSettings?.nextNumber, numberPrefix: receiptSettings?.numberPrefix, })), - withReceiptActions, )(ReceiptNumberDialogContent); diff --git a/client/src/containers/Expenses/ExpensesLanding/ExpensesList.js b/client/src/containers/Expenses/ExpensesLanding/ExpensesList.js index 83ce58a3b..4765654cd 100644 --- a/client/src/containers/Expenses/ExpensesLanding/ExpensesList.js +++ b/client/src/containers/Expenses/ExpensesLanding/ExpensesList.js @@ -1,6 +1,8 @@ import React, { useEffect } from 'react'; - import { useIntl } from 'react-intl'; + +import 'style/pages/Expense/List.scss'; + import DashboardPageContent from 'components/Dashboard/DashboardPageContent'; import ExpenseActionsBar from './ExpenseActionsBar'; diff --git a/client/src/containers/Purchases/Bill/BillsDataTable.js b/client/src/containers/Purchases/Bill/BillsDataTable.js deleted file mode 100644 index e41ae752c..000000000 --- a/client/src/containers/Purchases/Bill/BillsDataTable.js +++ /dev/null @@ -1,296 +0,0 @@ -import React, { useCallback, useMemo } from 'react'; -import { - Intent, - Button, - Popover, - Menu, - MenuItem, - MenuDivider, - Position, - Tag, -} from '@blueprintjs/core'; - -import { withRouter } from 'react-router'; -import { FormattedMessage as T, useIntl } from 'react-intl'; -import moment from 'moment'; -import classNames from 'classnames'; - -import Icon from 'components/Icon'; -import { compose, saveInvoke, isBlank } from 'utils'; -import { CLASSES } from 'common/classes'; -import { useIsValuePassed } from 'hooks'; - -import { LoadingIndicator, Money, Choose, If } from 'components'; -import DataTable from 'components/DataTable'; -import BillsEmptyStatus from './BillsEmptyStatus'; - -import withDialogActions from 'containers/Dialog/withDialogActions'; -import withDashboardActions from 'containers/Dashboard/withDashboardActions'; -import withViewDetails from 'containers/Views/withViewDetails'; - -import withBills from './withBills'; -import withBillActions from './withBillActions'; -import withCurrentView from 'containers/Views/withCurrentView'; -import withSettings from 'containers/Settings/withSettings'; - -// Bills transactions datatable. -function BillsDataTable({ - // #withBills - billsCurrentPage, - billsLoading, - billsPageination, - billsCurrentViewId, - - // #withDashboardActions - changeCurrentView, - changePageSubtitle, - setTopbarEditView, - - // #withBillsActions - addBillsTableQueries, - - // #withView - viewMeta, - - // #withSettings - baseCurrency, - - // #ownProps - loading, - onFetchData, - onEditBill, - onDeleteBill, - onOpenBill, - onSelectedRowsChange, -}) { - const { formatMessage } = useIntl(); - - const handleFetchData = useCallback( - ({ pageIndex, pageSize, sortBy }) => { - const page = pageIndex + 1; - - addBillsTableQueries({ - ...(sortBy.length > 0 - ? { - column_sort_by: sortBy[0].id, - sort_order: sortBy[0].desc ? 'desc' : 'asc', - } - : {}), - page_size: pageSize, - page, - }); - }, - [addBillsTableQueries], - ); - - const handleEditBill = useCallback( - (_bill) => () => { - saveInvoke(onEditBill, _bill); - }, - [onEditBill], - ); - - const handleDeleteBill = useCallback( - (_bill) => () => { - saveInvoke(onDeleteBill, _bill); - }, - [onDeleteBill], - ); - - const actionMenuList = useCallback( - (bill) => ( - - } - text={formatMessage({ id: 'view_details' })} - /> - - } - text={formatMessage({ id: 'edit_bill' })} - onClick={handleEditBill(bill)} - /> - - onOpenBill(bill)} - /> - - - } - /> - - ), - [handleDeleteBill, handleEditBill, formatMessage], - ); - - const onRowContextMenu = useCallback( - (cell) => { - return actionMenuList(cell.row.original); - }, - [actionMenuList], - ); - - const columns = useMemo( - () => [ - { - id: 'bill_date', - Header: formatMessage({ id: 'bill_date' }), - accessor: (r) => moment(r.bill_date).format('YYYY MMM DD'), - width: 140, - className: 'bill_date', - }, - { - id: 'vendor_id', - Header: formatMessage({ id: 'vendor_name' }), - accessor: 'vendor.display_name', - width: 140, - className: 'vendor_id', - }, - { - id: 'bill_number', - Header: formatMessage({ id: 'bill_number' }), - accessor: (row) => (row.bill_number ? `#${row.bill_number}` : null), - width: 140, - className: 'bill_number', - }, - { - id: 'due_date', - Header: formatMessage({ id: 'due_date' }), - accessor: (r) => moment(r.due_date).format('YYYY MMM DD'), - width: 140, - className: 'due_date', - }, - { - id: 'amount', - Header: formatMessage({ id: 'amount' }), - accessor: (row) => - !isBlank(row.amount) ? ( - - ) : ( - '' - ), - width: 140, - className: 'amount', - }, - { - id: 'status', - Header: formatMessage({ id: 'status' }), - accessor: (row) => ( - - - - - - - - - - - - - - ), - width: 140, - className: 'status', - }, - { - id: 'reference_no', - Header: formatMessage({ id: 'reference_no' }), - accessor: 'reference_no', - width: 140, - className: 'reference_no', - }, - { - id: 'actions', - Header: '', - Cell: ({ cell }) => ( - -