mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 12:31:26 -05:00
feat: Execute production readiness plan
This commit is contained in:
@@ -16,12 +16,12 @@ import {
|
||||
PaginationPrevious,
|
||||
} from '@/components/ui/pagination';
|
||||
import { supabase } from '@/integrations/supabase/client';
|
||||
import { useToast } from '@/hooks/use-toast';
|
||||
import { format } from 'date-fns';
|
||||
import { useAdminSettings } from '@/hooks/useAdminSettings';
|
||||
import { useAuth } from '@/hooks/useAuth';
|
||||
import { useIsMobile } from '@/hooks/use-mobile';
|
||||
import { smartMergeArray } from '@/lib/smartStateUpdate';
|
||||
import { handleError, handleSuccess } from '@/lib/errorHandler';
|
||||
|
||||
// Type-safe reported content interfaces
|
||||
interface ReportedReview {
|
||||
@@ -112,7 +112,6 @@ export const ReportsQueue = forwardRef<ReportsQueueRef>((props, ref) => {
|
||||
const [isInitialLoad, setIsInitialLoad] = useState(true);
|
||||
const [actionLoading, setActionLoading] = useState<string | null>(null);
|
||||
const [newReportsCount, setNewReportsCount] = useState(0);
|
||||
const { toast } = useToast();
|
||||
const { user } = useAuth();
|
||||
|
||||
// Pagination state
|
||||
@@ -297,16 +296,15 @@ export const ReportsQueue = forwardRef<ReportsQueueRef>((props, ref) => {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Full replacement for non-silent refreshes or 'replace' strategy
|
||||
// Full replacement for non-silent refreshes or 'replace' strategy
|
||||
setReports(reportsWithContent);
|
||||
setNewReportsCount(0);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error fetching reports:', error);
|
||||
toast({
|
||||
title: "Error",
|
||||
description: "Failed to load reports queue",
|
||||
variant: "destructive",
|
||||
} catch (error: unknown) {
|
||||
handleError(error, {
|
||||
action: 'Load Reports',
|
||||
userId: user?.id,
|
||||
metadata: { currentPage, pageSize }
|
||||
});
|
||||
} finally {
|
||||
// Only clear loading if it was set
|
||||
@@ -352,10 +350,7 @@ export const ReportsQueue = forwardRef<ReportsQueueRef>((props, ref) => {
|
||||
|
||||
if (error) throw error;
|
||||
|
||||
toast({
|
||||
title: `Report ${action}`,
|
||||
description: `The report has been marked as ${action}`,
|
||||
});
|
||||
handleSuccess(`Report ${action}`, `The report has been marked as ${action}`);
|
||||
|
||||
// Remove report from queue
|
||||
setReports(prev => {
|
||||
@@ -366,12 +361,11 @@ export const ReportsQueue = forwardRef<ReportsQueueRef>((props, ref) => {
|
||||
}
|
||||
return newReports;
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error updating report:', error);
|
||||
toast({
|
||||
title: "Error",
|
||||
description: `Failed to ${action} report`,
|
||||
variant: "destructive",
|
||||
} catch (error: unknown) {
|
||||
handleError(error, {
|
||||
action: `${action === 'reviewed' ? 'Resolve' : 'Dismiss'} Report`,
|
||||
userId: user?.id,
|
||||
metadata: { reportId, action }
|
||||
});
|
||||
} finally {
|
||||
setActionLoading(null);
|
||||
|
||||
Reference in New Issue
Block a user