@@ -32,6 +32,7 @@ import Link from '#components/Link';
3232import NonFieldError from '#components/NonFieldError' ;
3333import Page from '#components/Page' ;
3434import useGlobalEnums from '#hooks/domain/useGlobalEnums' ;
35+ import usePermissions from '#hooks/domain/usePermissions' ;
3536import useAlertContext from '#hooks/useAlert' ;
3637import useRouting from '#hooks/useRouting' ;
3738import {
@@ -76,7 +77,15 @@ const defaultFormValues: FormType = {};
7677export function Component ( ) {
7778 const strings = useTranslation ( i18n ) ;
7879
80+ const {
81+ isCountryAdmin,
82+ isRegionAdmin,
83+ isSuperUser,
84+ isIfrcAdmin,
85+ } = usePermissions ( ) ;
86+
7987 const { goBack } = useRouting ( ) ;
88+
8089 const alert = useAlertContext ( ) ;
8190 const {
8291 deployments_eru_type : eruTypeOptions ,
@@ -116,6 +125,7 @@ export function Component() {
116125 } ) ) ,
117126 } ) ;
118127 } ;
128+
119129 const {
120130 trigger : updateEruReadiness ,
121131 pending : updateEruReadinessPending ,
@@ -290,9 +300,19 @@ export function Component() {
290300 fetchEruReadinessData ( newValue ) ;
291301 }
292302 } ,
293- [ fetchEruReadinessData , setValue ] ,
303+ [
304+ fetchEruReadinessData ,
305+ setValue ,
306+ ] ,
294307 ) ;
295308
309+ const permittedEruOwners = eruOwnerResponse ?. results ?. filter ( ( owner ) => (
310+ isSuperUser
311+ || isIfrcAdmin
312+ || isCountryAdmin ( owner . national_society_country_details . id )
313+ || isRegionAdmin ( owner . national_society_country_details . region ?? undefined )
314+ ) ) ;
315+
296316 const eruTypes = useMemo ( ( ) => (
297317 value . eru_types ?. map ( ( eruType ) => eruType . type ) . filter ( isDefined )
298318 ) , [ value . eru_types ] ) ;
@@ -359,7 +379,7 @@ export function Component() {
359379 >
360380 < SelectInput
361381 name = "eru_owner"
362- options = { eruOwnerResponse ?. results }
382+ options = { permittedEruOwners }
363383 onChange = { handleEruOwnerChange }
364384 value = { value . eru_owner }
365385 keySelector = { eruOwnerKeySelector }
0 commit comments