1+ import { useCallback } from 'react' ;
12import { useOutletContext } from 'react-router-dom' ;
23import {
34 Container ,
5+ RawList ,
46 TextOutput ,
57} from '@ifrc-go/ui' ;
68import { useTranslation } from '@ifrc-go/ui/hooks' ;
@@ -11,24 +13,73 @@ import {
1113} from '@togglecorp/fujs' ;
1214
1315import Link from '#components/Link' ;
14- import { type CountryOutletContext } from '#utils/outletContext' ;
16+ import {
17+ type CountryOutletContext ,
18+ type CountryResponse ,
19+ } from '#utils/outletContext' ;
1520
1621import i18n from './i18n.json' ;
1722import styles from './styles.module.css' ;
1823
1924const year = new Date ( ) . getFullYear ( ) ;
25+
2026const legalStatusLink = 'https://fednet.ifrc.org/en/support/legal/legal/legal-status/' ;
2127
28+ interface DelegationInformationProps {
29+ name : string | null | undefined ;
30+ contact : string | null | undefined ;
31+ delegationOfficeType : string ;
32+ }
33+
34+ type CountryDelgation = NonNullable < CountryResponse > [ 'country_delegation' ] [ number ] ;
35+ const countryDelegationKeySelector = ( countryDelegation : CountryDelgation ) => (
36+ `${ countryDelegation . dotype_name } -${ countryDelegation . hod_first_name } -${ countryDelegation . hod_last_name } `
37+ ) ;
38+
39+ function DelegationInformation ( props : DelegationInformationProps ) {
40+ const {
41+ name,
42+ contact,
43+ delegationOfficeType,
44+ } = props ;
45+
46+ const strings = useTranslation ( i18n ) ;
47+
48+ return (
49+ < div className = { styles . delegation } >
50+ < TextOutput
51+ label = { resolveToString (
52+ strings . countryIFRCPresenceHeadOfDelegation ,
53+ { delegationOfficeType } ,
54+ ) }
55+ value = { name }
56+ strongValue
57+ />
58+ < TextOutput
59+ label = { strings . countryIFRCContact }
60+ value = { contact }
61+ strongValue
62+ />
63+ </ div >
64+ ) ;
65+ }
2266function Presence ( ) {
2367 const strings = useTranslation ( i18n ) ;
2468
2569 const { countryResponse } = useOutletContext < CountryOutletContext > ( ) ;
2670
27- const hodValue = [
28- countryResponse ?. country_delegation ?. hod_first_name ,
29- countryResponse ?. country_delegation ?. hod_last_name ,
30- ] . filter ( isTruthyString ) . join ( ' ' ) ;
71+ const countryDelegationRendererParams = useCallback ( ( _ : string , value : CountryDelgation ) => {
72+ const hodName = [
73+ value . hod_first_name ,
74+ value . hod_last_name ,
75+ ] . filter ( isTruthyString ) . join ( ' ' ) ;
3176
77+ return {
78+ name : hodName ,
79+ contact : value . hod_mobile_number ,
80+ delegationOfficeType : value . dotype_name ,
81+ } ;
82+ } , [ ] ) ;
3283 return (
3384 < Container
3485 className = { styles . presence }
@@ -54,17 +105,19 @@ function Presence() {
54105 ) }
55106 />
56107 ) }
57- contentViewType = "vertical"
58108 withHeaderBorder
59109 withInternalPadding
60- spacing = "comfortable"
110+ childrenContainerClassName = { styles . content }
61111 >
62- < div className = { styles . ifrcPresenceItem } >
63- < TextOutput
64- label = { strings . countryIFRCPresenceHeadOfDelegation }
65- value = { hodValue }
66- strongValue
112+ < div className = { styles . delegationInformation } >
113+ < RawList
114+ data = { countryResponse ?. country_delegation }
115+ keySelector = { countryDelegationKeySelector }
116+ renderer = { DelegationInformation }
117+ rendererParams = { countryDelegationRendererParams }
67118 />
119+ </ div >
120+ < div className = { styles . ifrcPresenceItem } >
68121 < Link
69122 href = { legalStatusLink }
70123 external
@@ -73,13 +126,6 @@ function Presence() {
73126 >
74127 { strings . countryIFRCLegalStatus }
75128 </ Link >
76- </ div >
77- < div className = { styles . ifrcPresenceItem } >
78- < TextOutput
79- label = { strings . countryIFRCContact }
80- value = { countryResponse ?. country_delegation ?. hod_mobile_number }
81- strongValue
82- />
83129 { isDefined ( countryResponse ?. disaster_law_url ) && (
84130 < Link
85131 href = { countryResponse . disaster_law_url }
@@ -110,10 +156,8 @@ function Presence() {
110156 ) }
111157 />
112158 ) }
113- contentViewType = "vertical"
114159 withHeaderBorder
115160 withInternalPadding
116- spacing = "comfortable"
117161 >
118162 { resolveToString (
119163 strings . countryICRCConfirmedPartner ,
0 commit comments