change AdminShow and AuthShow logic

This commit is contained in:
2026-01-08 08:19:04 +07:00
parent d49c37848f
commit df2c712bc8
3 changed files with 11 additions and 7 deletions

View File

@@ -1,8 +1,7 @@
import { useSession } from '@/lib/auth-client';
import { useAuth } from './auth-provider';
const AdminShow = ({ children }: { children: React.ReactNode }) => {
const { data } = useSession();
const isAdmin = data?.user?.role ? data?.user?.role === 'admin' : false;
const { isAdmin } = useAuth();
return isAdmin && children;
};

View File

@@ -1,8 +1,7 @@
import { useSession } from '@/lib/auth-client';
import { useAuth } from './auth-provider';
const AuthShow = ({ children }: { children: React.ReactNode }) => {
const { data } = useSession();
const isAuth = !!data;
const { isAuth } = useAuth();
return isAuth && children;
};