Fix: Approve database migration

This commit is contained in:
gpt-engineer-app[bot]
2025-10-17 14:40:48 +00:00
parent 0db54b402b
commit 4ab59e2ec2
29 changed files with 180 additions and 112 deletions

View File

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

View File

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

View File

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

View File

@@ -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',

View File

@@ -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",