Continue console cleanup

This commit is contained in:
gpt-engineer-app[bot]
2025-10-21 18:07:25 +00:00
parent 431b5197ba
commit c7f3e9e1b2
28 changed files with 99 additions and 69 deletions

View File

@@ -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];

View File

@@ -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',
});
}

View File

@@ -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 {

View File

@@ -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.');

View File

@@ -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 {

View File

@@ -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);

View File

@@ -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({

View File

@@ -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(() => {