'use client'; import Button from '@/components/Button'; import Tooltip from '@/components/Tooltip'; import { cn } from '@/lib/helper'; import { Icon } from '@iconify/react'; import { useAuth } from '@/services/hooks/useAuth'; type FloatingActionsButtonProps = { actions: { action: 'DETAIL' | 'EDIT' | 'DELETE'; icon: string; label?: string; onClick?: () => void; hidden?: boolean; disabled?: boolean; permissions?: string | string[]; }[]; approvals: { action: 'APPROVED' | 'REJECTED'; icon: string; label?: string; onClick?: () => void; disabled?: boolean; permissions?: string | string[]; }[]; selectedRowIds: number[]; onClose: () => void; }; const FloatingActionsButton = ({ actions, approvals, selectedRowIds, onClose, }: FloatingActionsButtonProps) => { const { permissionCheck } = useAuth(); // Jika tidak ada baris yang dipilih, jangan tampilkan FAB const positionStyles = selectedRowIds.length > 0 ? 'bottom-[5%] opacity-100' : 'bottom-[-5%] opacity-0'; // Helper untuk menentukan gaya warna tombol approval const getApprovalColor = (action: 'APPROVED' | 'REJECTED') => { if (action === 'APPROVED') return 'success'; if (action === 'REJECTED') return 'error'; return 'primary'; }; const getActionColor = (action: 'DETAIL' | 'EDIT' | 'DELETE') => { if (action === 'DETAIL') return 'white'; if (action === 'EDIT') return 'warning'; if (action === 'DELETE') return 'error'; return 'primary'; }; return ( // Container utama FAB
{/* === BARIS ATAS: Status Seleksi dan Actions (Termasuk Close) === */}

{selectedRowIds.length} Selected

{/* Render Aksi dari props.actions */} {actions .filter((action) => { if (action.hidden) return false; if (action.permissions) { if (typeof action.permissions === 'string') { return permissionCheck(action.permissions); } return action.permissions.some((permission) => permissionCheck(permission) ); } return true; }) .map((action, index) => { return ( ); })}
{/* Tombol Close */}
{/* === BARIS BAWAH: Approval Buttons (Approve/Reject) === */}
{approvals .filter((approval) => { if (approval.permissions) { if (typeof approval.permissions === 'string') { return permissionCheck(approval.permissions); } return approval.permissions.some((permission) => permissionCheck(permission) ); } return true; }) .map((approval, index) => ( ))}
); }; export default FloatingActionsButton;