mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 22:30:31 +00:00
feat: sales pdf preview.
This commit is contained in:
@@ -3,13 +3,14 @@ import { Tabs, Tab } from '@blueprintjs/core';
|
||||
import intl from 'react-intl-universal';
|
||||
|
||||
import JournalEntriesTable from '../../JournalEntriesTable/JournalEntriesTable';
|
||||
import InvoiceDetailTab from './InvoiceDetailTab';
|
||||
import { useInvoiceDetailDrawerContext } from './InvoiceDetailDrawerProvider';
|
||||
|
||||
/**
|
||||
* Invoice view detail.
|
||||
*/
|
||||
export default function InvoiceDetail() {
|
||||
const { transactions } = useInvoiceDetailDrawerContext();
|
||||
const { transactions, invoiceId } = useInvoiceDetailDrawerContext();
|
||||
|
||||
return (
|
||||
<div className="view-detail-drawer">
|
||||
@@ -19,7 +20,11 @@ export default function InvoiceDetail() {
|
||||
defaultSelectedTabId="journal_entries"
|
||||
renderActiveTabPanelOnly={false}
|
||||
>
|
||||
<Tab title={intl.get('details')} disabled={true} />
|
||||
<Tab
|
||||
title={intl.get('details')}
|
||||
id={'details'}
|
||||
panel={<InvoiceDetailTab invoiceId={invoiceId} />}
|
||||
/>
|
||||
<Tab
|
||||
title={intl.get('journal_entries')}
|
||||
id={'journal_entries'}
|
||||
|
||||
@@ -23,6 +23,7 @@ function InvoiceDetailDrawerProvider({ invoiceId, ...props }) {
|
||||
//provider.
|
||||
const provider = {
|
||||
transactions,
|
||||
invoiceId,
|
||||
};
|
||||
return (
|
||||
<DashboardInsider loading={isTransactionLoading}>
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
import React from 'react';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
|
||||
import {
|
||||
Button,
|
||||
NavbarGroup,
|
||||
Classes,
|
||||
NavbarDivider,
|
||||
Intent,
|
||||
} from '@blueprintjs/core';
|
||||
import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar';
|
||||
|
||||
import { useInvoiceDetailDrawerContext } from './InvoiceDetailDrawerProvider';
|
||||
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
import withAlertsActions from 'containers/Alert/withAlertActions';
|
||||
import withDrawerActions from 'containers/Drawer/withDrawerActions';
|
||||
|
||||
import { Icon, FormattedMessage as T } from 'components';
|
||||
|
||||
import { safeCallback, compose } from 'utils';
|
||||
|
||||
function InvoiceDetailTab({
|
||||
invoiceId,
|
||||
// #withDialogActions
|
||||
openDialog,
|
||||
|
||||
// #withAlertsActions
|
||||
openAlert,
|
||||
|
||||
// #withDrawerActions
|
||||
closeDrawer,
|
||||
}) {
|
||||
const history = useHistory();
|
||||
|
||||
// Handle edit sale invoice.
|
||||
const onEditInvoice = () => {
|
||||
return invoiceId
|
||||
? (history.push(`/invoices/${invoiceId}/edit`),
|
||||
closeDrawer('invoice-detail-drawer'))
|
||||
: null;
|
||||
};
|
||||
|
||||
// Handle delete sale invoice.
|
||||
const onDeleteInvoice = () => {
|
||||
return invoiceId
|
||||
? (openAlert('invoice-delete', { invoiceId }),
|
||||
closeDrawer('invoice-detail-drawer'))
|
||||
: null;
|
||||
};
|
||||
|
||||
// Handle print invoices.
|
||||
const onPrintInvoice = () => {
|
||||
openDialog('invoice-pdf-preview', { invoiceId });
|
||||
};
|
||||
|
||||
return (
|
||||
<DashboardActionsBar>
|
||||
<NavbarGroup>
|
||||
<Button
|
||||
className={Classes.MINIMAL}
|
||||
icon={<Icon icon="pen-18" />}
|
||||
text={<T id={'edit_invoice'} />}
|
||||
onClick={safeCallback(onEditInvoice)}
|
||||
/>
|
||||
<NavbarDivider />
|
||||
<Button
|
||||
className={Classes.MINIMAL}
|
||||
icon={<Icon icon="print-16" />}
|
||||
text={<T id={'print'} />}
|
||||
onClick={safeCallback(onPrintInvoice)}
|
||||
/>
|
||||
<Button
|
||||
className={Classes.MINIMAL}
|
||||
icon={<Icon icon={'trash-16'} iconSize={16} />}
|
||||
text={<T id={'delete'} />}
|
||||
intent={Intent.DANGER}
|
||||
onClick={safeCallback(onDeleteInvoice)}
|
||||
/>
|
||||
</NavbarGroup>
|
||||
</DashboardActionsBar>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(
|
||||
withDialogActions,
|
||||
withDrawerActions,
|
||||
withAlertsActions,
|
||||
)(InvoiceDetailTab);
|
||||
Reference in New Issue
Block a user