diff --git a/src/App.tsx b/src/App.tsx index f24b4dd..95ad3e5 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -35,14 +35,20 @@ import Invoices from "./pages/dashboard/Invoices"; import InvoiceDetail from "./pages/dashboard/InvoiceDetail"; import HotelManagement from "./pages/dashboard/HotelManagement"; import RestaurantPOS from "./pages/dashboard/RestaurantPOS"; -import Personalization from "./pages/dashboard/Personalization"; -import Security from "./pages/dashboard/Security"; import VehicleManagement from "./pages/dashboard/VehicleManagement"; import Sustainability from "./pages/dashboard/Sustainability"; import Establishments from "./pages/dashboard/Establishments"; import Analytics from "./pages/dashboard/Analytics"; import SearchPlaces from "./pages/dashboard/SearchPlaces"; import SearchEstablishments from "./pages/dashboard/SearchEstablishments"; +// Config pages +import APIs from "./pages/dashboard/config/APIs"; +import Payments from "./pages/dashboard/config/Payments"; +import Parameters from "./pages/dashboard/config/Parameters"; +import Integrations from "./pages/dashboard/config/Integrations"; +import Audit from "./pages/dashboard/config/Audit"; +import SecurityCenter from "./pages/dashboard/config/SecurityCenter"; +import PersonalizationPage from "./pages/dashboard/config/PersonalizationPage"; // Commerce pages (for retail stores) import CommerceStore from "./pages/dashboard/commerce/Store"; import CommercePOS from "./pages/dashboard/commerce/POSTerminal"; @@ -507,6 +513,63 @@ const AppRouter = () => ( } /> + {/* Config Routes */} + + + + + + } /> + + + + + + + } /> + + + + + + + } /> + + + + + + + } /> + + + + + + + } /> + + + + + + + } /> + + + + + + + } /> + {/* Catch-all route */} } /> diff --git a/src/components/DashboardLayout.tsx b/src/components/DashboardLayout.tsx index 497aea0..f4eaa63 100644 --- a/src/components/DashboardLayout.tsx +++ b/src/components/DashboardLayout.tsx @@ -56,7 +56,8 @@ import { Radio, Sparkles, Leaf, - Store + Store, + Server } from 'lucide-react'; const DashboardLayout = ({ children }: { children: React.ReactNode }) => { @@ -115,7 +116,20 @@ const DashboardLayout = ({ children }: { children: React.ReactNode }) => { }, { icon: AlertTriangle, label: 'Emergencias', path: '/dashboard/admin?tab=emergency' }, { icon: MessageSquare, label: 'Soporte', path: '/dashboard/admin?tab=support' }, - { icon: Settings, label: 'Configuración', path: '/dashboard/admin?tab=config' }, + { + icon: Settings, + label: 'Configuración', + path: '/dashboard/config', + subItems: [ + { icon: Server, label: 'APIs', path: '/dashboard/config/apis' }, + { icon: CreditCard, label: 'Pagos', path: '/dashboard/config/payments' }, + { icon: Settings, label: 'Parámetros', path: '/dashboard/config/parameters' }, + { icon: Radio, label: 'Integraciones', path: '/dashboard/config/integrations' }, + { icon: FileText, label: 'Auditoría', path: '/dashboard/config/audit' }, + { icon: Shield, label: 'Security Center', path: '/dashboard/config/security' }, + { icon: Brain, label: 'Personalización', path: '/dashboard/config/personalization' } + ] + }, { icon: BarChart3, label: 'Analytics', path: '/dashboard/analytics' }, { icon: Search, label: 'Buscar Lugares', path: '/dashboard/search-places' }, { icon: Store, label: 'Buscar Comercios', path: '/dashboard/search-establishments' } diff --git a/src/pages/dashboard/config/APIs.tsx b/src/pages/dashboard/config/APIs.tsx new file mode 100644 index 0000000..4e7477f --- /dev/null +++ b/src/pages/dashboard/config/APIs.tsx @@ -0,0 +1,109 @@ +import React, { useState } from 'react'; +import { Server, TestTube, Edit, X, RefreshCw } from 'lucide-react'; +import { Button } from '@/components/ui/button'; +import { Input } from '@/components/ui/input'; +import { Badge } from '@/components/ui/badge'; +import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; +import { useSystemConfig } from '@/hooks/useSystemConfig'; + +const APIs = () => { + const [editingApi, setEditingApi] = useState(null); + const { + apiConfigs, + loading, + updateApiConfig, + testApiConnection, + } = useSystemConfig(); + + const handleApiEdit = (id: string, field: string, value: string) => { + const config = apiConfigs.find(c => c.id === id); + if (config) { + updateApiConfig({ ...config, [field]: value }); + setEditingApi(null); + } + }; + + return ( +
+
+

Configuración de APIs

+
+ + + + + + APIs Externas + + + + {loading ? ( +
+ +
+ ) : ( +
+ {apiConfigs.map((config) => ( +
+
+

{config.name}

+
+ + {config.status} + + +
+
+
+
+ + {editingApi === config.id + '-endpoint' ? ( +
+ { + if (e.key === 'Enter') { + handleApiEdit(config.id, 'endpoint', e.currentTarget.value); + } + }} + /> + +
+ ) : ( +
+ {config.endpoint} + +
+ )} +
+
+ + {config.timeout}ms +
+
+
+ ))} +
+ )} +
+
+
+ ); +}; + +export default APIs; diff --git a/src/pages/dashboard/config/Audit.tsx b/src/pages/dashboard/config/Audit.tsx new file mode 100644 index 0000000..4f121f5 --- /dev/null +++ b/src/pages/dashboard/config/Audit.tsx @@ -0,0 +1,15 @@ +import React from 'react'; +import AuditLogs from '@/components/security/AuditLogs'; + +const Audit = () => { + return ( +
+
+

Registro de Auditoría

+
+ +
+ ); +}; + +export default Audit; diff --git a/src/pages/dashboard/config/Integrations.tsx b/src/pages/dashboard/config/Integrations.tsx new file mode 100644 index 0000000..9662264 --- /dev/null +++ b/src/pages/dashboard/config/Integrations.tsx @@ -0,0 +1,88 @@ +import React from 'react'; +import { Wifi, RefreshCw, CheckCircle, XCircle, Clock } from 'lucide-react'; +import { Button } from '@/components/ui/button'; +import { Badge } from '@/components/ui/badge'; +import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; +import { useSystemConfig } from '@/hooks/useSystemConfig'; + +const Integrations = () => { + const { + integrations, + loading, + syncIntegration, + } = useSystemConfig(); + + const getStatusIcon = (status: string) => { + switch (status) { + case 'connected': + return ; + case 'error': + return ; + default: + return ; + } + }; + + return ( +
+
+

Integraciones

+
+ + + + + + Servicios Externos + + + + {loading ? ( +
+ +
+ ) : ( +
+ {integrations.map((integration) => ( +
+
+
+ {getStatusIcon(integration.status)} +
+

{integration.name}

+

{integration.type}

+
+
+
+ + {integration.status} + + +
+
+ {integration.lastSync && ( +
+ Última sincronización: {new Date(integration.lastSync).toLocaleString()} +
+ )} +
+ ))} +
+ )} +
+
+
+ ); +}; + +export default Integrations; diff --git a/src/pages/dashboard/config/Parameters.tsx b/src/pages/dashboard/config/Parameters.tsx new file mode 100644 index 0000000..2f39378 --- /dev/null +++ b/src/pages/dashboard/config/Parameters.tsx @@ -0,0 +1,95 @@ +import React, { useState } from 'react'; +import { Settings, Edit, X, RefreshCw } from 'lucide-react'; +import { Button } from '@/components/ui/button'; +import { Input } from '@/components/ui/input'; +import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; +import { useSystemConfig } from '@/hooks/useSystemConfig'; + +const Parameters = () => { + const [editingParam, setEditingParam] = useState(null); + const { + systemParameters, + loading, + updateSystemParameter, + } = useSystemConfig(); + + const handleParamEdit = (id: string, value: string) => { + const param = systemParameters.find(p => p.id === id); + if (param) { + updateSystemParameter({ ...param, value }); + setEditingParam(null); + } + }; + + return ( +
+
+

Parámetros del Sistema

+
+ + + + + + Configuración Global + + + + {loading ? ( +
+ +
+ ) : ( +
+ {systemParameters.map((param) => ( +
+
+
+

{param.key}

+

{param.description}

+
+
+
+ {editingParam === param.id ? ( +
+ { + if (e.key === 'Enter') { + handleParamEdit(param.id, e.currentTarget.value); + } + }} + /> + +
+ ) : ( +
+ + {param.value} + + +
+ )} +
+
+ Tipo: {param.type} +
+
+ ))} +
+ )} +
+
+
+ ); +}; + +export default Parameters; diff --git a/src/pages/dashboard/config/Payments.tsx b/src/pages/dashboard/config/Payments.tsx new file mode 100644 index 0000000..c1f955b --- /dev/null +++ b/src/pages/dashboard/config/Payments.tsx @@ -0,0 +1,133 @@ +import React, { useState } from 'react'; +import { CreditCard, TestTube, Edit, X, RefreshCw, Eye, EyeOff } from 'lucide-react'; +import { Button } from '@/components/ui/button'; +import { Input } from '@/components/ui/input'; +import { Switch } from '@/components/ui/switch'; +import { Badge } from '@/components/ui/badge'; +import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; +import { useSystemConfig } from '@/hooks/useSystemConfig'; + +const Payments = () => { + const [editingPayment, setEditingPayment] = useState(null); + const [showSecrets, setShowSecrets] = useState>({}); + const { + paymentConfigs, + loading, + updatePaymentConfig, + testPaymentConnection, + } = useSystemConfig(); + + const handlePaymentEdit = (id: string, field: string, value: string | boolean) => { + const config = paymentConfigs.find(c => c.id === id); + if (config) { + if (field === 'enabled' || field === 'testMode') { + updatePaymentConfig({ ...config, [field]: value }); + } else { + updatePaymentConfig({ + ...config, + credentials: { ...config.credentials, [field]: value as string } + }); + } + setEditingPayment(null); + } + }; + + const toggleSecretVisibility = (key: string) => { + setShowSecrets(prev => ({ ...prev, [key]: !prev[key] })); + }; + + return ( +
+
+

Configuración de Medios de Pago

+
+ + + + + + Proveedores de Pago + + + + {loading ? ( +
+ +
+ ) : paymentConfigs.length === 0 ? ( +
+ +

+ No hay configuraciones de pago +

+

+ Configure los proveedores de pago para comenzar a procesar transacciones +

+
+ ) : ( +
+ {paymentConfigs.map((config) => ( +
+
+
+

{config.name}

+

{config.provider.toUpperCase()}

+
+
+ + {config.status} + + + {config.testMode ? 'Test' : 'Producción'} + + + handlePaymentEdit(config.id, 'enabled', checked) + } + /> + +
+
+ +
+ {config.provider === 'stripe' && ( +
+
+ +
+ + {config.credentials.publishableKey || 'No configurado'} + +
+
+ +
+ +
+ + {config.credentials.secretKey ? '••••••••••••' : 'No configurado'} + +
+
+
+ )} +
+
+ ))} +
+ )} +
+
+
+ ); +}; + +export default Payments; diff --git a/src/pages/dashboard/config/PersonalizationPage.tsx b/src/pages/dashboard/config/PersonalizationPage.tsx new file mode 100644 index 0000000..7aca915 --- /dev/null +++ b/src/pages/dashboard/config/PersonalizationPage.tsx @@ -0,0 +1,24 @@ +import React from 'react'; +import AIRecommendations from '@/components/personalization/AIRecommendations'; +import UserPreferences from '@/components/personalization/UserPreferences'; +import BehaviorAnalytics from '@/components/personalization/BehaviorAnalytics'; +import SegmentManagement from '@/components/personalization/SegmentManagement'; + +const PersonalizationPage = () => { + return ( +
+
+

Personalización

+
+ +
+ + + + +
+
+ ); +}; + +export default PersonalizationPage; diff --git a/src/pages/dashboard/config/SecurityCenter.tsx b/src/pages/dashboard/config/SecurityCenter.tsx new file mode 100644 index 0000000..e0e8326 --- /dev/null +++ b/src/pages/dashboard/config/SecurityCenter.tsx @@ -0,0 +1,22 @@ +import React from 'react'; +import ThreatDetection from '@/components/security/ThreatDetection'; +import AccessControl from '@/components/security/AccessControl'; +import ComplianceMonitor from '@/components/security/ComplianceMonitor'; + +const SecurityCenter = () => { + return ( +
+
+

Centro de Seguridad

+
+ +
+ + + +
+
+ ); +}; + +export default SecurityCenter;