mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 08:31:12 -05:00
Fix feature path catch blocks
This commit is contained in:
@@ -154,7 +154,7 @@ export function MarkdownEditor({
|
|||||||
if (!imageUrl) throw new Error('Failed to generate image URL');
|
if (!imageUrl) throw new Error('Failed to generate image URL');
|
||||||
|
|
||||||
return imageUrl;
|
return imageUrl;
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
console.error('Image upload failed:', error);
|
console.error('Image upload failed:', error);
|
||||||
throw new Error(error instanceof Error ? error.message : 'Failed to upload image');
|
throw new Error(error instanceof Error ? error.message : 'Failed to upload image');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ export function NovuMigrationUtility() {
|
|||||||
title: "Migration completed",
|
title: "Migration completed",
|
||||||
description: `Successfully migrated ${successCount} users. ${failureCount} failures.`,
|
description: `Successfully migrated ${successCount} users. ${failureCount} failures.`,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
const errorMsg = getErrorMessage(error);
|
const errorMsg = getErrorMessage(error);
|
||||||
toast({
|
toast({
|
||||||
variant: "destructive",
|
variant: "destructive",
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export function ProfileAuditLog() {
|
|||||||
|
|
||||||
if (error) throw error;
|
if (error) throw error;
|
||||||
setLogs((data || []) as AuditLogEntry[]);
|
setLogs((data || []) as AuditLogEntry[]);
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
handleError(error, { action: 'Load audit logs' });
|
handleError(error, { action: 'Load audit logs' });
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ export const SystemActivityLog = forwardRef<SystemActivityLogRef, SystemActivity
|
|||||||
type: filterType === 'all' ? undefined : filterType,
|
type: filterType === 'all' ? undefined : filterType,
|
||||||
});
|
});
|
||||||
setActivities(data);
|
setActivities(data);
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
console.error('Error loading system activities:', error);
|
console.error('Error loading system activities:', error);
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/component
|
|||||||
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger } from '@/components/ui/alert-dialog';
|
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger } from '@/components/ui/alert-dialog';
|
||||||
import { supabase } from '@/integrations/supabase/client';
|
import { supabase } from '@/integrations/supabase/client';
|
||||||
import { useToast } from '@/hooks/use-toast';
|
import { useToast } from '@/hooks/use-toast';
|
||||||
|
import { getErrorMessage } from '@/lib/errorHandler';
|
||||||
import { Beaker, CheckCircle, ChevronDown, Trash2, AlertTriangle } from 'lucide-react';
|
import { Beaker, CheckCircle, ChevronDown, Trash2, AlertTriangle } from 'lucide-react';
|
||||||
import { clearTestData, getTestDataStats } from '@/lib/testDataGenerator';
|
import { clearTestData, getTestDataStats } from '@/lib/testDataGenerator';
|
||||||
|
|
||||||
@@ -87,7 +88,7 @@ export function TestDataGenerator() {
|
|||||||
try {
|
try {
|
||||||
const data = await getTestDataStats();
|
const data = await getTestDataStats();
|
||||||
setStats(data);
|
setStats(data);
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
console.error('Failed to load stats:', error);
|
console.error('Failed to load stats:', error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -149,11 +150,11 @@ export function TestDataGenerator() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
await loadStats();
|
await loadStats();
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
console.error('Generation error:', error);
|
console.error('Generation error:', error);
|
||||||
toast({
|
toast({
|
||||||
title: "Generation failed",
|
title: "Generation failed",
|
||||||
description: error.message || "Failed to generate test data",
|
description: getErrorMessage(error),
|
||||||
variant: "destructive",
|
variant: "destructive",
|
||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
@@ -173,11 +174,11 @@ export function TestDataGenerator() {
|
|||||||
description: `Removed ${deleted} test submissions`
|
description: `Removed ${deleted} test submissions`
|
||||||
});
|
});
|
||||||
setResults(null);
|
setResults(null);
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
console.error('Clear error:', error);
|
console.error('Clear error:', error);
|
||||||
toast({
|
toast({
|
||||||
title: 'Clear Failed',
|
title: 'Clear Failed',
|
||||||
description: error.message,
|
description: getErrorMessage(error),
|
||||||
variant: 'destructive'
|
variant: 'destructive'
|
||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ export function ContentTabs() {
|
|||||||
setRecentRides(recentRidesData || []);
|
setRecentRides(recentRidesData || []);
|
||||||
setRecentChanges(processedChanges);
|
setRecentChanges(processedChanges);
|
||||||
setRecentlyOpened(combinedOpened);
|
setRecentlyOpened(combinedOpened);
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
console.error('Error fetching content:', error);
|
console.error('Error fetching content:', error);
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ export function FeaturedParks() {
|
|||||||
|
|
||||||
setTopRatedParks(topRated || []);
|
setTopRatedParks(topRated || []);
|
||||||
setMostRidesParks(mostRides || []);
|
setMostRidesParks(mostRides || []);
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
console.error('Error fetching featured parks:', error);
|
console.error('Error fetching featured parks:', error);
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ export function ParkGrid() {
|
|||||||
|
|
||||||
if (error) throw error;
|
if (error) throw error;
|
||||||
setParks(data || []);
|
setParks(data || []);
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
console.error('Error fetching parks:', error);
|
console.error('Error fetching parks:', error);
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ export function AddRideCreditDialog({ userId, open, onOpenChange, onSuccess }: A
|
|||||||
handleReset();
|
handleReset();
|
||||||
onSuccess(data.id); // Pass the new ID
|
onSuccess(data.id); // Pass the new ID
|
||||||
onOpenChange(false);
|
onOpenChange(false);
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
console.error('Error adding credit:', error);
|
console.error('Error adding credit:', error);
|
||||||
toast.error(getErrorMessage(error));
|
toast.error(getErrorMessage(error));
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ export function RideCreditCard({ credit, position, maxPosition, viewMode, isEdit
|
|||||||
setIsEditing(false);
|
setIsEditing(false);
|
||||||
// Optimistic update - pass specific changes
|
// Optimistic update - pass specific changes
|
||||||
onUpdate(credit.id, { ride_count: editCount });
|
onUpdate(credit.id, { ride_count: editCount });
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
console.error('Error updating count:', error);
|
console.error('Error updating count:', error);
|
||||||
toast.error(getErrorMessage(error));
|
toast.error(getErrorMessage(error));
|
||||||
} finally {
|
} finally {
|
||||||
@@ -91,7 +91,7 @@ export function RideCreditCard({ credit, position, maxPosition, viewMode, isEdit
|
|||||||
if (error) throw error;
|
if (error) throw error;
|
||||||
|
|
||||||
toast.success('Ride count increased');
|
toast.success('Ride count increased');
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
console.error('Error incrementing count:', error);
|
console.error('Error incrementing count:', error);
|
||||||
toast.error(getErrorMessage(error));
|
toast.error(getErrorMessage(error));
|
||||||
// Rollback on error
|
// Rollback on error
|
||||||
@@ -111,7 +111,7 @@ export function RideCreditCard({ credit, position, maxPosition, viewMode, isEdit
|
|||||||
try {
|
try {
|
||||||
await onReorder(credit.id, editPosition);
|
await onReorder(credit.id, editPosition);
|
||||||
toast.success('Position updated');
|
toast.success('Position updated');
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
console.error('Error changing position:', error);
|
console.error('Error changing position:', error);
|
||||||
toast.error(getErrorMessage(error));
|
toast.error(getErrorMessage(error));
|
||||||
setEditPosition(position);
|
setEditPosition(position);
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ export function UserBlockButton({ targetUserId, targetUsername, variant = 'outli
|
|||||||
});
|
});
|
||||||
|
|
||||||
setReason('');
|
setReason('');
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
const errorMsg = getErrorMessage(error);
|
const errorMsg = getErrorMessage(error);
|
||||||
console.error('Error blocking user:', errorMsg);
|
console.error('Error blocking user:', errorMsg);
|
||||||
toast({
|
toast({
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ export function UserReviewsList({ userId, reviewCount }: UserReviewsListProps) {
|
|||||||
|
|
||||||
if (error) throw error;
|
if (error) throw error;
|
||||||
setReviews(data || []);
|
setReviews(data || []);
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
console.error('Error fetching reviews:', error);
|
console.error('Error fetching reviews:', error);
|
||||||
toast.error(getErrorMessage(error));
|
toast.error(getErrorMessage(error));
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ export function ReviewForm({
|
|||||||
setRating(0);
|
setRating(0);
|
||||||
setPhotos([]);
|
setPhotos([]);
|
||||||
onReviewSubmitted();
|
onReviewSubmitted();
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
console.error('Error submitting review:', error);
|
console.error('Error submitting review:', error);
|
||||||
toast({
|
toast({
|
||||||
title: "Error",
|
title: "Error",
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ export function ReviewsList({ entityType, entityId, entityName }: ReviewsListPro
|
|||||||
|
|
||||||
const { data } = await query;
|
const { data } = await query;
|
||||||
setReviews((data || []) as ReviewWithProfile[]);
|
setReviews((data || []) as ReviewWithProfile[]);
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
console.error('Error fetching reviews:', error);
|
console.error('Error fetching reviews:', error);
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { useRef, useCallback } from 'react';
|
|||||||
import { supabase } from '@/integrations/supabase/client';
|
import { supabase } from '@/integrations/supabase/client';
|
||||||
import { createTableQuery } from '@/lib/supabaseHelpers';
|
import { createTableQuery } from '@/lib/supabaseHelpers';
|
||||||
import { logger } from '@/lib/logger';
|
import { logger } from '@/lib/logger';
|
||||||
|
import { getErrorMessage } from '@/lib/errorHandler';
|
||||||
import { MODERATION_CONSTANTS } from '@/lib/moderation/constants';
|
import { MODERATION_CONSTANTS } from '@/lib/moderation/constants';
|
||||||
import type { Database } from '@/integrations/supabase/types';
|
import type { Database } from '@/integrations/supabase/types';
|
||||||
|
|
||||||
@@ -183,8 +184,8 @@ export function useEntityCache() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return data || [];
|
return data || [];
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
logger.error(`Failed to bulk fetch ${type}:`, error);
|
logger.error(`Failed to bulk fetch ${type}:`, { error: getErrorMessage(error) });
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}, [getCached, setCached, getUncachedIds]);
|
}, [getCached, setCached, getUncachedIds]);
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ export function useModerationFilters(
|
|||||||
if (saved) {
|
if (saved) {
|
||||||
return JSON.parse(saved);
|
return JSON.parse(saved);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
console.error('Failed to load persisted filters:', error);
|
console.error('Failed to load persisted filters:', error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,7 +151,7 @@ export function useModerationFilters(
|
|||||||
return parsed;
|
return parsed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
console.error('Failed to load persisted sort:', error);
|
console.error('Failed to load persisted sort:', error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,7 +193,7 @@ export function useModerationFilters(
|
|||||||
activeTab,
|
activeTab,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
console.error('Failed to persist filters:', error);
|
console.error('Failed to persist filters:', error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -204,7 +204,7 @@ export function useModerationFilters(
|
|||||||
if (persist) {
|
if (persist) {
|
||||||
try {
|
try {
|
||||||
localStorage.setItem(`${storageKey}_sort`, JSON.stringify(sortConfig));
|
localStorage.setItem(`${storageKey}_sort`, JSON.stringify(sortConfig));
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
console.error('Failed to persist sort:', error);
|
console.error('Failed to persist sort:', error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -330,7 +330,7 @@ export function useModerationQueueManager(config: ModerationQueueManagerConfig):
|
|||||||
|
|
||||||
// Refresh stats to update counts
|
// Refresh stats to update counts
|
||||||
queue.refreshStats();
|
queue.refreshStats();
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
const errorMsg = getErrorMessage(error);
|
const errorMsg = getErrorMessage(error);
|
||||||
console.error("Error deleting submission:", errorMsg);
|
console.error("Error deleting submission:", errorMsg);
|
||||||
|
|
||||||
@@ -371,7 +371,7 @@ export function useModerationQueueManager(config: ModerationQueueManagerConfig):
|
|||||||
queue.refreshStats();
|
queue.refreshStats();
|
||||||
|
|
||||||
setItems((prev) => prev.filter((i) => i.id !== item.id));
|
setItems((prev) => prev.filter((i) => i.id !== item.id));
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
const errorMsg = getErrorMessage(error);
|
const errorMsg = getErrorMessage(error);
|
||||||
console.error("Error resetting submission:", errorMsg);
|
console.error("Error resetting submission:", errorMsg);
|
||||||
toast({
|
toast({
|
||||||
@@ -439,7 +439,7 @@ export function useModerationQueueManager(config: ModerationQueueManagerConfig):
|
|||||||
|
|
||||||
// Refresh stats to update counts
|
// Refresh stats to update counts
|
||||||
queue.refreshStats();
|
queue.refreshStats();
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
const errorMsg = getErrorMessage(error);
|
const errorMsg = getErrorMessage(error);
|
||||||
console.error("Error retrying failed items:", errorMsg);
|
console.error("Error retrying failed items:", errorMsg);
|
||||||
toast({
|
toast({
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ export function usePagination(config: PaginationConfig = {}): PaginationState {
|
|||||||
if (saved) {
|
if (saved) {
|
||||||
return JSON.parse(saved);
|
return JSON.parse(saved);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
console.error('Failed to load pagination state:', error);
|
console.error('Failed to load pagination state:', error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,7 +157,7 @@ export function usePagination(config: PaginationConfig = {}): PaginationState {
|
|||||||
pageSize,
|
pageSize,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
console.error('Failed to persist pagination state:', error);
|
console.error('Failed to persist pagination state:', error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,8 +118,8 @@ export function useProfileCache() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return data || [];
|
return data || [];
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
logger.error('Failed to bulk fetch profiles:', error);
|
logger.error('Failed to bulk fetch profiles:', { error: getErrorMessage(error) });
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}, [getCached, setCached, getUncachedIds]);
|
}, [getCached, setCached, getUncachedIds]);
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export function useCountries() {
|
|||||||
value: country.toLowerCase().replace(/\s+/g, '_')
|
value: country.toLowerCase().replace(/\s+/g, '_')
|
||||||
}))
|
}))
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
console.error('Error fetching countries:', error);
|
console.error('Error fetching countries:', error);
|
||||||
setCountries([]);
|
setCountries([]);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -72,7 +72,7 @@ export function useStatesProvinces(country?: string) {
|
|||||||
value: state.toLowerCase().replace(/\s+/g, '_')
|
value: state.toLowerCase().replace(/\s+/g, '_')
|
||||||
}))
|
}))
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
console.error('Error fetching states/provinces:', error);
|
console.error('Error fetching states/provinces:', error);
|
||||||
setStatesProvinces([]);
|
setStatesProvinces([]);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -108,7 +108,7 @@ export function useManufacturers() {
|
|||||||
value: company.id
|
value: company.id
|
||||||
}))
|
}))
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
console.error('Error fetching manufacturers:', error);
|
console.error('Error fetching manufacturers:', error);
|
||||||
setManufacturers([]);
|
setManufacturers([]);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -149,7 +149,7 @@ export function useRideModels(manufacturerId?: string) {
|
|||||||
value: model.id
|
value: model.id
|
||||||
}))
|
}))
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
console.error('Error fetching ride models:', error);
|
console.error('Error fetching ride models:', error);
|
||||||
setRideModels([]);
|
setRideModels([]);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -188,7 +188,7 @@ export function useCompanyHeadquarters() {
|
|||||||
value: hq.toLowerCase().replace(/\s+/g, '_')
|
value: hq.toLowerCase().replace(/\s+/g, '_')
|
||||||
}))
|
}))
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
console.error('Error fetching headquarters:', error);
|
console.error('Error fetching headquarters:', error);
|
||||||
setHeadquarters([]);
|
setHeadquarters([]);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -224,7 +224,7 @@ export function useOperators() {
|
|||||||
value: company.id
|
value: company.id
|
||||||
}))
|
}))
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
console.error('Error fetching operators:', error);
|
console.error('Error fetching operators:', error);
|
||||||
setOperators([]);
|
setOperators([]);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -260,7 +260,7 @@ export function usePropertyOwners() {
|
|||||||
value: company.id
|
value: company.id
|
||||||
}))
|
}))
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
console.error('Error fetching property owners:', error);
|
console.error('Error fetching property owners:', error);
|
||||||
setPropertyOwners([]);
|
setPropertyOwners([]);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
Reference in New Issue
Block a user