diff options
Diffstat (limited to 'modern/src/common/util/permissions.js')
-rw-r--r-- | modern/src/common/util/permissions.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/modern/src/common/util/permissions.js b/modern/src/common/util/permissions.js new file mode 100644 index 00000000..72ca0b08 --- /dev/null +++ b/modern/src/common/util/permissions.js @@ -0,0 +1,11 @@ +import { useSelector } from 'react-redux'; + +export const useAdministrator = () => useSelector((state) => state.session.user?.administrator); + +export const useReadonly = () => useSelector((state) => state.session.server?.readonly || state.session.user?.readonly); + +export const useDeviceReadonly = () => useSelector((state) => state.session.server?.readonly || state.session.user?.readonly + || state.session.server?.deviceReadonly || state.session.user?.deviceReadonly); + +export const useEditable = () => useSelector((state) => state.session.user?.administrator + || (!state.session.server?.readonly && !state.session.user?.readonly)); |