0052725b88
- Created UserViewSheet component to display user details including username, full name, role, status, and timestamps. - Created RoleViewSheet component to display role details including name, level, status, creation date, and associated permissions. - Introduced permissions configuration in a new permissions.ts file, defining categories and permission codes for better management. - Implemented middleware for authentication, ensuring access control for protected routes.
19 lines
509 B
TypeScript
19 lines
509 B
TypeScript
'use client'
|
|
|
|
import { useAuth } from '@/contexts/auth-context'
|
|
|
|
export function usePermission(permission: string): boolean {
|
|
const { permissions } = useAuth()
|
|
return permissions.has(permission)
|
|
}
|
|
|
|
export function usePermissions(codes: string[]): boolean[] {
|
|
const { permissions } = useAuth()
|
|
return codes.map((code) => permissions.has(code))
|
|
}
|
|
|
|
export function useHasAnyPermission(codes: string[]): boolean {
|
|
const { permissions } = useAuth()
|
|
return codes.some((code) => permissions.has(code))
|
|
}
|