Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(webapp): add Inventory Adjustment option to the item drawer #158

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
FormattedMessage as T,
Can,
} from '@/components';
import { ItemDetailActionsMoreBtn } from './ItemDetailActionsMoreBtn';

import { compose } from '@/utils';

Expand Down Expand Up @@ -71,6 +72,7 @@ function ItemDetailActionsBar({
onClick={handleDeleteItem}
/>
</Can>
<ItemDetailActionsMoreBtn />
</NavbarGroup>
</DashboardActionsBar>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -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 (
<Popover
minimal={true}
interactionKind={PopoverInteractionKind.CLICK}
position={Position.BOTTOM_LEFT}
modifiers={{
offset: { offset: '0, 4' },
}}
content={
<Menu>
<Can
I={InventoryAdjustmentAction.Edit}
a={AbilitySubject.InventoryAdjustment}
>
<MenuItem
text={<T id={'item.view_drawer.make_adjustment'} />}
onClick={handleInventoryAdjustment}
/>
</Can>
</Menu>
}
>
<Button icon={<Icon icon="more-vert" iconSize={16} />} minimal={true} />
</Popover>
);
},
);