mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 06:40:31 +00:00
chrone: sperate client and server to different repos.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import React, { lazy } from 'react';
|
||||
import withDrawers from 'containers/Drawer/withDrawers';
|
||||
|
||||
import { Drawer, DrawerSuspense } from 'components';
|
||||
import { compose } from 'utils';
|
||||
|
||||
const InvoicesDrawerContent = lazy(() => import('./InvoiceDrawerContent'));
|
||||
|
||||
/**
|
||||
* invoice drawer.
|
||||
*/
|
||||
function InvoiceDrawer({
|
||||
name,
|
||||
//#withDrawer
|
||||
isOpen,
|
||||
payload: { invoiceId },
|
||||
|
||||
}) {
|
||||
|
||||
return (
|
||||
<Drawer isOpen={isOpen} name={name}>
|
||||
<DrawerSuspense>
|
||||
<InvoicesDrawerContent invoiceId={invoiceId} />
|
||||
</DrawerSuspense>
|
||||
</Drawer>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(withDrawers())(InvoiceDrawer);
|
||||
@@ -0,0 +1,18 @@
|
||||
import React from 'react';
|
||||
import { InvoiceDrawerProvider } from './InvoiceDrawerProvider';
|
||||
import InvoicePaper from './InvoicePaper';
|
||||
|
||||
/**
|
||||
* Invoice drawer content.
|
||||
*/
|
||||
export default function InvoiceDrawerContent({
|
||||
// #ownProp
|
||||
invoiceId,
|
||||
}) {
|
||||
|
||||
return (
|
||||
<InvoiceDrawerProvider invoiceId={invoiceId}>
|
||||
<InvoicePaper />
|
||||
</InvoiceDrawerProvider>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
import React, { createContext, useContext } from 'react';
|
||||
import { useInvoice } from 'hooks/query';
|
||||
import { DrawerHeaderContent, DashboardInsider } from 'components';
|
||||
|
||||
const InvoiceDrawerContext = createContext();
|
||||
|
||||
/**
|
||||
* Invoice drawer provider.
|
||||
*/
|
||||
function InvoiceDrawerProvider({ invoiceId, ...props }) {
|
||||
// Fetch sale invoice details.
|
||||
const {
|
||||
data: { entries, ...invoice },
|
||||
isLoading: isInvoiceLoading,
|
||||
} = useInvoice(invoiceId, {
|
||||
enabled: !!invoiceId,
|
||||
});
|
||||
// Provider payload.
|
||||
const provider = {
|
||||
invoiceId,
|
||||
invoice,
|
||||
entries,
|
||||
|
||||
isInvoiceLoading,
|
||||
};
|
||||
|
||||
return (
|
||||
<DashboardInsider loading={isInvoiceLoading}>
|
||||
<DrawerHeaderContent name={'invoice-drawer'} />
|
||||
<InvoiceDrawerContext.Provider value={provider} {...props} />
|
||||
</DashboardInsider>
|
||||
);
|
||||
}
|
||||
const useInvoiceDrawerContext = () => useContext(InvoiceDrawerContext);
|
||||
|
||||
export { InvoiceDrawerProvider, useInvoiceDrawerContext };
|
||||
38
src/containers/Sales/Invoices/InvoiceDetails/InvoicePaper.js
Normal file
38
src/containers/Sales/Invoices/InvoiceDetails/InvoicePaper.js
Normal file
@@ -0,0 +1,38 @@
|
||||
import React from 'react';
|
||||
import { useInvoiceDrawerContext } from './InvoiceDrawerProvider';
|
||||
import PaperTemplate from 'containers/Drawers/PaperTemplate/PaperTemplate';
|
||||
import intl from 'react-intl-universal';
|
||||
|
||||
export default function InvoicePaper() {
|
||||
const { invoice, entries } = useInvoiceDrawerContext();
|
||||
|
||||
const propLabels = {
|
||||
labels: {
|
||||
name: intl.get('invoice'),
|
||||
billedTo: intl.get('billed_to'),
|
||||
date: intl.get('invoice_date_'),
|
||||
refNo: intl.get('invoice_no__'),
|
||||
billedFrom: intl.get('billed_from'),
|
||||
amount: intl.get('invoice_amount'),
|
||||
dueDate: intl.get('due_date_'),
|
||||
},
|
||||
};
|
||||
|
||||
const defaultValues = {
|
||||
billedTo: invoice.customer.display_name,
|
||||
date: invoice.invoice_date,
|
||||
amount: invoice.balance,
|
||||
billedFrom: '',
|
||||
dueDate: invoice.due_date,
|
||||
referenceNo: invoice.invoice_no,
|
||||
...invoice,
|
||||
};
|
||||
|
||||
return (
|
||||
<PaperTemplate
|
||||
labels={propLabels.labels}
|
||||
paperData={defaultValues}
|
||||
entries={entries}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user