mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 06:10:31 +00:00
feat: sales pdf preview.
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import React from 'react';
|
||||
import { Tabs, Tab } from '@blueprintjs/core';
|
||||
import intl from 'react-intl-universal';
|
||||
import EstimateDetailTab from './EstimateDetailTab';
|
||||
|
||||
/**
|
||||
* Estimate view detail
|
||||
*/
|
||||
export default function EstimateDetail() {
|
||||
return (
|
||||
<div className="view-detail-drawer">
|
||||
<Tabs animate={true} large={true}>
|
||||
<Tab
|
||||
title={intl.get('details')}
|
||||
id={'details'}
|
||||
panel={<EstimateDetailTab />}
|
||||
/>
|
||||
</Tabs>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import React from 'react';
|
||||
|
||||
import 'style/components/Drawers/ViewDetail/ViewDetail.scss';
|
||||
|
||||
import EstimateDetail from './EstimateDetail';
|
||||
import { EstimateDetailDrawerProvider } from './EstimateDetailDrawerProvider';
|
||||
|
||||
/**
|
||||
* Estimate detail drawer content.
|
||||
*/
|
||||
export default function EstimateDetailDrawerContent({
|
||||
// #ownProp
|
||||
estimate,
|
||||
}) {
|
||||
return (
|
||||
<EstimateDetailDrawerProvider estimateId={estimate}>
|
||||
<EstimateDetail />
|
||||
</EstimateDetailDrawerProvider>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import { DrawerHeaderContent, DashboardInsider } from 'components';
|
||||
|
||||
const EstimateDetailDrawerContext = React.createContext();
|
||||
|
||||
/**
|
||||
* Estimate detail provider.
|
||||
*/
|
||||
function EstimateDetailDrawerProvider({ estimateId, ...props }) {
|
||||
const provider = {
|
||||
estimateId,
|
||||
};
|
||||
|
||||
return (
|
||||
<DashboardInsider>
|
||||
<DrawerHeaderContent
|
||||
name="estimate-detail-drawer"
|
||||
title={intl.get('estimate_details')}
|
||||
/>
|
||||
|
||||
<EstimateDetailDrawerContext.Provider value={provider} {...props} />
|
||||
</DashboardInsider>
|
||||
);
|
||||
}
|
||||
|
||||
const useEstimateDetailDrawerContext = () =>
|
||||
React.useContext(EstimateDetailDrawerContext);
|
||||
|
||||
export { EstimateDetailDrawerProvider, useEstimateDetailDrawerContext };
|
||||
@@ -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 { useEstimateDetailDrawerContext } from './EstimateDetailDrawerProvider';
|
||||
|
||||
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 EstimateDetailTab({
|
||||
// #withDialogActions
|
||||
openDialog,
|
||||
|
||||
// #withAlertsActions
|
||||
openAlert,
|
||||
|
||||
// #withDrawerActions
|
||||
closeDrawer,
|
||||
}) {
|
||||
const history = useHistory();
|
||||
|
||||
const { estimateId } = useEstimateDetailDrawerContext();
|
||||
|
||||
// Handle edit sale estimate.
|
||||
const onEditEstimate = () => {
|
||||
return estimateId
|
||||
? (history.push(`/estimates/${estimateId}/edit`),
|
||||
closeDrawer('estimate-detail-drawer'))
|
||||
: null;
|
||||
};
|
||||
|
||||
// Handle delete sale estimate.
|
||||
const onDeleteEstimate = () => {
|
||||
return estimateId
|
||||
? (openAlert('estimate-delete', { estimateId }),
|
||||
closeDrawer('estimate-detail-drawer'))
|
||||
: null;
|
||||
};
|
||||
|
||||
// Handle print estimate.
|
||||
const onPrintEstimate = () => {
|
||||
openDialog('estimate-pdf-preview', { estimateId });
|
||||
};
|
||||
|
||||
return (
|
||||
<DashboardActionsBar>
|
||||
<NavbarGroup>
|
||||
<Button
|
||||
className={Classes.MINIMAL}
|
||||
icon={<Icon icon="pen-18" />}
|
||||
text={<T id={'edit_estimate'} />}
|
||||
onClick={safeCallback(onEditEstimate)}
|
||||
/>
|
||||
<NavbarDivider />
|
||||
<Button
|
||||
className={Classes.MINIMAL}
|
||||
icon={<Icon icon="print-16" />}
|
||||
text={<T id={'print'} />}
|
||||
onClick={safeCallback(onPrintEstimate)}
|
||||
/>
|
||||
<Button
|
||||
className={Classes.MINIMAL}
|
||||
icon={<Icon icon={'trash-16'} iconSize={16} />}
|
||||
text={<T id={'delete'} />}
|
||||
intent={Intent.DANGER}
|
||||
onClick={safeCallback(onDeleteEstimate)}
|
||||
/>
|
||||
</NavbarGroup>
|
||||
</DashboardActionsBar>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(
|
||||
withDialogActions,
|
||||
withAlertsActions,
|
||||
withDrawerActions,
|
||||
)(EstimateDetailTab);
|
||||
26
client/src/containers/Drawers/EstimateDetailDrawer/index.js
Normal file
26
client/src/containers/Drawers/EstimateDetailDrawer/index.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import React from 'react';
|
||||
import { Drawer, DrawerSuspense } from 'components';
|
||||
import withDrawers from 'containers/Drawer/withDrawers';
|
||||
|
||||
import { compose } from 'utils';
|
||||
|
||||
const EstimateDetailDrawerContent = React.lazy(() =>
|
||||
import('./EstimateDetailDrawerContent'),
|
||||
);
|
||||
|
||||
function EstimateDetailDrawer({
|
||||
name,
|
||||
// #withDrawer
|
||||
isOpen,
|
||||
payload: { estimateId },
|
||||
}) {
|
||||
return (
|
||||
<Drawer isOpen={isOpen} name={name} size={'750px'}>
|
||||
<DrawerSuspense>
|
||||
<EstimateDetailDrawerContent estimate={estimateId} />
|
||||
</DrawerSuspense>
|
||||
</Drawer>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(withDrawers())(EstimateDetailDrawer);
|
||||
@@ -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);
|
||||
@@ -3,18 +3,23 @@ import { Tabs, Tab } from '@blueprintjs/core';
|
||||
import intl from 'react-intl-universal';
|
||||
|
||||
import JournalEntriesTable from '../../JournalEntriesTable/JournalEntriesTable';
|
||||
import ReceiptDetailTab from './ReceiptDetailTab';
|
||||
import { useReceiptDetailDrawerContext } from './ReceiptDetailDrawerProvider';
|
||||
|
||||
/**
|
||||
* Receipt view detail.
|
||||
*/
|
||||
export default function ReceiptDetail() {
|
||||
const { transactions } = useReceiptDetailDrawerContext();
|
||||
const { transactions, receiptId } = useReceiptDetailDrawerContext();
|
||||
|
||||
return (
|
||||
<div className="view-detail-drawer">
|
||||
<Tabs animate={true} large={true} defaultSelectedTabId="journal_entries">
|
||||
<Tab title={intl.get('details')} id={'details'} disabled={true} />
|
||||
<Tab
|
||||
title={intl.get('details')}
|
||||
id={'details'}
|
||||
panel={<ReceiptDetailTab receiptId={receiptId} />}
|
||||
/>
|
||||
<Tab
|
||||
title={intl.get('journal_entries')}
|
||||
id={'journal_entries'}
|
||||
|
||||
@@ -25,6 +25,7 @@ function ReceiptDetailDrawerProvider({ receiptId, ...props }) {
|
||||
//provider.
|
||||
const provider = {
|
||||
transactions,
|
||||
receiptId,
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
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 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 ReceiptDetailTab({
|
||||
receiptId,
|
||||
// #withDialogActions
|
||||
openDialog,
|
||||
|
||||
// #withAlertsActions
|
||||
openAlert,
|
||||
|
||||
// #withDrawerActions
|
||||
closeDrawer,
|
||||
}) {
|
||||
const history = useHistory();
|
||||
|
||||
// Handle edit sale receipt.
|
||||
const onEditReceipt = () => {
|
||||
return receiptId
|
||||
? (history.push(`/receipts/${receiptId}/edit`),
|
||||
closeDrawer('receipt-detail-drawer'))
|
||||
: null;
|
||||
};
|
||||
|
||||
// Handle delete sale receipt.
|
||||
const onDeleteReceipt = () => {
|
||||
return receiptId
|
||||
? (openAlert('receipt-delete', { receiptId }),
|
||||
closeDrawer('receipt-detail-drawer'))
|
||||
: null;
|
||||
};
|
||||
// Handle print receipt.
|
||||
const onPrintReceipt = () => {
|
||||
openDialog('receipt-pdf-preview', { receiptId });
|
||||
};
|
||||
return (
|
||||
<DashboardActionsBar>
|
||||
<NavbarGroup>
|
||||
<Button
|
||||
className={Classes.MINIMAL}
|
||||
icon={<Icon icon="pen-18" />}
|
||||
text={<T id={'edit_receipt'} />}
|
||||
onClick={safeCallback(onEditReceipt)}
|
||||
/>
|
||||
<NavbarDivider />
|
||||
<Button
|
||||
className={Classes.MINIMAL}
|
||||
icon={<Icon icon="print-16" />}
|
||||
text={<T id={'print'} />}
|
||||
onClick={safeCallback(onPrintReceipt)}
|
||||
/>
|
||||
<Button
|
||||
className={Classes.MINIMAL}
|
||||
icon={<Icon icon={'trash-16'} iconSize={16} />}
|
||||
text={<T id={'delete'} />}
|
||||
intent={Intent.DANGER}
|
||||
onClick={safeCallback(onDeleteReceipt)}
|
||||
/>
|
||||
</NavbarGroup>
|
||||
</DashboardActionsBar>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(
|
||||
withDialogActions,
|
||||
withDrawerActions,
|
||||
withAlertsActions,
|
||||
)(ReceiptDetailTab);
|
||||
Reference in New Issue
Block a user