import React, { useState, useEffect } from 'react'; import { Shield, Zap, Clock, Activity, Send, X, Terminal } from 'lucide-react'; import { motion, AnimatePresence } from 'framer-motion'; import styles from './RuleModal.module.css'; import type { EscalationRule } from '@nexus/shared'; interface RuleModalProps { rule?: EscalationRule | null; onClose: () => void; onSave: (data: any) => void; loading?: boolean; } export const RuleModal: React.FC = ({ rule, onClose, onSave, loading }) => { const [formData, setFormData] = useState({ name: '', priority_level: 'P0', threshold_minutes: 30, action: 'NOTIFY_LEAD', is_active: true }); useEffect(() => { if (rule) { setFormData({ name: rule.name, priority_level: rule.priority_level, threshold_minutes: rule.threshold_minutes, action: rule.action, is_active: rule.is_active }); } }, [rule]); const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); onSave(formData); }; return (
e.stopPropagation()} initial={{ x: '100%', opacity: 0.8 }} animate={{ x: 0, opacity: 1 }} exit={{ x: '100%', opacity: 0 }} transition={{ type: 'spring', damping: 30, stiffness: 200 }} >
LOGIC CONFIGURATOR
{rule ? 'Edit Escalation Protocol' : 'Initialize New Protocol'} Define automated hierarchy and conditional triggers.
1. PROTOCOL IDENTITY
setFormData({ ...formData, name: e.target.value })} required />
2. TARGET TIER
3. SLA WINDOW
setFormData({ ...formData, threshold_minutes: parseInt(e.target.value) || 0 })} min="1" required /> MINS
4. TRIGGERED ACTION
LOGIC PREVIEW
IF AGE > {formData.threshold_minutes} MINS (DEADLINE) ➔ {formData.action.replace(/_/g, ' ')}
{loading ? 'DEPLOYING...' : rule ? 'UPDATE PROTOCOL' : 'DEPLOY PROTOCOL'}
); };