1+ "use client" ;
2+
3+ import { useUserAccount } from "@/utils/useUserAccount" ;
4+ import NotFoundPage from "@/app/not-found" ;
5+ import useIsMobile from "@/utils/useIsMobile" ;
6+ import { useRouter } from "next/navigation" ;
7+
8+ export default function AdminPage ( ) {
9+ const isMobile = useIsMobile ( ) ;
10+ const userAccount = useUserAccount ( ) ;
11+ const router = useRouter ( ) ;
12+
13+ if ( userAccount . isLoading === true ) {
14+ return ( < div > </ div > ) ;
15+ }
16+
17+ if ( userAccount . isLogin === false && userAccount . isLoading === false ) {
18+ return < NotFoundPage /> ;
19+ }
20+
21+ const userData = userAccount . userData ;
22+
23+ if ( userData ?. permission !== 2 && userAccount . isLoading === false ) {
24+ return < NotFoundPage /> ;
25+ }
26+
27+ return isMobile ? (
28+ < div className = "flex flex-col-reverse justify-start w-screen h-screen pt-16 pb-16 px-2 relative overflow-y-auto" >
29+ < div className = "flex flex-col items-center justify-center h-full" >
30+ < h1 className = "text-3xl font-bold mb-6" > 管理員頁面</ h1 >
31+ < p className = "text-lg bg-red-200 rounded-lg p-4 mb-4 font-bold" > 請注意您目前是管理員身份登入系統,< br /> 這意味著您的操作都會直接或間接影響整個平台的運作,< br /> 請謹慎操作。</ p >
32+ < p className = "text-xl mb-4" > 請選擇您要管理的項目:</ p >
33+ < div className = "flex flex-col space-y-4" >
34+ < button className = "bg-white text-[#5fcdf5] px-4 py-2 rounded-full disabled:cursor-not-allowed" onClick = { ( ) => router . push ( "/admin/sig-leader" ) } >
35+ SIG Leader 管理
36+ </ button >
37+ < button className = "bg-white text-[#5fcdf5] px-4 py-2 rounded-full disabled:cursor-not-allowed" onClick = { ( ) => router . push ( "/admin/sig-advisor" ) } >
38+ SIG 指導老師管理
39+ </ button >
40+ < button className = "bg-white text-[#5fcdf5] px-4 py-2 rounded-full disabled:cursor-not-allowed" disabled onClick = { ( ) => router . push ( "/admin/post" ) } >
41+ 貼文管理(開發中)
42+ </ button >
43+ </ div >
44+ </ div >
45+ </ div >
46+ ) : (
47+ < div className = "pt-5 h-[calc(100%-6.5rem)]" >
48+ < div className = "flex flex-col items-center justify-center h-full" >
49+ < h1 className = "text-3xl font-bold mb-6" > 管理員頁面</ h1 >
50+ < p className = "text-lg bg-red-200 rounded-lg p-4 mb-4 font-bold" > 請注意您目前是管理員身份登入系統,< br /> 這意味著您的操作都會直接或間接影響整個平台的運作,< br /> 請謹慎操作。</ p >
51+ < p className = "text-xl mb-4" > 請選擇您要管理的項目:</ p >
52+ < div className = "flex flex-col space-y-4" >
53+ < button className = "bg-white text-[#5fcdf5] px-4 py-2 rounded-full disabled:cursor-not-allowed" onClick = { ( ) => router . push ( "/admin/sig-leader" ) } >
54+ SIG Leader 管理
55+ </ button >
56+ < button className = "bg-white text-[#5fcdf5] px-4 py-2 rounded-full disabled:cursor-not-allowed" onClick = { ( ) => router . push ( "/admin/sig-advisor" ) } >
57+ SIG 指導老師管理
58+ </ button >
59+ < button className = "bg-white text-[#5fcdf5] px-4 py-2 rounded-full disabled:cursor-not-allowed" disabled onClick = { ( ) => router . push ( "/admin/post" ) } >
60+ 貼文管理(開發中)
61+ </ button >
62+ </ div >
63+ </ div >
64+ </ div >
65+ ) ;
66+ }
0 commit comments