chore: renmame payment receive term to payment received

This commit is contained in:
Ahmed Bouhuolia
2024-08-13 15:15:07 +02:00
parent 961e4b99e8
commit 038d4dd5a7
67 changed files with 181 additions and 184 deletions

View File

@@ -0,0 +1,55 @@
// @ts-nocheck
import React from 'react';
import { Intent, Alert } from '@blueprintjs/core';
import { FormattedMessage as T } from '@/components';
import withAlertActions from '@/containers/Alert/withAlertActions';
import withAlertStoreConnect from '@/containers/Alert/withAlertStoreConnect';
import { saveInvoke, compose } from '@/utils';
/**
* Clearning all lines alert.
*/
function ClearningAllLinesAlert({
name,
onConfirm,
// #withAlertStoreConnect
isOpen,
payload: {},
// #withAlertActions
closeAlert,
}) {
// Handle the alert cancel.
const handleCancel = () => {
closeAlert(name);
};
// Handle confirm delete manual journal.
const handleConfirm = (event) => {
closeAlert(name);
saveInvoke(onConfirm, event)
};
return (
<Alert
cancelButtonText={<T id={'cancel'} />}
confirmButtonText={<T id={'action'} />}
intent={Intent.DANGER}
isOpen={isOpen}
onCancel={handleCancel}
onConfirm={handleConfirm}
>
<p>
<T id={'clearing_the_table_lines_will_delete_all_credits'} />
</p>
</Alert>
);
}
export default compose(
withAlertStoreConnect(),
withAlertActions,
)(ClearningAllLinesAlert);

View File

@@ -0,0 +1,95 @@
// @ts-nocheck
import React from 'react';
import intl from 'react-intl-universal';
import {
AppToaster,
FormattedMessage as T,
FormattedHTMLMessage,
} from '@/components';
import { Intent, Alert } from '@blueprintjs/core';
import { useDeletePaymentReceive } from '@/hooks/query';
import withAlertStoreConnect from '@/containers/Alert/withAlertStoreConnect';
import withAlertActions from '@/containers/Alert/withAlertActions';
import withDrawerActions from '@/containers/Drawer/withDrawerActions';
import { handleDeleteErrors } from './_utils';
import { compose } from '@/utils';
import { DRAWERS } from '@/constants/drawers';
/**
* Payment receive delete alert.
*/
function PaymentReceivedDeleteAlert({
name,
// #withAlertStoreConnect
isOpen,
payload: { paymentReceiveId },
// #withAlertActions
closeAlert,
// #withDrawerActions
closeDrawer,
}) {
const { mutateAsync: deletePaymentReceiveMutate, isLoading } =
useDeletePaymentReceive();
// Handle cancel payment Receive.
const handleCancelDeleteAlert = () => {
closeAlert(name);
};
// Handle confirm delete payment receive.
const handleConfirmPaymentReceiveDelete = () => {
deletePaymentReceiveMutate(paymentReceiveId)
.then(() => {
AppToaster.show({
message: intl.get(
'the_payment_received_has_been_deleted_successfully',
),
intent: Intent.SUCCESS,
});
closeDrawer(DRAWERS.PAYMENT_RECEIVED_DETAILS);
})
.catch(
({
response: {
data: { errors },
},
}) => {
handleDeleteErrors(errors);
},
)
.finally(() => {
closeAlert(name);
});
};
return (
<Alert
cancelButtonText={<T id={'cancel'} />}
confirmButtonText={<T id={'delete'} />}
icon="trash"
intent={Intent.DANGER}
isOpen={isOpen}
onCancel={handleCancelDeleteAlert}
onConfirm={handleConfirmPaymentReceiveDelete}
loading={isLoading}
>
<p>
<FormattedHTMLMessage
id={'once_delete_this_payment_received_you_will_able_to_restore_it'}
/>
</p>
</Alert>
);
}
export default compose(
withAlertStoreConnect(),
withAlertActions,
withDrawerActions,
)(PaymentReceivedDeleteAlert);

View File

@@ -0,0 +1,11 @@
import { Intent } from '@blueprintjs/core';
import { AppToaster } from '@/components';
export const handleDeleteErrors = (errors: any) => {
if (errors.find((e: any) => e.type === 'CANNOT_DELETE_TRANSACTION_MATCHED')) {
AppToaster.show({
intent: Intent.DANGER,
message: 'Cannot delete a transaction matched with a bank transaction.',
});
}
};