mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +00:00
re-structure to monorepo.
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
// @ts-nocheck
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import { Intent, Alert } from '@blueprintjs/core';
|
||||
import {
|
||||
AppToaster,
|
||||
FormattedMessage as T,
|
||||
FormattedHTMLMessage,
|
||||
} from '@/components';
|
||||
|
||||
import withAlertStoreConnect from '@/containers/Alert/withAlertStoreConnect';
|
||||
import withAlertActions from '@/containers/Alert/withAlertActions';
|
||||
import withDrawerActions from '@/containers/Drawer/withDrawerActions';
|
||||
|
||||
import { useDeleteReconcileVendorCredit } from '@/hooks/query';
|
||||
import { compose } from '@/utils';
|
||||
|
||||
/**
|
||||
* Reconcile vendor credit delete alert.
|
||||
*/
|
||||
function ReconcileVendorCreditDeleteAlert({
|
||||
name,
|
||||
|
||||
// #withAlertStoreConnect
|
||||
isOpen,
|
||||
payload: { vendorCreditId },
|
||||
|
||||
// #withAlertActions
|
||||
closeAlert,
|
||||
|
||||
// #withDrawerActions
|
||||
closeDrawer,
|
||||
}) {
|
||||
const { isLoading, mutateAsync: deleteReconcileVendorCreditMutate } =
|
||||
useDeleteReconcileVendorCredit();
|
||||
|
||||
// handle cancel delete credit note alert.
|
||||
const handleCancelDeleteAlert = () => {
|
||||
closeAlert(name);
|
||||
};
|
||||
|
||||
const handleConfirmReconcileVendorCreditDelete = () => {
|
||||
deleteReconcileVendorCreditMutate(vendorCreditId)
|
||||
.then(() => {
|
||||
AppToaster.show({
|
||||
message: intl.get('reconcile_vendor_credit.alert.success_message'),
|
||||
intent: Intent.SUCCESS,
|
||||
});
|
||||
// closeDrawer('vendor-credit-detail-drawer');
|
||||
})
|
||||
.catch(
|
||||
({
|
||||
response: {
|
||||
data: { errors },
|
||||
},
|
||||
}) => {},
|
||||
)
|
||||
.finally(() => {
|
||||
closeAlert(name);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Alert
|
||||
cancelButtonText={<T id={'cancel'} />}
|
||||
confirmButtonText={<T id={'delete'} />}
|
||||
icon="trash"
|
||||
intent={Intent.DANGER}
|
||||
isOpen={isOpen}
|
||||
onCancel={handleCancelDeleteAlert}
|
||||
onConfirm={handleConfirmReconcileVendorCreditDelete}
|
||||
loading={isLoading}
|
||||
>
|
||||
<p>
|
||||
<FormattedHTMLMessage
|
||||
id={
|
||||
'reconcile_vendor_credit.alert.once_you_delete_this_reconcile_vendor_credit'
|
||||
}
|
||||
/>
|
||||
</p>
|
||||
</Alert>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(
|
||||
withAlertStoreConnect(),
|
||||
withAlertActions,
|
||||
withDrawerActions,
|
||||
)(ReconcileVendorCreditDeleteAlert);
|
||||
@@ -0,0 +1,78 @@
|
||||
// @ts-nocheck
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import { Intent, Alert } from '@blueprintjs/core';
|
||||
import { FormattedMessage as T, AppToaster } from '@/components';
|
||||
import { useDeleteRefundVendorCredit } from '@/hooks/query';
|
||||
|
||||
import withAlertActions from '@/containers/Alert/withAlertActions';
|
||||
import withAlertStoreConnect from '@/containers/Alert/withAlertStoreConnect';
|
||||
import withDrawerActions from '@/containers/Drawer/withDrawerActions';
|
||||
|
||||
import { compose } from '@/utils';
|
||||
|
||||
/**
|
||||
* Refund Vendor transactions delete alert.
|
||||
*/
|
||||
function RefundVendorCreditDeleteAlert({
|
||||
name,
|
||||
// #withAlertStoreConnect
|
||||
isOpen,
|
||||
payload: { vendorCreditId },
|
||||
// #withAlertActions
|
||||
closeAlert,
|
||||
|
||||
// #withDrawerActions
|
||||
closeDrawer,
|
||||
}) {
|
||||
const { mutateAsync: deleteRefundVendorCreditMutate, isLoading } =
|
||||
useDeleteRefundVendorCredit();
|
||||
|
||||
// Handle cancel delete.
|
||||
const handleCancelAlert = () => {
|
||||
closeAlert(name);
|
||||
};
|
||||
|
||||
// Handle confirm delete .
|
||||
const handleConfirmRefundVendorCreditDelete = () => {
|
||||
deleteRefundVendorCreditMutate(vendorCreditId)
|
||||
.then(() => {
|
||||
AppToaster.show({
|
||||
message: intl.get(
|
||||
'refund_vendor_credit_transactions.alert.delete_message',
|
||||
),
|
||||
intent: Intent.SUCCESS,
|
||||
});
|
||||
closeDrawer('refund-vendor-detail-drawer');
|
||||
})
|
||||
.catch(() => {})
|
||||
.finally(() => {
|
||||
closeAlert(name);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Alert
|
||||
cancelButtonText={<T id={'cancel'} />}
|
||||
confirmButtonText={<T id={'delete'} />}
|
||||
icon="trash"
|
||||
intent={Intent.DANGER}
|
||||
isOpen={isOpen}
|
||||
onCancel={handleCancelAlert}
|
||||
onConfirm={handleConfirmRefundVendorCreditDelete}
|
||||
loading={isLoading}
|
||||
>
|
||||
<p>
|
||||
<T
|
||||
id={`refund_vendor_credit_transactions.once_your_delete_this_refund_vendor_credit`}
|
||||
/>
|
||||
</p>
|
||||
</Alert>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(
|
||||
withAlertStoreConnect(),
|
||||
withAlertActions,
|
||||
withDrawerActions,
|
||||
)(RefundVendorCreditDeleteAlert);
|
||||
@@ -0,0 +1,88 @@
|
||||
// @ts-nocheck
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import { Intent, Alert } from '@blueprintjs/core';
|
||||
import {
|
||||
AppToaster,
|
||||
FormattedMessage as T,
|
||||
FormattedHTMLMessage,
|
||||
} from '@/components';
|
||||
|
||||
import withAlertStoreConnect from '@/containers/Alert/withAlertStoreConnect';
|
||||
import withAlertActions from '@/containers/Alert/withAlertActions';
|
||||
import withDrawerActions from '@/containers/Drawer/withDrawerActions';
|
||||
import { handleDeleteErrors } from '@/containers/Purchases/CreditNotes/CreditNotesLanding/utils';
|
||||
import { useDeleteVendorCredit } from '@/hooks/query';
|
||||
import { compose } from '@/utils';
|
||||
|
||||
/**
|
||||
* Vendor Credit delete alert.
|
||||
*/
|
||||
function VendorCreditDeleteAlert({
|
||||
name,
|
||||
|
||||
// #withAlertStoreConnect
|
||||
isOpen,
|
||||
payload: { vendorCreditId },
|
||||
|
||||
// #withAlertActions
|
||||
closeAlert,
|
||||
|
||||
// #withDrawerActions
|
||||
closeDrawer,
|
||||
}) {
|
||||
const { isLoading, mutateAsync: deleteVendorCreditMutate } =
|
||||
useDeleteVendorCredit();
|
||||
|
||||
// handle cancel delete credit note alert.
|
||||
const handleCancelDeleteAlert = () => {
|
||||
closeAlert(name);
|
||||
};
|
||||
const handleConfirmCreditDelete = () => {
|
||||
deleteVendorCreditMutate(vendorCreditId)
|
||||
.then(() => {
|
||||
AppToaster.show({
|
||||
message: intl.get('vendor_credits.alert.delete_message'),
|
||||
intent: Intent.SUCCESS,
|
||||
});
|
||||
closeDrawer('vendor-credit-detail-drawer');
|
||||
})
|
||||
.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={handleConfirmCreditDelete}
|
||||
loading={isLoading}
|
||||
>
|
||||
<p>
|
||||
<FormattedHTMLMessage
|
||||
id={'vendor_credits.note.once_delete_this_vendor_credit_note'}
|
||||
/>
|
||||
</p>
|
||||
</Alert>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(
|
||||
withAlertStoreConnect(),
|
||||
withAlertActions,
|
||||
withDrawerActions,
|
||||
)(VendorCreditDeleteAlert);
|
||||
@@ -0,0 +1,69 @@
|
||||
// @ts-nocheck
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import { AppToaster, FormattedMessage as T } from '@/components';
|
||||
import { Intent, Alert } from '@blueprintjs/core';
|
||||
|
||||
import { useOpenVendorCredit } from '@/hooks/query';
|
||||
|
||||
import withAlertStoreConnect from '@/containers/Alert/withAlertStoreConnect';
|
||||
import withAlertActions from '@/containers/Alert/withAlertActions';
|
||||
|
||||
import { compose } from '@/utils';
|
||||
|
||||
/**
|
||||
* Vendor credit opened alert.
|
||||
*/
|
||||
function VendorCreditOpenedAlert({
|
||||
name,
|
||||
|
||||
// #withAlertStoreConnect
|
||||
isOpen,
|
||||
payload: { vendorCreditId },
|
||||
|
||||
// #withAlertActions
|
||||
closeAlert,
|
||||
}) {
|
||||
const { mutateAsync: openVendorCreditMutate, isLoading } =
|
||||
useOpenVendorCredit();
|
||||
|
||||
// Handle cancel opened credit note alert.
|
||||
const handleAlertCancel = () => {
|
||||
closeAlert(name);
|
||||
};
|
||||
|
||||
// Handle confirm vendor credit as opened.
|
||||
const handleAlertConfirm = () => {
|
||||
openVendorCreditMutate(vendorCreditId)
|
||||
.then(() => {
|
||||
AppToaster.show({
|
||||
message: intl.get('vendor_credit_opened.alert.success_message'),
|
||||
intent: Intent.SUCCESS,
|
||||
});
|
||||
})
|
||||
.catch((error) => {})
|
||||
.finally(() => {
|
||||
closeAlert(name);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Alert
|
||||
cancelButtonText={<T id={'cancel'} />}
|
||||
confirmButtonText={<T id={'open'} />}
|
||||
intent={Intent.WARNING}
|
||||
isOpen={isOpen}
|
||||
onCancel={handleAlertCancel}
|
||||
onConfirm={handleAlertConfirm}
|
||||
loading={isLoading}
|
||||
>
|
||||
<p>
|
||||
<T id={'vendor_credit_opened.are_sure_to_open_this_credit'} />
|
||||
</p>
|
||||
</Alert>
|
||||
);
|
||||
}
|
||||
export default compose(
|
||||
withAlertStoreConnect(),
|
||||
withAlertActions,
|
||||
)(VendorCreditOpenedAlert);
|
||||
Reference in New Issue
Block a user