Skip to content

Commit 63b867f

Browse files
committed
feat: add key hasManagerPermissions in user roles hook
1 parent ae2b158 commit 63b867f

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

src/Common/Hooks/UseGetUserRoles/UseGetUserRoles.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,29 @@
1616

1717
import { useEffect, useState } from 'react'
1818
import { getUserRole } from '../../Common.service'
19-
import { useGetUserRolesType } from './types'
19+
import { UseGetUserRolesType } from './types'
2020
import { showError } from '../../Helper'
2121

2222
/**
2323
* @description It will return isSuperAdmin and would be set to false by default, might need few optimizations like dep, etc
24-
* @returns {useGetUserRolesType} isSuperAdmin, canManageAllAccess
24+
* @returns {UseGetUserRolesType} isSuperAdmin, canManageAllAccess
2525
*/
26-
const useGetUserRoles = (): useGetUserRolesType => {
27-
const [result, setResult] = useState<useGetUserRolesType>({ isSuperAdmin: false, canManageAllAccess: false })
26+
const useGetUserRoles = (): UseGetUserRolesType => {
27+
const [result, setResult] = useState<UseGetUserRolesType>({
28+
isSuperAdmin: false,
29+
canManageAllAccess: false,
30+
hasManagerPermissions: false,
31+
})
2832

2933
useEffect(() => {
3034
getUserRole()
3135
.then(({ result: apiResult }) => {
36+
const hasManagerPermissions = apiResult.roles.some((role) => role.startsWith('role:manager'))
37+
3238
setResult({
3339
isSuperAdmin: apiResult.superAdmin ?? false,
3440
canManageAllAccess: apiResult.canManageAllAccess ?? false,
41+
hasManagerPermissions,
3542
})
3643
})
3744
.catch((error) => {

src/Common/Hooks/UseGetUserRoles/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414
* limitations under the License.
1515
*/
1616

17-
export interface useGetUserRolesType {
17+
export interface UseGetUserRolesType {
1818
isSuperAdmin: boolean
1919
/**
2020
* User can give access to all other users
2121
*/
2222
canManageAllAccess?: boolean
23+
hasManagerPermissions: boolean
2324
}

src/Shared/Components/ReactSelect/utils.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ export const getCommonSelectStyle = (styleOverrides = {}): StylesConfig => ({
3939
...base,
4040
minHeight: '32px',
4141
boxShadow: 'none',
42-
backgroundColor: state.isDisabled ? 'var(--N100)' : 'var(--bg-secondary)',
42+
backgroundColor: 'var(--bg-secondary)',
4343
border: '1px solid var(--N200)',
4444
cursor: state.isDisabled ? 'not-allowed' : 'pointer',
45+
opacity: state.isDisabled ? 0.5 : 1,
4546

4647
'&:hover': {
4748
borderColor: 'var(--N300)',

0 commit comments

Comments
 (0)