diff --git a/attached_assets/image_1758446016976.png b/attached_assets/image_1758446016976.png
new file mode 100644
index 0000000..aef8b73
Binary files /dev/null and b/attached_assets/image_1758446016976.png differ
diff --git a/client/src/components/RouterProduction.tsx b/client/src/components/RouterProduction.tsx
index f265020..90a32f6 100644
--- a/client/src/components/RouterProduction.tsx
+++ b/client/src/components/RouterProduction.tsx
@@ -28,19 +28,21 @@ import Layout from "@/components/Layout";
function RouterProduction() {
const { isAuthenticated, isLoading, user, environment, error } = useAuthUnified();
- // Debug complet pour la production
- console.log('🔍 RouterProduction Debug:', {
- environment,
- isAuthenticated,
- isLoading,
- hasUser: !!user,
- userId: user?.id,
- username: user?.username,
- error: error?.message
- });
+ // Debug uniquement en développement
+ if (import.meta.env.DEV) {
+ console.log('🔍 RouterProduction Debug:', {
+ environment,
+ isAuthenticated,
+ isLoading,
+ hasUser: !!user,
+ userId: user?.id,
+ username: user?.username,
+ error: error?.message
+ });
+ }
// Debug minimal basé sur l'environnement
- if (environment === 'production' && error) {
+ if (environment === 'production' && error && import.meta.env.DEV) {
console.error('🚨 Production Auth Error:', error);
}
@@ -58,7 +60,9 @@ function RouterProduction() {
if (!isAuthenticated) {
// Redirection automatique vers la page d'authentification
if (typeof window !== 'undefined' && window.location.pathname !== '/auth') {
- console.log('🔄 User not authenticated, redirecting to auth page');
+ if (import.meta.env.DEV) {
+ console.log('🔄 User not authenticated, redirecting to auth page');
+ }
window.location.href = '/auth';
return (
@@ -109,7 +113,9 @@ function RouterProduction() {
{() => {
if (typeof window !== 'undefined') {
- console.log('🔄 Authenticated user on /auth, redirecting to dashboard');
+ if (import.meta.env.DEV) {
+ console.log('🔄 Authenticated user on /auth, redirecting to dashboard');
+ }
window.location.href = '/';
}
return ;
diff --git a/client/src/hooks/useAuthUnified.ts b/client/src/hooks/useAuthUnified.ts
index 39e9b76..f282332 100644
--- a/client/src/hooks/useAuthUnified.ts
+++ b/client/src/hooks/useAuthUnified.ts
@@ -10,12 +10,14 @@ export function useAuthUnified() {
window.location.hostname.includes('replit.dev')) &&
import.meta.env.DEV === true;
- // Debug logging pour comprendre l'environnement
- console.log('🔍 Auth Environment Debug:', {
- hostname: typeof window !== 'undefined' ? window.location.hostname : 'N/A',
- isDev: import.meta.env.DEV,
- environment: isDevelopment ? 'development' : 'production'
- });
+ // Debug logging uniquement en développement
+ if (import.meta.env.DEV) {
+ console.log('🔍 Auth Environment Debug:', {
+ hostname: typeof window !== 'undefined' ? window.location.hostname : 'N/A',
+ isDev: import.meta.env.DEV,
+ environment: isDevelopment ? 'development' : 'production'
+ });
+ }
// État pour la version production (fetch direct)
const [productionUser, setProductionUser] = useState(null);
@@ -43,28 +45,40 @@ export function useAuthUnified() {
// Fonction pour rafraîchir l'authentification
const refreshAuth = () => {
- console.log('🔄 RefreshAuth called, isDevelopment:', isDevelopment);
+ if (import.meta.env.DEV) {
+ console.log('🔄 RefreshAuth called, isDevelopment:', isDevelopment);
+ }
if (!isDevelopment) {
- console.log('🔄 Triggering production auth refresh');
+ if (import.meta.env.DEV) {
+ console.log('🔄 Triggering production auth refresh');
+ }
setRefreshTrigger(prev => {
const newValue = prev + 1;
- console.log('🔄 Production refresh trigger updated:', prev, '->', newValue);
+ if (import.meta.env.DEV) {
+ console.log('🔄 Production refresh trigger updated:', prev, '->', newValue);
+ }
return newValue;
});
} else {
- console.log('🔄 Development mode - using React Query refresh');
+ if (import.meta.env.DEV) {
+ console.log('🔄 Development mode - using React Query refresh');
+ }
developmentQuery.refetch();
}
};
// Fonction pour rafraîchir de manière synchrone (pour après login)
const forceAuthRefresh = async () => {
- console.log('🔄 ForceAuthRefresh called, isDevelopment:', isDevelopment);
+ if (import.meta.env.DEV) {
+ console.log('🔄 ForceAuthRefresh called, isDevelopment:', isDevelopment);
+ }
if (!isDevelopment) {
// En production, faire un fetch immédiat et forcer un re-render
try {
- console.log('🔄 Production force refresh - fetching user data');
+ if (import.meta.env.DEV) {
+ console.log('🔄 Production force refresh - fetching user data');
+ }
setProductionLoading(true);
const response = await fetch('/api/user', {
@@ -78,7 +92,9 @@ export function useAuthUnified() {
if (response.ok) {
const userData = await response.json();
- console.log('✅ Production force refresh success:', { username: userData?.username, id: userData?.id });
+ if (import.meta.env.DEV) {
+ console.log('✅ Production force refresh success:', { username: userData?.username, id: userData?.id });
+ }
setProductionUser(userData);
setProductionError(null);
setProductionLoading(false);
@@ -88,14 +104,18 @@ export function useAuthUnified() {
return userData;
} else {
- console.log('❌ Production force refresh failed:', response.status);
+ if (import.meta.env.DEV) {
+ console.log('❌ Production force refresh failed:', response.status);
+ }
setProductionUser(null);
setProductionError(null);
setProductionLoading(false);
return null;
}
} catch (error) {
- console.error('❌ Production force refresh error:', error);
+ if (import.meta.env.DEV) {
+ console.error('❌ Production force refresh error:', error);
+ }
setProductionError(error);
setProductionUser(null);
setProductionLoading(false);
@@ -103,7 +123,9 @@ export function useAuthUnified() {
}
} else {
// En développement, forcer un refetch avec invalidation du cache
- console.log('🔄 Development mode - invalidating cache and refetching');
+ if (import.meta.env.DEV) {
+ console.log('🔄 Development mode - invalidating cache and refetching');
+ }
const queryClient = useQueryClient();
queryClient.invalidateQueries({ queryKey: ['/api/user'] });
@@ -111,11 +133,13 @@ export function useAuthUnified() {
await new Promise(resolve => setTimeout(resolve, 50));
const result = await developmentQuery.refetch();
- console.log('🔄 Development refetch result:', {
- success: result.isSuccess,
- hasData: !!result.data,
- userId: result.data?.id
- });
+ if (import.meta.env.DEV) {
+ console.log('🔄 Development refetch result:', {
+ success: result.isSuccess,
+ hasData: !!result.data,
+ userId: result.data?.id
+ });
+ }
return result.data;
}
};
@@ -128,7 +152,9 @@ export function useAuthUnified() {
const checkAuth = async () => {
try {
- console.log('🔄 Production auth check starting, refreshTrigger:', refreshTrigger);
+ if (import.meta.env.DEV) {
+ console.log('🔄 Production auth check starting, refreshTrigger:', refreshTrigger);
+ }
setProductionLoading(true);
const response = await fetch('/api/user', {
@@ -140,19 +166,25 @@ export function useAuthUnified() {
}
});
- console.log('🔄 Production auth response:', response.status);
+ if (import.meta.env.DEV) {
+ console.log('🔄 Production auth response:', response.status);
+ }
if (!isMounted) return;
if (response.ok) {
const userData = await response.json();
- console.log('✅ Production auth success:', { username: userData?.username, id: userData?.id });
+ if (import.meta.env.DEV) {
+ console.log('✅ Production auth success:', { username: userData?.username, id: userData?.id });
+ }
if (isMounted) {
setProductionUser(userData);
setProductionError(null);
}
} else if (response.status === 401) {
- console.log('❌ Production auth 401 - user not authenticated');
+ if (import.meta.env.DEV) {
+ console.log('❌ Production auth 401 - user not authenticated');
+ }
if (isMounted) {
setProductionUser(null);
setProductionError(null);
@@ -161,14 +193,18 @@ export function useAuthUnified() {
throw new Error(`Auth failed: ${response.status}`);
}
} catch (err) {
- console.error('Production auth error:', err);
+ if (import.meta.env.DEV) {
+ console.error('Production auth error:', err);
+ }
if (isMounted) {
setProductionError(err);
setProductionUser(null);
}
} finally {
if (isMounted) {
- console.log('🔄 Production auth check complete, loading set to false');
+ if (import.meta.env.DEV) {
+ console.log('🔄 Production auth check complete, loading set to false');
+ }
setProductionLoading(false);
}
}
diff --git a/client/src/pages/AuthPage.tsx b/client/src/pages/AuthPage.tsx
index 56baf19..e4ebdb7 100644
--- a/client/src/pages/AuthPage.tsx
+++ b/client/src/pages/AuthPage.tsx
@@ -95,7 +95,9 @@ export default function AuthPage() {
return response;
},
onSuccess: async (loginResult) => {
- console.log('✅ Login successful, refreshing auth state...');
+ if (import.meta.env.DEV) {
+ console.log('✅ Login successful, refreshing auth state...');
+ }
toast({
title: "Connexion réussie",
@@ -108,10 +110,14 @@ export default function AuthPage() {
// Force immediate authentication state refresh
const refreshedUserData = await forceAuthRefresh();
- console.log('🔄 Force auth refresh result:', refreshedUserData);
+ if (import.meta.env.DEV) {
+ console.log('🔄 Force auth refresh result:', refreshedUserData);
+ }
if (refreshedUserData && refreshedUserData.id) {
- console.log('🔄 User data confirmed, forcing redirect...');
+ if (import.meta.env.DEV) {
+ console.log('🔄 User data confirmed, forcing redirect...');
+ }
setLocation("/");
} else {
setTimeout(() => {
@@ -133,12 +139,14 @@ export default function AuthPage() {
});
// Debug logging for authentication state
- console.log('🔍 AuthPage Debug:', {
- isAuthenticated,
- isLoading,
- userId: user?.id,
- username: user?.username
- });
+ if (import.meta.env.DEV) {
+ console.log('🔍 AuthPage Debug:', {
+ isAuthenticated,
+ isLoading,
+ userId: user?.id,
+ username: user?.username
+ });
+ }
useEffect(() => {
if (defaultCredentialsCheck) {
@@ -149,7 +157,9 @@ export default function AuthPage() {
// Redirect if already authenticated
useEffect(() => {
if (!isLoading && isAuthenticated && user) {
- console.log('🔄 User authenticated, redirecting to dashboard...', { user: user.username, authenticated: isAuthenticated });
+ if (import.meta.env.DEV) {
+ console.log('🔄 User authenticated, redirecting to dashboard...', { user: user.username, authenticated: isAuthenticated });
+ }
// Force immediate redirect to home page
setLocation("/");
}
diff --git a/client/src/pages/BLReconciliation.tsx b/client/src/pages/BLReconciliation.tsx
index 7c43089..4018ba4 100644
--- a/client/src/pages/BLReconciliation.tsx
+++ b/client/src/pages/BLReconciliation.tsx
@@ -628,23 +628,24 @@ export default function BLReconciliation() {
// Filtrage des livraisons par recherche et statut de validation
const filterDeliveries = (deliveries: any[]) => {
- // Debug temporaire pour production
+ // Debug temporaire pour identifier le problème
if (deliveries.length > 0 && filterStatus !== "all") {
- console.log('🔍 DEBUG Filtre Production:', {
+ console.log('🔍 DEBUG Filtre:', {
filterStatus,
totalDeliveries: deliveries.length,
- firstDelivery: {
- id: deliveries[0].id,
- reconciled: deliveries[0].reconciled,
- type: typeof deliveries[0].reconciled,
- rawValue: JSON.stringify(deliveries[0].reconciled)
- }
+ exemples: deliveries.slice(0, 3).map(d => ({
+ id: d.id,
+ reconciled: d.reconciled,
+ type: typeof d.reconciled,
+ rawValue: JSON.stringify(d.reconciled),
+ supplier: d.supplier?.name
+ }))
});
}
return deliveries.filter((delivery: any) => {
// Conversion sûre de reconciled - gestion de tous les cas possibles
- // PostgreSQL peut retourner : true/false, 1/0, "t"/"f", "true"/"false"
+ // PostgreSQL peut retourner : true/false, 1/0, "t"/"f", "true"/"false", null, undefined
const isReconciled =
delivery.reconciled === true ||
delivery.reconciled === 1 ||
@@ -652,12 +653,31 @@ export default function BLReconciliation() {
delivery.reconciled === "true" ||
(typeof delivery.reconciled === 'string' && delivery.reconciled.toLowerCase() === 'true');
- // Filtre par statut validé
- if (filterStatus === "validated" && !isReconciled) {
- return false;
+ // Filtre par statut validé - avec debug pour chaque élément filtré
+ if (filterStatus === "validated") {
+ const keep = isReconciled;
+ if (!keep && delivery.blNumber) {
+ console.log(`❌ Filtré (non validé):`, {
+ id: delivery.id,
+ bl: delivery.blNumber,
+ reconciled: delivery.reconciled,
+ isReconciled
+ });
+ }
+ return keep;
}
- if (filterStatus === "not_validated" && isReconciled) {
- return false;
+
+ if (filterStatus === "not_validated") {
+ const keep = !isReconciled;
+ if (!keep && delivery.blNumber) {
+ console.log(`❌ Filtré (validé):`, {
+ id: delivery.id,
+ bl: delivery.blNumber,
+ reconciled: delivery.reconciled,
+ isReconciled
+ });
+ }
+ return keep;
}
// Filtre par recherche