@@ -2,6 +2,7 @@ import { List } from "@mui/material";
2
2
3
3
import { CreateProjectListItem } from "../../../../../components/projects/CreateProject/CreateProjectListItem" ;
4
4
import { useGetPersonalUnit } from "../../../../../hooks/useGetPersonalUnit" ;
5
+ import { useASAuthorizationStatus } from "../../../../../hooks/useIsAuthorized" ;
5
6
import { useKeycloakUser } from "../../../../../hooks/useKeycloakUser" ;
6
7
import { useSelectedOrganisation } from "../../../../../state/organisationSelection" ;
7
8
import { useSelectedUnit } from "../../../../../state/unitSelection" ;
@@ -24,20 +25,20 @@ export const UnitActions = () => {
24
25
25
26
const { data : personalUnit , isLoading, error } = useGetPersonalUnit ( ) ;
26
27
28
+ const isAdminUser = useASAuthorizationStatus ( ) === process . env . NEXT_PUBLIC_KEYCLOAK_AS_ADMIN_ROLE ;
29
+
30
+ const organisationIsDefault = organisation ?. name === process . env . NEXT_PUBLIC_DEFAULT_ORG_NAME ;
31
+
27
32
return (
28
33
< List sx = { { width : "100%" } } >
29
- { ! ! ( isOrganisationOwner || organisation ?. caller_is_member ) &&
30
- organisation ?. name !== process . env . NEXT_PUBLIC_DEFAULT_ORG_NAME && < CreateUnitListItem /> }
31
- { personalUnit === undefined &&
32
- ! isLoading &&
33
- ! error &&
34
- organisation ?. name === process . env . NEXT_PUBLIC_DEFAULT_ORG_NAME && (
35
- < CreateDefaultUnitListItem />
36
- ) }
37
- { ! ! isUnitOwner && ! ! unit && (
34
+ { ! ! ( isAdminUser || isOrganisationOwner || ! ! organisation ?. caller_is_member ) &&
35
+ ! organisationIsDefault && < CreateUnitListItem /> }
36
+ { personalUnit === undefined && ! isLoading && ! error && ! ! organisationIsDefault && (
37
+ < CreateDefaultUnitListItem />
38
+ ) }
39
+ { ! ! ( isAdminUser || isUnitOwner ) && ! ! unit && (
38
40
< DeleteUnitListItem unit = { unit } onDelete = { ( ) => setUnit ( undefined ) } />
39
41
) }
40
-
41
42
{ ! ! unit && < EditUnitListItem unit = { unit } /> }
42
43
{ ! ! unit && ! ! ( unit . caller_is_member || unit . owner_id === user . username ) && (
43
44
< CreateProjectListItem unit = { unit } />
0 commit comments