UNPKG

plazbot

Version:

Official Plazbot SDK for creating AI agents for WhatsApp, portals, and developers.

47 lines (46 loc) 2.4 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { usePlazbotContext } from '../../context/PlazbotContext'; import { resolveIcon } from '../../styles/icons'; function extractEntries(result) { if (!result || typeof result !== 'object') return []; try { const obj = result; return Object.entries(obj) .filter(([, v]) => v !== null && v !== undefined && typeof v !== 'object') .map(([k, v]) => [k, String(v)]); } catch { return []; } } export function ServiceResultCard({ action, style }) { const { theme, iconMode } = usePlazbotContext(); const entries = extractEntries(action.result); if (entries.length === 0) { return null; } return (_jsxs("div", { style: { borderRadius: theme.borderRadius, backgroundColor: theme.cardBg, border: `1px solid ${theme.borderColor}`, overflow: 'hidden', fontFamily: theme.fontFamily, animation: 'plazbot-scale-in 0.2s ease-out', ...style, }, children: [_jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: '8px', padding: '10px 14px', borderBottom: `1px solid ${theme.borderColor}`, fontSize: theme.fontSizeSm, }, children: [resolveIcon('globe', iconMode) && _jsx("span", { style: { fontSize: '14px' }, children: resolveIcon('globe', iconMode) }), _jsx("span", { style: { fontWeight: 500, color: theme.textColor }, children: action.name ?? 'Resultado del servicio' })] }), _jsx("div", { style: { padding: '8px 14px' }, children: entries.map(([key, value], i) => (_jsxs("div", { style: { display: 'flex', justifyContent: 'space-between', padding: '6px 0', borderBottom: i < entries.length - 1 ? `1px solid ${theme.borderColor}` : 'none', fontSize: theme.fontSizeSm, gap: '12px', }, children: [_jsx("span", { style: { color: theme.textSecondary, flexShrink: 0 }, children: key }), _jsx("span", { style: { color: theme.textColor, fontWeight: 500, textAlign: 'right', wordBreak: 'break-word' }, children: value })] }, i))) })] })); }