import React from 'react'; import { ChevronRight, Zap, RefreshCw, CheckCircle2, AlertCircle, } from 'lucide-react'; function pretty(val) { if (val == null || val === '') return '(empty)'; if (typeof val === 'object') { try { return JSON.stringify(val, null, 2); } catch { return String(val); } } try { return JSON.stringify(JSON.parse(val), null, 2); } catch { return String(val); } } export default function StepCard({ step, isRunning, isRunningAll, res, onExecute }) { const status = res?.analysis?.status; const stateClass = status === 'success' ? ' is-ok' : status === 'failed' ? ' is-err' : isRunning ? ' is-running' : ''; // endpoint is "METHOD /path" — split out method and path for display const endpointParts = (step.endpoint || '').trim().split(/\s+/); const method = endpointParts.length >= 2 ? endpointParts[0].toUpperCase() : ''; const endpointPath = endpointParts.length >= 2 ? endpointParts.slice(1).join(' ') : step.endpoint; return (
{pretty(res.request.body)}
>
)}
{res.request.form_data && Object.keys(res.request.form_data).length > 0 && (
<>
Form data
{JSON.stringify(res.request.form_data, null, 2)}
>
)}
{pretty(res.response.body)}
>
)}