import { useState } from 'react'; export default function ApprovalModal({ approvals, onApprove, onReject }) { const [processing, setProcessing] = useState({}); const handleApprove = async (id) => { setProcessing(p => ({ ...p, [id]: 'approving' })); try { await onApprove(id); } finally { setProcessing(p => ({ ...p, [id]: null })); } }; const handleReject = async (id) => { setProcessing(p => ({ ...p, [id]: 'rejecting' })); try { await onReject(id); } finally { setProcessing(p => ({ ...p, [id]: null })); } }; if (approvals.length === 0) return null; return (

Pending Approvals ({approvals.length})

{approvals.map((approval) => (
{approval.type === 'ssh_command' ? 'SSH Command' : 'Create Monitor'}

{approval.description}

{approval.reason && (

Why: {approval.reason}

)} {approval.type === 'ssh_command' && (

Command to execute:

{approval.details.command}

On host: {approval.details.hostname}

)} {approval.type === 'create_monitor' && (

Name: {approval.details.name}

Type: {approval.details.type}

Target: {approval.details.target}

)}
))}
); }