diff --git a/client/src/containers/Drawers/BillDrawer/BillDetailActionsBar.js b/client/src/containers/Drawers/BillDrawer/BillDetailActionsBar.js
new file mode 100644
index 000000000..e67562ccf
--- /dev/null
+++ b/client/src/containers/Drawers/BillDrawer/BillDetailActionsBar.js
@@ -0,0 +1,77 @@
+import React from 'react';
+import { useHistory } from 'react-router-dom';
+
+import {
+ Button,
+ NavbarGroup,
+ Classes,
+ NavbarDivider,
+ Intent,
+} from '@blueprintjs/core';
+import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar';
+
+import { useBillDrawerContext } from './BillDrawerProvider';
+
+import withDialogActions from 'containers/Dialog/withDialogActions';
+import withAlertsActions from 'containers/Alert/withAlertActions';
+import withDrawerActions from 'containers/Drawer/withDrawerActions';
+
+import { Icon, FormattedMessage as T } from 'components';
+
+import { safeCallback, compose } from 'utils';
+
+function BillDetailActionsBar({
+ // #withDialogActions
+ openDialog,
+
+ // #withAlertsActions
+ openAlert,
+
+ // #withDrawerActions
+ closeDrawer,
+}) {
+ const history = useHistory();
+
+ const { billId } = useBillDrawerContext();
+
+ // Handle edit bill.
+ const onEditBill = () => {
+ return billId
+ ? (history.push(`/bills/${billId}/edit`), closeDrawer('bill-drawer'))
+ : null;
+ };
+
+ // Handle delete bill.
+ const onDeleteBill = () => {
+ return billId
+ ? (openAlert('bill-delete', { billId }), closeDrawer('bill-drawer'))
+ : null;
+ };
+
+ return (
+
+
+ }
+ text={}
+ onClick={safeCallback(onEditBill)}
+ />
+
+ }
+ text={}
+ intent={Intent.DANGER}
+ onClick={safeCallback(onDeleteBill)}
+ />
+
+
+ );
+}
+
+export default compose(
+ withDialogActions,
+ withDrawerActions,
+ withAlertsActions,
+)(BillDetailActionsBar);
diff --git a/client/src/containers/Drawers/BillDrawer/BillDetailHeader.js b/client/src/containers/Drawers/BillDrawer/BillDetailHeader.js
new file mode 100644
index 000000000..3667521d2
--- /dev/null
+++ b/client/src/containers/Drawers/BillDrawer/BillDetailHeader.js
@@ -0,0 +1,46 @@
+import React from 'react';
+import intl from 'react-intl-universal';
+
+import { DataTable, Card, DetailsMenu, DetailItem } from 'components';
+
+import { useBillDrawerContext } from './BillDrawerProvider';
+
+/**
+ * Bill detail header.
+ */
+export default function BillDetailHeader() {
+ const {
+ bill: {
+ vendor,
+ bill_number,
+ formatted_amount,
+ formatted_bill_date,
+ formatted_due_amount,
+ formatted_due_date,
+ formatted_payment_amount,
+ },
+ } = useBillDrawerContext();
+
+ return (
+
+
+
+ {formatted_amount}
+ {bill_number}
+
+ {formatted_bill_date}
+
+
+ {vendor?.display_name}
+
+
+ {formatted_due_amount}
+
+
+ {formatted_due_date}
+
+
+
+
+ );
+}
diff --git a/client/src/containers/Drawers/BillDrawer/BillDetailTab.js b/client/src/containers/Drawers/BillDrawer/BillDetailTab.js
new file mode 100644
index 000000000..bbea084fe
--- /dev/null
+++ b/client/src/containers/Drawers/BillDrawer/BillDetailTab.js
@@ -0,0 +1,14 @@
+import React from 'react';
+import BillDetailActionsBar from './BillDetailActionsBar';
+import BillDetailHeader from './BillDetailHeader';
+import BillDetailTable from './BillDetailTable';
+
+export default function BillDetailTab() {
+ return (
+
+
+
+
+
+ );
+}
diff --git a/client/src/containers/Drawers/BillDrawer/BillDetailTable.js b/client/src/containers/Drawers/BillDrawer/BillDetailTable.js
new file mode 100644
index 000000000..3c104208f
--- /dev/null
+++ b/client/src/containers/Drawers/BillDrawer/BillDetailTable.js
@@ -0,0 +1,46 @@
+import React from 'react';
+
+import intl from 'react-intl-universal';
+
+import { DataTable, Card } from 'components';
+
+import { useBillDrawerContext } from './BillDrawerProvider';
+
+export default function BillDetailTable() {
+ const {
+ bill: { entries },
+ } = useBillDrawerContext();
+
+ const columns = React.useMemo(() => [
+ {
+ Header: intl.get('product_and_service'),
+ accessor: 'item.name',
+ width: 150,
+ },
+ {
+ Header: intl.get('description'),
+ accessor: 'description',
+ },
+ {
+ Header: intl.get('quantity'),
+ accessor: 'quantity',
+ width: 100,
+ },
+ {
+ Header: intl.get('rate'),
+ accessor: 'rate',
+ width: 100,
+ },
+ {
+ Header: intl.get('amount'),
+ accessor: 'amount',
+ width: 100,
+ },
+ ]);
+
+ return (
+
+
+
+ );
+}
diff --git a/client/src/containers/Drawers/BillDrawer/BillDrawerDetails.js b/client/src/containers/Drawers/BillDrawer/BillDrawerDetails.js
index d1ac37f33..73f552cba 100644
--- a/client/src/containers/Drawers/BillDrawer/BillDrawerDetails.js
+++ b/client/src/containers/Drawers/BillDrawer/BillDrawerDetails.js
@@ -2,6 +2,7 @@ import React from 'react';
import { Tabs, Tab } from '@blueprintjs/core';
import intl from 'react-intl-universal';
+import BillDetailTab from './BillDetailTab';
import LocatedLandedCostTable from './LocatedLandedCostTable';
import JournalEntriesTable from '../../JournalEntriesTable/JournalEntriesTable';
import { useBillDrawerContext } from './BillDrawerProvider';
@@ -17,7 +18,11 @@ export default function BillDrawerDetails() {
return (
-
+ }
+ />
);
}
-
-// 42 / fon-w 600
\ No newline at end of file
diff --git a/client/src/containers/Drawers/BillDrawer/BillDrawerProvider.js b/client/src/containers/Drawers/BillDrawer/BillDrawerProvider.js
index 12b11263c..b8d880fbf 100644
--- a/client/src/containers/Drawers/BillDrawer/BillDrawerProvider.js
+++ b/client/src/containers/Drawers/BillDrawer/BillDrawerProvider.js
@@ -1,8 +1,11 @@
import React from 'react';
import intl from 'react-intl-universal';
import { DrawerHeaderContent, DashboardInsider } from 'components';
-import { useBillLocatedLandedCost } from 'hooks/query';
-import { useTransactionsByReference } from 'hooks/query';
+import {
+ useBill,
+ useTransactionsByReference,
+ useBillLocatedLandedCost,
+} from 'hooks/query';
const BillDrawerContext = React.createContext();
@@ -10,7 +13,11 @@ const BillDrawerContext = React.createContext();
* Bill drawer provider.
*/
function BillDrawerProvider({ billId, ...props }) {
-
+ // Handle fetch bill details.
+ const { isLoading: isBillLoading, data: bill } = useBill(billId, {
+ enabled: !!billId,
+ });
+
// Handle fetch transaction by reference.
const { data, isLoading: isTransactionLoading } = useTransactionsByReference(
{
@@ -31,10 +38,13 @@ function BillDrawerProvider({ billId, ...props }) {
transactions,
billId,
data,
+ bill,
};
return (
-
+