From dd7d11ffb7a688678c9cdf59318838f7e5c891a8 Mon Sep 17 00:00:00 2001
From: elforjani13 <39470382+elforjani13@users.noreply.github.com>
Date: Tue, 11 Jan 2022 14:33:51 +0200
Subject: [PATCH 1/2] feat(CreditNotePdf): credit note pdf preview.
---
.../CreditNotePdfPreviewDialogContent.js | 47 +++++++++++++++++++
.../CreditNotePdfPreviewDialog/index.js | 42 +++++++++++++++++
.../CreditNoteDetailActionsBar.js | 13 +++++
src/hooks/query/creditNote.js | 8 ++++
4 files changed, 110 insertions(+)
create mode 100644 src/containers/Dialogs/CreditNotePdfPreviewDialog/CreditNotePdfPreviewDialogContent.js
create mode 100644 src/containers/Dialogs/CreditNotePdfPreviewDialog/index.js
diff --git a/src/containers/Dialogs/CreditNotePdfPreviewDialog/CreditNotePdfPreviewDialogContent.js b/src/containers/Dialogs/CreditNotePdfPreviewDialog/CreditNotePdfPreviewDialogContent.js
new file mode 100644
index 000000000..3c13480c9
--- /dev/null
+++ b/src/containers/Dialogs/CreditNotePdfPreviewDialog/CreditNotePdfPreviewDialogContent.js
@@ -0,0 +1,47 @@
+import React from 'react';
+import { AnchorButton } from '@blueprintjs/core';
+
+import { DialogContent, PdfDocumentPreview, T } from 'components';
+import { usePdfCreditNote } from 'hooks/query';
+
+import withDialogActions from 'containers/Dialog/withDialogActions';
+import { compose } from 'utils';
+
+function CreditNotePdfPreviewDialogContent({
+ subscriptionForm: { creditNoteId },
+}) {
+ const { isLoading, pdfUrl } = usePdfCreditNote(creditNoteId);
+
+ return (
+
+
+
+
+
+ );
+}
+
+export default compose(withDialogActions)(CreditNotePdfPreviewDialogContent);
diff --git a/src/containers/Dialogs/CreditNotePdfPreviewDialog/index.js b/src/containers/Dialogs/CreditNotePdfPreviewDialog/index.js
new file mode 100644
index 000000000..061cc6b85
--- /dev/null
+++ b/src/containers/Dialogs/CreditNotePdfPreviewDialog/index.js
@@ -0,0 +1,42 @@
+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';
+
+const PdfPreviewDialogContent = React.lazy(() =>
+ import('./CreditNotePdfPreviewDialogContent'),
+);
+
+/**
+ * Credit note PDF previwe dialog.
+ */
+function CreditNotePdfPreviewDialog({
+ dialogName,
+ payload = { creditNoteId: null },
+ isOpen,
+}) {
+ return (
+ }
+ className={classNames(CLASSES.DIALOG_PDF_PREVIEW)}
+ autoFocus={true}
+ canEscapeKeyClose={true}
+ isOpen={isOpen}
+ style={{ width: '1000px' }}
+ >
+
+
+
+
+ );
+}
+export default compose(withDialogRedux())(CreditNotePdfPreviewDialog);
diff --git a/src/containers/Drawers/CreditNoteDetailDrawer/CreditNoteDetailActionsBar.js b/src/containers/Drawers/CreditNoteDetailDrawer/CreditNoteDetailActionsBar.js
index 5d7810b34..2ab7d47a6 100644
--- a/src/containers/Drawers/CreditNoteDetailDrawer/CreditNoteDetailActionsBar.js
+++ b/src/containers/Drawers/CreditNoteDetailDrawer/CreditNoteDetailActionsBar.js
@@ -65,6 +65,11 @@ function CreditNoteDetailActionsBar({
openDialog('reconcile-credit-note', { creditNoteId });
};
+ // Handle print credit note.
+ const handlePrintCreditNote = () => {
+ openDialog('credit-note-pdf-preview', { creditNoteId });
+ };
+
return (
@@ -88,6 +93,14 @@ function CreditNoteDetailActionsBar({
+
+ }
+ text={}
+ onClick={handlePrintCreditNote}
+ />
+
+
+ }
+ text={}
+ onClick={handlePrintPaymentReceive}
+ />
+