From e5d0f160967a7fee1ed0ec05b53a7bb1a3364195 Mon Sep 17 00:00:00 2001 From: Ahmed Bouhuolia Date: Thu, 15 Jun 2023 19:49:23 +0200 Subject: [PATCH] feat(webapp): add Inventory Adjustment option to the item drawer --- .../ItemDetailDrawer/ItemDetailActionsBar.tsx | 2 + .../ItemDetailActionsMoreBtn.tsx | 64 +++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 packages/webapp/src/containers/Drawers/ItemDetailDrawer/ItemDetailActionsMoreBtn.tsx diff --git a/packages/webapp/src/containers/Drawers/ItemDetailDrawer/ItemDetailActionsBar.tsx b/packages/webapp/src/containers/Drawers/ItemDetailDrawer/ItemDetailActionsBar.tsx index 0213e8509..8a164ce96 100644 --- a/packages/webapp/src/containers/Drawers/ItemDetailDrawer/ItemDetailActionsBar.tsx +++ b/packages/webapp/src/containers/Drawers/ItemDetailDrawer/ItemDetailActionsBar.tsx @@ -21,6 +21,7 @@ import { FormattedMessage as T, Can, } from '@/components'; +import { ItemDetailActionsMoreBtn } from './ItemDetailActionsMoreBtn'; import { compose } from '@/utils'; @@ -71,6 +72,7 @@ function ItemDetailActionsBar({ onClick={handleDeleteItem} /> + ); diff --git a/packages/webapp/src/containers/Drawers/ItemDetailDrawer/ItemDetailActionsMoreBtn.tsx b/packages/webapp/src/containers/Drawers/ItemDetailDrawer/ItemDetailActionsMoreBtn.tsx new file mode 100644 index 000000000..23ce3aa3b --- /dev/null +++ b/packages/webapp/src/containers/Drawers/ItemDetailDrawer/ItemDetailActionsMoreBtn.tsx @@ -0,0 +1,64 @@ +// @ts-nocheck +import React from 'react'; +import * as R from 'ramda'; +import { Can, Icon, T } from '@/components'; +import { + Button, + Menu, + MenuItem, + Popover, + PopoverInteractionKind, + Position, +} from '@blueprintjs/core'; +import { + AbilitySubject, + InventoryAdjustmentAction, +} from '@/constants/abilityOption'; +import { useItemDetailDrawerContext } from './ItemDetailDrawerProvider'; +import withDialogActions from '@/containers/Dialog/withDialogActions'; + +/** + * Invoice details more actions menu. + * @returns {React.JSX} + */ +export const ItemDetailActionsMoreBtn = R.compose(withDialogActions)( + ({ + //#withDialogActions, + openDialog, + }) => { + const { itemId, item } = useItemDetailDrawerContext(); + + // Cannot continue if the item type is not inventory. + if (item.type !== 'inventory') return null; + + const handleInventoryAdjustment = () => { + openDialog('inventory-adjustment', { itemId }); + }; + + return ( + + + } + onClick={handleInventoryAdjustment} + /> + + + } + > +