mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-24 06:31:14 -05:00
Fix: Approve database migration
This commit is contained in:
@@ -15,6 +15,7 @@ import { DatePicker } from '@/components/ui/date-picker';
|
||||
import { FlexibleDateInput, type DatePrecision } from '@/components/ui/flexible-date-input';
|
||||
import { SlugField } from '@/components/ui/slug-field';
|
||||
import { toast } from '@/hooks/use-toast';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { MapPin, Save, X, Plus } from 'lucide-react';
|
||||
import { toDateOnly } from '@/lib/dateUtils';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
@@ -192,10 +193,11 @@ export function ParkForm({ onSubmit, onCancel, initialData, isEditing = false }:
|
||||
? "The park information has been updated successfully."
|
||||
: "The new park has been created successfully."
|
||||
});
|
||||
} catch (error: any) {
|
||||
} catch (error) {
|
||||
const errorMsg = getErrorMessage(error);
|
||||
toast({
|
||||
title: "Error",
|
||||
description: error.message || "Failed to save park information.",
|
||||
description: errorMsg,
|
||||
variant: "destructive"
|
||||
});
|
||||
} finally {
|
||||
|
||||
@@ -20,6 +20,7 @@ import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } f
|
||||
import { Combobox } from '@/components/ui/combobox';
|
||||
import { SlugField } from '@/components/ui/slug-field';
|
||||
import { toast } from '@/hooks/use-toast';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { Plus, Zap, Save, X } from 'lucide-react';
|
||||
import { toDateOnly } from '@/lib/dateUtils';
|
||||
import { useUnitPreferences } from '@/hooks/useUnitPreferences';
|
||||
@@ -263,10 +264,11 @@ export function RideForm({ onSubmit, onCancel, initialData, isEditing = false }:
|
||||
? "Ride, manufacturer, and model submitted for review"
|
||||
: "Ride submitted for review"
|
||||
});
|
||||
} catch (error: any) {
|
||||
} catch (error) {
|
||||
const errorMsg = getErrorMessage(error);
|
||||
toast({
|
||||
title: "Error",
|
||||
description: error.message || "Failed to save ride information.",
|
||||
description: errorMsg,
|
||||
variant: "destructive"
|
||||
});
|
||||
} finally {
|
||||
|
||||
@@ -8,6 +8,7 @@ import { useAuth } from '@/hooks/useAuth';
|
||||
import { useProfile } from '@/hooks/useProfile';
|
||||
import { useToast } from '@/hooks/use-toast';
|
||||
import { useAuthModal } from '@/hooks/useAuthModal';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
|
||||
export function AuthButtons() {
|
||||
const { user, loading: authLoading, signOut } = useAuth();
|
||||
@@ -25,11 +26,12 @@ export function AuthButtons() {
|
||||
description: "You've been signed out successfully."
|
||||
});
|
||||
navigate('/');
|
||||
} catch (error: any) {
|
||||
} catch (error) {
|
||||
const errorMsg = getErrorMessage(error);
|
||||
toast({
|
||||
variant: "destructive",
|
||||
title: "Error signing out",
|
||||
description: error.message
|
||||
description: errorMsg
|
||||
});
|
||||
} finally {
|
||||
setLoggingOut(false);
|
||||
|
||||
@@ -8,6 +8,7 @@ import { AlertCircle } from 'lucide-react';
|
||||
import { type DependencyConflict, type SubmissionItemWithDeps } from '@/lib/submissionItemsService';
|
||||
import { useToast } from '@/hooks/use-toast';
|
||||
import { useAuth } from '@/hooks/useAuth';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
|
||||
interface ConflictResolutionDialogProps {
|
||||
open: boolean;
|
||||
@@ -67,10 +68,11 @@ export function ConflictResolutionDialog({
|
||||
|
||||
onResolve();
|
||||
onOpenChange(false);
|
||||
} catch (error: any) {
|
||||
} catch (error) {
|
||||
const errorMsg = getErrorMessage(error);
|
||||
toast({
|
||||
title: 'Error',
|
||||
description: error.message || 'Failed to resolve conflicts',
|
||||
description: errorMsg,
|
||||
variant: 'destructive',
|
||||
});
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import { Textarea } from '@/components/ui/textarea';
|
||||
import { toast } from '@/hooks/use-toast';
|
||||
import { useIsMobile } from '@/hooks/use-mobile';
|
||||
import { useUserRole } from '@/hooks/useUserRole';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { useAuth } from '@/hooks/useAuth';
|
||||
import { editSubmissionItem, type SubmissionItemWithDeps } from '@/lib/submissionItemsService';
|
||||
import { ParkForm } from '@/components/admin/ParkForm';
|
||||
@@ -58,10 +59,11 @@ export function ItemEditDialog({ item, open, onOpenChange, onComplete }: ItemEdi
|
||||
|
||||
onComplete();
|
||||
onOpenChange(false);
|
||||
} catch (error: any) {
|
||||
} catch (error) {
|
||||
const errorMsg = getErrorMessage(error);
|
||||
toast({
|
||||
title: 'Error',
|
||||
description: error.message || 'Failed to save changes',
|
||||
description: errorMsg,
|
||||
variant: 'destructive',
|
||||
});
|
||||
} finally {
|
||||
|
||||
@@ -3,6 +3,7 @@ import { supabase } from '@/integrations/supabase/client';
|
||||
import { PhotoGrid } from '@/components/common/PhotoGrid';
|
||||
import type { PhotoSubmissionItem } from '@/types/photo-submissions';
|
||||
import type { PhotoItem } from '@/types/photos';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
|
||||
interface PhotoSubmissionDisplayProps {
|
||||
submissionId: string;
|
||||
@@ -81,10 +82,11 @@ export function PhotoSubmissionDisplay({ submissionId }: PhotoSubmissionDisplayP
|
||||
|
||||
setPhotos(data || []);
|
||||
console.log(`✅ Successfully loaded ${data?.length || 0} photos`);
|
||||
} catch (error: any) {
|
||||
console.error('❌ PhotoSubmissionDisplay error:', error);
|
||||
} catch (error) {
|
||||
const errorMsg = getErrorMessage(error);
|
||||
console.error('❌ PhotoSubmissionDisplay error:', errorMsg);
|
||||
setPhotos([]);
|
||||
setError(error.message || 'Failed to load photos');
|
||||
setError(errorMsg);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
} from '@/components/ui/select';
|
||||
import { supabase } from '@/integrations/supabase/client';
|
||||
import { useToast } from '@/hooks/use-toast';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
|
||||
interface Moderator {
|
||||
user_id: string;
|
||||
@@ -87,8 +88,9 @@ export function ReassignDialog({
|
||||
});
|
||||
|
||||
setModerators(moderatorsList);
|
||||
} catch (error: any) {
|
||||
console.error('Error fetching moderators:', error);
|
||||
} catch (error) {
|
||||
const errorMsg = getErrorMessage(error);
|
||||
console.error('Error fetching moderators:', errorMsg);
|
||||
toast({
|
||||
title: 'Error',
|
||||
description: 'Failed to load moderators list',
|
||||
|
||||
@@ -2,6 +2,7 @@ import { useState, useEffect, forwardRef, useImperativeHandle } from 'react';
|
||||
import { supabase } from '@/integrations/supabase/client';
|
||||
import { useAuth } from '@/hooks/useAuth';
|
||||
import { useToast } from '@/hooks/use-toast';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { ActivityCard } from './ActivityCard';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { Activity as ActivityIcon } from 'lucide-react';
|
||||
@@ -150,8 +151,9 @@ export const RecentActivity = forwardRef<RecentActivityRef>((props, ref) => {
|
||||
// Full replacement for non-silent refreshes or 'replace' strategy
|
||||
setActivities(recentActivities);
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error('Error fetching recent activity:', error);
|
||||
} catch (error) {
|
||||
const errorMsg = getErrorMessage(error);
|
||||
console.error('Error fetching recent activity:', errorMsg);
|
||||
toast({
|
||||
title: "Error",
|
||||
description: "Failed to load recent activity",
|
||||
|
||||
@@ -7,6 +7,7 @@ import { UserX } from 'lucide-react';
|
||||
import { supabase } from '@/integrations/supabase/client';
|
||||
import { useAuth } from '@/hooks/useAuth';
|
||||
import { useToast } from '@/hooks/use-toast';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
|
||||
interface UserBlockButtonProps {
|
||||
targetUserId: string;
|
||||
@@ -42,8 +43,9 @@ export function UserBlockButton({ targetUserId, targetUsername, variant = 'outli
|
||||
});
|
||||
|
||||
setReason('');
|
||||
} catch (error: any) {
|
||||
console.error('Error blocking user:', error);
|
||||
} catch (error) {
|
||||
const errorMsg = getErrorMessage(error);
|
||||
console.error('Error blocking user:', errorMsg);
|
||||
toast({
|
||||
title: 'Error',
|
||||
description: 'Failed to block user',
|
||||
|
||||
@@ -4,6 +4,7 @@ import { supabase } from '@/integrations/supabase/client';
|
||||
import { useToast } from '@/hooks/use-toast';
|
||||
import { AlertTriangle, Loader2 } from 'lucide-react';
|
||||
import { useState } from 'react';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
|
||||
interface DeletionStatusBannerProps {
|
||||
scheduledDate: string;
|
||||
@@ -37,11 +38,12 @@ export function DeletionStatusBanner({ scheduledDate, onCancelled }: DeletionSta
|
||||
});
|
||||
|
||||
onCancelled();
|
||||
} catch (error: any) {
|
||||
} catch (error) {
|
||||
const errorMsg = getErrorMessage(error);
|
||||
toast({
|
||||
variant: 'destructive',
|
||||
title: 'Error',
|
||||
description: error.message || 'Failed to cancel deletion',
|
||||
description: errorMsg,
|
||||
});
|
||||
} finally {
|
||||
setLoading(false);
|
||||
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
} from '@/components/ui/form';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { handleError, handleSuccess, AppError } from '@/lib/errorHandler';
|
||||
import { handleError, handleSuccess, AppError, getErrorMessage } from '@/lib/errorHandler';
|
||||
import { logger } from '@/lib/logger';
|
||||
import { supabase } from '@/integrations/supabase/client';
|
||||
import { Loader2, Mail, CheckCircle2, AlertCircle } from 'lucide-react';
|
||||
@@ -185,13 +185,12 @@ export function EmailChangeDialog({ open, onOpenChange, currentEmail, userId }:
|
||||
);
|
||||
|
||||
setStep('success');
|
||||
} catch (error: any) {
|
||||
} catch (error) {
|
||||
const errorMsg = getErrorMessage(error);
|
||||
logger.error('Email change failed', {
|
||||
userId,
|
||||
action: 'email_change',
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
errorCode: error.code,
|
||||
errorStatus: error.status
|
||||
error: errorMsg,
|
||||
});
|
||||
|
||||
if (error.message?.includes('rate limit') || error.status === 429) {
|
||||
|
||||
@@ -9,6 +9,7 @@ import { useQuery } from '@tanstack/react-query';
|
||||
import { supabase } from '@/integrations/supabase/client';
|
||||
import { useAuth } from '@/hooks/useAuth';
|
||||
import { toast } from 'sonner';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { deleteTimelineEvent } from '@/lib/entitySubmissionHelpers';
|
||||
import type { EntityType, TimelineEvent } from '@/types/timeline';
|
||||
|
||||
@@ -113,10 +114,11 @@ export function EntityTimelineManager({
|
||||
toast.success('Event deleted', {
|
||||
description: 'Your timeline event has been deleted successfully.'
|
||||
});
|
||||
} catch (error: any) {
|
||||
console.error('Delete error:', error);
|
||||
} catch (error) {
|
||||
const errorMsg = getErrorMessage(error);
|
||||
console.error('Delete error:', errorMsg);
|
||||
toast.error('Failed to delete event', {
|
||||
description: error.message || 'Please try again.'
|
||||
description: errorMsg
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -46,6 +46,7 @@ import { Loader2, Trash } from 'lucide-react';
|
||||
import { useAuth } from '@/hooks/useAuth';
|
||||
import { useToast } from '@/hooks/use-toast';
|
||||
import { submitTimelineEvent, submitTimelineEventUpdate, deleteTimelineEvent } from '@/lib/entitySubmissionHelpers';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import type {
|
||||
EntityType,
|
||||
TimelineEventFormData,
|
||||
@@ -195,11 +196,12 @@ export function TimelineEventEditorDialog({
|
||||
onOpenChange(false);
|
||||
setShowDeleteConfirm(false);
|
||||
form.reset();
|
||||
} catch (error: any) {
|
||||
console.error('Delete error:', error);
|
||||
} catch (error) {
|
||||
const errorMsg = getErrorMessage(error);
|
||||
console.error('Delete error:', errorMsg);
|
||||
toast({
|
||||
title: 'Failed to delete event',
|
||||
description: error.message || 'Please try again.',
|
||||
description: errorMsg,
|
||||
variant: 'destructive',
|
||||
});
|
||||
} finally {
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
FileImage
|
||||
} from 'lucide-react';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { supabase } from '@/integrations/supabase/client';
|
||||
|
||||
interface PhotoUploadProps {
|
||||
@@ -266,11 +267,11 @@ export function PhotoUpload({
|
||||
}
|
||||
|
||||
setUploadProgress(100);
|
||||
} catch (error: any) {
|
||||
} catch (error) {
|
||||
previewUrls.forEach(url => revokeObjectUrl(url));
|
||||
const errorMessage = error.message || 'Upload failed';
|
||||
setError(errorMessage);
|
||||
onError?.(errorMessage);
|
||||
const errorMsg = getErrorMessage(error);
|
||||
setError(errorMsg);
|
||||
onError?.(errorMsg);
|
||||
} finally {
|
||||
setUploading(false);
|
||||
setUploadProgress(0);
|
||||
|
||||
Reference in New Issue
Block a user