mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 10:31:13 -05:00
Continue console cleanup
This commit is contained in:
@@ -35,6 +35,8 @@ import { getCloudflareImageUrl } from '@/lib/cloudflareImageUtils';
|
||||
import { useAutoSave } from '@/hooks/useAutoSave';
|
||||
import { CheckCircle2, Loader2, AlertCircle } from 'lucide-react';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { logger } from '@/lib/logger';
|
||||
|
||||
interface MarkdownEditorProps {
|
||||
value: string;
|
||||
@@ -155,7 +157,7 @@ export function MarkdownEditor({
|
||||
|
||||
return imageUrl;
|
||||
} catch (error: unknown) {
|
||||
console.error('Image upload failed:', error);
|
||||
logger.error('Image upload failed', { error: getErrorMessage(error) });
|
||||
throw new Error(error instanceof Error ? error.message : 'Failed to upload image');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,8 @@ import {
|
||||
ReviewLifecycleDetails,
|
||||
SubmissionWorkflowDetails
|
||||
} from '@/lib/systemActivityService';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { logger } from '@/lib/logger';
|
||||
|
||||
export interface SystemActivityLogRef {
|
||||
refresh: () => Promise<void>;
|
||||
@@ -192,7 +194,7 @@ export const SystemActivityLog = forwardRef<SystemActivityLogRef, SystemActivity
|
||||
});
|
||||
setActivities(data);
|
||||
} catch (error: unknown) {
|
||||
console.error('Error loading system activities:', error);
|
||||
logger.error('Failed to load system activities', { error: getErrorMessage(error) });
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
setIsRefreshing(false);
|
||||
|
||||
@@ -14,6 +14,7 @@ import { useToast } from '@/hooks/use-toast';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { Beaker, CheckCircle, ChevronDown, Trash2, AlertTriangle } from 'lucide-react';
|
||||
import { clearTestData, getTestDataStats } from '@/lib/testDataGenerator';
|
||||
import { logger } from '@/lib/logger';
|
||||
|
||||
const PRESETS = {
|
||||
small: { label: 'Small', description: '~30 submissions - Quick test', counts: '5 parks, 10 rides, 3 companies, 2 models, 5 photo sets' },
|
||||
@@ -89,7 +90,7 @@ export function TestDataGenerator() {
|
||||
const data = await getTestDataStats();
|
||||
setStats(data);
|
||||
} catch (error: unknown) {
|
||||
console.error('Failed to load stats:', error);
|
||||
logger.error('Failed to load test data stats', { error: getErrorMessage(error) });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -151,7 +152,6 @@ export function TestDataGenerator() {
|
||||
|
||||
await loadStats();
|
||||
} catch (error: unknown) {
|
||||
console.error('Generation error:', error);
|
||||
toast({
|
||||
title: "Generation failed",
|
||||
description: getErrorMessage(error),
|
||||
@@ -175,7 +175,6 @@ export function TestDataGenerator() {
|
||||
});
|
||||
setResults(null);
|
||||
} catch (error: unknown) {
|
||||
console.error('Clear error:', error);
|
||||
toast({
|
||||
title: 'Clear Failed',
|
||||
description: getErrorMessage(error),
|
||||
|
||||
@@ -16,6 +16,8 @@ import { MFAChallenge } from './MFAChallenge';
|
||||
import { verifyMfaUpgrade } from '@/lib/authService';
|
||||
import { setAuthMethod } from '@/lib/sessionFlags';
|
||||
import { validateEmailNotDisposable } from '@/lib/emailValidation';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { logger } from '@/lib/logger';
|
||||
|
||||
interface AuthModalProps {
|
||||
open: boolean;
|
||||
@@ -241,7 +243,7 @@ export function AuthModal({ open, onOpenChange, defaultTab = 'signin' }: AuthMod
|
||||
username: formData.username,
|
||||
}
|
||||
}).catch(err => {
|
||||
console.error('Failed to register Novu subscriber:', err);
|
||||
logger.error('Failed to register Novu subscriber', { error: getErrorMessage(err) });
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { supabase } from '@/integrations/supabase/client';
|
||||
import { invokeWithTracking } from '@/lib/edgeFunctionTracking';
|
||||
import { toast } from 'sonner';
|
||||
import { getSessionAAL } from '@/types/supabase-session';
|
||||
import { useToast } from '@/hooks/use-toast';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { useRequireMFA } from '@/hooks/useRequireMFA';
|
||||
import {
|
||||
@@ -30,6 +29,7 @@ interface MFARemovalDialogProps {
|
||||
|
||||
export function MFARemovalDialog({ open, onOpenChange, factorId, onSuccess }: MFARemovalDialogProps) {
|
||||
const { requiresMFA } = useRequireMFA();
|
||||
const { toast } = useToast();
|
||||
const [step, setStep] = useState<'password' | 'totp' | 'confirm'>('password');
|
||||
const [password, setPassword] = useState('');
|
||||
const [totpCode, setTotpCode] = useState('');
|
||||
@@ -43,7 +43,11 @@ export function MFARemovalDialog({ open, onOpenChange, factorId, onSuccess }: MF
|
||||
const currentAal = getSessionAAL(session);
|
||||
|
||||
if (currentAal !== 'aal2') {
|
||||
toast.error('Please verify your identity with MFA before making security changes');
|
||||
toast({
|
||||
title: 'MFA Required',
|
||||
description: 'Please verify your identity with MFA before making security changes',
|
||||
variant: 'destructive'
|
||||
});
|
||||
onOpenChange(false);
|
||||
}
|
||||
};
|
||||
@@ -62,7 +66,11 @@ export function MFARemovalDialog({ open, onOpenChange, factorId, onSuccess }: MF
|
||||
|
||||
const handlePasswordVerification = async () => {
|
||||
if (!password.trim()) {
|
||||
toast.error('Please enter your password');
|
||||
toast({
|
||||
title: 'Password Required',
|
||||
description: 'Please enter your password',
|
||||
variant: 'destructive'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -80,10 +88,12 @@ export function MFARemovalDialog({ open, onOpenChange, factorId, onSuccess }: MF
|
||||
|
||||
if (error) throw error;
|
||||
|
||||
toast.success('Password verified');
|
||||
toast({
|
||||
title: 'Password Verified',
|
||||
description: 'Password verified successfully'
|
||||
});
|
||||
setStep('totp');
|
||||
} catch (error: unknown) {
|
||||
console.error('Password verification failed:', error);
|
||||
toast.error(getErrorMessage(error));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -92,7 +102,11 @@ export function MFARemovalDialog({ open, onOpenChange, factorId, onSuccess }: MF
|
||||
|
||||
const handleTOTPVerification = async () => {
|
||||
if (!totpCode.trim() || totpCode.length !== 6) {
|
||||
toast.error('Please enter a valid 6-digit code');
|
||||
toast({
|
||||
title: 'Invalid Code',
|
||||
description: 'Please enter a valid 6-digit code',
|
||||
variant: 'destructive'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -122,10 +136,12 @@ export function MFARemovalDialog({ open, onOpenChange, factorId, onSuccess }: MF
|
||||
throw new Error('Session must be at AAL2 to remove MFA');
|
||||
}
|
||||
|
||||
toast.success('TOTP code verified');
|
||||
toast({
|
||||
title: 'Code Verified',
|
||||
description: 'TOTP code verified successfully'
|
||||
});
|
||||
setStep('confirm');
|
||||
} catch (error: unknown) {
|
||||
console.error('TOTP verification failed:', error);
|
||||
toast.error(getErrorMessage(error));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -135,7 +151,11 @@ export function MFARemovalDialog({ open, onOpenChange, factorId, onSuccess }: MF
|
||||
const handleMFARemoval = async () => {
|
||||
// Phase 2: Check if user's role requires MFA
|
||||
if (requiresMFA) {
|
||||
toast.error('Your role requires two-factor authentication and it cannot be disabled');
|
||||
toast({
|
||||
title: 'MFA Required',
|
||||
description: 'Your role requires two-factor authentication and it cannot be disabled',
|
||||
variant: 'destructive'
|
||||
});
|
||||
handleClose();
|
||||
return;
|
||||
}
|
||||
@@ -152,11 +172,13 @@ export function MFARemovalDialog({ open, onOpenChange, factorId, onSuccess }: MF
|
||||
if (error) throw error;
|
||||
if (data?.error) throw new Error(data.error);
|
||||
|
||||
toast.success('Two-factor authentication has been disabled');
|
||||
toast({
|
||||
title: 'MFA Disabled',
|
||||
description: 'Two-factor authentication has been disabled'
|
||||
});
|
||||
handleClose();
|
||||
onSuccess();
|
||||
} catch (error: unknown) {
|
||||
console.error('MFA removal failed:', error);
|
||||
toast.error(getErrorMessage(error));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
|
||||
@@ -6,6 +6,8 @@ import { RecentChangeCard } from './RecentChangeCard';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Park, Ride, ActivityEntry } from '@/types/database';
|
||||
import { supabase } from '@/integrations/supabase/client';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { logger } from '@/lib/logger';
|
||||
|
||||
export function ContentTabs() {
|
||||
const [trendingParks, setTrendingParks] = useState<Park[]>([]);
|
||||
@@ -92,7 +94,7 @@ export function ContentTabs() {
|
||||
setRecentChanges(processedChanges);
|
||||
setRecentlyOpened(combinedOpened);
|
||||
} catch (error: unknown) {
|
||||
console.error('Error fetching content:', error);
|
||||
logger.error('Failed to fetch content', { error: getErrorMessage(error) });
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ import { Badge } from '@/components/ui/badge';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Park } from '@/types/database';
|
||||
import { supabase } from '@/integrations/supabase/client';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { logger } from '@/lib/logger';
|
||||
|
||||
export function FeaturedParks() {
|
||||
const [topRatedParks, setTopRatedParks] = useState<Park[]>([]);
|
||||
@@ -42,7 +44,7 @@ export function FeaturedParks() {
|
||||
setTopRatedParks(topRated || []);
|
||||
setMostRidesParks(mostRides || []);
|
||||
} catch (error: unknown) {
|
||||
console.error('Error fetching featured parks:', error);
|
||||
logger.error('Failed to fetch featured parks', { error: getErrorMessage(error) });
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
@@ -82,10 +82,7 @@ export const EntityEditPreview = ({ submissionId, entityType, entityName }: Enti
|
||||
.eq('submission_id', submissionId)
|
||||
.order('order_index', { ascending: true });
|
||||
|
||||
if (error) {
|
||||
console.error('EntityEditPreview.fetchSubmissionItems: Failed to fetch submission items:', error);
|
||||
throw error;
|
||||
}
|
||||
if (error) throw error;
|
||||
|
||||
if (items && items.length > 0) {
|
||||
const firstItem = items[0];
|
||||
|
||||
@@ -4,6 +4,7 @@ import { TooltipProvider } from '@/components/ui/tooltip';
|
||||
import { useToast } from '@/hooks/use-toast';
|
||||
import { useUserRole } from '@/hooks/useUserRole';
|
||||
import { useAuth } from '@/hooks/useAuth';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { PhotoModal } from './PhotoModal';
|
||||
import { SubmissionReviewManager } from './SubmissionReviewManager';
|
||||
import { ItemEditDialog } from './ItemEditDialog';
|
||||
@@ -110,10 +111,9 @@ export const ModerationQueue = forwardRef<ModerationQueueRef, ModerationQueuePro
|
||||
});
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
console.error('Error fetching items for edit:', error);
|
||||
toast({
|
||||
title: 'Error',
|
||||
description: 'Failed to load submission items',
|
||||
description: getErrorMessage(error),
|
||||
variant: 'destructive',
|
||||
});
|
||||
}
|
||||
|
||||
@@ -51,7 +51,6 @@ export function PhotoSubmissionDisplay({ submissionId }: PhotoSubmissionDisplayP
|
||||
setPhotos(data || []);
|
||||
} catch (error: unknown) {
|
||||
const errorMsg = getErrorMessage(error);
|
||||
console.error('❌ PhotoSubmissionDisplay error:', errorMsg);
|
||||
setPhotos([]);
|
||||
setError(errorMsg);
|
||||
} finally {
|
||||
|
||||
@@ -10,7 +10,8 @@ import { Badge } from '@/components/ui/badge';
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
||||
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger } from '@/components/ui/alert-dialog';
|
||||
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
|
||||
import { handleError, handleSuccess } from '@/lib/errorHandler';
|
||||
import { handleError, handleSuccess, getErrorMessage } from '@/lib/errorHandler';
|
||||
import { logger } from '@/lib/logger';
|
||||
|
||||
interface UserProfile {
|
||||
id: string;
|
||||
@@ -100,7 +101,7 @@ export function ProfileManager() {
|
||||
_details: { banned: ban }
|
||||
});
|
||||
|
||||
if (logError) console.error('Error logging action:', logError);
|
||||
if (logError) logger.error('Failed to log admin action', { error: getErrorMessage(logError) });
|
||||
|
||||
handleSuccess('Success', `User ${ban ? 'banned' : 'unbanned'} successfully.`);
|
||||
|
||||
@@ -175,7 +176,7 @@ export function ProfileManager() {
|
||||
_details: { role: newRole, previous_roles: currentRoles }
|
||||
});
|
||||
|
||||
if (logError) console.error('Error logging action:', logError);
|
||||
if (logError) logger.error('Failed to log admin action', { error: getErrorMessage(logError) });
|
||||
|
||||
handleSuccess('Success', 'User role updated successfully.');
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import { Label } from '@/components/ui/label';
|
||||
import { supabase } from '@/integrations/supabase/client';
|
||||
import { useAuth } from '@/hooks/useAuth';
|
||||
import { useToast } from '@/hooks/use-toast';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
|
||||
interface ReportButtonProps {
|
||||
entityType: 'review' | 'profile' | 'content_submission';
|
||||
@@ -69,10 +70,9 @@ export function ReportButton({ entityType, entityId, className }: ReportButtonPr
|
||||
setReportType('');
|
||||
setReason('');
|
||||
} catch (error: unknown) {
|
||||
console.error('Error submitting report:', error);
|
||||
toast({
|
||||
title: "Error",
|
||||
description: "Failed to submit report. Please try again.",
|
||||
description: getErrorMessage(error),
|
||||
variant: "destructive",
|
||||
});
|
||||
} finally {
|
||||
|
||||
@@ -7,6 +7,7 @@ import { Alert, AlertDescription } from '@/components/ui/alert';
|
||||
import { AlertCircle, Loader2 } from 'lucide-react';
|
||||
import type { SubmissionItemData } from '@/types/submissions';
|
||||
import { logger } from '@/lib/logger';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
|
||||
interface SubmissionItemsListProps {
|
||||
submissionId: string;
|
||||
@@ -61,7 +62,7 @@ export const SubmissionItemsList = memo(function SubmissionItemsList({
|
||||
setItems((itemsData || []) as SubmissionItemData[]);
|
||||
setHasPhotos(photoData && photoData.length > 0);
|
||||
} catch (err) {
|
||||
console.error('Error fetching submission items:', err);
|
||||
logger.error('Failed to fetch submission items', { error: getErrorMessage(err) });
|
||||
setError('Failed to load submission details');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
|
||||
@@ -35,6 +35,7 @@ import { ItemEditDialog } from './ItemEditDialog';
|
||||
import { ValidationBlockerDialog } from './ValidationBlockerDialog';
|
||||
import { WarningConfirmDialog } from './WarningConfirmDialog';
|
||||
import { validateMultipleItems, ValidationResult } from '@/lib/entityValidationSchemas';
|
||||
import { logger } from '@/lib/logger';
|
||||
|
||||
interface SubmissionReviewManagerProps {
|
||||
submissionId: string;
|
||||
@@ -417,7 +418,7 @@ export function SubmissionReviewManager({
|
||||
);
|
||||
|
||||
if (error) {
|
||||
console.error('Edge function error:', error);
|
||||
logger.error('Edge function failed', { error: getErrorMessage(error) });
|
||||
// Fallback to direct database update if email fails
|
||||
await escalateSubmission(submissionId, reason, user.id);
|
||||
toast({
|
||||
|
||||
@@ -9,7 +9,8 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@
|
||||
import { supabase } from '@/integrations/supabase/client';
|
||||
import { useAuth } from '@/hooks/useAuth';
|
||||
import { useUserRole } from '@/hooks/useUserRole';
|
||||
import { handleError, handleSuccess } from '@/lib/errorHandler';
|
||||
import { handleError, handleSuccess, getErrorMessage } from '@/lib/errorHandler';
|
||||
import { logger } from '@/lib/logger';
|
||||
|
||||
// Type-safe role definitions
|
||||
const VALID_ROLES = ['admin', 'moderator', 'user'] as const;
|
||||
@@ -122,7 +123,7 @@ export function UserRoleManager() {
|
||||
const filteredResults = (data || []).filter(profile => !existingUserIds.includes(profile.user_id));
|
||||
setSearchResults(filteredResults);
|
||||
} catch (error: unknown) {
|
||||
console.error('Error searching users:', error);
|
||||
logger.error('User search failed', { error: getErrorMessage(error) });
|
||||
}
|
||||
};
|
||||
useEffect(() => {
|
||||
|
||||
@@ -8,6 +8,8 @@ import { Sheet, SheetContent, SheetTrigger, SheetHeader, SheetTitle } from '@/co
|
||||
import { ParkCard } from './ParkCard';
|
||||
import { Park } from '@/types/database';
|
||||
import { supabase } from '@/integrations/supabase/client';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { logger } from '@/lib/logger';
|
||||
|
||||
export function ParkGrid() {
|
||||
const [parks, setParks] = useState<Park[]>([]);
|
||||
@@ -41,7 +43,7 @@ export function ParkGrid() {
|
||||
if (error) throw error;
|
||||
setParks(data || []);
|
||||
} catch (error: unknown) {
|
||||
console.error('Error fetching parks:', error);
|
||||
logger.error('Failed to fetch featured parks', { error: getErrorMessage(error) });
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
@@ -69,7 +69,6 @@ export function AddRideCreditDialog({ userId, open, onOpenChange, onSuccess }: A
|
||||
onSuccess(data.id); // Pass the new ID
|
||||
onOpenChange(false);
|
||||
} catch (error: unknown) {
|
||||
console.error('Error adding credit:', error);
|
||||
toast.error(getErrorMessage(error));
|
||||
} finally {
|
||||
setSubmitting(false);
|
||||
|
||||
@@ -69,7 +69,6 @@ export function RideCreditCard({ credit, position, maxPosition, viewMode, isEdit
|
||||
// Optimistic update - pass specific changes
|
||||
onUpdate(credit.id, { ride_count: editCount });
|
||||
} catch (error: unknown) {
|
||||
console.error('Error updating count:', error);
|
||||
toast.error(getErrorMessage(error));
|
||||
} finally {
|
||||
setUpdating(false);
|
||||
@@ -92,7 +91,6 @@ export function RideCreditCard({ credit, position, maxPosition, viewMode, isEdit
|
||||
|
||||
toast.success('Ride count increased');
|
||||
} catch (error: unknown) {
|
||||
console.error('Error incrementing count:', error);
|
||||
toast.error(getErrorMessage(error));
|
||||
// Rollback on error
|
||||
onUpdate(credit.id, { ride_count: credit.ride_count });
|
||||
@@ -112,7 +110,6 @@ export function RideCreditCard({ credit, position, maxPosition, viewMode, isEdit
|
||||
await onReorder(credit.id, editPosition);
|
||||
toast.success('Position updated');
|
||||
} catch (error: unknown) {
|
||||
console.error('Error changing position:', error);
|
||||
toast.error(getErrorMessage(error));
|
||||
setEditPosition(position);
|
||||
}
|
||||
|
||||
@@ -44,11 +44,9 @@ export function UserBlockButton({ targetUserId, targetUsername, variant = 'outli
|
||||
|
||||
setReason('');
|
||||
} catch (error: unknown) {
|
||||
const errorMsg = getErrorMessage(error);
|
||||
console.error('Error blocking user:', errorMsg);
|
||||
toast({
|
||||
title: 'Error',
|
||||
description: 'Failed to block user',
|
||||
description: getErrorMessage(error),
|
||||
variant: 'destructive'
|
||||
});
|
||||
} finally {
|
||||
|
||||
@@ -94,7 +94,6 @@ export function UserReviewsList({ userId, reviewCount }: UserReviewsListProps) {
|
||||
if (error) throw error;
|
||||
setReviews(data || []);
|
||||
} catch (error: unknown) {
|
||||
console.error('Error fetching reviews:', error);
|
||||
toast.error(getErrorMessage(error));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
|
||||
@@ -15,6 +15,8 @@ import { toast } from '@/hooks/use-toast';
|
||||
import { PhotoUpload } from '@/components/upload/PhotoUpload';
|
||||
import { StarRating } from './StarRating';
|
||||
import { toDateOnly } from '@/lib/dateUtils';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { logger } from '@/lib/logger';
|
||||
const reviewSchema = z.object({
|
||||
rating: z.number().min(0.5).max(5).multipleOf(0.5),
|
||||
title: z.string().optional(),
|
||||
@@ -107,7 +109,7 @@ export function ReviewForm({
|
||||
.insert(photoRecords);
|
||||
|
||||
if (photosError) {
|
||||
console.error('Error inserting review photos:', photosError);
|
||||
logger.error('Failed to insert review photos', { error: getErrorMessage(photosError) });
|
||||
// Don't throw - review is already created
|
||||
}
|
||||
}
|
||||
@@ -121,10 +123,9 @@ export function ReviewForm({
|
||||
setPhotos([]);
|
||||
onReviewSubmitted();
|
||||
} catch (error: unknown) {
|
||||
console.error('Error submitting review:', error);
|
||||
toast({
|
||||
title: "Error",
|
||||
description: "Failed to submit review. Please try again.",
|
||||
description: getErrorMessage(error),
|
||||
variant: "destructive"
|
||||
});
|
||||
} finally {
|
||||
|
||||
@@ -6,6 +6,8 @@ import { Star, ThumbsUp, Calendar, MapPin } from 'lucide-react';
|
||||
import { supabase } from '@/integrations/supabase/client';
|
||||
import { ReportButton } from '@/components/moderation/ReportButton';
|
||||
import { StarRating } from './StarRating';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { logger } from '@/lib/logger';
|
||||
|
||||
interface ReviewWithProfile {
|
||||
id: string;
|
||||
@@ -63,7 +65,7 @@ export function ReviewsList({ entityType, entityId, entityName }: ReviewsListPro
|
||||
const { data } = await query;
|
||||
setReviews((data || []) as ReviewWithProfile[]);
|
||||
} catch (error: unknown) {
|
||||
console.error('Error fetching reviews:', error);
|
||||
logger.error('Failed to fetch reviews', { error: getErrorMessage(error), entityType, entityId });
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import { MapPin, Star, Search as SearchIcon, Castle, FerrisWheel, Waves, Theater
|
||||
import { Park, Ride, Company } from '@/types/database';
|
||||
import { supabase } from '@/integrations/supabase/client';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { logger } from '@/lib/logger';
|
||||
|
||||
interface SearchResultsProps {
|
||||
query: string;
|
||||
@@ -64,7 +66,7 @@ export function SearchResults({ query, onClose }: SearchResultsProps) {
|
||||
|
||||
setResults(allResults);
|
||||
} catch (error: unknown) {
|
||||
console.error('Search error:', error);
|
||||
logger.error('Search failed', { error: getErrorMessage(error), query });
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
@@ -168,7 +168,6 @@ export function AccountProfileTab() {
|
||||
const { data: { session }, error: sessionError } = await supabase.auth.getSession();
|
||||
|
||||
if (sessionError || !session?.access_token) {
|
||||
console.error('Session error:', sessionError);
|
||||
throw new Error('Your session has expired. Please refresh the page and try again.');
|
||||
}
|
||||
|
||||
@@ -180,7 +179,6 @@ export function AccountProfileTab() {
|
||||
);
|
||||
|
||||
if (error) {
|
||||
console.error('Edge function error:', error);
|
||||
throw error;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ import { DragDropZone } from './DragDropZone';
|
||||
import { supabase } from '@/integrations/supabase/client';
|
||||
import { toast } from '@/hooks/use-toast';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { logger } from '@/lib/logger';
|
||||
|
||||
export interface UploadedImage {
|
||||
url: string;
|
||||
@@ -68,7 +70,7 @@ export function EntityMultiImageUploader({
|
||||
try {
|
||||
URL.revokeObjectURL(image.url);
|
||||
} catch (error: unknown) {
|
||||
console.error('Error revoking object URL:', error);
|
||||
logger.error('Failed to revoke object URL', { error: getErrorMessage(error) });
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -106,10 +108,9 @@ export function EntityMultiImageUploader({
|
||||
card_assignment: cardIndex >= 0 ? cardIndex : null,
|
||||
});
|
||||
} catch (error: unknown) {
|
||||
console.error('Failed to load entity photos:', error);
|
||||
toast({
|
||||
title: 'Error',
|
||||
description: 'Failed to load existing photos',
|
||||
description: getErrorMessage(error),
|
||||
variant: 'destructive',
|
||||
});
|
||||
} finally {
|
||||
|
||||
@@ -17,6 +17,8 @@ import { PhotoModal } from '@/components/moderation/PhotoModal';
|
||||
import { supabase } from '@/integrations/supabase/client';
|
||||
import { EntityPhotoGalleryProps } from '@/types/submissions';
|
||||
import { useUserRole } from '@/hooks/useUserRole';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { logger } from '@/lib/logger';
|
||||
|
||||
interface Photo {
|
||||
id: string;
|
||||
@@ -72,7 +74,7 @@ export function EntityPhotoGallery({
|
||||
|
||||
setPhotos(mappedPhotos);
|
||||
} catch (error: unknown) {
|
||||
console.error('📷 [FETCH PHOTOS] Error:', error);
|
||||
logger.error('Failed to fetch photos', { error: getErrorMessage(error), entityId, entityType });
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ import { Textarea } from '@/components/ui/textarea';
|
||||
import { useToast } from '@/hooks/use-toast';
|
||||
import { Trash2, Pencil } from 'lucide-react';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { logger } from '@/lib/logger';
|
||||
|
||||
interface Photo {
|
||||
id: string;
|
||||
@@ -78,10 +80,9 @@ export function PhotoManagementDialog({
|
||||
if (error) throw error;
|
||||
setPhotos(data || []);
|
||||
} catch (error: unknown) {
|
||||
console.error('Error fetching photos:', error);
|
||||
toast({
|
||||
title: 'Error',
|
||||
description: 'Failed to load photos',
|
||||
description: getErrorMessage(error),
|
||||
variant: 'destructive',
|
||||
});
|
||||
} finally {
|
||||
@@ -123,7 +124,7 @@ export function PhotoManagementDialog({
|
||||
if (data?.name) entityName = data.name;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Error fetching entity name:', err);
|
||||
logger.error('Failed to fetch entity name', { error: getErrorMessage(err), entityType, entityId });
|
||||
}
|
||||
|
||||
// Create content submission
|
||||
@@ -173,10 +174,9 @@ export function PhotoManagementDialog({
|
||||
setDeleteReason('');
|
||||
onOpenChange(false);
|
||||
} catch (error: unknown) {
|
||||
console.error('Error requesting photo deletion:', error);
|
||||
toast({
|
||||
title: 'Error',
|
||||
description: 'Failed to submit deletion request',
|
||||
description: getErrorMessage(error),
|
||||
variant: 'destructive',
|
||||
});
|
||||
}
|
||||
@@ -238,10 +238,9 @@ export function PhotoManagementDialog({
|
||||
});
|
||||
onOpenChange(false);
|
||||
} catch (error: unknown) {
|
||||
console.error('Error requesting photo edit:', error);
|
||||
toast({
|
||||
title: 'Error',
|
||||
description: 'Failed to submit edit request',
|
||||
description: getErrorMessage(error),
|
||||
variant: 'destructive',
|
||||
});
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ export function PhotoUpload({
|
||||
try {
|
||||
URL.revokeObjectURL(url);
|
||||
} catch (error: unknown) {
|
||||
console.error('Error revoking object URL:', error);
|
||||
logger.error('Failed to revoke object URL', { error: getErrorMessage(error) });
|
||||
}
|
||||
});
|
||||
objectUrlsRef.current.clear();
|
||||
@@ -91,7 +91,7 @@ export function PhotoUpload({
|
||||
URL.revokeObjectURL(url);
|
||||
objectUrlsRef.current.delete(url);
|
||||
} catch (error: unknown) {
|
||||
console.error('Error revoking object URL:', error);
|
||||
logger.error('Failed to revoke object URL', { error: getErrorMessage(error) });
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -129,7 +129,6 @@ export function PhotoUpload({
|
||||
);
|
||||
|
||||
if (uploadError) {
|
||||
console.error('Upload URL error:', uploadError);
|
||||
revokeObjectUrl(previewUrl);
|
||||
throw new Error(uploadError.message);
|
||||
}
|
||||
@@ -196,7 +195,7 @@ export function PhotoUpload({
|
||||
}
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
console.error('Status poll error:', error);
|
||||
logger.error('Status poll error', { error: getErrorMessage(error) });
|
||||
}
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 500));
|
||||
@@ -340,7 +339,7 @@ export function PhotoUpload({
|
||||
alt="Avatar"
|
||||
className="w-24 h-24 rounded-full object-cover border-2 border-border"
|
||||
onError={(e) => {
|
||||
console.error('Failed to load avatar image:', uploadedImages[0].thumbnailUrl);
|
||||
logger.warn('Failed to load avatar image');
|
||||
e.currentTarget.src = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiBmaWxsPSIjZjNmNGY2Ii8+CjxwYXRoIGQ9Im0xNSAxMi0zLTMtMy4wMDEgM0w2IDlsNi02aDZ2NloiIGZpbGw9IiM5Y2EzYWYiLz4KPC9zdmc+';
|
||||
}}
|
||||
/>
|
||||
@@ -488,7 +487,7 @@ export function PhotoUpload({
|
||||
alt={image.filename}
|
||||
className="w-full aspect-square object-cover rounded-lg border"
|
||||
onError={(e) => {
|
||||
console.error('Failed to load image:', image.thumbnailUrl);
|
||||
logger.warn('Failed to load thumbnail image');
|
||||
e.currentTarget.src = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiBmaWxsPSIjZjNmNGY2Ii8+CjxwYXRoIGQ9Im0xNSAxMi0zLTMtMy4wMDEgM0w2IDlsNi02aDZ2NloiIGZpbGw9IiM5Y2EzYWYiLz4KPC9zdmc+';
|
||||
}}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user