plazbot
Version:
Official Plazbot SDK for creating AI agents for WhatsApp, portals, and developers.
59 lines (58 loc) • 2.27 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { usePlazbotContext } from '../../context/PlazbotContext';
import { resolveIcon } from '../../styles/icons';
const intentToIconKey = {
tag: 'tag',
asign: 'assign',
stage: 'stage',
segmentation: 'segmentation',
solved: 'solved',
agentshutdown: 'transfer',
};
function getIconKey(intent) {
if (!intent)
return 'gear';
const lower = intent.toLowerCase();
for (const [key, iconKey] of Object.entries(intentToIconKey)) {
if (lower.includes(key))
return iconKey;
}
return 'gear';
}
function getLabel(intent) {
if (!intent)
return 'Accion ejecutada';
if (intent.includes('tag'))
return 'Etiqueta aplicada';
if (intent.includes('asign'))
return 'Agente asignado';
if (intent.includes('stage'))
return 'Fase cambiada';
if (intent.includes('segmentation'))
return 'Segmentacion aplicada';
if (intent.includes('solved'))
return 'Conversacion resuelta';
if (intent.includes('agentShutDown'))
return 'Transferido a humano';
return 'Accion ejecutada';
}
export function ActionCard({ action, style }) {
const { theme, iconMode } = usePlazbotContext();
const iconKey = getIconKey(action.intent);
const icon = resolveIcon(iconKey, iconMode);
const label = getLabel(action.intent);
const resultStr = action.result != null ? String(action.result) : '';
return (_jsxs("div", { style: {
display: 'flex',
alignItems: 'center',
gap: '10px',
padding: '10px 14px',
borderRadius: theme.borderRadius,
backgroundColor: theme.cardBg,
border: `1px solid ${theme.borderColor}`,
fontFamily: theme.fontFamily,
fontSize: theme.fontSizeSm,
animation: 'plazbot-scale-in 0.2s ease-out',
...style,
}, children: [icon && _jsx("span", { style: { fontSize: '18px' }, children: icon }), _jsxs("div", { children: [_jsx("div", { style: { fontWeight: 500, color: theme.textColor }, children: label }), resultStr && (_jsx("div", { style: { color: theme.textSecondary, marginTop: '2px' }, children: resultStr }))] })] }));
}