Fix jwt-token
This commit is contained in:
@@ -2,7 +2,6 @@ import React from 'react';
|
|||||||
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
|
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
|
||||||
import { Toaster } from 'react-hot-toast';
|
import { Toaster } from 'react-hot-toast';
|
||||||
import { AuthProvider } from './contexts/AuthContext';
|
import { AuthProvider } from './contexts/AuthContext';
|
||||||
import { MultiTenantAuthProvider } from './contexts/MultiTenantAuthContext';
|
|
||||||
import { SocketProvider } from './contexts/SocketContext';
|
import { SocketProvider } from './contexts/SocketContext';
|
||||||
import APP_CONFIG from './config/app';
|
import APP_CONFIG from './config/app';
|
||||||
import Layout from './components/Layout';
|
import Layout from './components/Layout';
|
||||||
@@ -19,10 +18,9 @@ import ProtectedRoute from './components/ProtectedRoute';
|
|||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
return (
|
return (
|
||||||
<MultiTenantAuthProvider>
|
<AuthProvider>
|
||||||
<AuthProvider>
|
<SocketProvider>
|
||||||
<SocketProvider>
|
<Router basename={APP_CONFIG.basePath}>
|
||||||
<Router basename={APP_CONFIG.basePath}>
|
|
||||||
<div className="App">
|
<div className="App">
|
||||||
<Toaster
|
<Toaster
|
||||||
position="top-center"
|
position="top-center"
|
||||||
@@ -83,7 +81,6 @@ function App() {
|
|||||||
</Router>
|
</Router>
|
||||||
</SocketProvider>
|
</SocketProvider>
|
||||||
</AuthProvider>
|
</AuthProvider>
|
||||||
</MultiTenantAuthProvider>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import React, { createContext, useContext, useEffect, useState } from 'react';
|
import React, { createContext, useContext, useEffect, useState } from 'react';
|
||||||
import { io } from 'socket.io-client';
|
import { io } from 'socket.io-client';
|
||||||
import { useAuth } from './AuthContext';
|
import { useAuth } from './AuthContext';
|
||||||
import { useMultiTenantAuth } from './MultiTenantAuthContext';
|
|
||||||
import toast from 'react-hot-toast';
|
import toast from 'react-hot-toast';
|
||||||
import APP_CONFIG from '../config/app';
|
import APP_CONFIG from '../config/app';
|
||||||
|
|
||||||
@@ -17,8 +16,8 @@ export const SocketProvider = ({ children }) => {
|
|||||||
const [notificationsEnabled, setNotificationsEnabled] = useState(
|
const [notificationsEnabled, setNotificationsEnabled] = useState(
|
||||||
localStorage.getItem('notificationsEnabled') !== 'false' // Default to enabled
|
localStorage.getItem('notificationsEnabled') !== 'false' // Default to enabled
|
||||||
);
|
);
|
||||||
const { isAuthenticated } = useAuth();
|
const { isAuthenticated, user } = useAuth();
|
||||||
const { state: { tenant } } = useMultiTenantAuth();
|
const tenant = user?.tenant_id;
|
||||||
|
|
||||||
// Mobile notification management
|
// Mobile notification management
|
||||||
const [notificationCooldown, setNotificationCooldown] = useState(new Map());
|
const [notificationCooldown, setNotificationCooldown] = useState(new Map());
|
||||||
@@ -141,6 +140,8 @@ export const SocketProvider = ({ children }) => {
|
|||||||
if (tenant) {
|
if (tenant) {
|
||||||
newSocket.emit('join_tenant_room', tenant);
|
newSocket.emit('join_tenant_room', tenant);
|
||||||
console.log(`🔒 Joined 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');
|
toast.success('Connected to real-time updates');
|
||||||
|
|||||||
Reference in New Issue
Block a user