mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 07:10:33 +00:00
refactoring: drawers suspense.
This commit is contained in:
20
client/src/components/Drawer/Drawer.js
Normal file
20
client/src/components/Drawer/Drawer.js
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { FormattedMessage as T, useIntl } from 'react-intl';
|
||||||
|
import { Position, Drawer } from '@blueprintjs/core';
|
||||||
|
|
||||||
|
export default function ({ children, isOpen, isClose, drawerProps }) {
|
||||||
|
return (
|
||||||
|
<Drawer
|
||||||
|
isOpen={isOpen}
|
||||||
|
title={<T id={'view_paper'} />}
|
||||||
|
position={Position.RIGHT}
|
||||||
|
canOutsideClickClose={true}
|
||||||
|
canEscapeKeyClose={true}
|
||||||
|
size={'65%'}
|
||||||
|
onClose={isClose}
|
||||||
|
{...drawerProps}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</Drawer>
|
||||||
|
);
|
||||||
|
}
|
||||||
6
client/src/components/Drawer/DrawerSuspense.js
Normal file
6
client/src/components/Drawer/DrawerSuspense.js
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import React, { Suspense } from 'react';
|
||||||
|
import { Spinner } from '@blueprintjs/core';
|
||||||
|
|
||||||
|
export default function DrawerSuspense({ children }) {
|
||||||
|
return <Suspense fallback={<Spinner size={30} />}>{children}</Suspense>;
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@ import React from 'react';
|
|||||||
import EstimateDrawer from 'containers/Sales/Estimates/EstimateDetails/EstimateDrawer';
|
import EstimateDrawer from 'containers/Sales/Estimates/EstimateDetails/EstimateDrawer';
|
||||||
import InvoiceDrawer from 'containers/Sales/Invoices/InvoiceDetails/InvoiceDrawer';
|
import InvoiceDrawer from 'containers/Sales/Invoices/InvoiceDetails/InvoiceDrawer';
|
||||||
import ReceiptDrawer from 'containers/Sales/Receipts/ReceiptDetails/ReceiptDrawer';
|
import ReceiptDrawer from 'containers/Sales/Receipts/ReceiptDetails/ReceiptDrawer';
|
||||||
import PaymentReceive from 'containers/Sales/PaymentReceives/PaymentDetails/PaymentDrawer';
|
import PaymentDrawer from 'containers/Sales/PaymentReceives/PaymentDetails/PaymentDrawer';
|
||||||
|
|
||||||
export default function DrawersContainer() {
|
export default function DrawersContainer() {
|
||||||
return (
|
return (
|
||||||
@@ -10,7 +10,7 @@ export default function DrawersContainer() {
|
|||||||
<EstimateDrawer name={'estimate-drawer'} />
|
<EstimateDrawer name={'estimate-drawer'} />
|
||||||
<InvoiceDrawer name={'invoice-drawer'} />
|
<InvoiceDrawer name={'invoice-drawer'} />
|
||||||
<ReceiptDrawer name={'receipt-drawer'} />
|
<ReceiptDrawer name={'receipt-drawer'} />
|
||||||
<PaymentReceive name={'payment-receive-drawer'} />
|
<PaymentDrawer name={'payment-receive-drawer'} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
import If from './Utils/If';
|
import If from './Utils/If';
|
||||||
import Money from './Money';
|
import Money from './Money';
|
||||||
import Icon from './Icon';
|
import Icon from './Icon';
|
||||||
@@ -33,7 +32,7 @@ import Col from './Grid/Col';
|
|||||||
import CloudLoadingIndicator from './CloudLoadingIndicator';
|
import CloudLoadingIndicator from './CloudLoadingIndicator';
|
||||||
import MoneyExchangeRate from './MoneyExchangeRate';
|
import MoneyExchangeRate from './MoneyExchangeRate';
|
||||||
import ContactSelecetList from './ContactSelecetList';
|
import ContactSelecetList from './ContactSelecetList';
|
||||||
import CurrencySelectList from './CurrencySelectList'
|
import CurrencySelectList from './CurrencySelectList';
|
||||||
import SalutationList from './SalutationList';
|
import SalutationList from './SalutationList';
|
||||||
import DisplayNameList from './DisplayNameList';
|
import DisplayNameList from './DisplayNameList';
|
||||||
import MoneyInputGroup from './Forms/MoneyInputGroup';
|
import MoneyInputGroup from './Forms/MoneyInputGroup';
|
||||||
@@ -44,12 +43,14 @@ import InputPrependText from './Forms/InputPrependText';
|
|||||||
import PageFormBigNumber from './PageFormBigNumber';
|
import PageFormBigNumber from './PageFormBigNumber';
|
||||||
import AccountsMultiSelect from './AccountsMultiSelect';
|
import AccountsMultiSelect from './AccountsMultiSelect';
|
||||||
import ContactsMultiSelect from './ContactsMultiSelect';
|
import ContactsMultiSelect from './ContactsMultiSelect';
|
||||||
import Skeleton from './Skeleton'
|
import Skeleton from './Skeleton';
|
||||||
import ContextMenu from './ContextMenu'
|
import ContextMenu from './ContextMenu';
|
||||||
import TableFastCell from './Datatable/TableFastCell';
|
import TableFastCell from './Datatable/TableFastCell';
|
||||||
import DashboardContentTable from './Dashboard/DashboardContentTable';
|
import DashboardContentTable from './Dashboard/DashboardContentTable';
|
||||||
import DashboardPageContent from './Dashboard/DashboardPageContent';
|
import DashboardPageContent from './Dashboard/DashboardPageContent';
|
||||||
import DashboardInsider from './Dashboard/DashboardInsider';
|
import DashboardInsider from './Dashboard/DashboardInsider';
|
||||||
|
import Drawer from './Drawer/Drawer';
|
||||||
|
import DrawerSuspense from './Drawer/DrawerSuspense';
|
||||||
|
|
||||||
const Hint = FieldHint;
|
const Hint = FieldHint;
|
||||||
|
|
||||||
@@ -105,5 +106,7 @@ export {
|
|||||||
ContextMenu,
|
ContextMenu,
|
||||||
DashboardContentTable,
|
DashboardContentTable,
|
||||||
DashboardPageContent,
|
DashboardPageContent,
|
||||||
DashboardInsider
|
DashboardInsider,
|
||||||
|
Drawer,
|
||||||
|
DrawerSuspense,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import { FormattedMessage as T, useIntl } from 'react-intl';
|
|
||||||
import { Position, Drawer } from '@blueprintjs/core';
|
|
||||||
|
|
||||||
export default function DrawerTemplate({
|
|
||||||
children,
|
|
||||||
isOpen,
|
|
||||||
isClose,
|
|
||||||
drawerProps,
|
|
||||||
}) {
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<Drawer
|
|
||||||
isOpen={isOpen}
|
|
||||||
usePortal={false}
|
|
||||||
hasBackdrop={true}
|
|
||||||
title={<T id={'view_paper'} />}
|
|
||||||
position={Position.RIGHT}
|
|
||||||
canOutsideClickClose={true}
|
|
||||||
canEscapeKeyClose={true}
|
|
||||||
size={'65%'}
|
|
||||||
onClose={isClose}
|
|
||||||
{...drawerProps}
|
|
||||||
>
|
|
||||||
{children}
|
|
||||||
</Drawer>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,11 +1,14 @@
|
|||||||
import React from 'react';
|
import React, { lazy } from 'react';
|
||||||
import DrawerTemplate from 'containers/Drawers/DrawerTemplate';
|
|
||||||
import PaperTemplate from 'containers/Drawers/PaperTemplate/PaperTemplate';
|
|
||||||
import withDrawers from 'containers/Drawer/withDrawers';
|
import withDrawers from 'containers/Drawer/withDrawers';
|
||||||
import withDrawerActions from 'containers/Drawer/withDrawerActions';
|
import withDrawerActions from 'containers/Drawer/withDrawerActions';
|
||||||
|
|
||||||
|
import { Drawer, DrawerSuspense } from 'components';
|
||||||
import { compose } from 'utils';
|
import { compose } from 'utils';
|
||||||
|
|
||||||
|
const EstimateDrawerContent = lazy(() =>
|
||||||
|
import('containers/Drawers/PaperTemplate/PaperTemplate'),
|
||||||
|
);
|
||||||
|
|
||||||
function EstimateDrawer({
|
function EstimateDrawer({
|
||||||
name,
|
name,
|
||||||
//#withDrawer
|
//#withDrawer
|
||||||
@@ -18,12 +21,12 @@ function EstimateDrawer({
|
|||||||
const handleDrawerClose = () => {
|
const handleDrawerClose = () => {
|
||||||
closeDrawer(name);
|
closeDrawer(name);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DrawerTemplate isOpen={isOpen} isClose={handleDrawerClose}>
|
<Drawer isOpen={isOpen} isClose={handleDrawerClose}>
|
||||||
<PaperTemplate />
|
<DrawerSuspense>
|
||||||
</DrawerTemplate>
|
<EstimateDrawerContent />
|
||||||
|
</DrawerSuspense>
|
||||||
|
</Drawer>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,17 @@
|
|||||||
import React from 'react';
|
import React, { lazy } from 'react';
|
||||||
import DrawerTemplate from 'containers/Drawers/DrawerTemplate';
|
|
||||||
import PaperTemplate from 'containers/Drawers/PaperTemplate/PaperTemplate';
|
|
||||||
import withDrawers from 'containers/Drawer/withDrawers';
|
import withDrawers from 'containers/Drawer/withDrawers';
|
||||||
import withDrawerActions from 'containers/Drawer/withDrawerActions';
|
import withDrawerActions from 'containers/Drawer/withDrawerActions';
|
||||||
|
|
||||||
|
import { Drawer, DrawerSuspense } from 'components';
|
||||||
import { compose } from 'utils';
|
import { compose } from 'utils';
|
||||||
|
|
||||||
|
const InvoicesDrawerContent = lazy(() =>
|
||||||
|
import('containers/Drawers/PaperTemplate/PaperTemplate'),
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* invoice drawer.
|
||||||
|
*/
|
||||||
function InvoiceDrawer({
|
function InvoiceDrawer({
|
||||||
name,
|
name,
|
||||||
//#withDrawer
|
//#withDrawer
|
||||||
@@ -32,9 +38,11 @@ function InvoiceDrawer({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DrawerTemplate isOpen={isOpen} isClose={handleDrawerClose}>
|
<Drawer isOpen={isOpen} isClose={handleDrawerClose}>
|
||||||
<PaperTemplate labels={propLabels.labels} />
|
<DrawerSuspense>
|
||||||
</DrawerTemplate>
|
<InvoicesDrawerContent labels={propLabels.labels} />
|
||||||
|
</DrawerSuspense>
|
||||||
|
</Drawer>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,17 @@
|
|||||||
import React from 'react';
|
import React, { lazy } from 'react';
|
||||||
import DrawerTemplate from 'containers/Drawers/DrawerTemplate';
|
|
||||||
import PaymentPaperTemplate from 'containers/Drawers/PaymentPaperTemplate/PaymentPaperTemplate';
|
|
||||||
import withDrawers from 'containers/Drawer/withDrawers';
|
import withDrawers from 'containers/Drawer/withDrawers';
|
||||||
import withDrawerActions from 'containers/Drawer/withDrawerActions';
|
import withDrawerActions from 'containers/Drawer/withDrawerActions';
|
||||||
|
import { Drawer, DrawerSuspense } from 'components';
|
||||||
|
|
||||||
import { compose } from 'utils';
|
import { compose } from 'utils';
|
||||||
|
|
||||||
|
const PaymentReceiveDrawerContent = lazy(() =>
|
||||||
|
import('containers/Drawers/PaymentPaperTemplate/PaymentPaperTemplate'),
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* payment receive drawer.
|
||||||
|
*/
|
||||||
function PaymentReceiveDrawer({
|
function PaymentReceiveDrawer({
|
||||||
name,
|
name,
|
||||||
//#withDrawer
|
//#withDrawer
|
||||||
@@ -20,9 +26,11 @@ function PaymentReceiveDrawer({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DrawerTemplate isOpen={isOpen} isClose={handleDrawerClose}>
|
<Drawer isOpen={isOpen} isClose={handleDrawerClose}>
|
||||||
<PaymentPaperTemplate />
|
<DrawerSuspense>
|
||||||
</DrawerTemplate>
|
<PaymentReceiveDrawerContent />
|
||||||
|
</DrawerSuspense>
|
||||||
|
</Drawer>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,17 @@
|
|||||||
import React from 'react';
|
import React, { lazy } from 'react';
|
||||||
import DrawerTemplate from 'containers/Drawers/DrawerTemplate';
|
|
||||||
import PaperTemplate from 'containers/Drawers/PaperTemplate/PaperTemplate';
|
|
||||||
import withDrawers from 'containers/Drawer/withDrawers';
|
import withDrawers from 'containers/Drawer/withDrawers';
|
||||||
import withDrawerActions from 'containers/Drawer/withDrawerActions';
|
import withDrawerActions from 'containers/Drawer/withDrawerActions';
|
||||||
|
|
||||||
|
import { Drawer, DrawerSuspense } from 'components';
|
||||||
import { compose } from 'utils';
|
import { compose } from 'utils';
|
||||||
|
|
||||||
|
const ReceiptDrawerContent = lazy(() =>
|
||||||
|
import('containers/Drawers/PaperTemplate/PaperTemplate'),
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* receipt drawer.
|
||||||
|
*/
|
||||||
const ReceiptDrawer = ({
|
const ReceiptDrawer = ({
|
||||||
name,
|
name,
|
||||||
//#withDrawer
|
//#withDrawer
|
||||||
@@ -33,9 +39,11 @@ const ReceiptDrawer = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<DrawerTemplate isOpen={isOpen} isClose={handleDrawerClose}>
|
<Drawer isOpen={isOpen} isClose={handleDrawerClose}>
|
||||||
<PaperTemplate labels={propLabels.labels} />
|
<DrawerSuspense>
|
||||||
</DrawerTemplate>
|
<ReceiptDrawerContent labels={propLabels.labels} />
|
||||||
|
</DrawerSuspense>
|
||||||
|
</Drawer>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user