feat: Bill drawer.

This commit is contained in:
elforjani3
2021-07-22 17:42:43 +02:00
parent 1091e3f996
commit 1eacc254d8
13 changed files with 290 additions and 3 deletions

View File

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

View File

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

View File

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

View File

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

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

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