mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
feat: Bill drawer.
This commit is contained in:
@@ -66,6 +66,30 @@ export default function AllocateLandedCostEntriesTable({
|
||||
rate: '100000',
|
||||
amount: '400',
|
||||
},
|
||||
{
|
||||
item_id: 'ITEM',
|
||||
quantity: '30000',
|
||||
rate: '100000',
|
||||
amount: '400',
|
||||
},
|
||||
{
|
||||
item_id: 'ITEM',
|
||||
quantity: '30000',
|
||||
rate: '100000',
|
||||
amount: '400',
|
||||
},
|
||||
{
|
||||
item_id: 'ITEM',
|
||||
quantity: '30000',
|
||||
rate: '100000',
|
||||
amount: '400',
|
||||
},
|
||||
{
|
||||
item_id: 'ITEM',
|
||||
quantity: '30000',
|
||||
rate: '100000',
|
||||
amount: '400',
|
||||
},
|
||||
];
|
||||
|
||||
return <DataTableEditable columns={columns} data={LL} />;
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import React from 'react';
|
||||
import { BillDrawerProvider } from './BillDrawerProvider';
|
||||
import BillDrawerDetails from './BillDrawerDetails';
|
||||
/**
|
||||
* Bill drawer content.
|
||||
*/
|
||||
export default function BillDrawerContent({
|
||||
// #ownProp
|
||||
billId,
|
||||
}) {
|
||||
return (
|
||||
<BillDrawerProvider billId={billId}>
|
||||
<BillDrawerDetails />
|
||||
</BillDrawerProvider>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import React from 'react';
|
||||
import { Tabs, Tab } from '@blueprintjs/core';
|
||||
import intl from 'react-intl-universal';
|
||||
|
||||
import LocatedLandedCostTable from './LocatedLandedCostTable';
|
||||
|
||||
import 'style/components/Drawer/BillDrawer.scss';
|
||||
|
||||
/**
|
||||
* Bill view details.
|
||||
*/
|
||||
export default function BillDrawerDetails() {
|
||||
return (
|
||||
<div className="bill-drawer">
|
||||
<Tabs animate={true} large={true} selectedTabId="landed_cost">
|
||||
<Tab title={intl.get('details')} id={'details'} disabled={true} />
|
||||
<Tab
|
||||
title={intl.get('located_landed_cost')}
|
||||
id={'landed_cost'}
|
||||
panel={<LocatedLandedCostTable />}
|
||||
/>
|
||||
</Tabs>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import { DrawerHeaderContent, DashboardInsider } from 'components';
|
||||
|
||||
const BillDrawerContext = React.createContext();
|
||||
|
||||
/**
|
||||
* Bill drawer provider.
|
||||
*/
|
||||
function BillDrawerProvider({ billId, ...props }) {
|
||||
//provider.
|
||||
const provider = {};
|
||||
return (
|
||||
<DashboardInsider>
|
||||
<DrawerHeaderContent
|
||||
name="bill-drawer"
|
||||
title={intl.get('bill_details')}
|
||||
/>
|
||||
<BillDrawerContext.Provider value={provider} {...props} />
|
||||
</DashboardInsider>
|
||||
);
|
||||
}
|
||||
|
||||
const useBillDrawerContext = () => React.useContext(BillDrawerContext);
|
||||
|
||||
export { BillDrawerProvider, useBillDrawerContext };
|
||||
@@ -0,0 +1,22 @@
|
||||
import React from 'react';
|
||||
import { DataTable } from 'components';
|
||||
import { useLocatedLandedCostColumns, ActionsMenu } from './components';
|
||||
|
||||
/**
|
||||
* Located landed cost table.
|
||||
*/
|
||||
function LocatedLandedCostTable() {
|
||||
const columns = useLocatedLandedCostColumns();
|
||||
|
||||
const DATA = [
|
||||
{
|
||||
name: 'INV-1000',
|
||||
amount: '10.000.000',
|
||||
allocation_method: 'Bill',
|
||||
},
|
||||
];
|
||||
|
||||
return <DataTable columns={columns} data={DATA} ContextMenu={ActionsMenu} />;
|
||||
}
|
||||
|
||||
export default LocatedLandedCostTable;
|
||||
41
client/src/containers/Drawers/BillDrawer/components.js
Normal file
41
client/src/containers/Drawers/BillDrawer/components.js
Normal file
@@ -0,0 +1,41 @@
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import { Intent, MenuItem, Menu } from '@blueprintjs/core';
|
||||
import { safeCallback } from 'utils';
|
||||
import { Icon } from 'components';
|
||||
|
||||
/**
|
||||
* Actions menu.
|
||||
*/
|
||||
export function ActionsMenu({ row: { original }, payload: { onDelete } }) {
|
||||
return (
|
||||
<Menu>
|
||||
<MenuItem
|
||||
icon={<Icon icon="trash-16" iconSize={16} />}
|
||||
text={intl.get('delete_transaction')}
|
||||
intent={Intent.DANGER}
|
||||
// onClick={safeCallback(onDelete, original)}
|
||||
/>
|
||||
</Menu>
|
||||
);
|
||||
}
|
||||
|
||||
export function useLocatedLandedCostColumns() {
|
||||
return React.useMemo(() => [
|
||||
{
|
||||
Header: intl.get('name'),
|
||||
accessor: 'name',
|
||||
width: 150,
|
||||
},
|
||||
{
|
||||
Header: intl.get('amount'),
|
||||
accessor: 'amount',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
Header: intl.get('allocation_method'),
|
||||
accessor: 'allocation_method',
|
||||
width: 100,
|
||||
},
|
||||
]);
|
||||
}
|
||||
27
client/src/containers/Drawers/BillDrawer/index.js
Normal file
27
client/src/containers/Drawers/BillDrawer/index.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import React from 'react';
|
||||
import { Drawer, DrawerSuspense } from 'components';
|
||||
import withDrawers from 'containers/Drawer/withDrawers';
|
||||
|
||||
import { compose } from 'utils';
|
||||
|
||||
const BillDrawerContent = React.lazy(() => import('./BillDrawerContent'));
|
||||
|
||||
/**
|
||||
* Bill drawer.
|
||||
*/
|
||||
function BillDrawer({
|
||||
name,
|
||||
// #withDrawer
|
||||
isOpen,
|
||||
payload: { billId },
|
||||
}) {
|
||||
return (
|
||||
<Drawer isOpen={isOpen} name={name} size={'750px'}>
|
||||
<DrawerSuspense>
|
||||
<BillDrawerContent bill={billId} />
|
||||
</DrawerSuspense>
|
||||
</Drawer>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(withDrawers())(BillDrawer);
|
||||
@@ -14,6 +14,7 @@ import withBillActions from './withBillsActions';
|
||||
import withSettings from 'containers/Settings/withSettings';
|
||||
import withAlertsActions from 'containers/Alert/withAlertActions';
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
import withDrawerActions from 'containers/Drawer/withDrawerActions';
|
||||
import { useBillsTableColumns, ActionsMenu } from './components';
|
||||
import { useBillsListContext } from './BillsListProvider';
|
||||
|
||||
@@ -32,6 +33,9 @@ function BillsDataTable({
|
||||
|
||||
// #withDialogActions
|
||||
openDialog,
|
||||
|
||||
// #withDrawerActions
|
||||
openDrawer,
|
||||
}) {
|
||||
// Bills list context.
|
||||
const { bills, pagination, isBillsLoading, isBillsFetching, isEmptyStatus } =
|
||||
@@ -78,6 +82,11 @@ function BillsDataTable({
|
||||
openDialog('allocate-landed-cost', { billId: id });
|
||||
};
|
||||
|
||||
// Handle view detail bill.
|
||||
const handleViewDetailBill = ({ id }) => {
|
||||
openDrawer('bill-drawer', { billId: id });
|
||||
};
|
||||
|
||||
if (isEmptyStatus) {
|
||||
return <BillsEmptyStatus />;
|
||||
}
|
||||
@@ -106,6 +115,7 @@ function BillsDataTable({
|
||||
onOpen: handleOpenBill,
|
||||
onQuick: handleQuickPaymentMade,
|
||||
onAllocateLandedCost: handleAllocateLandedCost,
|
||||
onViewDetails: handleViewDetailBill,
|
||||
}}
|
||||
/>
|
||||
);
|
||||
@@ -115,6 +125,7 @@ export default compose(
|
||||
withBills(({ billsTableState }) => ({ billsTableState })),
|
||||
withBillActions,
|
||||
withAlertsActions,
|
||||
withDrawerActions,
|
||||
withDialogActions,
|
||||
withSettings(({ organizationSettings }) => ({
|
||||
baseCurrency: organizationSettings?.baseCurrency,
|
||||
|
||||
@@ -20,7 +20,14 @@ import moment from 'moment';
|
||||
* Actions menu.
|
||||
*/
|
||||
export function ActionsMenu({
|
||||
payload: { onEdit, onOpen, onDelete, onQuick, onAllocateLandedCost },
|
||||
payload: {
|
||||
onEdit,
|
||||
onOpen,
|
||||
onDelete,
|
||||
onQuick,
|
||||
onViewDetails,
|
||||
onAllocateLandedCost,
|
||||
},
|
||||
row: { original },
|
||||
}) {
|
||||
return (
|
||||
@@ -28,6 +35,7 @@ export function ActionsMenu({
|
||||
<MenuItem
|
||||
icon={<Icon icon="reader-18" />}
|
||||
text={intl.get('view_details')}
|
||||
onClick={safeCallback(onViewDetails, original)}
|
||||
/>
|
||||
<MenuDivider />
|
||||
<MenuItem
|
||||
|
||||
Reference in New Issue
Block a user