mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-21 16:11:13 -05:00
Refactor admin settings access
This commit is contained in:
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user