Skip to content

FinceptTerminal is a modern finance application offering advanced market analytics, investment research, and economic data tools, designed for interactive exploration and data-driven decision-making in a user-friendly environment.

profile update

tilakpatel22c9e6601e44cd
diff --git a/fincept-terminal-desktop/src/components/command-bar/CommandBar.tsx b/fincept-terminal-desktop/src/components/command-bar/CommandBar.tsx
new file mode 100644
index 000000000..ac0eaa15a
--- /dev/null
+++ b/fincept-terminal-desktop/src/components/command-bar/CommandBar.tsx
@@ -0,0 +1,248 @@
+// File: src/components/command-bar/CommandBar.tsx
+// Bloomberg-style command bar with autocomplete
+
+import React, { useState, useRef, useEffect } from 'react';
+import { Terminal, ChevronRight } from 'lucide-react';
+import { searchCommands, getCommand, Command } from './commandRegistry';
+
+interface CommandBarProps {
+ onExecuteCommand: (tabId: string) => void;
+}
+
+export const CommandBar: React.FC<CommandBarProps> = ({ onExecuteCommand }) => {
+ const [input, setInput] = useState('');
+ const [suggestions, setSuggestions] = useState<Command[]>([]);
+ const [selectedIndex, setSelectedIndex] = useState(0);
+ const [showSuggestions, setShowSuggestions] = useState(false);
+ const inputRef = useRef<HTMLInputElement>(null);
+ const suggestionsRef = useRef<HTMLDivElement>(null);
+
+ // Update suggestions when input changes
+ useEffect(() => {
+ if (input.trim().length === 0) {
+ setSuggestions([]);
+ setShowSuggestions(false);
+ setSelectedIndex(0);
+ return;
+ }
+
+ const results = searchCommands(input);
+ setSuggestions(results.slice(0, 10)); // Show top 10 results
+ setShowSuggestions(results.length > 0);
+ setSelectedIndex(0);
+ }, [input]);
+
+ // Handle keyboard navigation
+ const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
+ if (!showSuggestions || suggestions.length === 0) {
+ if (e.key === 'Enter') {
+ executeCommand(input);
+ }
+ return;
+ }
+
+ switch (e.key) {
+ case 'ArrowDown':
+ e.preventDefault();
+ setSelectedIndex(prev => (prev + 1) % suggestions.length);
+ break;
+ case 'ArrowUp':
+ e.preventDefault();
+ setSelectedIndex(prev => (prev - 1 + suggestions.length) % suggestions.length);
+ break;
+ case 'Tab':
+ e.preventDefault();
+ if (suggestions[selectedIndex]) {
+ setInput(suggestions[selectedIndex].aliases[0]);
+ setShowSuggestions(false);
+ }
+ break;
+ case 'Enter':
+ e.preventDefault();
+ if (suggestions[selectedIndex]) {
+ executeCommand(suggestions[selectedIndex].aliases[0]);
+ } else {
+ executeCommand(input);
+ }
+ break;
+ case 'Escape':
+ setShowSuggestions(false);
+ setInput('');
+ inputRef.current?.blur();
+ break;
+ }
+ };
+
+ // Execute command
+ const executeCommand = (commandInput: string) => {
+ const cmd = getCommand(commandInput.trim());
+ if (cmd && typeof cmd.action === 'string') {
+ onExecuteCommand(cmd.action);
+ setInput('');
+ setShowSuggestions(false);
+ inputRef.current?.blur();
+ } else if (cmd && typeof cmd.action === 'function') {
+ cmd.action();
+ setInput('');
+ setShowSuggestions(false);
+ inputRef.current?.blur();
+ }
+ };
+
+ // Click outside to close suggestions
+ useEffect(() => {
+ const handleClickOutside = (event: MouseEvent) => {
+ if (
+ suggestionsRef.current &&
+ !suggestionsRef.current.contains(event.target as Node) &&
+ inputRef.current &&
+ !inputRef.current.contains(event.target as Node)
+ ) {
+ setShowSuggestions(false);
+ }
+ };
+
+ document.addEventListener('mousedown', handleClickOutside);
+ return () => document.removeEventListener('mousedown', handleClickOutside);
+ }, []);
+
+ return (
+ <div style={{ position: 'relative', flex: 1, maxWidth: '400px' }}>
+ <div style={{
+ display: 'flex',
+ alignItems: 'center',
+ backgroundColor: '#1a1a1a',
+ border: '1px solid #404040',
+ borderRadius: '2px',
+ padding: '0 8px',
+ height: '24px'
+ }}>
+ <Terminal size={12} color="#ea580c" style={{ marginRight: '6px', flexShrink: 0 }} />
+ <input
+ ref={inputRef}
+ type="text"
+ value={input}
+ onChange={(e) => setInput(e.target.value)}
+ onKeyDown={handleKeyDown}
+ onFocus={() => {
+ if (input.trim().length > 0) {
+ setShowSuggestions(true);
+ }
+ }}
+ placeholder="Enter Command..."
+ style={{
+ flex: 1,
+ backgroundColor: 'transparent',
+ border: 'none',
+ outline: 'none',
+ color: '#ffffff',
+ fontSize: '11px',
+ fontFamily: 'Consolas, "Courier New", monospace',
+ padding: '0'
+ }}
+ />
+ </div>
+
+ {/* Autocomplete Suggestions */}
+ {showSuggestions && suggestions.length > 0 && (
+ <div
+ ref={suggestionsRef}
+ style={{
+ position: 'absolute',
+ top: '100%',
+ left: 0,
+ right: 0,
+ marginTop: '2px',
+ backgroundColor: '#1a1a1a',
+ border: '1px solid #404040',
+ borderRadius: '2px',
+ maxHeight: '300px',
+ overflowY: 'auto',
+ zIndex: 9999,
+ boxShadow: '0 4px 12px rgba(0,0,0,0.5)'
+ }}
+ >
+ {suggestions.map((cmd, index) => (
+ <div
+ key={cmd.id}
+ onClick={() => {
+ setInput(cmd.aliases[0]);
+ executeCommand(cmd.aliases[0]);
+ }}
+ style={{
+ padding: '8px 12px',
+ cursor: 'pointer',
+ backgroundColor: index === selectedIndex ? '#2a2a2a' : 'transparent',
+ borderLeft: index === selectedIndex ? '3px solid #ea580c' : '3px solid transparent',
+ display: 'flex',
+ alignItems: 'flex-start',
+ gap: '12px',
+ transition: 'all 0.1s'
+ }}
+ onMouseEnter={() => setSelectedIndex(index)}
+ >
+ <div style={{ flex: 1 }}>
+ <div style={{
+ display: 'flex',
+ alignItems: 'center',
+ gap: '8px',
+ marginBottom: '2px'
+ }}>
+ <span style={{
+ color: '#ffffff',
+ fontSize: '11px',
+ fontFamily: 'Consolas, "Courier New", monospace',
+ fontWeight: 'bold'
+ }}>
+ {cmd.aliases[0].toUpperCase()}
+ </span>
+ <ChevronRight size={10} color="#666" />
+ <span style={{
+ color: '#a3a3a3',
+ fontSize: '11px'
+ }}>
+ {cmd.name}
+ </span>
+ {cmd.shortcut && (
+ <span style={{
+ marginLeft: 'auto',
+ color: '#666',
+ fontSize: '10px',
+ fontFamily: 'Consolas, "Courier New", monospace'
+ }}>
+ {cmd.shortcut}
+ </span>
+ )}
+ </div>
+ <div style={{
+ color: '#737373',
+ fontSize: '10px',
+ marginLeft: '0'
+ }}>
+ {cmd.description}
+ </div>
+ </div>
+ </div>
+ ))}
+ </div>
+ )}
+
+ {/* Help Text */}
+ {!showSuggestions && input.trim().length === 0 && (
+ <div style={{
+ position: 'absolute',
+ top: '100%',
+ left: 0,
+ marginTop: '4px',
+ color: '#666',
+ fontSize: '9px',
+ fontFamily: 'Consolas, "Courier New", monospace'
+ }}>
+ Type a command (e.g., DASH, MKTS, PORT) or use F1-F12 shortcuts
+ </div>
+ )}
+ </div>
+ );
+};
+
+export default CommandBar;
diff --git a/fincept-terminal-desktop/src/components/command-bar/commandRegistry.ts b/fincept-terminal-desktop/src/components/command-bar/commandRegistry.ts
new file mode 100644
index 000000000..3d0b82f95
--- /dev/null
+++ b/fincept-terminal-desktop/src/components/command-bar/commandRegistry.ts
@@ -0,0 +1,421 @@
+// File: src/components/command-bar/commandRegistry.ts
+// Command registry for Fincept Terminal - Bloomberg-style command system
+
+export interface Command {
+ id: string;
+ name: string;
+ description: string;
+ aliases: string[];
+ category: 'navigation' | 'action' | 'data' | 'tool' | 'system';
+ action: string | (() => void);
+ shortcut?: string;
+ keywords?: string[];
+}
+
+export const COMMANDS: Command[] = [
+ // Navigation Commands - Primary Tabs (F-keys)
+ {
+ id: 'dash',
+ name: 'Dashboard',
+ description: 'Navigate to Dashboard overview',
+ aliases: ['dash', 'home', 'main', 'overview'],
+ category: 'navigation',
+ action: 'dashboard',
+ shortcut: 'F1',
+ keywords: ['dashboard', 'home', 'main', 'overview', 'summary']
+ },
+ {
+ id: 'mkts',
+ name: 'Markets',
+ description: 'View live market data',
+ aliases: ['mkts', 'markets', 'market', 'live'],
+ category: 'navigation',
+ action: 'markets',
+ shortcut: 'F2',
+ keywords: ['markets', 'stocks', 'quotes', 'prices', 'live', 'real-time']
+ },
+ {
+ id: 'news',
+ name: 'News',
+ description: 'Financial news feed',
+ aliases: ['news', 'headlines', 'feed'],
+ category: 'navigation',
+ action: 'news',
+ shortcut: 'F3',
+ keywords: ['news', 'headlines', 'articles', 'feed', 'financial news']
+ },
+ {
+ id: 'port',
+ name: 'Portfolio',
+ description: 'Portfolio management',
+ aliases: ['port', 'portfolio', 'pf', 'holdings'],
+ category: 'navigation',
+ action: 'portfolio',
+ shortcut: 'F4',
+ keywords: ['portfolio', 'holdings', 'positions', 'assets']
+ },
+ {
+ id: 'bktest',
+ name: 'Backtesting',
+ description: 'Strategy backtesting',
+ aliases: ['bktest', 'backtest', 'bt', 'test'],
+ category: 'navigation',
+ action: 'backtesting',
+ shortcut: 'F5',
+ keywords: ['backtest', 'strategy', 'testing', 'historical']
+ },
+ {
+ id: 'watch',
+ name: 'Watchlist',
+ description: 'Manage watchlists',
+ aliases: ['watch', 'watchlist', 'wl', 'list'],
+ category: 'navigation',
+ action: 'watchlist',
+ shortcut: 'F6',
+ keywords: ['watchlist', 'favorites', 'monitor', 'track']
+ },
+ {
+ id: 'rsrch',
+ name: 'Equity Research',
+ description: 'Equity research tools',
+ aliases: ['rsrch', 'research', 'equity', 'analysis'],
+ category: 'navigation',
+ action: 'research',
+ shortcut: 'F7',
+ keywords: ['research', 'equity', 'analysis', 'fundamental', 'valuation']
+ },
+ {
+ id: 'scrn',
+ name: 'Screener',
+ description: 'Stock screener',
+ aliases: ['scrn', 'screener', 'filter', 'scan'],
+ category: 'navigation',
+ action: 'screener',
+ shortcut: 'F8',
+ keywords: ['screener', 'filter', 'scan', 'search', 'criteria']
+ },
+ {
+ id: 'trade',
+ name: 'Crypto Trading',
+ description: 'Cryptocurrency trading',
+ aliases: ['trade', 'trading', 'crypto', 'kraken'],
+ category: 'navigation',
+ action: 'trading',
+ shortcut: 'F9',
+ keywords: ['trading', 'crypto', 'cryptocurrency', 'kraken', 'exchange']
+ },
+ {
+ id: 'ai',
+ name: 'AI Chat',
+ description: 'AI Assistant chat',
+ aliases: ['ai', 'chat', 'assistant', 'bot'],
+ category: 'navigation',
+ action: 'chat',
+ shortcut: 'F10',
+ keywords: ['ai', 'chat', 'assistant', 'bot', 'help']
+ },
+ {
+ id: 'prof',
+ name: 'Profile',
+ description: 'User profile settings',
+ aliases: ['prof', 'profile', 'account', 'settings'],
+ category: 'navigation',
+ action: 'profile',
+ shortcut: 'F12',
+ keywords: ['profile', 'account', 'user', 'settings', 'preferences']
+ },
+
+ // Additional Navigation Commands
+ {
+ id: 'eqtrade',
+ name: 'Equity Trading',
+ description: 'Stock trading interface',
+ aliases: ['eqtrade', 'stocks', 'equities'],
+ category: 'navigation',
+ action: 'equity-trading',
+ keywords: ['equity', 'stocks', 'trading', 'shares']
+ },
+ {
+ id: 'poly',
+ name: 'Polymarket',
+ description: 'Prediction markets',
+ aliases: ['poly', 'polymarket', 'prediction'],
+ category: 'navigation',
+ action: 'polymarket',
+ keywords: ['polymarket', 'prediction', 'markets', 'betting']
+ },
+ {
+ id: 'deriv',
+ name: 'Derivatives',
+ description: 'Options and derivatives',
+ aliases: ['deriv', 'derivatives', 'options'],
+ category: 'navigation',
+ action: 'derivatives',
+ keywords: ['derivatives', 'options', 'futures', 'pricing']
+ },
+ {
+ id: 'econ',
+ name: 'Economics',
+ description: 'Economic indicators',
+ aliases: ['econ', 'economics', 'indicators'],
+ category: 'navigation',
+ action: 'economics',
+ keywords: ['economics', 'indicators', 'macro', 'economic data']
+ },
+ {
+ id: 'dbn',
+ name: 'DBnomics',
+ description: 'Economic database',
+ aliases: ['dbn', 'dbnomics', 'database'],
+ category: 'navigation',
+ action: 'dbnomics',
+ keywords: ['dbnomics', 'database', 'economic', 'data']
+ },
+ {
+ id: 'geo',
+ name: 'Geopolitics',
+ description: 'Geopolitical analysis',
+ aliases: ['geo', 'geopolitics', 'politics'],
+ category: 'navigation',
+ action: 'geopolitics',
+ keywords: ['geopolitics', 'politics', 'global', 'analysis']
+ },
+ {
+ id: 'marine',
+ name: 'Maritime',
+ description: 'Maritime intelligence',
+ aliases: ['marine', 'maritime', 'shipping'],
+ category: 'navigation',
+ action: 'maritime',
+ keywords: ['maritime', 'shipping', 'vessels', 'ports']
+ },
+ {
+ id: 'polygon',
+ name: 'Polygon.io',
+ description: 'Polygon market data',
+ aliases: ['polygon', 'poly'],
+ category: 'navigation',
+ action: 'polygon',
+ keywords: ['polygon', 'data', 'market', 'api']
+ },
+ {
+ id: 'relmap',
+ name: 'Relationship Map',
+ description: 'Entity relationship mapping',
+ aliases: ['relmap', 'relationships', 'map'],
+ category: 'navigation',
+ action: 'relationship-map',
+ keywords: ['relationship', 'map', 'network', 'connections']
+ },
+ {
+ id: '3dviz',
+ name: '3D Visualization',
+ description: '3D data visualization',
+ aliases: ['3dviz', '3d', 'viz', 'visualization'],
+ category: 'navigation',
+ action: '3d-viz',
+ keywords: ['3d', 'visualization', 'graphics', 'visual']
+ },
+
+ // Tools
+ {
+ id: 'quantlab',
+ name: 'AI Quant Lab',
+ description: 'Quantitative analysis lab',
+ aliases: ['quantlab', 'quant', 'lab'],
+ category: 'tool',
+ action: 'ai-quant-lab',
+ keywords: ['quant', 'quantitative', 'lab', 'analysis']
+ },
+ {
+ id: 'agents',
+ name: 'Agent Config',
+ description: 'Configure AI agents',
+ aliases: ['agents', 'config', 'agent'],
+ category: 'tool',
+ action: 'agents',
+ keywords: ['agents', 'ai', 'configuration', 'setup']
+ },
+ {
+ id: 'mcp',
+ name: 'MCP Servers',
+ description: 'Model Context Protocol',
+ aliases: ['mcp', 'servers', 'protocol'],
+ category: 'tool',
+ action: 'mcp',
+ keywords: ['mcp', 'servers', 'protocol', 'model']
+ },
+ {
+ id: 'excel',
+ name: 'Excel Workbook',
+ description: 'Excel integration',
+ aliases: ['excel', 'spreadsheet', 'xls'],
+ category: 'tool',
+ action: 'excel',
+ keywords: ['excel', 'spreadsheet', 'workbook', 'xls']
+ },
+ {
+ id: 'nodes',
+ name: 'Node Editor',
+ description: 'Visual workflow editor',
+ aliases: ['nodes', 'workflow', 'editor'],
+ category: 'tool',
+ action: 'nodes',
+ keywords: ['nodes', 'workflow', 'visual', 'editor']
+ },
+ {
+ id: 'code',
+ name: 'Code Editor',
+ description: 'Code development',
+ aliases: ['code', 'editor', 'dev'],
+ category: 'tool',
+ action: 'code',
+ keywords: ['code', 'editor', 'development', 'programming']
+ },
+ {
+ id: 'datasrc',
+ name: 'Data Sources',
+ description: 'Manage data sources',
+ aliases: ['datasrc', 'datasources', 'sources'],
+ category: 'data',
+ action: 'datasources',
+ keywords: ['data', 'sources', 'connections', 'api']
+ },
+ {
+ id: 'datamap',
+ name: 'Data Mapping',
+ description: 'Data transformation',
+ aliases: ['datamap', 'mapping', 'transform'],
+ category: 'data',
+ action: 'datamapping',
+ keywords: ['data', 'mapping', 'transformation', 'etl']
+ },
+ {
+ id: 'report',
+ name: 'Report Builder',
+ description: 'Create reports',
+ aliases: ['report', 'builder', 'reports'],
+ category: 'tool',
+ action: 'reportbuilder',
+ keywords: ['report', 'builder', 'document', 'generate']
+ },
+ {
+ id: 'contexts',
+ name: 'Recorded Contexts',
+ description: 'View recorded contexts',
+ aliases: ['contexts', 'recorded', 'history'],
+ category: 'data',
+ action: 'contexts',
+ keywords: ['contexts', 'recorded', 'history', 'sessions']
+ },
+ {
+ id: 'monitor',
+ name: 'Monitoring',
+ description: 'System monitoring',
+ aliases: ['monitor', 'monitoring', 'system'],
+ category: 'system',
+ action: 'monitoring',
+ keywords: ['monitoring', 'system', 'performance', 'status']
+ },
+
+ // Community
+ {
+ id: 'forum',
+ name: 'Forum',
+ description: 'Community forum',
+ aliases: ['forum', 'community', 'discuss'],
+ category: 'navigation',
+ action: 'forum',
+ keywords: ['forum', 'community', 'discussion', 'posts']
+ },
+ {
+ id: 'market',
+ name: 'Marketplace',
+ description: 'Extension marketplace',
+ aliases: ['market', 'marketplace', 'store'],
+ category: 'navigation',
+ action: 'marketplace',
+ keywords: ['marketplace', 'store', 'extensions', 'plugins']
+ },
+ {
+ id: 'docs',
+ name: 'Documentation',
+ description: 'User documentation',
+ aliases: ['docs', 'help', 'manual'],
+ category: 'navigation',
+ action: 'docs',
+ keywords: ['documentation', 'help', 'manual', 'guide']
+ },
+ {
+ id: 'support',
+ name: 'Support',
+ description: 'Support tickets',
+ aliases: ['support', 'ticket', 'help'],
+ category: 'system',
+ action: 'support',
+ keywords: ['support', 'ticket', 'help', 'assistance']
+ },
+ {
+ id: 'settings',
+ name: 'Settings',
+ description: 'Application settings',
+ aliases: ['settings', 'preferences', 'config'],
+ category: 'system',
+ action: 'settings',
+ keywords: ['settings', 'preferences', 'configuration', 'options']
+ }
+];
+
+// Search and filter commands
+export function searchCommands(query: string): Command[] {
+ if (!query || query.trim().length === 0) {
+ return COMMANDS;
+ }
+
+ const lowerQuery = query.toLowerCase().trim();
+
+ return COMMANDS.filter(cmd => {
+ // Check if query matches command name
+ if (cmd.name.toLowerCase().includes(lowerQuery)) return true;
+
+ // Check if query matches any alias
+ if (cmd.aliases.some(alias => alias.toLowerCase().includes(lowerQuery))) return true;
+
+ // Check if query matches description
+ if (cmd.description.toLowerCase().includes(lowerQuery)) return true;
+
+ // Check if query matches any keyword
+ if (cmd.keywords && cmd.keywords.some(kw => kw.toLowerCase().includes(lowerQuery))) return true;
+
+ return false;
+ }).sort((a, b) => {
+ // Prioritize exact alias matches
+ const aExactAlias = a.aliases.some(alias => alias.toLowerCase() === lowerQuery);
+ const bExactAlias = b.aliases.some(alias => alias.toLowerCase() === lowerQuery);
+ if (aExactAlias && !bExactAlias) return -1;
+ if (!aExactAlias && bExactAlias) return 1;
+
+ // Prioritize name matches
+ const aNameMatch = a.name.toLowerCase().includes(lowerQuery);
+ const bNameMatch = b.name.toLowerCase().includes(lowerQuery);
+ if (aNameMatch && !bNameMatch) return -1;
+ if (!aNameMatch && bNameMatch) return 1;
+
+ // Otherwise keep original order
+ return 0;
+ });
+}
+
+// Get command by ID or alias
+export function getCommand(identifier: string): Command | undefined {
+ const lowerIdentifier = identifier.toLowerCase().trim();
+ return COMMANDS.find(cmd =>
+ cmd.id === lowerIdentifier ||
+ cmd.aliases.some(alias => alias.toLowerCase() === lowerIdentifier)
+ );
+}
+
+// Get all commands by category
+export function getCommandsByCategory(category: Command['category']): Command[] {
+ return COMMANDS.filter(cmd => cmd.category === category);
+}
diff --git a/fincept-terminal-desktop/src/components/command-bar/index.ts b/fincept-terminal-desktop/src/components/command-bar/index.ts
new file mode 100644
index 000000000..f54b405b0
--- /dev/null
+++ b/fincept-terminal-desktop/src/components/command-bar/index.ts
@@ -0,0 +1,6 @@
+// File: src/components/command-bar/index.ts
+// Export command bar components
+
+export { CommandBar } from './CommandBar';
+export { searchCommands, getCommand, getCommandsByCategory, COMMANDS } from './commandRegistry';
+export type { Command } from './commandRegistry';
diff --git a/fincept-terminal-desktop/src/components/dashboard/DashboardScreen.tsx b/fincept-terminal-desktop/src/components/dashboard/DashboardScreen.tsx
index dde40d882..12f3ec90a 100644
--- a/fincept-terminal-desktop/src/components/dashboard/DashboardScreen.tsx
+++ b/fincept-terminal-desktop/src/components/dashboard/DashboardScreen.tsx
@@ -12,6 +12,7 @@ import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, D
import { Button } from '@/components/ui/button';
import { Progress } from '@/components/ui/progress';
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert';
+import { CommandBar } from '@/components/command-bar';
// Eagerly loaded tabs (needed immediately)
import ForumTab from '@/components/tabs/ForumTab';
@@ -964,9 +965,8 @@ function FinxeptTerminalContent() {
{/* Left: Branding & Status Info */}
<div style={{ display: 'flex', alignItems: 'center', gap: '10px' }}>
<span style={{ backgroundColor: '#ea580c', color: 'white', padding: '2px 5px', fontSize: '8px', fontWeight: 'bold' }}>FINXEPT PROFESSIONAL</span>
- <span style={{ color: '#a3a3a3', fontSize: '9px' }}>{t('labels.enterCommand')}</span>
<div style={{ width: '1px', height: '14px', backgroundColor: '#525252' }}></div>
- <span style={{ color: '#a3a3a3', fontSize: '9px' }}>{t('labels.search')}</span>
+ <CommandBar onExecuteCommand={setActiveTab} />
<div style={{ width: '1px', height: '14px', backgroundColor: '#525252' }}></div>
<HeaderTimeDisplay />
<div style={{ width: '1px', height: '14px', backgroundColor: '#525252' }}></div>
diff --git a/fincept-terminal-desktop/src/components/tabs/ProfileTab.tsx b/fincept-terminal-desktop/src/components/tabs/ProfileTab.tsx
index 518a318c1..c9887216f 100644
--- a/fincept-terminal-desktop/src/components/tabs/ProfileTab.tsx
+++ b/fincept-terminal-desktop/src/components/tabs/ProfileTab.tsx
@@ -36,6 +36,8 @@ const ProfileTab: React.FC = () => {
const [usageData, setUsageData] = useState<any>(null);
const [paymentHistory, setPaymentHistory] = useState<any[]>([]);
const [showApiKey, setShowApiKey] = useState(false);
+ const [showLogoutConfirm, setShowLogoutConfirm] = useState(false);
+ const [showRegenerateConfirm, setShowRegenerateConfirm] = useState(false);
useEffect(() => {
fetchSectionData();
@@ -62,21 +64,27 @@ const ProfileTab: React.FC = () => {
};
const handleLogout = async () => {
- if (confirm('Logout from Fincept Terminal?')) {
- await logout();
- }
+ setShowLogoutConfirm(true);
+ };
+
+ const confirmLogout = async () => {
+ setShowLogoutConfirm(false);
+ await logout();
};
const handleRegenerateKey = async () => {
if (!session?.api_key) return;
- if (confirm('Regenerate API Key? Your old key will be invalidated.')) {
- setLoading(true);
- const result = await UserApiService.regenerateApiKey(session.api_key);
- setLoading(false);
- if (result.success) {
- alert('API Key regenerated successfully!');
- await refreshUserData();
- }
+ setShowRegenerateConfirm(true);
+ };
+
+ const confirmRegenerateKey = async () => {
+ if (!session?.api_key) return;
+ setShowRegenerateConfirm(false);
+ setLoading(true);
+ const result = await UserApiService.regenerateApiKey(session.api_key);
+ setLoading(false);
+ if (result.success) {
+ await refreshUserData();
}
};
@@ -214,6 +222,158 @@ const ProfileTab: React.FC = () => {
]}
statusInfo={`Last Updated: ${new Date().toLocaleTimeString()}`}
/>
+
+ {/* Logout Confirmation Modal */}
+ {showLogoutConfirm && (
+ <div style={{
+ position: 'fixed',
+ top: 0,
+ left: 0,
+ right: 0,
+ bottom: 0,
+ backgroundColor: 'rgba(0,0,0,0.8)',
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ zIndex: 1000
+ }}>
+ <div style={{
+ backgroundColor: COLORS.PANEL_BG,
+ border: `2px solid ${COLORS.ORANGE}`,
+ padding: '24px',
+ maxWidth: '400px',
+ width: '90%'
+ }}>
+ <div style={{
+ color: COLORS.ORANGE,
+ fontSize: '14px',
+ fontWeight: 'bold',
+ marginBottom: '16px',
+ display: 'flex',
+ alignItems: 'center',
+ gap: '8px'
+ }}>
+ <LogOut size={18} />
+ CONFIRM LOGOUT
+ </div>
+ <div style={{
+ color: COLORS.MUTED,
+ fontSize: '11px',
+ marginBottom: '16px'
+ }}>
+ Are you sure you want to logout from Fincept Terminal?
+ </div>
+ <div style={{ display: 'flex', gap: '8px', justifyContent: 'flex-end' }}>
+ <button
+ onClick={() => setShowLogoutConfirm(false)}
+ style={{
+ padding: '8px 16px',
+ backgroundColor: COLORS.HEADER_BG,
+ border: `1px solid ${COLORS.BORDER}`,
+ color: COLORS.WHITE,
+ cursor: 'pointer',
+ fontSize: '11px',
+ fontFamily: 'monospace'
+ }}
+ >
+ CANCEL
+ </button>
+ <button
+ onClick={confirmLogout}
+ style={{
+ padding: '8px 16px',
+ backgroundColor: COLORS.RED,
+ border: 'none',
+ color: COLORS.WHITE,
+ cursor: 'pointer',
+ fontSize: '11px',
+ fontFamily: 'monospace',
+ fontWeight: 'bold'
+ }}
+ >
+ LOGOUT
+ </button>
+ </div>
+ </div>
+ </div>
+ )}
+
+ {/* Regenerate API Key Confirmation Modal */}
+ {showRegenerateConfirm && (
+ <div style={{
+ position: 'fixed',
+ top: 0,
+ left: 0,
+ right: 0,
+ bottom: 0,
+ backgroundColor: 'rgba(0,0,0,0.8)',
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ zIndex: 1000
+ }}>
+ <div style={{
+ backgroundColor: COLORS.PANEL_BG,
+ border: `2px solid ${COLORS.ORANGE}`,
+ padding: '24px',
+ maxWidth: '400px',
+ width: '90%'
+ }}>
+ <div style={{
+ color: COLORS.ORANGE,
+ fontSize: '14px',
+ fontWeight: 'bold',
+ marginBottom: '16px',
+ display: 'flex',
+ alignItems: 'center',
+ gap: '8px'
+ }}>
+ <Key size={18} />
+ REGENERATE API KEY
+ </div>
+ <div style={{
+ color: COLORS.MUTED,
+ fontSize: '11px',
+ marginBottom: '16px'
+ }}>
+ Your current API key will be invalidated. Are you sure you want to continue?
+ </div>
+ <div style={{ display: 'flex', gap: '8px', justifyContent: 'flex-end' }}>
+ <button
+ onClick={() => setShowRegenerateConfirm(false)}
+ style={{
+ padding: '8px 16px',
+ backgroundColor: COLORS.HEADER_BG,
+ border: `1px solid ${COLORS.BORDER}`,
+ color: COLORS.WHITE,
+ cursor: 'pointer',
+ fontSize: '11px',
+ fontFamily: 'monospace'
+ }}
+ >
+ CANCEL
+ </button>
+ <button
+ onClick={confirmRegenerateKey}
+ disabled={loading}
+ style={{
+ padding: '8px 16px',
+ backgroundColor: COLORS.ORANGE,
+ border: 'none',
+ color: COLORS.WHITE,
+ cursor: loading ? 'not-allowed' : 'pointer',
+ fontSize: '11px',
+ fontFamily: 'monospace',
+ fontWeight: 'bold',
+ opacity: loading ? 0.5 : 1
+ }}
+ >
+ {loading ? 'REGENERATING...' : 'CONFIRM'}
+ </button>
+ </div>
+ </div>
+ </div>
+ )}
</div>
);
};
@@ -336,46 +496,58 @@ const SecuritySection: React.FC<{
showApiKey: boolean;
setShowApiKey: (show: boolean) => void;
}> = ({ session, onRegenerateKey, loading, showApiKey, setShowApiKey }) => {
+ const { refreshUserData } = useAuth();
const apiKey = session?.api_key || '';
const [mfaLoading, setMfaLoading] = React.useState(false);
const [showPasswordPrompt, setShowPasswordPrompt] = React.useState(false);
const [password, setPassword] = React.useState('');
+ const [statusMessage, setStatusMessage] = React.useState<{ type: 'success' | 'error', text: string } | null>(null);
const handleEnableMFA = async () => {
if (!session?.api_key) return;
- if (confirm('Enable Multi-Factor Authentication? You will receive OTP codes via email for login.')) {
- setMfaLoading(true);
- const result = await UserApiService.enableMFA(session.api_key);
- setMfaLoading(false);
- if (result.success) {
- alert('MFA enabled successfully! You will receive OTP codes via email during login.');
- window.location.reload(); // Refresh to update MFA status
- } else {
- alert(`Failed to enable MFA: ${result.error}`);
- }
+ setMfaLoading(true);
+ setStatusMessage(null);
+ const result = await UserApiService.enableMFA(session.api_key);
+ setMfaLoading(false);
+ if (result.success) {
+ setStatusMessage({ type: 'success', text: 'MFA enabled! You will receive OTP codes via email during login.' });
+ setTimeout(async () => {
+ await refreshUserData();
+ setStatusMessage(null);
+ }, 2000);
+ } else {
+ setStatusMessage({ type: 'error', text: result.error || 'Failed to enable MFA' });
+ setTimeout(() => setStatusMessage(null), 3000);
}
};
const handleDisableMFA = async () => {
if (!session?.api_key) return;
setShowPasswordPrompt(true);
+ setStatusMessage(null);
};
const confirmDisableMFA = async () => {
if (!password) {
- alert('Please enter your password to disable MFA.');
+ setStatusMessage({ type: 'error', text: 'Please enter your password' });
+ setTimeout(() => setStatusMessage(null), 3000);
return;
}
setMfaLoading(true);
+ setStatusMessage(null);
const result = await UserApiService.disableMFA(session.api_key, password);
setMfaLoading(false);
setShowPasswordPrompt(false);
setPassword('');
if (result.success) {
- alert('MFA disabled successfully!');
- window.location.reload(); // Refresh to update MFA status
+ setStatusMessage({ type: 'success', text: 'MFA disabled successfully!' });
+ setTimeout(async () => {
+ await refreshUserData();
+ setStatusMessage(null);
+ }, 2000);
} else {
- alert(`Failed to disable MFA: ${result.error}`);
+ setStatusMessage({ type: 'error', text: result.error || 'Failed to disable MFA' });
+ setTimeout(() => setStatusMessage(null), 3000);
}
};
@@ -436,6 +608,21 @@ const SecuritySection: React.FC<{
<DataPanel title="SECURITY STATUS" icon={<Shield size={16} />}>
<div style={{ padding: '8px 0' }}>
+ {/* Status Message */}
+ {statusMessage && (
+ <div style={{
+ padding: '8px 12px',
+ backgroundColor: statusMessage.type === 'success' ? 'rgba(16, 185, 129, 0.1)' : 'rgba(239, 68, 68, 0.1)',
+ border: `1px solid ${statusMessage.type === 'success' ? COLORS.GREEN : COLORS.RED}`,
+ color: statusMessage.type === 'success' ? COLORS.GREEN : COLORS.RED,
+ fontSize: '10px',
+ marginBottom: '12px',
+ fontFamily: 'monospace'
+ }}>
+ {statusMessage.text}
+ </div>
+ )}
+
<SecurityRow
label="EMAIL VERIFICATION"
enabled={session?.user_info?.is_verified}