Refactor admin settings access

This commit is contained in:
gpt-engineer-app[bot]
2025-09-28 19:27:19 +00:00
parent 1f0808a74a
commit 01b6d0b955
3 changed files with 12 additions and 3 deletions

View File

@@ -1,6 +1,7 @@
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
import { supabase } from '@/integrations/supabase/client';
import { useAuth } from './useAuth';
import { useUserRole } from './useUserRole';
import { useToast } from './use-toast';
interface AdminSetting {
@@ -13,6 +14,7 @@ interface AdminSetting {
export function useAdminSettings() {
const { user } = useAuth();
const { isSuperuser } = useUserRole();
const { toast } = useToast();
const queryClient = useQueryClient();
@@ -31,7 +33,7 @@ export function useAdminSettings() {
if (error) throw error;
return data as AdminSetting[];
},
enabled: !!user
enabled: !!user && isSuperuser()
});
const updateSettingMutation = useMutation({