add prettier
This commit is contained in:
1 parent
6a9a45a4cc
commit
07fc6c0b6c
35 files changed
+530
-461
No files matched your search
+4
-4
@@ -1,6 +1,6 @@
|
||||
import {TypedUseSelectorHook, useDispatch, useSelector} from 'react-redux';
|
||||
import { TypedUseSelectorHook, useDispatch, useSelector } from 'react-redux'
|
||||
|
||||
import {AppDispatch, RootState} from '../store';
|
||||
import { AppDispatch, RootState } from '../store'
|
||||
|
||||
export const useAppDispatch = () => useDispatch<AppDispatch>();
|
||||
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;
|
||||
export const useAppDispatch = () => useDispatch<AppDispatch>()
|
||||
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector
|
||||
+13
-12
@@ -1,17 +1,18 @@
|
||||
import {useMemo} from 'react';
|
||||
import {useAppSelector} from './redux.ts';
|
||||
import {PermissionKeys} from '../types/roles.type.ts';
|
||||
import { useMemo } from 'react'
|
||||
|
||||
import { PermissionKeys } from '../types/roles.type.ts'
|
||||
import { useAppSelector } from './redux.ts'
|
||||
|
||||
export const useRole = () => {
|
||||
const {profile} = useAppSelector((state: any) => state.profileReducer);
|
||||
const role: string = useMemo(() => profile && profile.role, [profile]);
|
||||
const { profile } = useAppSelector((state: any) => state.profileReducer)
|
||||
const role: string = useMemo(() => profile && profile.role, [profile])
|
||||
|
||||
const hasPermission = (permission: PermissionKeys) => {
|
||||
const userPermission = profile.permissions || [];
|
||||
return userPermission.includes(permission);
|
||||
};
|
||||
const hasPermission = (permission: PermissionKeys) => {
|
||||
const userPermission = profile.permissions || []
|
||||
return userPermission.includes(permission)
|
||||
}
|
||||
|
||||
return {role, hasPermission};
|
||||
};
|
||||
return { role, hasPermission }
|
||||
}
|
||||
|
||||
export default useRole;
|
||||
export default useRole
|
||||
Reference in new issue
Block a user