Fix jwt-token

This commit is contained in:
2025-09-17 21:41:40 +02:00
parent 726f931b74
commit 8c2943ac84
2 changed files with 7 additions and 9 deletions

View File

@@ -1,7 +1,6 @@
import React, { createContext, useContext, useEffect, useState } from 'react';
import { io } from 'socket.io-client';
import { useAuth } from './AuthContext';
import { useMultiTenantAuth } from './MultiTenantAuthContext';
import toast from 'react-hot-toast';
import APP_CONFIG from '../config/app';
@@ -17,8 +16,8 @@ export const SocketProvider = ({ children }) => {
const [notificationsEnabled, setNotificationsEnabled] = useState(
localStorage.getItem('notificationsEnabled') !== 'false' // Default to enabled
);
const { isAuthenticated } = useAuth();
const { state: { tenant } } = useMultiTenantAuth();
const { isAuthenticated, user } = useAuth();
const tenant = user?.tenant_id;
// Mobile notification management
const [notificationCooldown, setNotificationCooldown] = useState(new Map());
@@ -141,6 +140,8 @@ export const SocketProvider = ({ children }) => {
if (tenant) {
newSocket.emit('join_tenant_room', tenant);
console.log(`🔒 Joined tenant room: ${tenant}`);
} else {
console.warn('⚠️ No tenant available for Socket.IO room isolation');
}
toast.success('Connected to real-time updates');