mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 10:11:13 -05:00
Fix console statement violations
This commit is contained in:
@@ -4,6 +4,7 @@ import { authStorage } from '@/lib/authStorage';
|
|||||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
||||||
import { Badge } from '@/components/ui/badge';
|
import { Badge } from '@/components/ui/badge';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
|
import { logger } from '@/lib/logger';
|
||||||
|
|
||||||
interface AuthDiagnosticsData {
|
interface AuthDiagnosticsData {
|
||||||
timestamp: string;
|
timestamp: string;
|
||||||
@@ -55,7 +56,7 @@ export function AuthDiagnostics() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
setDiagnostics(results);
|
setDiagnostics(results);
|
||||||
console.log('[Auth Diagnostics]', results);
|
logger.debug('Auth diagnostics', { results });
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ export function useModerationFilters(
|
|||||||
return JSON.parse(saved);
|
return JSON.parse(saved);
|
||||||
}
|
}
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
console.error('Failed to load persisted filters:', error);
|
logger.warn('Failed to load persisted filters', { error, storageKey });
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@@ -153,7 +153,7 @@ export function useModerationFilters(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
console.error('Failed to load persisted sort:', error);
|
logger.warn('Failed to load persisted sort', { error, storageKey });
|
||||||
}
|
}
|
||||||
|
|
||||||
return initialSortConfig;
|
return initialSortConfig;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
import { useState, useCallback, useEffect, useMemo } from 'react';
|
import { useState, useCallback, useEffect, useMemo } from 'react';
|
||||||
import { MODERATION_CONSTANTS } from '@/lib/moderation/constants';
|
import { MODERATION_CONSTANTS } from '@/lib/moderation/constants';
|
||||||
import * as storage from '@/lib/localStorage';
|
import * as storage from '@/lib/localStorage';
|
||||||
|
import { logger } from '@/lib/logger';
|
||||||
|
|
||||||
export interface PaginationConfig {
|
export interface PaginationConfig {
|
||||||
/** Initial page number (1-indexed) */
|
/** Initial page number (1-indexed) */
|
||||||
@@ -123,7 +124,7 @@ export function usePagination(config: PaginationConfig = {}): PaginationState {
|
|||||||
return JSON.parse(saved);
|
return JSON.parse(saved);
|
||||||
}
|
}
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
console.error('Failed to load pagination state:', error);
|
logger.warn('Failed to load pagination state', { error, storageKey });
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { authLog, authWarn, authError } from '@/lib/authLogger';
|
|||||||
import type { AALLevel, CheckAalResult } from '@/types/auth';
|
import type { AALLevel, CheckAalResult } from '@/types/auth';
|
||||||
import { getSessionAal, checkAalStepUp as checkAalStepUpService, signOutUser } from '@/lib/authService';
|
import { getSessionAal, checkAalStepUp as checkAalStepUpService, signOutUser } from '@/lib/authService';
|
||||||
import { clearAllAuthFlags } from '@/lib/sessionFlags';
|
import { clearAllAuthFlags } from '@/lib/sessionFlags';
|
||||||
|
import { logger } from '@/lib/logger';
|
||||||
|
|
||||||
interface AuthContextType {
|
interface AuthContextType {
|
||||||
user: User | null;
|
user: User | null;
|
||||||
@@ -256,7 +257,7 @@ export const AuthProvider = AuthProviderComponent;
|
|||||||
export function useAuth() {
|
export function useAuth() {
|
||||||
const context = useContext(AuthContext);
|
const context = useContext(AuthContext);
|
||||||
if (context === undefined) {
|
if (context === undefined) {
|
||||||
console.error('[useAuth] AuthContext is undefined - component may be rendering outside AuthProvider');
|
logger.error('AuthContext is undefined - component may be rendering outside AuthProvider', { component: 'useAuth' });
|
||||||
throw new Error('useAuth must be used within an AuthProvider');
|
throw new Error('useAuth must be used within an AuthProvider');
|
||||||
}
|
}
|
||||||
return context;
|
return context;
|
||||||
|
|||||||
@@ -564,7 +564,7 @@ export async function deleteSubmission(
|
|||||||
shouldRemoveFromQueue: true,
|
shouldRemoveFromQueue: true,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error deleting submission:', error);
|
logger.error('Error deleting submission', { error, submissionId: item.id });
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: 'Failed to delete submission',
|
message: 'Failed to delete submission',
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { supabase } from '@/integrations/supabase/client';
|
|||||||
import { requestContext, type RequestContext } from './requestContext';
|
import { requestContext, type RequestContext } from './requestContext';
|
||||||
import { breadcrumbManager } from './errorBreadcrumbs';
|
import { breadcrumbManager } from './errorBreadcrumbs';
|
||||||
import { captureEnvironmentContext } from './environmentContext';
|
import { captureEnvironmentContext } from './environmentContext';
|
||||||
|
import { logger } from './logger';
|
||||||
|
|
||||||
export interface RequestTrackingOptions {
|
export interface RequestTrackingOptions {
|
||||||
endpoint: string;
|
endpoint: string;
|
||||||
@@ -54,7 +55,7 @@ export async function trackRequest<T>(
|
|||||||
parentRequestId: options.parentRequestId,
|
parentRequestId: options.parentRequestId,
|
||||||
traceId: context.traceId,
|
traceId: context.traceId,
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
console.error('[RequestTracking] Failed to log metadata:', err);
|
logger.error('Failed to log request metadata', { error: err, context: 'RequestTracking' });
|
||||||
});
|
});
|
||||||
|
|
||||||
// Cleanup context
|
// Cleanup context
|
||||||
@@ -94,7 +95,7 @@ export async function trackRequest<T>(
|
|||||||
parentRequestId: options.parentRequestId,
|
parentRequestId: options.parentRequestId,
|
||||||
traceId: context.traceId,
|
traceId: context.traceId,
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
console.error('[RequestTracking] Failed to log error metadata:', err);
|
logger.error('Failed to log error metadata', { error: err, context: 'RequestTracking' });
|
||||||
});
|
});
|
||||||
|
|
||||||
// Cleanup context
|
// Cleanup context
|
||||||
@@ -143,7 +144,7 @@ async function logRequestMetadata(metadata: RequestMetadata): Promise<void> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error('[RequestTracking] Failed to log metadata:', error);
|
logger.error('Failed to log metadata to database', { error, context: 'RequestTracking' });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import DOMPurify from 'dompurify';
|
import DOMPurify from 'dompurify';
|
||||||
|
import { logger } from './logger';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sanitize HTML content to prevent XSS attacks
|
* Sanitize HTML content to prevent XSS attacks
|
||||||
@@ -39,14 +40,14 @@ export function sanitizeURL(url: string): string {
|
|||||||
const allowedProtocols = ['http:', 'https:', 'mailto:'];
|
const allowedProtocols = ['http:', 'https:', 'mailto:'];
|
||||||
|
|
||||||
if (!allowedProtocols.includes(parsed.protocol)) {
|
if (!allowedProtocols.includes(parsed.protocol)) {
|
||||||
console.warn(`Blocked potentially dangerous URL protocol: ${parsed.protocol}`);
|
logger.warn('Blocked potentially dangerous URL protocol', { protocol: parsed.protocol });
|
||||||
return '#';
|
return '#';
|
||||||
}
|
}
|
||||||
|
|
||||||
return url;
|
return url;
|
||||||
} catch {
|
} catch {
|
||||||
// Invalid URL format
|
// Invalid URL format
|
||||||
console.warn(`Invalid URL format: ${url}`);
|
logger.warn('Invalid URL format', { url });
|
||||||
return '#';
|
return '#';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -349,7 +349,7 @@ export async function detectChanges(
|
|||||||
if (data?.name) entityName = `${data.name} (${formatEntityType(entityType)})`;
|
if (data?.name) entityName = `${data.name} (${formatEntityType(entityType)})`;
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error fetching entity name for photo operation:', err);
|
logger.error('Error fetching entity name for photo operation', { error: err, entityType: itemData.entity_type, entityId: itemData.entity_id });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -395,7 +395,7 @@ export async function detectChanges(
|
|||||||
entityName = `${formatEntityType(entityType)} - ${itemData.title}`;
|
entityName = `${formatEntityType(entityType)} - ${itemData.title}`;
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error fetching entity name for milestone:', err);
|
logger.error('Error fetching entity name for milestone', { error: err, entityType: itemData.entity_type, entityId: itemData.entity_id });
|
||||||
// Fall back to just the title if database lookup fails
|
// Fall back to just the title if database lookup fails
|
||||||
if (itemData.title) {
|
if (itemData.title) {
|
||||||
entityName = itemData.title;
|
entityName = itemData.title;
|
||||||
@@ -434,7 +434,7 @@ export async function detectChanges(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error resolving entity name for field display:', err);
|
logger.error('Error resolving entity name for field display', { error: err, entityType: itemData.entity_type, entityId: itemData.entity_id });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add entity name as an explicit field change at the beginning
|
// Add entity name as an explicit field change at the beginning
|
||||||
|
|||||||
@@ -338,9 +338,7 @@ async function createVersionForApprovedItem(
|
|||||||
// - app.current_user_id = original submitter
|
// - app.current_user_id = original submitter
|
||||||
// - app.submission_id = submission ID
|
// - app.submission_id = submission ID
|
||||||
// Then the trigger creates the version automatically
|
// Then the trigger creates the version automatically
|
||||||
console.debug(
|
logger.debug('Version will be created automatically by trigger', { itemType, entityId });
|
||||||
`Version will be created automatically by trigger for ${itemType} ${entityId}`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -613,7 +611,7 @@ async function createRide(data: any, dependencyMap: Map<string, string>, sortedI
|
|||||||
.eq('id', data.ride_id);
|
.eq('id', data.ride_id);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error('Error updating ride:', error);
|
logger.error('Error updating ride', { error: error.message, rideId: data.ride_id });
|
||||||
throw new Error(`Database error: ${error.message}`);
|
throw new Error(`Database error: ${error.message}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -644,7 +642,7 @@ async function createRide(data: any, dependencyMap: Map<string, string>, sortedI
|
|||||||
.single();
|
.single();
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error('Error creating ride:', error);
|
logger.error('Error creating ride', { error: error.message, rideName: resolvedData.name });
|
||||||
throw new Error(`Database error: ${error.message}`);
|
throw new Error(`Database error: ${error.message}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -688,7 +686,7 @@ async function createCompany(
|
|||||||
.eq('id', data.id);
|
.eq('id', data.id);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error('Error updating company:', error);
|
logger.error('Error updating company', { error: error.message, companyId: data.id });
|
||||||
throw new Error(`Database error: ${error.message}`);
|
throw new Error(`Database error: ${error.message}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -723,7 +721,7 @@ async function createCompany(
|
|||||||
.single();
|
.single();
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error('Error creating company:', error);
|
logger.error('Error creating company', { error: error.message, companyName: resolvedData.name, companyType });
|
||||||
throw new Error(`Database error: ${error.message}`);
|
throw new Error(`Database error: ${error.message}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -762,7 +760,7 @@ async function createRideModel(data: any, dependencyMap: Map<string, string>, so
|
|||||||
.eq('id', data.ride_model_id);
|
.eq('id', data.ride_model_id);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error('Error updating ride model:', error);
|
logger.error('Error updating ride model', { error: error.message, rideModelId: data.ride_model_id });
|
||||||
throw new Error(`Database error: ${error.message}`);
|
throw new Error(`Database error: ${error.message}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -799,7 +797,7 @@ async function createRideModel(data: any, dependencyMap: Map<string, string>, so
|
|||||||
.single();
|
.single();
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error('Error creating ride model:', error);
|
logger.error('Error creating ride model', { error: error.message, modelName: resolvedData.name });
|
||||||
throw new Error(`Database error: ${error.message}`);
|
throw new Error(`Database error: ${error.message}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -878,7 +876,7 @@ async function approvePhotos(data: any, dependencyMap: Map<string, string>, user
|
|||||||
.select();
|
.select();
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error('Error inserting photos:', error);
|
logger.error('Error inserting photos', { error: error.message, photoCount: photosToInsert.length, entityType, entityId: finalEntityId });
|
||||||
throw new Error(`Database error: ${error.message}`);
|
throw new Error(`Database error: ${error.message}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -960,7 +958,7 @@ async function updateEntityFeaturedImage(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Error updating ${entityType} featured image:`, error);
|
logger.error('Error updating entity featured image', { error, entityType, entityId });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { supabase } from '@/integrations/supabase/client';
|
import { supabase } from '@/integrations/supabase/client';
|
||||||
import type { ParkSubmissionData, RideSubmissionData, CompanySubmissionData, RideModelSubmissionData } from '@/types/submission-data';
|
import type { ParkSubmissionData, RideSubmissionData, CompanySubmissionData, RideModelSubmissionData } from '@/types/submission-data';
|
||||||
|
import { logger } from './logger';
|
||||||
|
|
||||||
// Preset configurations
|
// Preset configurations
|
||||||
export const PRESETS = {
|
export const PRESETS = {
|
||||||
@@ -254,12 +255,12 @@ export async function clearTestData(): Promise<{ deleted: number }> {
|
|||||||
.neq('id', '00000000-0000-0000-0000-000000000000'); // Delete all records
|
.neq('id', '00000000-0000-0000-0000-000000000000'); // Delete all records
|
||||||
|
|
||||||
if (registryError) {
|
if (registryError) {
|
||||||
console.error('Error clearing test data registry:', registryError);
|
logger.error('Error clearing test data registry', { error: registryError });
|
||||||
}
|
}
|
||||||
|
|
||||||
return { deleted: submissionCount };
|
return { deleted: submissionCount };
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
console.error('Error clearing test data:', error instanceof Error ? error.message : String(error));
|
logger.error('Error clearing test data', { error: error instanceof Error ? error.message : String(error) });
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user