-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added context menu for merge/split in import tx
- Loading branch information
Showing
4 changed files
with
78 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import CallMergeIcon from '@mui/icons-material/CallMerge'; | ||
import CallSplitIcon from '@mui/icons-material/CallSplit'; | ||
import Menu from '@mui/material/Menu'; | ||
import MenuItem from '@mui/material/MenuItem'; | ||
|
||
const ContextMenu = ({ contextMenuPosition, setContextMenuPosition,selectedRowSize, apiRef }) => { | ||
const handleSplitTransaction = () => { | ||
setContextMenuPosition(null); | ||
const tx = apiRef.current.getSelectedRows().values().next().value; | ||
console.log(tx); | ||
}; | ||
|
||
const handleMergeTransaction = () => { | ||
setContextMenuPosition(null); | ||
const tx = Array.from(apiRef.current.getSelectedRows().values()); | ||
console.log(tx); | ||
}; | ||
|
||
return ( | ||
<Menu | ||
open={contextMenuPosition !== null} | ||
onClose={() => setContextMenuPosition(null)} | ||
anchorReference="anchorPosition" | ||
anchorPosition={ contextMenuPosition || undefined } | ||
slotProps={{ | ||
root: { | ||
onContextMenu: (e) => { | ||
e.preventDefault(); | ||
setContextMenuPosition(null); | ||
}, | ||
}, | ||
}} | ||
> | ||
<MenuItem | ||
onClick={handleSplitTransaction} | ||
disabled={selectedRowSize !== 1} | ||
> | ||
<CallSplitIcon sx={{ marginRight: '.7rem' }} /> | ||
Split Transaction | ||
</MenuItem> | ||
<MenuItem | ||
onClick={handleMergeTransaction} | ||
disabled={selectedRowSize < 2 || selectedRowSize > 3} | ||
> | ||
<CallMergeIcon sx={{ marginRight: '.7rem' }} /> | ||
Merge Transactions | ||
</MenuItem> | ||
</Menu> | ||
); | ||
}; | ||
export default ContextMenu; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters