Files
btpxpress-frontend/components/chantiers/ChantierMenuActions.tsx
2025-10-13 05:29:32 +02:00

100 lines
2.3 KiB
TypeScript

/**
* Menu d'actions pour les chantiers - Actions prioritaires BTP
*/
import React, { useRef } from 'react';
import { Button } from 'primereact/button';
import { Menu } from 'primereact/menu';
import { MenuItem } from 'primereact/menuitem';
import { ChantierActif } from '../../hooks/useDashboard';
interface ChantierMenuActionsProps {
chantier: ChantierActif;
onAction: (action: string, chantier: ChantierActif) => void;
}
const ChantierMenuActions: React.FC<ChantierMenuActionsProps> = ({
chantier,
onAction
}) => {
const menuRef = useRef<Menu>(null);
// Actions prioritaires pour le workflow BTP
const menuItems: MenuItem[] = [
{
label: 'Gestion chantier',
items: [
{
label: 'Suspendre le chantier',
icon: 'pi pi-pause',
command: () => onAction('suspend', chantier)
},
{
label: 'Clôturer le chantier',
icon: 'pi pi-check-circle',
command: () => onAction('close', chantier)
}
]
},
{
separator: true
},
{
label: 'Communication',
items: [
{
label: 'Notification client',
icon: 'pi pi-send',
command: () => onAction('notify-client', chantier)
},
{
label: 'Rapport de synthèse',
icon: 'pi pi-file-pdf',
command: () => onAction('generate-report', chantier)
}
]
},
{
separator: true
},
{
label: 'Financier',
items: [
{
label: 'Facture intermédiaire',
icon: 'pi pi-euro',
command: () => onAction('generate-invoice', chantier)
},
{
label: 'Créer un avenant',
icon: 'pi pi-file-plus',
command: () => onAction('create-amendment', chantier)
}
]
}
];
const toggleMenu = (event: React.MouseEvent) => {
menuRef.current?.toggle(event);
};
return (
<>
<Button
icon="pi pi-ellipsis-v"
className="p-button-text p-button-rounded p-button-sm"
onClick={toggleMenu}
aria-label="Plus d'actions"
style={{ color: '#6B7280' }}
/>
<Menu
ref={menuRef}
model={menuItems}
popup
style={{ minWidth: '250px' }}
/>
</>
);
};
export default ChantierMenuActions;