From f2105a81eecc2b10f0ce69a441ae2cf9d596454b Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sat, 11 Oct 2025 14:55:26 +0000 Subject: [PATCH] Fix: Multilingual and currency selectors not updating --- src/App.tsx | 13 +-- src/components/DashboardLayout.tsx | 36 ++++---- src/pages/dashboard/commerce/Cashier.tsx | 10 ++- src/pages/dashboard/commerce/Customers.tsx | 6 +- src/pages/dashboard/commerce/Inventory.tsx | 2 + src/pages/dashboard/commerce/POSTerminal.tsx | 28 +++--- src/pages/dashboard/commerce/Staff.tsx | 2 + src/pages/dashboard/commerce/Store.tsx | 92 +++++++++++--------- 8 files changed, 108 insertions(+), 81 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index ef02433..2684242 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -7,6 +7,7 @@ import { BrowserRouter, Routes, Route, Navigate } from "react-router-dom"; import { useAuth, AuthProvider } from "@/contexts/AuthContext"; import { CartProvider } from "@/contexts/CartContext"; import { LanguageProvider } from "@/contexts/LanguageContext"; +import { CurrencyProvider } from "@/contexts/CurrencyContext"; import ErrorBoundary from "@/components/ErrorBoundary"; import FrontendLayout from "@/components/layouts/FrontendLayout"; import Index from "./pages/Index"; @@ -507,11 +508,13 @@ const App = () => ( - - - - - + + + + + + + diff --git a/src/components/DashboardLayout.tsx b/src/components/DashboardLayout.tsx index 478d0cd..bb88ef9 100644 --- a/src/components/DashboardLayout.tsx +++ b/src/components/DashboardLayout.tsx @@ -76,7 +76,7 @@ const DashboardLayout = ({ children }: { children: React.ReactNode }) => { }; const menuItems = [ - { icon: Home, label: 'Dashboard', path: '/dashboard' }, + { icon: Home, label: t('dashboard'), path: '/dashboard' }, { icon: Settings, label: 'Admin Panel', @@ -139,7 +139,7 @@ const DashboardLayout = ({ children }: { children: React.ReactNode }) => { { icon: DoorOpen, label: 'Check-in', path: '/dashboard/hotel/checkin' }, { icon: BellRing, label: 'Room Service', path: '/dashboard/hotel/room-service' }, { icon: Key, label: 'Acceso', path: '/dashboard/hotel/keyless' }, - { icon: Users, label: 'Personal', path: '/dashboard/hotel/staff' } + { icon: Users, label: t('staff'), path: '/dashboard/hotel/staff' } ] }, { @@ -153,8 +153,8 @@ const DashboardLayout = ({ children }: { children: React.ReactNode }) => { { icon: Receipt, label: 'Cuentas', path: '/dashboard/restaurant/bills' }, { icon: Grid3x3, label: 'Mesas', path: '/dashboard/restaurant/tables' }, { icon: UtensilsCrossed, label: 'Menú', path: '/dashboard/restaurant/menu' }, - { icon: Package, label: 'Inventario', path: '/dashboard/restaurant/inventory' }, - { icon: Users, label: 'Personal', path: '/dashboard/restaurant/staff' } + { icon: Package, label: t('inventory'), path: '/dashboard/restaurant/inventory' }, + { icon: Users, label: t('staff'), path: '/dashboard/restaurant/staff' } ] }, { icon: Brain, label: 'Personalization', path: '/dashboard/personalization' }, @@ -163,25 +163,25 @@ const DashboardLayout = ({ children }: { children: React.ReactNode }) => { { icon: Leaf, label: 'Sustainability', path: '/dashboard/sustainability' }, { icon: Store, - label: 'Comercios', + label: t('commerce'), path: '/dashboard/commerce', subItems: [ - { icon: Store, label: 'Mi Comercio', path: '/dashboard/commerce/store' }, - { icon: CreditCard, label: 'POS Ventas', path: '/dashboard/commerce/pos' }, - { icon: Package, label: 'Inventario', path: '/dashboard/commerce/inventory' }, - { icon: Users, label: 'Clientes', path: '/dashboard/commerce/customers' }, - { icon: Users, label: 'Personal', path: '/dashboard/commerce/staff' }, - { icon: Receipt, label: 'Caja', path: '/dashboard/commerce/cashier' }, - { icon: BarChart3, label: 'Reportes', path: '/dashboard/commerce/reports' }, - { icon: DollarSign, label: 'Ventas', path: '/dashboard/commerce/sales' } + { icon: Store, label: t('myStore'), path: '/dashboard/commerce/store' }, + { icon: CreditCard, label: t('posTerminal'), path: '/dashboard/commerce/pos' }, + { icon: Package, label: t('inventory'), path: '/dashboard/commerce/inventory' }, + { icon: Users, label: t('customers'), path: '/dashboard/commerce/customers' }, + { icon: Users, label: t('staff'), path: '/dashboard/commerce/staff' }, + { icon: Receipt, label: t('cashier'), path: '/dashboard/commerce/cashier' }, + { icon: BarChart3, label: t('reports'), path: '/dashboard/commerce/reports' }, + { icon: DollarSign, label: t('sales'), path: '/dashboard/commerce/sales' } ] }, - { icon: Wallet, label: 'Wallet', path: '/dashboard/wallet' }, + { icon: Wallet, label: t('wallet'), path: '/dashboard/wallet' }, { icon: MessageSquare, label: 'Message', path: '/dashboard/messages', badge: '2' }, ]; const listingItems = [ - { icon: List, label: 'My Listing', path: '/dashboard/my-listings', hasSubmenu: true }, + { icon: List, label: t('myListings'), path: '/dashboard/my-listings', hasSubmenu: true }, { icon: Star, label: 'Reviews', path: '/dashboard/reviews' }, { icon: BookOpen, label: 'Bookings', path: '/dashboard/bookings' }, { icon: Heart, label: 'Bookmark', path: '/dashboard/bookmarks' }, @@ -189,9 +189,9 @@ const DashboardLayout = ({ children }: { children: React.ReactNode }) => { ]; const accountItems = [ - { icon: User, label: 'Edit Profile', path: '/dashboard/profile' }, - { icon: CreditCard, label: 'Wallet', path: '/dashboard/wallet' }, - { icon: Settings, label: 'Setting', path: '/dashboard/settings' }, + { icon: User, label: t('profile'), path: '/dashboard/profile' }, + { icon: CreditCard, label: t('wallet'), path: '/dashboard/wallet' }, + { icon: Settings, label: t('settings'), path: '/dashboard/settings' }, ]; return ( diff --git a/src/pages/dashboard/commerce/Cashier.tsx b/src/pages/dashboard/commerce/Cashier.tsx index 7a505a0..d62ae6a 100644 --- a/src/pages/dashboard/commerce/Cashier.tsx +++ b/src/pages/dashboard/commerce/Cashier.tsx @@ -6,8 +6,10 @@ import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { Badge } from '@/components/ui/badge'; import { useToast } from '@/hooks/use-toast'; +import { useLanguage } from '@/contexts/LanguageContext'; const Cashier = () => { + const { t } = useLanguage(); const { toast } = useToast(); const [cashierData] = useState({ openingBalance: 1000.00, @@ -25,19 +27,19 @@ const Cashier = () => { }); const handleOpenCashier = () => { - toast({ title: 'Caja Abierta', description: 'Caja abierta con saldo inicial' }); + toast({ title: t('openCashier'), description: t('openCashier') }); }; const handleCloseCashier = () => { - toast({ title: 'Caja Cerrada', description: 'Caja cerrada. Generando reporte...' }); + toast({ title: t('closeCashier'), description: t('closeCashier') }); }; const handleAddTransaction = () => { if (newTransaction.amount <= 0) { - toast({ title: 'Error', description: 'Ingresa un monto válido', variant: 'destructive' }); + toast({ title: t('error'), description: t('amount'), variant: 'destructive' }); return; } - toast({ title: 'Éxito', description: 'Transacción registrada' }); + toast({ title: t('success'), description: t('registerTransaction') }); setNewTransaction({ type: 'sale', amount: 0, description: '' }); }; diff --git a/src/pages/dashboard/commerce/Customers.tsx b/src/pages/dashboard/commerce/Customers.tsx index 05d079d..cbb07da 100644 --- a/src/pages/dashboard/commerce/Customers.tsx +++ b/src/pages/dashboard/commerce/Customers.tsx @@ -7,8 +7,10 @@ import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { Badge } from '@/components/ui/badge'; import { useToast } from '@/hooks/use-toast'; +import { useLanguage } from '@/contexts/LanguageContext'; const Customers = () => { + const { t } = useLanguage(); const [customers, setCustomers] = useState([]); const { toast } = useToast(); @@ -23,7 +25,7 @@ const Customers = () => { const handleSubmit = async () => { try { - toast({ title: 'Éxito', description: 'Cliente agregado correctamente' }); + toast({ title: t('success'), description: t('add') }); setFormData({ firstName: '', lastName: '', @@ -33,7 +35,7 @@ const Customers = () => { notes: '' }); } catch (error: any) { - toast({ title: 'Error', description: error?.message || 'No se pudo agregar el cliente', variant: 'destructive' }); + toast({ title: t('error'), description: error?.message || t('error'), variant: 'destructive' }); } }; diff --git a/src/pages/dashboard/commerce/Inventory.tsx b/src/pages/dashboard/commerce/Inventory.tsx index 7a137df..0c77821 100644 --- a/src/pages/dashboard/commerce/Inventory.tsx +++ b/src/pages/dashboard/commerce/Inventory.tsx @@ -7,8 +7,10 @@ import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { Badge } from '@/components/ui/badge'; import { useToast } from '@/hooks/use-toast'; +import { useLanguage } from '@/contexts/LanguageContext'; const Inventory = () => { + const { t } = useLanguage(); const [inventory, setInventory] = useState([]); const { toast } = useToast(); diff --git a/src/pages/dashboard/commerce/POSTerminal.tsx b/src/pages/dashboard/commerce/POSTerminal.tsx index d0eebfe..fd829f3 100644 --- a/src/pages/dashboard/commerce/POSTerminal.tsx +++ b/src/pages/dashboard/commerce/POSTerminal.tsx @@ -6,8 +6,10 @@ import { Input } from '@/components/ui/input'; import { Badge } from '@/components/ui/badge'; import { useToast } from '@/hooks/use-toast'; import { apiClient } from '@/services/adminApi'; +import { useLanguage } from '@/contexts/LanguageContext'; const POSTerminal = () => { + const { t } = useLanguage(); const [products, setProducts] = useState([]); const [cart, setCart] = useState([]); const [searchTerm, setSearchTerm] = useState(''); @@ -58,15 +60,15 @@ const POSTerminal = () => { const handleCheckout = async () => { if (cart.length === 0) { - toast({ title: 'Error', description: 'El carrito está vacío', variant: 'destructive' }); + toast({ title: t('error'), description: t('cartEmpty'), variant: 'destructive' }); return; } try { - toast({ title: 'Éxito', description: `Venta procesada: $${getTotal().toFixed(2)}` }); + toast({ title: t('success'), description: `${t('total')}: $${getTotal().toFixed(2)}` }); setCart([]); } catch (error: any) { - toast({ title: 'Error', description: error?.message || 'No se pudo procesar la venta', variant: 'destructive' }); + toast({ title: t('error'), description: error?.message || t('error'), variant: 'destructive' }); } }; @@ -81,14 +83,14 @@ const POSTerminal = () => {
-

POS Terminal

-

Sistema punto de venta

+

{t('posTerminal')}

+

{t('currentSale')}

setSearchTerm(e.target.value)} className="max-w-md" @@ -101,8 +103,8 @@ const POSTerminal = () => { {filteredProducts.length === 0 ? (
-

No hay productos en el inventario

-

Agrega productos desde la sección de Inventario

+

{t('noProducts')}

+

{t('addProducts')}

) : ( filteredProducts.map((item) => ( @@ -122,7 +124,7 @@ const POSTerminal = () => { {item.category} ${item.price}
-

Stock: {item.stock}

+

{t('stock')}: {item.stock}

@@ -134,12 +136,12 @@ const POSTerminal = () => {
- Venta Actual + {t('currentSale')} {cart.length === 0 ? (

- No hay productos en la venta + {t('cartEmpty')}

) : ( <> @@ -167,12 +169,12 @@ const POSTerminal = () => {
- Total: + {t('total')}: ${getTotal().toFixed(2)}
diff --git a/src/pages/dashboard/commerce/Staff.tsx b/src/pages/dashboard/commerce/Staff.tsx index af00d5c..57fcd97 100644 --- a/src/pages/dashboard/commerce/Staff.tsx +++ b/src/pages/dashboard/commerce/Staff.tsx @@ -9,8 +9,10 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@ import { Badge } from '@/components/ui/badge'; import { useToast } from '@/hooks/use-toast'; import { apiClient } from '@/services/adminApi'; +import { useLanguage } from '@/contexts/LanguageContext'; const Staff = () => { + const { t } = useLanguage(); const [staff, setStaff] = useState([]); const [establishments, setEstablishments] = useState([]); const { toast } = useToast(); diff --git a/src/pages/dashboard/commerce/Store.tsx b/src/pages/dashboard/commerce/Store.tsx index fecc0ec..5d288f4 100644 --- a/src/pages/dashboard/commerce/Store.tsx +++ b/src/pages/dashboard/commerce/Store.tsx @@ -8,8 +8,10 @@ import { Label } from '@/components/ui/label'; import { Badge } from '@/components/ui/badge'; import { useToast } from '@/hooks/use-toast'; import { apiClient } from '@/services/adminApi'; +import { useLanguage } from '@/contexts/LanguageContext'; const Store = () => { + const { t } = useLanguage(); const [editing, setEditing] = useState(false); const [loading, setLoading] = useState(false); const { toast } = useToast(); @@ -62,11 +64,11 @@ const Store = () => { } else { await apiClient.post('/commerce/establishments', storeData); } - toast({ title: 'Éxito', description: 'Información de la tienda actualizada' }); + toast({ title: t('success'), description: t('save') }); setEditing(false); loadStoreData(); } catch (error: any) { - toast({ title: 'Error', description: error?.message || 'No se pudo guardar', variant: 'destructive' }); + toast({ title: t('error'), description: error?.message || t('error'), variant: 'destructive' }); } }; @@ -77,13 +79,13 @@ const Store = () => {
-

Mi Comercio

-

Información y configuración de tu tienda

+

{t('myStore')}

+

{t('storeInfo')}

@@ -92,9 +94,9 @@ const Store = () => {
- Estado del Comercio + {t('storeStatus')} - {storeData.isActive ? 'Activo' : 'Inactivo'} + {storeData.isActive ? t('active') : t('inactive')}
@@ -103,35 +105,35 @@ const Store = () => { {/* Basic Information */} - Información Básica + {t('basicInfo')}
- + setStoreData({ ...storeData, name: e.target.value })} disabled={!editing} - placeholder="Nombre de tu tienda" + placeholder={t('storeName')} />
- +