chrone: sperate client and server to different repos.

This commit is contained in:
a.bouhuolia
2021-09-21 17:13:53 +02:00
parent e011b2a82b
commit 18df5530c7
10015 changed files with 17686 additions and 97524 deletions

View File

@@ -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);

View File

@@ -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>
);
}

View File

@@ -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 };

View 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}
/>
);
}