- Introduced layout components for multiple admin dashboard sections including events, audit logs, bank accounts, blog articles, bookings, chat oversight, cities, contact messages, dashboard, discount codes, event categories, guest lists, identity verifications, manage events, manual notifications, notification rules, payments, provinces, push deliveries, reviews, settlements, sms messages, support tickets, user reports, and users. - Updated metadata for the auth layout to include the admin page title. - Modified branch protection documentation to clarify deployment notifications.
26 lines
502 B
TypeScript
26 lines
502 B
TypeScript
'use client'
|
|
|
|
import { useRouter } from 'next/navigation'
|
|
import { useEffect } from 'react'
|
|
|
|
import useAuth from '@/hooks/useAuth'
|
|
|
|
const AdminRoleGuard = ({ children }: { children: React.ReactNode }) => {
|
|
const { user } = useAuth()
|
|
const router = useRouter()
|
|
|
|
useEffect(() => {
|
|
if (user && user.role !== 'admin') {
|
|
router.replace('/auth')
|
|
}
|
|
}, [router, user])
|
|
|
|
if (user && user.role !== 'admin') {
|
|
return null
|
|
}
|
|
|
|
return <>{children}</>
|
|
}
|
|
|
|
export default AdminRoleGuard
|