refactoring: expenses landing list.

refactoring: customers landing list.
refactoring: vendors landing list.
refactoring: manual journals landing list.
This commit is contained in:
a.bouhuolia
2021-02-10 18:35:19 +02:00
parent 6e10ed0721
commit c68b4ca9ba
170 changed files with 2835 additions and 4430 deletions

View File

@@ -30,10 +30,7 @@ function AccountDeleteAlert({
closeAlert,
}) {
const { formatMessage } = useIntl();
const {
isLoading,
mutateAsync: deleteAccount,
} = useDeleteAccount();
const { isLoading, mutateAsync: deleteAccount } = useDeleteAccount();
// handle cancel delete account alert.
const handleCancelAccountDelete = () => {
@@ -41,17 +38,25 @@ function AccountDeleteAlert({
};
// Handle confirm account delete.
const handleConfirmAccountDelete = () => {
deleteAccount(accountId).then(() => {
AppToaster.show({
message: formatMessage({
id: 'the_account_has_been_successfully_deleted',
}),
intent: Intent.SUCCESS,
deleteAccount(accountId)
.then(() => {
AppToaster.show({
message: formatMessage({
id: 'the_account_has_been_successfully_deleted',
}),
intent: Intent.SUCCESS,
});
closeAlert(name);
})
.catch((error) => {
const {
response: {
data: { errors },
},
} = error;
handleDeleteErrors(errors);
closeAlert(name);
});
closeAlert(name);
}).catch(errors => {
handleDeleteErrors(errors);
});
};
return (

View File

@@ -6,7 +6,6 @@ import { transformErrors } from 'containers/Customers/utils';
import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
import withAlertActions from 'containers/Alert/withAlertActions';
import withCustomersActions from 'containers/Customers/withCustomersActions';
import { compose } from 'utils';
@@ -19,8 +18,6 @@ function CustomerBulkDeleteAlert({
// #withAlertStoreConnect
isOpen,
payload: { customersIds },
// #withCustomersActions
requestDeleteBulkCustomers,
// #withAlertActions
closeAlert,
@@ -77,5 +74,4 @@ function CustomerBulkDeleteAlert({
export default compose(
withAlertStoreConnect(),
withAlertActions,
withCustomersActions,
)(CustomerBulkDeleteAlert);

View File

@@ -1,17 +1,15 @@
import React, { useCallback, useState } from 'react';
import React, { useCallback } 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 { transformErrors } from 'containers/Customers/utils';
import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
import withAlertActions from 'containers/Alert/withAlertActions';
import withCustomersActions from 'containers/Customers/withCustomersActions';
import { useDeleteCustomer } from 'hooks/query';
import { compose } from 'utils';
@@ -26,8 +24,6 @@ function CustomerDeleteAlert({
// #withAlertStoreConnect
isOpen,
payload: { customerId },
// #withCustomersActions
requestDeleteCustomer,
// #withAlertActions
closeAlert,
@@ -53,9 +49,8 @@ function CustomerDeleteAlert({
}),
intent: Intent.SUCCESS,
});
queryCache.invalidateQueries('customers-table');
})
.catch((errors) => {
.catch(({ response: { data: { errors } } }) => {
transformErrors(errors);
})
.finally(() => {
@@ -86,5 +81,4 @@ function CustomerDeleteAlert({
export default compose(
withAlertStoreConnect(),
withAlertActions,
withCustomersActions,
)(CustomerDeleteAlert);

View File

@@ -24,7 +24,6 @@ function ExpenseDeleteAlert({
const {
mutateAsync: deleteExpenseMutate,
isLoading,
deleteExpense
} = useDeleteExpense();
// Handle cancel expense journal.

View File

@@ -37,8 +37,11 @@ function ExpensePublishAlert({
}),
intent: Intent.SUCCESS,
});
closeAlert(name)
})
.catch((error) => {});
.catch((error) => {
closeAlert(name)
});
};
return (
@@ -61,4 +64,4 @@ function ExpensePublishAlert({
export default compose(
withAlertStoreConnect(),
withAlertActions,
)(ExpensePublishAlert);
)(ExpensePublishAlert);

View File

@@ -24,7 +24,7 @@ function JournalDeleteAlert({
closeAlert,
}) {
const { formatMessage } = useIntl();
const { mutate: deleteJournalMutate } = useDeleteJournal();
const { mutateAsync: deleteJournalMutate, isLoading } = useDeleteJournal();
// Handle cancel delete manual journal.
const handleCancelAlert = () => {
@@ -33,16 +33,20 @@ function JournalDeleteAlert({
// Handle confirm delete manual journal.
const handleConfirmManualJournalDelete = () => {
deleteJournalMutate(manualJournalId).then(() => {
AppToaster.show({
message: formatMessage(
{ id: 'the_journal_has_been_deleted_successfully' },
{ number: journalNumber },
),
intent: Intent.SUCCESS,
deleteJournalMutate(manualJournalId)
.then(() => {
AppToaster.show({
message: formatMessage(
{ id: 'the_journal_has_been_deleted_successfully' },
{ number: journalNumber },
),
intent: Intent.SUCCESS,
});
closeAlert(name);
})
.catch(() => {
closeAlert(name);
});
});
};
return (
@@ -54,6 +58,7 @@ function JournalDeleteAlert({
isOpen={isOpen}
onCancel={handleCancelAlert}
onConfirm={handleConfirmManualJournalDelete}
loading={isLoading}
>
<p>
<T id={'once_delete_this_journal_you_will_able_to_restore_it'} />

View File

@@ -24,7 +24,7 @@ function JournalPublishAlert({
closeAlert,
}) {
const { formatMessage } = useIntl();
const { mutate: publishJournalMutate, isLoading } = usePublishJournal();
const { mutateAsync: publishJournalMutate, isLoading } = usePublishJournal();
// Handle cancel manual journal alert.
const handleCancel = () => {

View File

@@ -1,4 +1,4 @@
import React, { useCallback, useState } from 'react';
import React, { useCallback } from 'react';
import {
FormattedMessage as T,
FormattedHTMLMessage,
@@ -7,12 +7,12 @@ import {
import { Intent, Alert } from '@blueprintjs/core';
import { AppToaster } from 'components';
import { transformErrors } from 'containers/Customers/utils';
import { useDeleteVendor } from 'hooks/query';
import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
import withAlertActions from 'containers/Alert/withAlertActions';
import { compose } from 'utils';
import {
useDeleteVendor
} from 'hooks/query';
/**
* Vendor delete alert.
@@ -78,5 +78,6 @@ function VendorDeleteAlert({
}
export default compose(
withAlertStoreConnect(),
withAlertActions,
)(VendorDeleteAlert);