mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 08: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 { Badge } from '@/components/ui/badge';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { logger } from '@/lib/logger';
|
||||
|
||||
interface AuthDiagnosticsData {
|
||||
timestamp: string;
|
||||
@@ -55,7 +56,7 @@ export function AuthDiagnostics() {
|
||||
};
|
||||
|
||||
setDiagnostics(results);
|
||||
console.log('[Auth Diagnostics]', results);
|
||||
logger.debug('Auth diagnostics', { results });
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -134,7 +134,7 @@ export function useModerationFilters(
|
||||
return JSON.parse(saved);
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
console.error('Failed to load persisted filters:', error);
|
||||
logger.warn('Failed to load persisted filters', { error, storageKey });
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -153,7 +153,7 @@ export function useModerationFilters(
|
||||
}
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
console.error('Failed to load persisted sort:', error);
|
||||
logger.warn('Failed to load persisted sort', { error, storageKey });
|
||||
}
|
||||
|
||||
return initialSortConfig;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import { useState, useCallback, useEffect, useMemo } from 'react';
|
||||
import { MODERATION_CONSTANTS } from '@/lib/moderation/constants';
|
||||
import * as storage from '@/lib/localStorage';
|
||||
import { logger } from '@/lib/logger';
|
||||
|
||||
export interface PaginationConfig {
|
||||
/** Initial page number (1-indexed) */
|
||||
@@ -123,7 +124,7 @@ export function usePagination(config: PaginationConfig = {}): PaginationState {
|
||||
return JSON.parse(saved);
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
console.error('Failed to load pagination state:', error);
|
||||
logger.warn('Failed to load pagination state', { error, storageKey });
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -7,6 +7,7 @@ import { authLog, authWarn, authError } from '@/lib/authLogger';
|
||||
import type { AALLevel, CheckAalResult } from '@/types/auth';
|
||||
import { getSessionAal, checkAalStepUp as checkAalStepUpService, signOutUser } from '@/lib/authService';
|
||||
import { clearAllAuthFlags } from '@/lib/sessionFlags';
|
||||
import { logger } from '@/lib/logger';
|
||||
|
||||
interface AuthContextType {
|
||||
user: User | null;
|
||||
@@ -256,7 +257,7 @@ export const AuthProvider = AuthProviderComponent;
|
||||
export function useAuth() {
|
||||
const context = useContext(AuthContext);
|
||||
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');
|
||||
}
|
||||
return context;
|
||||
|
||||
@@ -564,7 +564,7 @@ export async function deleteSubmission(
|
||||
shouldRemoveFromQueue: true,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Error deleting submission:', error);
|
||||
logger.error('Error deleting submission', { error, submissionId: item.id });
|
||||
return {
|
||||
success: false,
|
||||
message: 'Failed to delete submission',
|
||||
|
||||
@@ -7,6 +7,7 @@ import { supabase } from '@/integrations/supabase/client';
|
||||
import { requestContext, type RequestContext } from './requestContext';
|
||||
import { breadcrumbManager } from './errorBreadcrumbs';
|
||||
import { captureEnvironmentContext } from './environmentContext';
|
||||
import { logger } from './logger';
|
||||
|
||||
export interface RequestTrackingOptions {
|
||||
endpoint: string;
|
||||
@@ -54,7 +55,7 @@ export async function trackRequest<T>(
|
||||
parentRequestId: options.parentRequestId,
|
||||
traceId: context.traceId,
|
||||
}).catch(err => {
|
||||
console.error('[RequestTracking] Failed to log metadata:', err);
|
||||
logger.error('Failed to log request metadata', { error: err, context: 'RequestTracking' });
|
||||
});
|
||||
|
||||
// Cleanup context
|
||||
@@ -94,7 +95,7 @@ export async function trackRequest<T>(
|
||||
parentRequestId: options.parentRequestId,
|
||||
traceId: context.traceId,
|
||||
}).catch(err => {
|
||||
console.error('[RequestTracking] Failed to log error metadata:', err);
|
||||
logger.error('Failed to log error metadata', { error: err, context: 'RequestTracking' });
|
||||
});
|
||||
|
||||
// Cleanup context
|
||||
@@ -143,7 +144,7 @@ async function logRequestMetadata(metadata: RequestMetadata): Promise<void> {
|
||||
});
|
||||
|
||||
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 { logger } from './logger';
|
||||
|
||||
/**
|
||||
* Sanitize HTML content to prevent XSS attacks
|
||||
@@ -39,14 +40,14 @@ export function sanitizeURL(url: string): string {
|
||||
const allowedProtocols = ['http:', 'https:', 'mailto:'];
|
||||
|
||||
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 url;
|
||||
} catch {
|
||||
// Invalid URL format
|
||||
console.warn(`Invalid URL format: ${url}`);
|
||||
logger.warn('Invalid URL format', { url });
|
||||
return '#';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -349,7 +349,7 @@ export async function detectChanges(
|
||||
if (data?.name) entityName = `${data.name} (${formatEntityType(entityType)})`;
|
||||
}
|
||||
} 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}`;
|
||||
}
|
||||
} 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
|
||||
if (itemData.title) {
|
||||
entityName = itemData.title;
|
||||
@@ -434,7 +434,7 @@ export async function detectChanges(
|
||||
}
|
||||
}
|
||||
} 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
|
||||
|
||||
@@ -338,9 +338,7 @@ async function createVersionForApprovedItem(
|
||||
// - app.current_user_id = original submitter
|
||||
// - app.submission_id = submission ID
|
||||
// Then the trigger creates the version automatically
|
||||
console.debug(
|
||||
`Version will be created automatically by trigger for ${itemType} ${entityId}`
|
||||
);
|
||||
logger.debug('Version will be created automatically by trigger', { itemType, entityId });
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -613,7 +611,7 @@ async function createRide(data: any, dependencyMap: Map<string, string>, sortedI
|
||||
.eq('id', data.ride_id);
|
||||
|
||||
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}`);
|
||||
}
|
||||
|
||||
@@ -644,7 +642,7 @@ async function createRide(data: any, dependencyMap: Map<string, string>, sortedI
|
||||
.single();
|
||||
|
||||
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}`);
|
||||
}
|
||||
|
||||
@@ -688,7 +686,7 @@ async function createCompany(
|
||||
.eq('id', data.id);
|
||||
|
||||
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}`);
|
||||
}
|
||||
|
||||
@@ -723,7 +721,7 @@ async function createCompany(
|
||||
.single();
|
||||
|
||||
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}`);
|
||||
}
|
||||
|
||||
@@ -762,7 +760,7 @@ async function createRideModel(data: any, dependencyMap: Map<string, string>, so
|
||||
.eq('id', data.ride_model_id);
|
||||
|
||||
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}`);
|
||||
}
|
||||
|
||||
@@ -799,7 +797,7 @@ async function createRideModel(data: any, dependencyMap: Map<string, string>, so
|
||||
.single();
|
||||
|
||||
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}`);
|
||||
}
|
||||
|
||||
@@ -878,7 +876,7 @@ async function approvePhotos(data: any, dependencyMap: Map<string, string>, user
|
||||
.select();
|
||||
|
||||
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}`);
|
||||
}
|
||||
|
||||
@@ -960,7 +958,7 @@ async function updateEntityFeaturedImage(
|
||||
}
|
||||
}
|
||||
} 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 type { ParkSubmissionData, RideSubmissionData, CompanySubmissionData, RideModelSubmissionData } from '@/types/submission-data';
|
||||
import { logger } from './logger';
|
||||
|
||||
// Preset configurations
|
||||
export const PRESETS = {
|
||||
@@ -254,12 +255,12 @@ export async function clearTestData(): Promise<{ deleted: number }> {
|
||||
.neq('id', '00000000-0000-0000-0000-000000000000'); // Delete all records
|
||||
|
||||
if (registryError) {
|
||||
console.error('Error clearing test data registry:', registryError);
|
||||
logger.error('Error clearing test data registry', { error: registryError });
|
||||
}
|
||||
|
||||
return { deleted: submissionCount };
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user