mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
refactoring: sales tables.
refacoring: purchases tables.
This commit is contained in:
@@ -8,6 +8,7 @@ import withAlertActions from 'containers/Alert/withAlertActions';
|
||||
|
||||
import { useActivateAccount } from 'hooks/query';
|
||||
import { compose } from 'utils';
|
||||
|
||||
/**
|
||||
* Account activate alert.
|
||||
*/
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -12,6 +12,9 @@ import withAlertActions from 'containers/Alert/withAlertActions';
|
||||
|
||||
import { compose } from 'utils';
|
||||
|
||||
/**
|
||||
* Account bulk delete alert.
|
||||
*/
|
||||
function AccountBulkDeleteAlert({
|
||||
// #ownProps
|
||||
name,
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -40,8 +40,9 @@ function BillOpenAlert({
|
||||
}),
|
||||
intent: Intent.SUCCESS,
|
||||
});
|
||||
closeAlert(name);
|
||||
})
|
||||
.finally((error) => {
|
||||
.catch((error) => {
|
||||
closeAlert(name);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useCallback, useState } from 'react';
|
||||
import React, { useCallback } from 'react';
|
||||
import {
|
||||
FormattedMessage as T,
|
||||
FormattedHTMLMessage,
|
||||
|
||||
@@ -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 (
|
||||
<Alert
|
||||
@@ -77,5 +71,4 @@ function EstimateRejectAlert({
|
||||
export default compose(
|
||||
withAlertStoreConnect(),
|
||||
withAlertActions,
|
||||
withEstimateActions,
|
||||
)(EstimateRejectAlert);
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
import React, { useCallback } from 'react';
|
||||
import React from 'react';
|
||||
import {
|
||||
FormattedMessage as T,
|
||||
FormattedHTMLMessage,
|
||||
useIntl,
|
||||
} from 'react-intl';
|
||||
import { Intent, Alert } from '@blueprintjs/core';
|
||||
import { queryCache } from 'react-query';
|
||||
|
||||
import { AppToaster } from 'components';
|
||||
import { useDeleteInvoice } from 'hooks/query';
|
||||
|
||||
import { handleDeleteErrors } from 'containers/Sales/Invoice/components';
|
||||
import { handleDeleteErrors } from 'containers/Sales/Invoices/InvoicesLanding/components';
|
||||
|
||||
import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
|
||||
import withAlertActions from 'containers/Alert/withAlertActions';
|
||||
import withInvoiceActions from 'containers/Sales/Invoice/withInvoiceActions';
|
||||
|
||||
import { compose } from 'utils';
|
||||
|
||||
@@ -32,12 +29,9 @@ function InvoiceDeleteAlert({
|
||||
closeAlert,
|
||||
}) {
|
||||
const { formatMessage } = useIntl();
|
||||
const {
|
||||
mutateAsync: deleteInvoiceMutate,
|
||||
isLoading
|
||||
} = useDeleteInvoice();
|
||||
const { mutateAsync: deleteInvoiceMutate, isLoading } = useDeleteInvoice();
|
||||
|
||||
// handle cancel delete invoice alert.
|
||||
// handle cancel delete invoice alert.
|
||||
const handleCancelDeleteAlert = () => {
|
||||
closeAlert(name);
|
||||
};
|
||||
@@ -84,5 +78,4 @@ function InvoiceDeleteAlert({
|
||||
export default compose(
|
||||
withAlertStoreConnect(),
|
||||
withAlertActions,
|
||||
withInvoiceActions,
|
||||
)(InvoiceDeleteAlert);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user