Add permission control to element
This commit is contained in:
16
src/components/common/Permission.tsx
Normal file
16
src/components/common/Permission.tsx
Normal file
@@ -0,0 +1,16 @@
|
||||
import React from 'react'
|
||||
import { hasPermission } from '@/util/auth.tsx'
|
||||
|
||||
interface PermissionProps extends React.PropsWithChildren {
|
||||
operationCode?: string
|
||||
}
|
||||
|
||||
const Permission: React.FC<PermissionProps> = (props) => {
|
||||
if (!props.operationCode || hasPermission(props.operationCode)) {
|
||||
return props.children
|
||||
}
|
||||
|
||||
return <></>
|
||||
}
|
||||
|
||||
export default Permission
|
||||
Reference in New Issue
Block a user