From df2c712bc8805326ed655affc950cccf598a07ad Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 8 Jan 2026 08:19:04 +0700 Subject: [PATCH] change AdminShow and AuthShow logic --- src/components/auth/AdminShow.tsx | 5 ++--- src/components/auth/AuthShow.tsx | 5 ++--- src/routes/(app)/(auth)/account/settings.tsx | 8 +++++++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/components/auth/AdminShow.tsx b/src/components/auth/AdminShow.tsx index 1323331..3d89f6b 100644 --- a/src/components/auth/AdminShow.tsx +++ b/src/components/auth/AdminShow.tsx @@ -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; }; diff --git a/src/components/auth/AuthShow.tsx b/src/components/auth/AuthShow.tsx index 4f7d62e..7dfbdc0 100644 --- a/src/components/auth/AuthShow.tsx +++ b/src/components/auth/AuthShow.tsx @@ -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; }; diff --git a/src/routes/(app)/(auth)/account/settings.tsx b/src/routes/(app)/(auth)/account/settings.tsx index 1a66679..ce2c0c7 100644 --- a/src/routes/(app)/(auth)/account/settings.tsx +++ b/src/routes/(app)/(auth)/account/settings.tsx @@ -7,5 +7,11 @@ export const Route = createFileRoute('/(app)/(auth)/account/settings')({ }); function RouteComponent() { - return
Hello "account/settings"!
; + return ( +
+
+ abc +
+
+ ); }