@decido/shell 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +13 -0
- package/package.json +65 -0
- package/src/AgentPlayer.tsx +105 -0
- package/src/DecidoPlayer.tsx +117 -0
- package/src/bridge/BridgeAgent.ts +443 -0
- package/src/components/DecidoIcon.tsx +56 -0
- package/src/components/JsonTreeEditor.tsx +117 -0
- package/src/components/PanelSplitter.tsx +71 -0
- package/src/components/PluginErrorBoundary.tsx +69 -0
- package/src/components/SafeLiquidUI.tsx +114 -0
- package/src/components/TransientLayer.tsx +92 -0
- package/src/components/agent/AgentChat.tsx +134 -0
- package/src/components/chat-extensions/IntentCatalogPanel.tsx +81 -0
- package/src/components/chat-extensions/chatSlashCommands.ts +101 -0
- package/src/components/controls/CreatorInputBar.tsx +144 -0
- package/src/components/controls/OSToolbar.tsx +90 -0
- package/src/components/controls/TimelineTape.tsx +43 -0
- package/src/components/debug/ActionTimelineTab.tsx +111 -0
- package/src/components/debug/CSSInspectorTab.tsx +436 -0
- package/src/components/debug/ExportTab.tsx +192 -0
- package/src/components/debug/FlowHealthTab.tsx +86 -0
- package/src/components/debug/LogsTab.tsx +110 -0
- package/src/components/debug/MorphStackTab.tsx +241 -0
- package/src/components/debug/NetworkTab.tsx +173 -0
- package/src/components/debug/PerformanceTab.tsx +171 -0
- package/src/components/debug/ProfilesTab.tsx +238 -0
- package/src/components/debug/ReplayTab.tsx +70 -0
- package/src/components/debug/StoresTab.tsx +255 -0
- package/src/components/debug/TopologyTab.tsx +59 -0
- package/src/components/debug/debugConfig.tsx +66 -0
- package/src/components/playground/DebugPanel.tsx +112 -0
- package/src/components/playground/HeaderCenterControls.tsx +92 -0
- package/src/components/playground/KeyframeListItem.tsx +70 -0
- package/src/components/playground/PlaygroundAppSidebar.tsx +171 -0
- package/src/components/playground/PlaygroundBottomControls.tsx +132 -0
- package/src/components/playground/PlaygroundCanvas.tsx +87 -0
- package/src/components/playground/PlaygroundChat.tsx +236 -0
- package/src/components/playground/PlaygroundErrorBoundary.tsx +63 -0
- package/src/components/playground/PlaygroundFloatingInput.tsx +352 -0
- package/src/components/playground/PlaygroundHeader.tsx +222 -0
- package/src/components/playground/PlaygroundSidebar.tsx +136 -0
- package/src/components/playground/PlaygroundTerminal.tsx +44 -0
- package/src/components/playground/SuggestionCards.tsx +29 -0
- package/src/components/playground/demos/ClinicaAINode.tsx +221 -0
- package/src/components/playground/demos/FinanceAINode.tsx +226 -0
- package/src/components/playground/demos/KiaAcademyNode.tsx +250 -0
- package/src/components/playground/demos/KiaBotNode.tsx +207 -0
- package/src/components/playground/demos/KiaCampaignNode.tsx +191 -0
- package/src/components/playground/demos/KiaComplianceNode.tsx +140 -0
- package/src/components/playground/demos/KiaCustomerJourneyNode.tsx +220 -0
- package/src/components/playground/demos/KiaCyberNode.tsx +203 -0
- package/src/components/playground/demos/KiaDashboardNode.tsx +399 -0
- package/src/components/playground/demos/KiaEmbudoOverviewNode.tsx +168 -0
- package/src/components/playground/demos/KiaExecutiveNode.tsx +169 -0
- package/src/components/playground/demos/KiaGamificationNode.tsx +229 -0
- package/src/components/playground/demos/KiaIntelligenceHubNode.tsx +165 -0
- package/src/components/playground/demos/KiaInventoryNode.tsx +183 -0
- package/src/components/playground/demos/KiaLeadScoringNode.tsx +226 -0
- package/src/components/playground/demos/KiaLiveSimulationNode.tsx +177 -0
- package/src/components/playground/demos/KiaMultiDealerNode.tsx +223 -0
- package/src/components/playground/demos/KiaNPSVoiceNode.tsx +214 -0
- package/src/components/playground/demos/KiaOmnichannelNode.tsx +162 -0
- package/src/components/playground/demos/KiaPBIBudgetNode.tsx +152 -0
- package/src/components/playground/demos/KiaPBIConversionNode.tsx +206 -0
- package/src/components/playground/demos/KiaPBIFunnelNode.tsx +184 -0
- package/src/components/playground/demos/KiaPBIOwnershipNode.tsx +113 -0
- package/src/components/playground/demos/KiaPBIPartnerNode.tsx +143 -0
- package/src/components/playground/demos/KiaPBIPreciosNode.tsx +120 -0
- package/src/components/playground/demos/KiaPBIRuntNode.tsx +205 -0
- package/src/components/playground/demos/KiaPartnerScoreNode.tsx +206 -0
- package/src/components/playground/demos/KiaPredictiveNode.tsx +226 -0
- package/src/components/playground/demos/KiaShowroomNode.tsx +194 -0
- package/src/components/playground/demos/KiaStoreNode.tsx +215 -0
- package/src/components/playground/demos/KiaSustainabilityNode.tsx +173 -0
- package/src/components/playground/demos/KiaUsedVehiclesNode.tsx +163 -0
- package/src/components/playground/demos/KiaWorkshopNode.tsx +221 -0
- package/src/components/playground/demos/SmartCityNode.tsx +205 -0
- package/src/components/playground/demos/kia_campaign_manifest.json +112 -0
- package/src/components/playground/input-parts/AIModelSelector.tsx +156 -0
- package/src/components/playground/input-parts/InputActions.tsx +80 -0
- package/src/components/playground/input-parts/InputToolbar.tsx +245 -0
- package/src/components/playground/input-parts/ResourceLibraryPanel.tsx +287 -0
- package/src/components/playground/sidebarDsdIO.ts +82 -0
- package/src/components/settings/SettingsPanel.tsx +267 -0
- package/src/components/shell/AppHeader.tsx +9 -0
- package/src/components/shell/AppShell.tsx +139 -0
- package/src/components/shell/ArtifactBar.tsx +97 -0
- package/src/components/shell/BootScreen.tsx +19 -0
- package/src/components/shell/CenterComposite.tsx +87 -0
- package/src/components/shell/CodeEditorPanel.tsx +88 -0
- package/src/components/shell/GlobalOverlays.tsx +228 -0
- package/src/components/shell/LayoutConfigurator.tsx +209 -0
- package/src/components/shell/LayoutGrid.tsx +178 -0
- package/src/components/shell/MorphShell.tsx +368 -0
- package/src/components/shell/PluginViewer.tsx +147 -0
- package/src/components/shell/ShellNexusPreview.tsx +458 -0
- package/src/components/shell/SlotRenderer.tsx +115 -0
- package/src/components/shell/TabBar.tsx +94 -0
- package/src/components/shell/TemplateLibrary.tsx +195 -0
- package/src/components/shell/layoutConstants.ts +35 -0
- package/src/components/shell/morphStageMeta.ts +15 -0
- package/src/components/shell/shells/BuiltInShells.tsx +443 -0
- package/src/components/shell/shells/DatawayChatShell.tsx +42 -0
- package/src/components/shell/shells/TokenPreview.tsx +339 -0
- package/src/components/shell/shells/bootShells.ts +31 -0
- package/src/components/shells/CreatorShell.tsx +37 -0
- package/src/components/shells/DecidoShell.tsx +447 -0
- package/src/components/shells/ExperimentalChatShell.tsx +245 -0
- package/src/components/shells/UserCanvas.tsx +44 -0
- package/src/components/studio/BlueprintManagerPanel.tsx +137 -0
- package/src/components/studio/DependencyTreePanel.tsx +192 -0
- package/src/components/studio/NodePalette.tsx +92 -0
- package/src/components/studio/NodePropertiesPanel.tsx +81 -0
- package/src/components/studio/ReactFlowEditor.tsx +242 -0
- package/src/components/studio/TimelineEditor.tsx +122 -0
- package/src/components/studio/TimelineKeyframeCard.tsx +99 -0
- package/src/components/studio/VariablePanel.tsx +181 -0
- package/src/components/studio/blueprint/BlueprintCard.tsx +82 -0
- package/src/components/studio/editor/CanvasContextMenu.tsx +107 -0
- package/src/components/studio/editor/EditorToolbar.tsx +80 -0
- package/src/components/studio/editor/StageContentRenderer.tsx +134 -0
- package/src/components/studio/editor/TrackPropertyEditors.tsx +133 -0
- package/src/components/studio/editor/TreeNodeItem.tsx +91 -0
- package/src/components/studio/editor/edgeStyles.ts +43 -0
- package/src/components/studio/editor/editorKeyHandler.ts +95 -0
- package/src/components/studio/editor/nodeTypeRegistry.ts +137 -0
- package/src/components/studio/editor/paletteCatalog.tsx +84 -0
- package/src/components/studio/nodes/shell/InteractionNodes.tsx +82 -0
- package/src/components/studio/nodes/shell/LayoutControlNodes.tsx +69 -0
- package/src/components/studio/nodes/shell/RegisterActionNode.tsx +20 -0
- package/src/components/studio/nodes/shell/RegisterButtonNode.tsx +22 -0
- package/src/components/studio/nodes/shell/RegisterPanelNode.tsx +19 -0
- package/src/components/studio/nodes/shell/RegisterSidebarNode.tsx +19 -0
- package/src/components/studio/nodes/shell/RegisterStatusBarNode.tsx +22 -0
- package/src/components/studio/nodes/shell/RegisterTabNode.tsx +21 -0
- package/src/components/studio/nodes/shell/RegisterTopBarNode.tsx +22 -0
- package/src/components/studio/nodes/shell/ShellConfigNode.tsx +51 -0
- package/src/components/studio/nodes/shell/ShellNodeBase.tsx +100 -0
- package/src/components/studio/nodes/shell/ThemeNodes.tsx +51 -0
- package/src/components/studio/nodes/shell/index.ts +12 -0
- package/src/components/widgets/BroadcastWidget.tsx +93 -0
- package/src/components/widgets/MarketplaceWidget.tsx +298 -0
- package/src/components/widgets/McpToolsWidget.tsx +231 -0
- package/src/components/widgets/OpsDashboard.tsx +59 -0
- package/src/components/widgets/QuickActionsWidget.tsx +60 -0
- package/src/components/widgets/UsageWidget.tsx +112 -0
- package/src/components/widgets/WidgetRenderer.tsx +892 -0
- package/src/components/widgets/WidgetSlotPanel.tsx +213 -0
- package/src/config/IconRegistry.ts +126 -0
- package/src/contexts/NetworkProvider.tsx +162 -0
- package/src/core/AIDirector.ts +71 -0
- package/src/core/EventBus.ts +37 -0
- package/src/core/PluginContext.tsx +141 -0
- package/src/hooks/listeners/useUIStateListener.ts +59 -0
- package/src/hooks/listeners/useWhatsAppListener.ts +110 -0
- package/src/hooks/morphBridge.ts +82 -0
- package/src/hooks/useAIModelSelector.ts +144 -0
- package/src/hooks/useAgentStream.ts +220 -0
- package/src/hooks/useAutoUpdater.ts +89 -0
- package/src/hooks/useBootSequence.ts +20 -0
- package/src/hooks/useExportDSD.ts +53 -0
- package/src/hooks/useFullscreen.ts +35 -0
- package/src/hooks/useGeminiStream.ts +282 -0
- package/src/hooks/useIntentLens.ts +224 -0
- package/src/hooks/useKeyboardShortcuts.ts +69 -0
- package/src/hooks/useLoggerBridge.ts +32 -0
- package/src/hooks/useMcpClient.ts +112 -0
- package/src/hooks/useNexusaiDeploy.ts +118 -0
- package/src/hooks/usePlaybackEngine.ts +21 -0
- package/src/hooks/usePlaygroundCommander.ts +475 -0
- package/src/hooks/usePluginEngine.ts +165 -0
- package/src/hooks/useScreenRecorder.ts +73 -0
- package/src/hooks/useShellKeyboard.ts +40 -0
- package/src/hooks/useShellShortcuts.ts +118 -0
- package/src/hooks/useSoundEffects.ts +35 -0
- package/src/hooks/useStudioConfig.ts +72 -0
- package/src/hooks/useSystemBoot.ts +84 -0
- package/src/hooks/useSystemTelemetry.ts +62 -0
- package/src/index.ts +97 -0
- package/src/lib/debugLogger.ts +80 -0
- package/src/lib/networkInterceptor.ts +100 -0
- package/src/mocks/decido.tsx +41 -0
- package/src/plugins/pluginAPI.ts +190 -0
- package/src/store/McpStore.ts +69 -0
- package/src/store/UpdaterStore.ts +60 -0
- package/src/store/engine.ts +392 -0
- package/src/store/index.ts +4 -0
- package/src/store/layoutPresets.ts +66 -0
- package/src/store/playgroundTypes.ts +98 -0
- package/src/store/useActionTimelineStore.ts +48 -0
- package/src/store/useDebugPanelStore.ts +98 -0
- package/src/store/useDebugProfileStore.ts +130 -0
- package/src/store/useLayoutStore.ts +205 -0
- package/src/store/useMorphInstanceStore.ts +289 -0
- package/src/store/useMorphologyStore.ts +103 -0
- package/src/store/usePlaygroundStore.ts +236 -0
- package/src/store/useShellRegistry.ts +123 -0
- package/src/store/useSuggestionsStore.ts +57 -0
- package/src/store/useThemeStore.ts +399 -0
- package/src/store/useUIComponentStore.ts +179 -0
- package/src/types/DecidoStoryDefinition.ts +43 -0
- package/src/utils/ai/ai-architect.ts +92 -0
- package/src/utils/ai/ai-code.ts +187 -0
- package/src/utils/ai/ai-core.ts +50 -0
- package/src/utils/ai/ai-media.ts +292 -0
- package/src/utils/layoutGraph.ts +67 -0
- package/tsconfig.json +17 -0
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import React, { useState, useEffect, useCallback } from 'react';
|
|
2
|
+
import { BaseNode } from '@decido/macia-core';
|
|
3
|
+
import {
|
|
4
|
+
Play, Pause, SkipForward, Activity, Zap, Users,
|
|
5
|
+
Car, ShoppingCart, Wrench, BarChart3, Radio, TrendingUp,
|
|
6
|
+
ArrowRight, Clock, Gauge, RefreshCw
|
|
7
|
+
} from 'lucide-react';
|
|
8
|
+
|
|
9
|
+
/* ═══════════════════════════════════════════════════════════════
|
|
10
|
+
KIA LIVE SIMULATION NODE — Real-Time Data Flow · Grecco Motors
|
|
11
|
+
Orchestrates simulated events across all ecosystem nodes
|
|
12
|
+
═══════════════════════════════════════════════════════════════ */
|
|
13
|
+
|
|
14
|
+
interface SimEvent {
|
|
15
|
+
id: number;
|
|
16
|
+
time: string;
|
|
17
|
+
source: string;
|
|
18
|
+
target: string;
|
|
19
|
+
type: 'lead' | 'service' | 'sale' | 'alert' | 'finance';
|
|
20
|
+
msg: string;
|
|
21
|
+
color: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const EVENT_TEMPLATES = [
|
|
25
|
+
{ source: '📱 WhatsApp Bot', target: '🎯 Lead Scoring', type: 'lead' as const, msg: 'Nuevo lead: María Gómez — Interesada en EV6', color: '#3b82f6' },
|
|
26
|
+
{ source: '🎯 Lead Scoring', target: '📊 Dashboard', type: 'lead' as const, msg: 'Lead HOT → Assign Johan S. Blanco (Score: 92)', color: '#ef4444' },
|
|
27
|
+
{ source: '🎮 Gamification', target: '📊 Dashboard', type: 'lead' as const, msg: 'Lucky Drive win: Mantenimiento Gratis → CRM reg', color: '#a855f7' },
|
|
28
|
+
{ source: '🔧 Workshop', target: '📊 Dashboard', type: 'service' as const, msg: 'Sportage KIA-5502 — Bahía 3 — QC Passed ✅', color: '#22c55e' },
|
|
29
|
+
{ source: '🏥 Fleet Health', target: '🔧 Workshop', type: 'alert' as const, msg: 'EV6-001: Bujía cilindro 1 desgaste 87% — Cita auto', color: '#f59e0b' },
|
|
30
|
+
{ source: '🛒 Store', target: '💰 Finance', type: 'sale' as const, msg: 'Pedido #1247: Polarizado 3M + Tapetes — $1.13M', color: '#06b6d4' },
|
|
31
|
+
{ source: '💰 Finance', target: '📊 Dashboard', type: 'finance' as const, msg: 'Pre-aprobación OK: Score 812, Bancolombia, $112M', color: '#22c55e' },
|
|
32
|
+
{ source: '🛡️ CyberOps', target: '📊 Dashboard', type: 'alert' as const, msg: 'Brute force blocked — IP 45.33.X.X — WAF active', color: '#ef4444' },
|
|
33
|
+
{ source: '🚗 Mobility', target: '🛡️ CyberOps', type: 'alert' as const, msg: 'V2X integrity check passed — EV6 fleet OK', color: '#22c55e' },
|
|
34
|
+
{ source: '📚 Academy', target: '📊 Dashboard', type: 'lead' as const, msg: 'Camila Torres → ADAS Expert cert completed 🏆', color: '#a855f7' },
|
|
35
|
+
{ source: '🔧 Workshop', target: '🛒 Store', type: 'service' as const, msg: 'Auto-order: Filtro aceite Sportage × 12 unid', color: '#06b6d4' },
|
|
36
|
+
{ source: '📱 WhatsApp Bot', target: '🎮 Gamification', type: 'lead' as const, msg: 'Redirect: Cliente quiere Test Drive → Showroom', color: '#3b82f6' },
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
const PIPELINE_STAGES = [
|
|
40
|
+
{ label: 'Leads', icon: Users, count: 437, color: '#3b82f6' },
|
|
41
|
+
{ label: 'Contacto', icon: Radio, count: 246, color: '#06b6d4' },
|
|
42
|
+
{ label: 'Show Up', icon: Car, count: 85, color: '#a855f7' },
|
|
43
|
+
{ label: 'Cotización', icon: BarChart3, count: 47, color: '#f59e0b' },
|
|
44
|
+
{ label: 'Cierre', icon: TrendingUp, count: 30, color: '#22c55e' },
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
export const KiaLiveSimulationNode = (props: any) => {
|
|
48
|
+
const [events, setEvents] = useState<SimEvent[]>([]);
|
|
49
|
+
const [isRunning, setIsRunning] = useState(true);
|
|
50
|
+
const [speed, setSpeed] = useState(1);
|
|
51
|
+
const [stats, setStats] = useState({ eventsTotal: 0, leads: 0, services: 0, sales: 0, alerts: 0 });
|
|
52
|
+
const [pipeline, setPipeline] = useState(PIPELINE_STAGES.map(s => ({ ...s })));
|
|
53
|
+
|
|
54
|
+
const addEvent = useCallback(() => {
|
|
55
|
+
const template = EVENT_TEMPLATES[Math.floor(Math.random() * EVENT_TEMPLATES.length)];
|
|
56
|
+
const ev: SimEvent = {
|
|
57
|
+
id: Date.now() + Math.random(),
|
|
58
|
+
time: new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', second: '2-digit' }),
|
|
59
|
+
...template,
|
|
60
|
+
};
|
|
61
|
+
setEvents(prev => [ev, ...prev].slice(0, 50));
|
|
62
|
+
setStats(prev => ({
|
|
63
|
+
eventsTotal: prev.eventsTotal + 1,
|
|
64
|
+
leads: prev.leads + (template.type === 'lead' ? 1 : 0),
|
|
65
|
+
services: prev.services + (template.type === 'service' ? 1 : 0),
|
|
66
|
+
sales: prev.sales + (template.type === 'sale' ? 1 : 0),
|
|
67
|
+
alerts: prev.alerts + (template.type === 'alert' ? 1 : 0),
|
|
68
|
+
}));
|
|
69
|
+
// Pipeline jitter
|
|
70
|
+
setPipeline(prev => prev.map((s, i) => ({
|
|
71
|
+
...s,
|
|
72
|
+
count: s.count + (i === 0 ? Math.floor(Math.random() * 3) : 0),
|
|
73
|
+
})));
|
|
74
|
+
}, []);
|
|
75
|
+
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (!isRunning) return;
|
|
78
|
+
const interval = setInterval(addEvent, 2500 / speed);
|
|
79
|
+
return () => clearInterval(interval);
|
|
80
|
+
}, [isRunning, speed, addEvent]);
|
|
81
|
+
|
|
82
|
+
const toggleSpeed = () => setSpeed(s => s >= 4 ? 1 : s * 2);
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<BaseNode {...props} title="Kia Live Simulation" width={520} height={620}>
|
|
86
|
+
<div className="flex flex-col h-full bg-[#060a12] text-white overflow-hidden">
|
|
87
|
+
|
|
88
|
+
{/* Header */}
|
|
89
|
+
<div className="flex items-center gap-3 p-3 bg-[#0c1222] border-b border-slate-800">
|
|
90
|
+
<div className="w-9 h-9 rounded-full bg-red-600/20 flex items-center justify-center border border-red-500/30">
|
|
91
|
+
<span className="text-red-500 font-bold text-[7px] tracking-widest">KIA</span>
|
|
92
|
+
</div>
|
|
93
|
+
<div className="flex-1">
|
|
94
|
+
<div className="text-xs font-bold tracking-wide flex items-center gap-2">
|
|
95
|
+
LIVE SIMULATION
|
|
96
|
+
{isRunning && <span className="w-1.5 h-1.5 rounded-full bg-green-400 animate-pulse" />}
|
|
97
|
+
</div>
|
|
98
|
+
<div className="text-[10px] text-slate-400">Grecco Motors · Event Stream · {stats.eventsTotal} eventos</div>
|
|
99
|
+
</div>
|
|
100
|
+
<div className="flex gap-1">
|
|
101
|
+
<button onClick={() => setIsRunning(!isRunning)}
|
|
102
|
+
className={`p-1.5 rounded-lg border transition-all ${isRunning
|
|
103
|
+
? 'bg-green-500/20 border-green-500/30 text-green-400'
|
|
104
|
+
: 'bg-slate-800 border-slate-700 text-slate-400'}`}>
|
|
105
|
+
{isRunning ? <Pause size={12} /> : <Play size={12} />}
|
|
106
|
+
</button>
|
|
107
|
+
<button onClick={toggleSpeed}
|
|
108
|
+
className="px-2 py-1 rounded-lg bg-slate-800 border border-slate-700 text-[10px] font-bold text-slate-300">
|
|
109
|
+
{speed}×
|
|
110
|
+
</button>
|
|
111
|
+
<button onClick={addEvent}
|
|
112
|
+
className="p-1.5 rounded-lg bg-slate-800 border border-slate-700 text-slate-400 hover:text-white">
|
|
113
|
+
<SkipForward size={12} />
|
|
114
|
+
</button>
|
|
115
|
+
</div>
|
|
116
|
+
</div>
|
|
117
|
+
|
|
118
|
+
{/* Stats Bar */}
|
|
119
|
+
<div className="flex gap-1 p-2 bg-[#0a0f1a] border-b border-slate-800">
|
|
120
|
+
{[
|
|
121
|
+
{ val: stats.leads, label: 'Leads', color: 'blue' },
|
|
122
|
+
{ val: stats.services, label: 'Servicios', color: 'green' },
|
|
123
|
+
{ val: stats.sales, label: 'Ventas', color: 'cyan' },
|
|
124
|
+
{ val: stats.alerts, label: 'Alertas', color: 'yellow' },
|
|
125
|
+
].map(s => (
|
|
126
|
+
<div key={s.label} className={`flex-1 bg-${s.color}-500/5 border border-${s.color}-500/10 rounded p-1.5 text-center`}>
|
|
127
|
+
<div className={`text-sm font-bold text-${s.color}-400`}>{s.val}</div>
|
|
128
|
+
<div className="text-[8px] text-slate-500">{s.label}</div>
|
|
129
|
+
</div>
|
|
130
|
+
))}
|
|
131
|
+
</div>
|
|
132
|
+
|
|
133
|
+
{/* Pipeline */}
|
|
134
|
+
<div className="flex items-center gap-0.5 px-3 py-2 border-b border-slate-800 bg-slate-900/30">
|
|
135
|
+
{pipeline.map((stage, i) => (
|
|
136
|
+
<React.Fragment key={stage.label}>
|
|
137
|
+
<div className="flex-1 text-center">
|
|
138
|
+
<div className="text-base font-bold" style={{ color: stage.color }}>{stage.count}</div>
|
|
139
|
+
<div className="text-[8px] text-slate-500">{stage.label}</div>
|
|
140
|
+
</div>
|
|
141
|
+
{i < pipeline.length - 1 && (
|
|
142
|
+
<ArrowRight size={10} className="text-slate-600 flex-shrink-0" />
|
|
143
|
+
)}
|
|
144
|
+
</React.Fragment>
|
|
145
|
+
))}
|
|
146
|
+
</div>
|
|
147
|
+
|
|
148
|
+
{/* Event Stream */}
|
|
149
|
+
<div className="flex-1 overflow-y-auto p-2 space-y-1">
|
|
150
|
+
{events.map(ev => (
|
|
151
|
+
<div key={ev.id} className="flex items-start gap-2 bg-slate-900/50 rounded-lg p-2 border border-slate-800/50"
|
|
152
|
+
style={{ borderLeftColor: ev.color, borderLeftWidth: '2px' }}>
|
|
153
|
+
<div className="flex-shrink-0">
|
|
154
|
+
<Activity size={10} className="mt-0.5" style={{ color: ev.color }} />
|
|
155
|
+
</div>
|
|
156
|
+
<div className="flex-1 min-w-0">
|
|
157
|
+
<div className="flex items-center gap-2 text-[9px] text-slate-500 mb-0.5">
|
|
158
|
+
<span className="font-mono">{ev.time}</span>
|
|
159
|
+
<span>{ev.source}</span>
|
|
160
|
+
<ArrowRight size={8} />
|
|
161
|
+
<span>{ev.target}</span>
|
|
162
|
+
</div>
|
|
163
|
+
<div className="text-[10px] text-slate-300 leading-relaxed">{ev.msg}</div>
|
|
164
|
+
</div>
|
|
165
|
+
</div>
|
|
166
|
+
))}
|
|
167
|
+
{events.length === 0 && (
|
|
168
|
+
<div className="text-slate-600 text-center py-12 text-xs">
|
|
169
|
+
<RefreshCw className="mx-auto mb-2 animate-spin" size={16} />
|
|
170
|
+
Iniciando simulación...
|
|
171
|
+
</div>
|
|
172
|
+
)}
|
|
173
|
+
</div>
|
|
174
|
+
</div>
|
|
175
|
+
</BaseNode>
|
|
176
|
+
);
|
|
177
|
+
};
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import { BaseNode } from '@decido/macia-core';
|
|
3
|
+
import {
|
|
4
|
+
Building2, TrendingUp, Users, BarChart3, Map,
|
|
5
|
+
ChevronUp, ChevronDown, Eye, Crown, Target, Layers
|
|
6
|
+
} from 'lucide-react';
|
|
7
|
+
|
|
8
|
+
/* ═══════════════════════════════════════════════════════════════
|
|
9
|
+
KIA MULTI-DEALER NODE — Multi-Concesionario · Red Metrokia
|
|
10
|
+
Benchmark, ranking, regional dashboard, template system
|
|
11
|
+
═══════════════════════════════════════════════════════════════ */
|
|
12
|
+
|
|
13
|
+
interface Dealer {
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
city: string;
|
|
17
|
+
region: string;
|
|
18
|
+
score: number;
|
|
19
|
+
prevScore: number;
|
|
20
|
+
ranking: string;
|
|
21
|
+
sales: number;
|
|
22
|
+
posventa: number;
|
|
23
|
+
nps: number;
|
|
24
|
+
ms: number;
|
|
25
|
+
color: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const DEALERS: Dealer[] = [
|
|
29
|
+
{ id: 'GRC-GIR', name: 'Grecco Girón', city: 'Girón', region: 'Santander', score: 94, prevScore: 91, ranking: 'S', sales: 41, posventa: 98, nps: 96.1, ms: 15.2, color: '#ef4444' },
|
|
30
|
+
{ id: 'GRC-VRO', name: 'Grecco V. Rosario', city: 'V. del Rosario', region: 'N. Santander', score: 91, prevScore: 88, ranking: 'S', sales: 27, posventa: 72, nps: 95.3, ms: 12.8, color: '#3b82f6' },
|
|
31
|
+
{ id: 'GRC-CUC', name: 'Grecco Cúcuta', city: 'Cúcuta', region: 'N. Santander', score: 87, prevScore: 85, ranking: 'S', sales: 9, posventa: 45, nps: 93.8, ms: 8.4, color: '#22c55e' },
|
|
32
|
+
{ id: 'GRC-BUC', name: 'Grecco Bucaramanga', city: 'Bucaramanga', region: 'Santander', score: 85, prevScore: 82, ranking: 'A', sales: 6, posventa: 38, nps: 94.2, ms: 6.1, color: '#f59e0b' },
|
|
33
|
+
{ id: 'GRC-PIE', name: 'Grecco Piedecuesta', city: 'Piedecuesta', region: 'Santander', score: 82, prevScore: 79, ranking: 'A', sales: 8, posventa: 32, nps: 92.0, ms: 5.5, color: '#a855f7' },
|
|
34
|
+
{ id: 'GRC-FLR', name: 'Grecco Floridablanca', city: 'Floridablanca', region: 'Santander', score: 80, prevScore: 78, ranking: 'A', sales: 4, posventa: 28, nps: 91.5, ms: 4.2, color: '#06b6d4' },
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
const REGIONS = ['Nacional', 'Santander', 'N. Santander'];
|
|
38
|
+
|
|
39
|
+
const TEMPLATES = [
|
|
40
|
+
{ name: 'Dashboard Ejecutivo', nodes: 7, slides: 6, uses: 12 },
|
|
41
|
+
{ name: 'Posventa Predictiva', nodes: 4, slides: 5, uses: 8 },
|
|
42
|
+
{ name: 'Embudo Comercial', nodes: 5, slides: 6, uses: 15 },
|
|
43
|
+
{ name: 'Partner Score 360°', nodes: 6, slides: 5, uses: 6 },
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
export const KiaMultiDealerNode = (props: any) => {
|
|
47
|
+
const [tab, setTab] = useState<'overview' | 'benchmark' | 'templates'>('overview');
|
|
48
|
+
const [region, setRegion] = useState('Nacional');
|
|
49
|
+
const [dealers, setDealers] = useState(DEALERS.map(d => ({ ...d })));
|
|
50
|
+
|
|
51
|
+
const filtered = region === 'Nacional' ? dealers : dealers.filter(d => d.region === region);
|
|
52
|
+
const totalSales = filtered.reduce((s, d) => s + d.sales, 0);
|
|
53
|
+
const avgNPS = (filtered.reduce((s, d) => s + d.nps, 0) / filtered.length).toFixed(1);
|
|
54
|
+
const avgScore = Math.round(filtered.reduce((s, d) => s + d.score, 0) / filtered.length);
|
|
55
|
+
|
|
56
|
+
// Subtle jitter
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
const interval = setInterval(() => {
|
|
59
|
+
setDealers(prev => prev.map(d => ({
|
|
60
|
+
...d,
|
|
61
|
+
sales: d.sales + Math.floor(Math.random() * 3 - 1),
|
|
62
|
+
score: Math.min(99, Math.max(60, d.score + Math.floor(Math.random() * 3 - 1))),
|
|
63
|
+
nps: Math.min(99, Math.max(70, parseFloat((d.nps + (Math.random() - 0.5)).toFixed(1)))),
|
|
64
|
+
})));
|
|
65
|
+
}, 7000);
|
|
66
|
+
return () => clearInterval(interval);
|
|
67
|
+
}, []);
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<BaseNode {...props} title="Kia Multi-Dealer" width={520} height={620}>
|
|
71
|
+
<div className="flex flex-col h-full bg-[#060a12] text-white overflow-hidden">
|
|
72
|
+
|
|
73
|
+
{/* Header */}
|
|
74
|
+
<div className="flex items-center gap-3 p-3 bg-[#0c1222] border-b border-slate-800">
|
|
75
|
+
<div className="w-9 h-9 rounded-full bg-red-600/20 flex items-center justify-center border border-red-500/30">
|
|
76
|
+
<Building2 size={16} className="text-red-400" />
|
|
77
|
+
</div>
|
|
78
|
+
<div className="flex-1">
|
|
79
|
+
<div className="text-xs font-bold tracking-wide flex items-center gap-2">
|
|
80
|
+
RED METROKIA
|
|
81
|
+
<span className="text-[8px] px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded font-normal">{DEALERS.length} SEDES</span>
|
|
82
|
+
</div>
|
|
83
|
+
<div className="text-[10px] text-slate-400">Multi-Concesionario · Benchmark · {totalSales} ventas/mes</div>
|
|
84
|
+
</div>
|
|
85
|
+
<select value={region} onChange={e => setRegion(e.target.value)}
|
|
86
|
+
className="bg-slate-800 border border-slate-700 rounded-lg px-2 py-1 text-[10px] text-slate-300 focus:outline-none">
|
|
87
|
+
{REGIONS.map(r => <option key={r} value={r}>{r}</option>)}
|
|
88
|
+
</select>
|
|
89
|
+
</div>
|
|
90
|
+
|
|
91
|
+
{/* Tabs */}
|
|
92
|
+
<div className="flex gap-1 p-2 bg-[#0a0f1a] border-b border-slate-800">
|
|
93
|
+
{([
|
|
94
|
+
{ key: 'overview' as const, icon: Map, label: 'Regional' },
|
|
95
|
+
{ key: 'benchmark' as const, icon: BarChart3, label: 'Benchmark' },
|
|
96
|
+
{ key: 'templates' as const, icon: Layers, label: 'Templates' },
|
|
97
|
+
]).map(t => (
|
|
98
|
+
<button key={t.key} onClick={() => setTab(t.key)}
|
|
99
|
+
className={`flex-1 flex items-center justify-center gap-1 py-1.5 rounded text-[9px] font-bold transition-all ${tab === t.key ? 'bg-red-600/20 text-red-400 border border-red-500/30' : 'text-slate-500'
|
|
100
|
+
}`}>
|
|
101
|
+
<t.icon size={10} /> {t.label}
|
|
102
|
+
</button>
|
|
103
|
+
))}
|
|
104
|
+
</div>
|
|
105
|
+
|
|
106
|
+
{/* Stats Bar */}
|
|
107
|
+
<div className="flex gap-1 px-3 py-2 border-b border-slate-800">
|
|
108
|
+
{[
|
|
109
|
+
{ label: 'Ventas/Mes', val: totalSales.toString(), color: 'text-blue-400' },
|
|
110
|
+
{ label: 'NPS Prom', val: `${avgNPS}%`, color: 'text-green-400' },
|
|
111
|
+
{ label: 'Score Prom', val: avgScore.toString(), color: 'text-purple-400' },
|
|
112
|
+
{ label: 'Sedes', val: filtered.length.toString(), color: 'text-slate-400' },
|
|
113
|
+
].map(s => (
|
|
114
|
+
<div key={s.label} className="flex-1 text-center bg-slate-900/50 rounded p-1.5 border border-slate-800/50">
|
|
115
|
+
<div className={`text-sm font-bold ${s.color}`}>{s.val}</div>
|
|
116
|
+
<div className="text-[8px] text-slate-500">{s.label}</div>
|
|
117
|
+
</div>
|
|
118
|
+
))}
|
|
119
|
+
</div>
|
|
120
|
+
|
|
121
|
+
{/* Content */}
|
|
122
|
+
<div className="flex-1 overflow-y-auto p-3 space-y-2">
|
|
123
|
+
|
|
124
|
+
{/* Overview — Regional Cards */}
|
|
125
|
+
{tab === 'overview' && filtered.map((d, i) => (
|
|
126
|
+
<div key={d.id} className="bg-slate-900/50 rounded-lg p-3 border border-slate-800"
|
|
127
|
+
style={{ borderLeftWidth: '3px', borderLeftColor: d.color }}>
|
|
128
|
+
<div className="flex items-center justify-between mb-2">
|
|
129
|
+
<div className="flex items-center gap-2">
|
|
130
|
+
{i === 0 && <Crown size={12} className="text-yellow-400" />}
|
|
131
|
+
<div>
|
|
132
|
+
<div className="text-[11px] font-bold">{d.name}</div>
|
|
133
|
+
<div className="text-[9px] text-slate-500">{d.city} · {d.region}</div>
|
|
134
|
+
</div>
|
|
135
|
+
</div>
|
|
136
|
+
<div className="flex items-center gap-2">
|
|
137
|
+
<div className={`px-2 py-0.5 rounded text-[10px] font-black ${d.ranking === 'S' ? 'bg-green-500/20 text-green-400' :
|
|
138
|
+
d.ranking === 'A' ? 'bg-blue-500/20 text-blue-400' :
|
|
139
|
+
'bg-yellow-500/20 text-yellow-400'
|
|
140
|
+
}`}>{d.ranking}</div>
|
|
141
|
+
<div className="text-right">
|
|
142
|
+
<div className="text-sm font-bold">{d.score}</div>
|
|
143
|
+
<div className={`text-[8px] flex items-center gap-0.5 ${d.score > d.prevScore ? 'text-green-400' : 'text-red-400'}`}>
|
|
144
|
+
{d.score > d.prevScore ? <ChevronUp size={8} /> : <ChevronDown size={8} />}
|
|
145
|
+
{Math.abs(d.score - d.prevScore)}
|
|
146
|
+
</div>
|
|
147
|
+
</div>
|
|
148
|
+
</div>
|
|
149
|
+
</div>
|
|
150
|
+
<div className="flex gap-3 text-[9px]">
|
|
151
|
+
<span className="text-slate-400">Ventas: <span className="font-bold text-blue-400">{d.sales}</span></span>
|
|
152
|
+
<span className="text-slate-400">Posventa: <span className="font-bold text-green-400">{d.posventa}</span></span>
|
|
153
|
+
<span className="text-slate-400">NPS: <span className="font-bold text-purple-400">{d.nps}%</span></span>
|
|
154
|
+
<span className="text-slate-400">MS: <span className="font-bold text-yellow-400">{d.ms}%</span></span>
|
|
155
|
+
</div>
|
|
156
|
+
</div>
|
|
157
|
+
))}
|
|
158
|
+
|
|
159
|
+
{/* Benchmark — Comparative Bars */}
|
|
160
|
+
{tab === 'benchmark' && (
|
|
161
|
+
<>
|
|
162
|
+
<div className="text-[9px] text-slate-500 font-bold uppercase mb-1">Benchmark por KPI</div>
|
|
163
|
+
{['score', 'sales', 'nps', 'ms'].map(kpi => (
|
|
164
|
+
<div key={kpi} className="bg-slate-900/50 rounded-lg p-2.5 border border-slate-800">
|
|
165
|
+
<div className="text-[9px] text-slate-400 font-bold uppercase mb-1.5">
|
|
166
|
+
{kpi === 'score' ? '⭐ Partner Score' : kpi === 'sales' ? '📊 Ventas/Mes' : kpi === 'nps' ? '💚 NPS' : '📈 Market Share'}
|
|
167
|
+
</div>
|
|
168
|
+
{filtered.sort((a, b) => {
|
|
169
|
+
const val = (d: Dealer) => kpi === 'score' ? d.score : kpi === 'sales' ? d.sales : kpi === 'nps' ? d.nps : d.ms;
|
|
170
|
+
return val(b) - val(a);
|
|
171
|
+
}).map((d, i) => {
|
|
172
|
+
const val = kpi === 'score' ? d.score : kpi === 'sales' ? d.sales : kpi === 'nps' ? d.nps : d.ms;
|
|
173
|
+
const max = kpi === 'score' ? 100 : kpi === 'sales' ? 100 : kpi === 'nps' ? 100 : 20;
|
|
174
|
+
return (
|
|
175
|
+
<div key={d.id} className="flex items-center gap-2 mb-1">
|
|
176
|
+
<span className="text-[8px] text-slate-500 w-3 text-right">{i + 1}</span>
|
|
177
|
+
<span className="text-[9px] font-semibold w-20 truncate" style={{ color: d.color }}>{d.name.split(' ')[0]}</span>
|
|
178
|
+
<div className="flex-1 h-1.5 bg-slate-800 rounded-full">
|
|
179
|
+
<div className="h-full rounded-full transition-all duration-700"
|
|
180
|
+
style={{ width: `${(val / max) * 100}%`, background: d.color }} />
|
|
181
|
+
</div>
|
|
182
|
+
<span className="text-[9px] font-bold text-white w-8 text-right">
|
|
183
|
+
{kpi === 'nps' || kpi === 'ms' ? `${val}%` : val}
|
|
184
|
+
</span>
|
|
185
|
+
</div>
|
|
186
|
+
);
|
|
187
|
+
})}
|
|
188
|
+
</div>
|
|
189
|
+
))}
|
|
190
|
+
</>
|
|
191
|
+
)}
|
|
192
|
+
|
|
193
|
+
{/* Templates */}
|
|
194
|
+
{tab === 'templates' && (
|
|
195
|
+
<>
|
|
196
|
+
<div className="text-[9px] text-slate-500 font-bold uppercase mb-1 flex items-center gap-1">
|
|
197
|
+
<Layers size={10} /> Templates Exportables
|
|
198
|
+
</div>
|
|
199
|
+
{TEMPLATES.map(t => (
|
|
200
|
+
<div key={t.name} className="bg-slate-900/50 rounded-lg p-3 border border-slate-800 flex items-center justify-between">
|
|
201
|
+
<div>
|
|
202
|
+
<div className="text-[11px] font-bold text-white">{t.name}</div>
|
|
203
|
+
<div className="text-[9px] text-slate-500">{t.nodes} nodos · {t.slides} slides · Usado {t.uses}×</div>
|
|
204
|
+
</div>
|
|
205
|
+
<button className="px-2.5 py-1 bg-red-600/20 border border-red-500/30 rounded-lg text-[9px] font-bold text-red-400 hover:bg-red-600/30 transition-all">
|
|
206
|
+
Exportar
|
|
207
|
+
</button>
|
|
208
|
+
</div>
|
|
209
|
+
))}
|
|
210
|
+
<div className="bg-blue-500/5 rounded-lg p-3 border border-blue-500/20 mt-2">
|
|
211
|
+
<div className="text-[10px] font-bold text-blue-400 mb-1">🔄 Sincronización</div>
|
|
212
|
+
<div className="text-[9px] text-slate-400">
|
|
213
|
+
Templates compartidos automáticamente con {DEALERS.length} sedes.
|
|
214
|
+
Cada sede puede personalizar datos locales manteniendo la estructura.
|
|
215
|
+
</div>
|
|
216
|
+
</div>
|
|
217
|
+
</>
|
|
218
|
+
)}
|
|
219
|
+
</div>
|
|
220
|
+
</div>
|
|
221
|
+
</BaseNode>
|
|
222
|
+
);
|
|
223
|
+
};
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import { BaseNode } from '@decido/macia-core';
|
|
3
|
+
import {
|
|
4
|
+
MessageCircle, Star, ThumbsUp, ThumbsDown, TrendingUp,
|
|
5
|
+
BarChart3, Heart, AlertCircle, Smile, Frown, Meh
|
|
6
|
+
} from 'lucide-react';
|
|
7
|
+
|
|
8
|
+
/* ═══════════════════════════════════════════════════════════════
|
|
9
|
+
KIA NPS & VOICE NODE — Voice of Customer · Grecco Motors
|
|
10
|
+
NPS tracking, sentiment analysis, survey automation, verbatims
|
|
11
|
+
═══════════════════════════════════════════════════════════════ */
|
|
12
|
+
|
|
13
|
+
const NPS_HISTORY = [
|
|
14
|
+
{ month: 'Sep', score: 82, responses: 156 },
|
|
15
|
+
{ month: 'Oct', score: 85, responses: 178 },
|
|
16
|
+
{ month: 'Nov', score: 88, responses: 192 },
|
|
17
|
+
{ month: 'Dic', score: 91, responses: 201 },
|
|
18
|
+
{ month: 'Ene', score: 93, responses: 215 },
|
|
19
|
+
{ month: 'Feb', score: 95, responses: 187 },
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
const VERBATIMS = [
|
|
23
|
+
{ name: 'María Gómez', model: 'EV6', rating: 5, text: 'Excelente atención de Johan. El EV6 supera expectativas. ¡100% recomendado!', sentiment: 'positive' as const, date: 'Feb 15' },
|
|
24
|
+
{ name: 'Carlos Ruiz', model: 'Sportage', rating: 4, text: 'Buen servicio posventa, pero el tiempo de espera fue un poco largo.', sentiment: 'neutral' as const, date: 'Feb 14' },
|
|
25
|
+
{ name: 'Laura Mejía', model: 'Seltos', rating: 5, text: 'Lucky Drive fue increíble. Gané accesorios gratis. Gran experiencia!', sentiment: 'positive' as const, date: 'Feb 13' },
|
|
26
|
+
{ name: 'Pedro Martínez', model: 'K3', rating: 2, text: 'Mi reclamación de garantía lleva 3 semanas sin resolver. Muy decepcionado.', sentiment: 'negative' as const, date: 'Feb 12' },
|
|
27
|
+
{ name: 'Ana Restrepo', model: 'Sorento', rating: 5, text: 'El cargador V2G en Grecco HQ es el mejor de la ciudad. Servicio AAA.', sentiment: 'positive' as const, date: 'Feb 11' },
|
|
28
|
+
{ name: 'Diego Arias', model: 'Picanto', rating: 3, text: 'El mantenimiento estuvo OK. Faltó comunicación sobre el tiempo estimado.', sentiment: 'neutral' as const, date: 'Feb 10' },
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
const CATEGORIES = [
|
|
32
|
+
{ label: 'Atención Ventas', score: 96, count: 89, trend: 3 },
|
|
33
|
+
{ label: 'Posventa', score: 88, count: 124, trend: -1 },
|
|
34
|
+
{ label: 'Experiencia Showroom', score: 94, count: 67, trend: 5 },
|
|
35
|
+
{ label: 'Financiación', score: 91, count: 45, trend: 2 },
|
|
36
|
+
{ label: 'Entrega Vehículo', score: 85, count: 38, trend: -2 },
|
|
37
|
+
{ label: 'Accesorios / Store', score: 92, count: 56, trend: 4 },
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
export const KiaNPSVoiceNode = (props: any) => {
|
|
41
|
+
const [tab, setTab] = useState<'overview' | 'verbatims' | 'categories'>('overview');
|
|
42
|
+
const [history, setHistory] = useState(NPS_HISTORY.map(h => ({ ...h })));
|
|
43
|
+
|
|
44
|
+
const currentNPS = history[history.length - 1].score;
|
|
45
|
+
const prevNPS = history[history.length - 2].score;
|
|
46
|
+
const totalResponses = history.reduce((s, h) => s + h.responses, 0);
|
|
47
|
+
const promoters = Math.round(totalResponses * 0.72);
|
|
48
|
+
const passives = Math.round(totalResponses * 0.18);
|
|
49
|
+
const detractors = Math.round(totalResponses * 0.10);
|
|
50
|
+
|
|
51
|
+
// NPS bar chart max
|
|
52
|
+
const maxScore = 100;
|
|
53
|
+
const barWidth = 100 / history.length;
|
|
54
|
+
|
|
55
|
+
// Jitter
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
const interval = setInterval(() => {
|
|
58
|
+
setHistory(prev => prev.map((h, i) =>
|
|
59
|
+
i === prev.length - 1
|
|
60
|
+
? { ...h, score: Math.min(99, Math.max(80, h.score + Math.floor(Math.random() * 3 - 1))), responses: h.responses + Math.floor(Math.random() * 3) }
|
|
61
|
+
: h
|
|
62
|
+
));
|
|
63
|
+
}, 6000);
|
|
64
|
+
return () => clearInterval(interval);
|
|
65
|
+
}, []);
|
|
66
|
+
|
|
67
|
+
const sentimentIcon = (s: string) =>
|
|
68
|
+
s === 'positive' ? <Smile size={12} className="text-green-400" /> :
|
|
69
|
+
s === 'negative' ? <Frown size={12} className="text-red-400" /> :
|
|
70
|
+
<Meh size={12} className="text-yellow-400" />;
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<BaseNode {...props} title="Kia NPS & Voice" width={480} height={620}>
|
|
74
|
+
<div className="flex flex-col h-full bg-slate-950 text-white overflow-hidden">
|
|
75
|
+
|
|
76
|
+
{/* Header */}
|
|
77
|
+
<div className="flex items-center gap-3 p-3 bg-slate-900 border-b border-slate-800">
|
|
78
|
+
<div className="w-9 h-9 rounded-full bg-pink-600/20 flex items-center justify-center border border-pink-500/30">
|
|
79
|
+
<Heart size={16} className="text-pink-400" />
|
|
80
|
+
</div>
|
|
81
|
+
<div className="flex-1">
|
|
82
|
+
<div className="text-xs font-bold tracking-wide flex items-center gap-2">
|
|
83
|
+
NPS & VOZ DEL CLIENTE
|
|
84
|
+
<span className="text-[8px] px-1.5 py-0.5 bg-green-500/20 text-green-400 rounded">{currentNPS} NPS</span>
|
|
85
|
+
</div>
|
|
86
|
+
<div className="text-[10px] text-slate-400">Grecco Motors · {totalResponses} respuestas · Sentiment AI</div>
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
{/* Tabs */}
|
|
91
|
+
<div className="flex gap-1 p-2 bg-slate-900/50 border-b border-slate-800">
|
|
92
|
+
{([
|
|
93
|
+
{ key: 'overview' as const, label: '📊 NPS' },
|
|
94
|
+
{ key: 'verbatims' as const, label: '💬 Verbatims' },
|
|
95
|
+
{ key: 'categories' as const, label: '📋 Categorías' },
|
|
96
|
+
]).map(t => (
|
|
97
|
+
<button key={t.key} onClick={() => setTab(t.key)}
|
|
98
|
+
className={`flex-1 py-1.5 rounded text-[9px] font-bold transition-all ${tab === t.key ? 'bg-pink-600/20 text-pink-400 border border-pink-500/30' : 'text-slate-500'
|
|
99
|
+
}`}>
|
|
100
|
+
{t.label}
|
|
101
|
+
</button>
|
|
102
|
+
))}
|
|
103
|
+
</div>
|
|
104
|
+
|
|
105
|
+
{/* Content */}
|
|
106
|
+
<div className="flex-1 overflow-y-auto p-3 space-y-3">
|
|
107
|
+
|
|
108
|
+
{tab === 'overview' && (
|
|
109
|
+
<>
|
|
110
|
+
{/* NPS Score */}
|
|
111
|
+
<div className="flex items-center gap-4 bg-slate-900/50 rounded-lg p-3 border border-slate-800">
|
|
112
|
+
<div className="text-center">
|
|
113
|
+
<div className="text-3xl font-black text-green-400">{currentNPS}</div>
|
|
114
|
+
<div className="text-[9px] text-slate-500">NPS Score</div>
|
|
115
|
+
<div className={`text-[9px] font-bold ${currentNPS >= prevNPS ? 'text-green-400' : 'text-red-400'}`}>
|
|
116
|
+
{currentNPS >= prevNPS ? '↑' : '↓'} {Math.abs(currentNPS - prevNPS)} pts
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
119
|
+
<div className="flex-1 space-y-1.5">
|
|
120
|
+
<div className="flex items-center gap-2">
|
|
121
|
+
<ThumbsUp size={10} className="text-green-400" />
|
|
122
|
+
<span className="text-[9px] text-slate-400 w-20">Promotores</span>
|
|
123
|
+
<div className="flex-1 h-2 bg-slate-800 rounded-full">
|
|
124
|
+
<div className="h-full rounded-full bg-green-500" style={{ width: '72%' }} />
|
|
125
|
+
</div>
|
|
126
|
+
<span className="text-[9px] font-bold text-green-400">{promoters}</span>
|
|
127
|
+
</div>
|
|
128
|
+
<div className="flex items-center gap-2">
|
|
129
|
+
<Meh size={10} className="text-yellow-400" />
|
|
130
|
+
<span className="text-[9px] text-slate-400 w-20">Pasivos</span>
|
|
131
|
+
<div className="flex-1 h-2 bg-slate-800 rounded-full">
|
|
132
|
+
<div className="h-full rounded-full bg-yellow-500" style={{ width: '18%' }} />
|
|
133
|
+
</div>
|
|
134
|
+
<span className="text-[9px] font-bold text-yellow-400">{passives}</span>
|
|
135
|
+
</div>
|
|
136
|
+
<div className="flex items-center gap-2">
|
|
137
|
+
<ThumbsDown size={10} className="text-red-400" />
|
|
138
|
+
<span className="text-[9px] text-slate-400 w-20">Detractores</span>
|
|
139
|
+
<div className="flex-1 h-2 bg-slate-800 rounded-full">
|
|
140
|
+
<div className="h-full rounded-full bg-red-500" style={{ width: '10%' }} />
|
|
141
|
+
</div>
|
|
142
|
+
<span className="text-[9px] font-bold text-red-400">{detractors}</span>
|
|
143
|
+
</div>
|
|
144
|
+
</div>
|
|
145
|
+
</div>
|
|
146
|
+
|
|
147
|
+
{/* NPS Trend Chart */}
|
|
148
|
+
<div className="bg-slate-900/50 rounded-lg p-3 border border-slate-800">
|
|
149
|
+
<div className="text-[9px] text-slate-500 font-bold uppercase mb-2">Tendencia NPS · 6 meses</div>
|
|
150
|
+
<svg viewBox="0 0 240 80" className="w-full">
|
|
151
|
+
{history.map((h, i) => {
|
|
152
|
+
const x = 20 + i * 38;
|
|
153
|
+
const barH = (h.score / maxScore) * 55;
|
|
154
|
+
return (
|
|
155
|
+
<React.Fragment key={h.month}>
|
|
156
|
+
<rect x={x} y={65 - barH} width={28} height={barH} rx={3}
|
|
157
|
+
fill={h.score >= 90 ? '#22c55e' : h.score >= 80 ? '#3b82f6' : '#f59e0b'}
|
|
158
|
+
opacity={0.7} />
|
|
159
|
+
<text x={x + 14} y={60 - barH} textAnchor="middle" fontSize="7" fontWeight="700"
|
|
160
|
+
fill="white">{h.score}</text>
|
|
161
|
+
<text x={x + 14} y={75} textAnchor="middle" fontSize="6" fill="#64748b">{h.month}</text>
|
|
162
|
+
</React.Fragment>
|
|
163
|
+
);
|
|
164
|
+
})}
|
|
165
|
+
</svg>
|
|
166
|
+
</div>
|
|
167
|
+
</>
|
|
168
|
+
)}
|
|
169
|
+
|
|
170
|
+
{tab === 'verbatims' && VERBATIMS.map((v, i) => (
|
|
171
|
+
<div key={i} className="bg-slate-900/50 rounded-lg p-2.5 border border-slate-800"
|
|
172
|
+
style={{ borderLeftWidth: '2px', borderLeftColor: v.sentiment === 'positive' ? '#22c55e' : v.sentiment === 'negative' ? '#ef4444' : '#f59e0b' }}>
|
|
173
|
+
<div className="flex items-center justify-between mb-1">
|
|
174
|
+
<div className="flex items-center gap-1.5">
|
|
175
|
+
{sentimentIcon(v.sentiment)}
|
|
176
|
+
<span className="text-[10px] font-bold">{v.name}</span>
|
|
177
|
+
<span className="text-[8px] text-slate-500">· {v.model}</span>
|
|
178
|
+
</div>
|
|
179
|
+
<div className="flex items-center gap-1">
|
|
180
|
+
{Array.from({ length: 5 }, (_, j) => (
|
|
181
|
+
<Star key={j} size={8} className={j < v.rating ? 'text-yellow-400 fill-yellow-400' : 'text-slate-700'} />
|
|
182
|
+
))}
|
|
183
|
+
</div>
|
|
184
|
+
</div>
|
|
185
|
+
<div className="text-[9px] text-slate-300 italic leading-relaxed">"{v.text}"</div>
|
|
186
|
+
<div className="text-[8px] text-slate-600 mt-1">{v.date}</div>
|
|
187
|
+
</div>
|
|
188
|
+
))}
|
|
189
|
+
|
|
190
|
+
{tab === 'categories' && CATEGORIES.map(c => (
|
|
191
|
+
<div key={c.label} className="bg-slate-900/50 rounded-lg p-2.5 border border-slate-800">
|
|
192
|
+
<div className="flex items-center justify-between mb-1">
|
|
193
|
+
<span className="text-[10px] font-bold">{c.label}</span>
|
|
194
|
+
<div className="flex items-center gap-2">
|
|
195
|
+
<span className={`text-[8px] ${c.trend > 0 ? 'text-green-400' : 'text-red-400'}`}>
|
|
196
|
+
{c.trend > 0 ? '↑' : '↓'}{Math.abs(c.trend)}%
|
|
197
|
+
</span>
|
|
198
|
+
<span className="text-sm font-bold text-green-400">{c.score}</span>
|
|
199
|
+
</div>
|
|
200
|
+
</div>
|
|
201
|
+
<div className="flex items-center gap-2">
|
|
202
|
+
<div className="flex-1 h-1.5 bg-slate-800 rounded-full">
|
|
203
|
+
<div className="h-full rounded-full bg-linear-to-r from-pink-500 to-green-500 transition-all duration-700"
|
|
204
|
+
style={{ width: `${c.score}%` }} />
|
|
205
|
+
</div>
|
|
206
|
+
<span className="text-[8px] text-slate-500">{c.count} resp</span>
|
|
207
|
+
</div>
|
|
208
|
+
</div>
|
|
209
|
+
))}
|
|
210
|
+
</div>
|
|
211
|
+
</div>
|
|
212
|
+
</BaseNode>
|
|
213
|
+
);
|
|
214
|
+
};
|