mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 21:00:31 +00:00
feat(PaymentReceivePdf): payment pdf preview.
This commit is contained in:
@@ -32,6 +32,8 @@ import ReconcileVendorCreditDialog from '../containers/Dialogs/ReconcileVendorCr
|
||||
import LockingTransactionsDialog from '../containers/Dialogs/LockingTransactionsDialog';
|
||||
import UnlockingTransactionsDialog from '../containers/Dialogs/UnlockingTransactionsDialog';
|
||||
import UnlockingPartialTransactionsDialog from '../containers/Dialogs/UnlockingPartialTransactionsDialog';
|
||||
import CreditNotePdfPreviewDialog from '../containers/Dialogs/CreditNotePdfPreviewDialog';
|
||||
import PaymentReceivePdfPreviewDialog from '../containers/Dialogs/PaymentReceivePdfPreviewDialog';
|
||||
|
||||
/**
|
||||
* Dialogs container.
|
||||
@@ -74,6 +76,8 @@ export default function DialogsContainer() {
|
||||
<UnlockingPartialTransactionsDialog
|
||||
dialogName={'unlocking-partial-transactions'}
|
||||
/>
|
||||
<CreditNotePdfPreviewDialog dialogName={'credit-note-pdf-preview'} />
|
||||
<PaymentReceivePdfPreviewDialog dialogName={'payment-pdf-preview'} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
import React from 'react';
|
||||
import { AnchorButton } from '@blueprintjs/core';
|
||||
|
||||
import { DialogContent, PdfDocumentPreview, T } from 'components';
|
||||
import { usePdfPaymentReceive } from 'hooks/query';
|
||||
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
import { compose } from 'utils';
|
||||
|
||||
function PaymentReceivePdfPreviewDialogContent({
|
||||
subscriptionForm: { paymentReceiveId },
|
||||
}) {
|
||||
const { isLoading, pdfUrl } = usePdfPaymentReceive(paymentReceiveId);
|
||||
|
||||
return (
|
||||
<DialogContent>
|
||||
<div class="dialog__header-actions">
|
||||
<AnchorButton
|
||||
href={pdfUrl}
|
||||
target={'__blank'}
|
||||
minimal={true}
|
||||
outlined={true}
|
||||
>
|
||||
<T id={'pdf_preview.preview.button'} />
|
||||
</AnchorButton>
|
||||
|
||||
<AnchorButton
|
||||
href={pdfUrl}
|
||||
download={'payment.pdf'}
|
||||
minimal={true}
|
||||
outlined={true}
|
||||
>
|
||||
<T id={'pdf_preview.download.button'} />
|
||||
</AnchorButton>
|
||||
</div>
|
||||
|
||||
<PdfDocumentPreview
|
||||
height={760}
|
||||
width={1000}
|
||||
isLoading={isLoading}
|
||||
url={pdfUrl}
|
||||
/>
|
||||
</DialogContent>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(withDialogActions)(
|
||||
PaymentReceivePdfPreviewDialogContent,
|
||||
);
|
||||
@@ -0,0 +1,44 @@
|
||||
import React from 'react';
|
||||
import classNames from 'classnames';
|
||||
|
||||
import { T, Dialog, DialogSuspense } from 'components';
|
||||
|
||||
import withDialogRedux from 'components/DialogReduxConnect';
|
||||
|
||||
import { CLASSES } from 'common/classes';
|
||||
import { compose } from 'utils';
|
||||
|
||||
// Lazy loading the content.
|
||||
const PdfPreviewDialogContent = React.lazy(() =>
|
||||
import('./PaymentReceivePdfPreviewContent'),
|
||||
);
|
||||
|
||||
/**
|
||||
* Payment receive PDF preview dialog.
|
||||
*/
|
||||
function PaymentReceivePdfPreviewDialog({
|
||||
dialogName,
|
||||
payload = { paymentReceiveId: null },
|
||||
isOpen,
|
||||
}) {
|
||||
return (
|
||||
<Dialog
|
||||
name={dialogName}
|
||||
title={<T id={'payment_receive_preview.dialog.title'} />}
|
||||
className={classNames(CLASSES.DIALOG_PDF_PREVIEW)}
|
||||
autoFocus={true}
|
||||
canEscapeKeyClose={true}
|
||||
isOpen={isOpen}
|
||||
style={{ width: '1000px' }}
|
||||
>
|
||||
<DialogSuspense>
|
||||
<PdfPreviewDialogContent
|
||||
dialogName={dialogName}
|
||||
subscriptionForm={payload}
|
||||
/>
|
||||
</DialogSuspense>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(withDialogRedux())(PaymentReceivePdfPreviewDialog);
|
||||
@@ -62,6 +62,11 @@ function PaymentReceiveActionsBar({
|
||||
openDialog('notify-payment-via-sms', { paymentReceiveId });
|
||||
};
|
||||
|
||||
// Handle print payment receive.
|
||||
const handlePrintPaymentReceive = () => {
|
||||
openDialog('payment-pdf-preview', { paymentReceiveId });
|
||||
};
|
||||
|
||||
return (
|
||||
<DrawerActionsBar>
|
||||
<NavbarGroup>
|
||||
@@ -74,6 +79,14 @@ function PaymentReceiveActionsBar({
|
||||
/>
|
||||
<NavbarDivider />
|
||||
</Can>
|
||||
<Can I={PaymentReceiveAction.View} a={AbilitySubject.PaymentReceive}>
|
||||
<Button
|
||||
className={Classes.MINIMAL}
|
||||
icon={<Icon icon="print-16" />}
|
||||
text={<T id={'print'} />}
|
||||
onClick={handlePrintPaymentReceive}
|
||||
/>
|
||||
</Can>
|
||||
<Can I={PaymentReceiveAction.Delete} a={AbilitySubject.PaymentReceive}>
|
||||
<Button
|
||||
className={Classes.MINIMAL}
|
||||
|
||||
@@ -2,6 +2,8 @@ import { useMutation, useQueryClient } from 'react-query';
|
||||
import { useRequestQuery } from '../useQueryRequest';
|
||||
import useApiRequest from '../useRequest';
|
||||
import { transformPagination, saveInvoke } from 'utils';
|
||||
import { useRequestPdf } from '../utils';
|
||||
|
||||
import t from './types';
|
||||
|
||||
// Common invalidate queries.
|
||||
@@ -31,11 +33,11 @@ const commonInvalidateQueries = (client) => {
|
||||
|
||||
client.invalidateQueries(t.CREDIT_NOTE);
|
||||
client.invalidateQueries(t.CREDIT_NOTES);
|
||||
|
||||
|
||||
// Invalidate reconcile.
|
||||
client.invalidateQueries(t.RECONCILE_CREDIT_NOTE);
|
||||
client.invalidateQueries(t.RECONCILE_CREDIT_NOTES);
|
||||
|
||||
|
||||
// Invalidate invoices payment transactions.
|
||||
client.invalidateQueries(t.SALE_INVOICE_PAYMENT_TRANSACTIONS);
|
||||
};
|
||||
@@ -224,3 +226,10 @@ export function usePaymentReceiveSMSDetail(
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the payment receive pdf document data.
|
||||
*/
|
||||
export function usePdfPaymentReceive(paymentReceiveId) {
|
||||
return useRequestPdf(`sales/payment_receives/${paymentReceiveId}`);
|
||||
}
|
||||
|
||||
@@ -1757,5 +1757,7 @@
|
||||
|
||||
"global_error.you_dont_have_permissions": "ليس لديك صلاحية الوصول إلى هذه الصفحة.",
|
||||
"global_error.transactions_locked": "تم قفل المعاملات التي تمت قبل {lockedToDate}. ومن ثم لا يمكن القيام بأي عمل.",
|
||||
"global_error.authorized_user_inactive": "المستخدم المصرح له تم تعطيلة."
|
||||
}
|
||||
"global_error.authorized_user_inactive": "المستخدم المصرح له تم تعطيلة.",
|
||||
"credit_note_preview.dialog.title":"معاينة إشعار الدائن PDF",
|
||||
"payment_receive_preview.dialog.title":"معاينة سند الزبون PDF"
|
||||
}
|
||||
|
||||
@@ -1737,5 +1737,7 @@
|
||||
|
||||
"global_error.you_dont_have_permissions": "You do not have permissions to access this page.",
|
||||
"global_error.transactions_locked": "Transactions before {lockedToDate} has been locked. Hence action cannot be performed.",
|
||||
"global_error.authorized_user_inactive": "The authorized user is inactive."
|
||||
"global_error.authorized_user_inactive": "The authorized user is inactive.",
|
||||
"credit_note_preview.dialog.title":"Credit Note PDF Preview",
|
||||
"payment_receive_preview.dialog.title":"Payment Receive PDF Preview"
|
||||
}
|
||||
Reference in New Issue
Block a user