refactor(FE): Refactor RowOptionsMenu to use PopoverButton and

PopoverContent
This commit is contained in:
rstubryan
2026-02-27 11:25:37 +07:00
parent 0b01eefe20
commit 5e3d2273d1
+11 -15
View File
@@ -34,6 +34,8 @@ import { isResponseSuccess } from '@/lib/api-helper';
import { BankApi, CustomerApi, SupplierApi } from '@/services/api/master-data'; import { BankApi, CustomerApi, SupplierApi } from '@/services/api/master-data';
import { Bank } from '@/types/api/master-data/bank'; import { Bank } from '@/types/api/master-data/bank';
import Modal, { useModal } from '@/components/Modal'; import Modal, { useModal } from '@/components/Modal';
import PopoverButton from '@/components/popover/PopoverButton';
import PopoverContent from '@/components/popover/PopoverContent';
import ConfirmationModal from '@/components/modal/ConfirmationModal'; import ConfirmationModal from '@/components/modal/ConfirmationModal';
import toast from 'react-hot-toast'; import toast from 'react-hot-toast';
import RequirePermission from '@/components/helper/RequirePermission'; import RequirePermission from '@/components/helper/RequirePermission';
@@ -64,27 +66,21 @@ const RowOptionsMenu = ({
return ( return (
<div className='relative'> <div className='relative'>
<Button <PopoverButton
tabIndex={0} tabIndex={0}
variant='ghost' variant='ghost'
color='none' color='none'
className='p-2'
popoverTarget={popoverId} popoverTarget={popoverId}
style={{ anchorName: popoverAnchorName } as React.CSSProperties} anchorName={popoverAnchorName}
> >
<Icon icon='material-symbols:more-vert' width={20} height={20} /> <Icon icon='material-symbols:more-vert' width={16} height={16} />
</Button> </PopoverButton>
<div <PopoverContent
id={popoverId} id={popoverId}
popover='auto' anchorName={popoverAnchorName}
style={{ positionAnchor: popoverAnchorName } as React.CSSProperties} position={popoverPosition === 'bottom' ? 'bottom-start' : 'left'}
className={cn( className='w-full max-w-40 rounded-xl border border-base-content/5 shadow-sm'
'fixed inset-auto bg-base-100 rounded-xl border border-base-content/5 shadow-sm w-full max-w-40 z-[100]',
popoverPosition === 'bottom'
? 'top-[anchor(bottom)] left-[anchor(left)] mt-1'
: 'bottom-[anchor(top)] left-[anchor(left)] mb-1'
)}
> >
<div className='flex flex-col bg-base-100 rounded-xl'> <div className='flex flex-col bg-base-100 rounded-xl'>
<RequirePermission <RequirePermission
@@ -173,7 +169,7 @@ const RowOptionsMenu = ({
</Button> </Button>
</RequirePermission> </RequirePermission>
</div> </div>
</div> </PopoverContent>
</div> </div>
); );
}; };