import React, { useState } from 'react'; import { Shield, ShieldAlert, ShieldCheck, RefreshCw, Zap } from 'lucide-react'; // Preset values for testing const PRESETS = { legitimate: { F3888: '2026-06-08 10:00:00', // Date F3886: 'Savings', // Account Type F3887: '170', // Account Code F3889: 'G365D', // Customer Code F3890: 'R', // Account State F3891: 'salaried', // Job Status F3892: 'M', // Gender F3893: 'RETAIL', // Channel F3894: '30', // Tx Interval F3895: '600', // Tx Amount F3896: '600', // Daily Limit F3897: '0' }, suspicious: { // For fraud, we set features that would tip off the model, e.g. very short interval, high amount, unemployed, etc. F3888: '2026-06-08 23:45:00', // Late night F3886: 'Savings', F3887: '999', // Different account code F3889: 'X999Z', F3890: 'S', // Suspicious state F3891: 'unemployed', // Unemployed job status F3892: 'F', F3893: 'INTERNET', // Internet channel F3894: '1', // Tx Interval of 1 second (very high speed!) F3895: '50000', // High transaction amount F3896: '100000', // High limit F3897: '1' // Alarm flag active } }; export default function ManualQueryForm({ onSubmit, modelName, threshold }) { const [formData, setFormData] = useState(PRESETS.legitimate); const [loading, setLoading] = useState(false); const [result, setResult] = useState(null); const handleInputChange = (key, value) => { setFormData(prev => ({ ...prev, [key]: value })); }; const loadPreset = (type) => { setFormData(PRESETS[type]); setResult(null); }; const handleSubmit = async (e) => { e.preventDefault(); setLoading(true); setResult(null); try { // Map form string numbers to float/int where appropriate const mappedData = {}; Object.keys(formData).forEach(key => { const val = formData[key]; if (!isNaN(val) && val.trim() !== '') { mappedData[key] = val.includes('.') ? parseFloat(val) : parseInt(val); } else { mappedData[key] = val; } }); const res = await onSubmit(mappedData); setResult(res); } catch (err) { console.error(err); alert('Prediction query failed. Ensure backend is running.'); } finally { setLoading(false); } }; return (

Real-Time Inspector

handleInputChange('F3888', e.target.value)} required />
handleInputChange('F3894', e.target.value)} required />
handleInputChange('F3895', e.target.value)} required />
handleInputChange('F3896', e.target.value)} required />
handleInputChange('F3890', e.target.value)} required />
{/* Real-time result display */} {result && (
DECISION RESULT {result.is_suspicious ? ( SUSPICIOUS ) : ( LEGITIMATE )}
{Math.round(result.probability * 100)}% Mule / Fraud Risk Score
{result.is_suspicious ? ( ⚠️ Threat Warning: ) : ( ✅ Normal activity: )}{' '} The system evaluated this transaction as{' '} {result.risk_level} Risk {' '} using the {modelName} model at threshold {threshold}.
)}
); }