17 lines
361 B
TypeScript
17 lines
361 B
TypeScript
import { PropsWithChildren } from 'react'
|
|
|
|
import { useRole } from '@hooks/useRole.tsx'
|
|
|
|
import { PermissionKeysType } from '@type/roles.type.ts'
|
|
|
|
const CanEdit = ({ children }: PropsWithChildren) => {
|
|
const { hasPermission } = useRole()
|
|
|
|
if (hasPermission(PermissionKeysType.write)) {
|
|
return <>{children}</>
|
|
}
|
|
return null
|
|
}
|
|
|
|
export default CanEdit
|