mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-24 06:51:13 -05:00
Continue console cleanup
This commit is contained in:
@@ -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(() => {
|
||||
|
||||
Reference in New Issue
Block a user