mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 22:11:24 -05:00
Fix and test error logging
This commit is contained in:
@@ -5,6 +5,7 @@ import { useUserRole } from './useUserRole';
|
||||
import { useToast } from './use-toast';
|
||||
import { useCallback, useMemo } from 'react';
|
||||
import type { Json } from '@/integrations/supabase/types';
|
||||
import { handleError } from '@/lib/errorHandler';
|
||||
|
||||
interface AdminSetting {
|
||||
id: string;
|
||||
@@ -58,6 +59,7 @@ export function useAdminSettings() {
|
||||
.eq('setting_key', key);
|
||||
|
||||
if (error) throw error;
|
||||
return { key, value };
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['admin-settings'] });
|
||||
@@ -66,11 +68,14 @@ export function useAdminSettings() {
|
||||
description: "The setting has been saved successfully.",
|
||||
});
|
||||
},
|
||||
onError: (error: Error) => {
|
||||
toast({
|
||||
title: "Error",
|
||||
description: error.message || "Failed to update setting",
|
||||
variant: "destructive",
|
||||
onError: (error: Error, variables) => {
|
||||
handleError(error, {
|
||||
action: 'Update Admin Setting',
|
||||
userId: user?.id,
|
||||
metadata: {
|
||||
settingKey: variables.key,
|
||||
attemptedValue: variables.value
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user