feat: uncategorize the cashflow transaction

This commit is contained in:
Ahmed Bouhuolia
2024-03-10 02:53:57 +02:00
parent 2baf407814
commit b71c79fef5
16 changed files with 246 additions and 3 deletions

View File

@@ -0,0 +1,16 @@
// @ts-nocheck
import React from 'react';
const UncategorizeTransactionAlert = React.lazy(
() => import('./UncategorizeTransactionAlert/UncategorizeTransactionAlert'),
);
/**
* Cashflow alerts.
*/
export const CashflowAlerts = [
{
name: 'cashflow-tranaction-uncategorize',
component: UncategorizeTransactionAlert,
},
];

View File

@@ -0,0 +1,83 @@
// @ts-nocheck
import React from 'react';
import { Intent, Alert } from '@blueprintjs/core';
import { FormattedMessage as T } from '@/components';
import { AppToaster } from '@/components';
import withAlertStoreConnect from '@/containers/Alert/withAlertStoreConnect';
import withAlertActions from '@/containers/Alert/withAlertActions';
import withDrawerActions from '@/containers/Drawer/withDrawerActions';
import { useUncategorizeTransaction } from '@/hooks/query';
import { compose } from '@/utils';
import { DRAWERS } from '@/constants/drawers';
/**
* Project delete alert.
*/
function UncategorizeTransactionAlert({
name,
// #withAlertStoreConnect
isOpen,
payload: { uncategorizedTransactionId },
// #withAlertActions
closeAlert,
// #withDrawerActions
closeDrawer,
}) {
const { mutateAsync: uncategorizeTransaction, isLoading } =
useUncategorizeTransaction();
// handle cancel delete project alert.
const handleCancelDeleteAlert = () => {
closeAlert(name);
};
// handleConfirm delete project
const handleConfirmBtnClick = () => {
uncategorizeTransaction(uncategorizedTransactionId)
.then(() => {
AppToaster.show({
message: 'The transaction has uncategorized successfully.',
intent: Intent.SUCCESS,
});
closeAlert(name);
closeDrawer(DRAWERS.CASHFLOW_TRNASACTION_DETAILS);
})
.catch(
({
response: {
data: { errors },
},
}) => {
AppToaster.show({
message: 'Something went wrong.',
intent: Intent.DANGER,
});
},
);
};
return (
<Alert
cancelButtonText={<T id={'cancel'} />}
confirmButtonText={'Uncategorize'}
intent={Intent.WARNING}
isOpen={isOpen}
onCancel={handleCancelDeleteAlert}
onConfirm={handleConfirmBtnClick}
loading={isLoading}
>
<p>Are you sure want to uncategorize the transaction?</p>
</Alert>
);
}
export default compose(
withAlertStoreConnect(),
withAlertActions,
withDrawerActions,
)(UncategorizeTransactionAlert);

View File

@@ -0,0 +1 @@
export * from './UncategorizeTransactionAlert';