@@ -20,6 +20,8 @@ import {
2020
2121import Link from '#components/Link' ;
2222import WikiLink from '#components/WikiLink' ;
23+ import useCountry from '#hooks/domain/useCountry' ;
24+ import usePermissions from '#hooks/domain/usePermissions' ;
2325import useDebouncedValue from '#hooks/useDebouncedValue' ;
2426import { type CountryOutletContext } from '#utils/outletContext' ;
2527import { useRequest } from '#utils/restRequest' ;
@@ -34,6 +36,20 @@ export function Component() {
3436 const { countryId, countryResponse } = useOutletContext < CountryOutletContext > ( ) ;
3537 const strings = useTranslation ( i18n ) ;
3638
39+ const {
40+ isCountryPerAdmin,
41+ isSuperUser,
42+ isRegionPerAdmin,
43+ isGuestUser,
44+ } = usePermissions ( ) ;
45+
46+ const countryDetails = useCountry ( { id : Number ( countryId ) } ) ;
47+ const regionId = isDefined ( countryDetails ) ? Number ( countryDetails ?. region ) : undefined ;
48+
49+ const isPerAdmin = isSuperUser
50+ || ( ! isGuestUser && isCountryPerAdmin ( Number ( countryId ) ) )
51+ || ( ! isGuestUser && isRegionPerAdmin ( regionId ) ) ;
52+
3753 const {
3854 pending : publicPerStatsPending ,
3955 response : publicPerStatsResponse ,
@@ -266,20 +282,34 @@ export function Component() {
266282 numPreferredGridContentColumns = { 5 }
267283 >
268284 { strengthComponents ?. map (
269- ( strengthComponent ) => (
270- < Container
271- heading = { strengthComponent ?. component_details . title }
272- headingLevel = { 5 }
273- key = { strengthComponent . component }
274- withHeaderBorder
275- withInternalPadding
276- icons = { < CheckboxFillIcon className = { styles . icon } /> }
277- withoutWrapInHeading
278- className = { styles . strengthComponent }
279- >
280- { strengthComponent ?. rating_details ?. title }
281- </ Container >
282- ) ,
285+ ( strengthComponent ) => {
286+ if ( ! isPerAdmin ) {
287+ return (
288+ < Container
289+ key = { strengthComponent . component }
290+ withInternalPadding
291+ className = { styles . strengthComponent }
292+ >
293+ { strengthComponent ?. component_details . title }
294+ </ Container >
295+ ) ;
296+ }
297+
298+ return (
299+ < Container
300+ heading = { strengthComponent ?. rating_details ?. title }
301+ headingLevel = { 5 }
302+ key = { strengthComponent . component }
303+ withHeaderBorder
304+ withInternalPadding
305+ icons = { < CheckboxFillIcon className = { styles . icon } /> }
306+ withoutWrapInHeading
307+ className = { styles . strengthComponent }
308+ >
309+ { strengthComponent ?. component_details . title }
310+ </ Container >
311+ ) ;
312+ } ,
283313 ) }
284314 </ Container >
285315 ) }
@@ -291,20 +321,33 @@ export function Component() {
291321 numPreferredGridContentColumns = { 5 }
292322 >
293323 { keyDevelopmentComponents ?. map (
294- ( keyDevelopmentComponent ) => (
295- < Container
296- heading = { keyDevelopmentComponent ?. component_details . title }
297- headingLevel = { 5 }
298- key = { keyDevelopmentComponent . component }
299- withHeaderBorder
300- withInternalPadding
301- icons = { < CheckboxFillIcon className = { styles . icon } /> }
302- withoutWrapInHeading
303- className = { styles . priorityComponent }
304- >
305- { keyDevelopmentComponent ?. rating_details ?. title }
306- </ Container >
307- ) ,
324+ ( keyDevelopmentComponent ) => {
325+ if ( ! isPerAdmin ) {
326+ return (
327+ < Container
328+ key = { keyDevelopmentComponent . component }
329+ withInternalPadding
330+ className = { styles . priorityComponent }
331+ >
332+ { keyDevelopmentComponent ?. component_details . title }
333+ </ Container >
334+ ) ;
335+ }
336+ return (
337+ < Container
338+ heading = { keyDevelopmentComponent ?. rating_details ?. title }
339+ headingLevel = { 5 }
340+ key = { keyDevelopmentComponent . component }
341+ withHeaderBorder
342+ withInternalPadding
343+ icons = { < CheckboxFillIcon className = { styles . icon } /> }
344+ withoutWrapInHeading
345+ className = { styles . priorityComponent }
346+ >
347+ { keyDevelopmentComponent ?. component_details . title }
348+ </ Container >
349+ ) ;
350+ } ,
308351 ) }
309352 </ Container >
310353 ) }
0 commit comments