Skip to content

Commit 8b2eff1

Browse files
authored
Merge pull request #947 from IFRCGo/feat/multiple-head-of-delegation
Show multiple head of delegation information for IFRC Presence
2 parents 59d7f58 + 179a073 commit 8b2eff1

File tree

4 files changed

+84
-24
lines changed

4 files changed

+84
-24
lines changed

.changeset/six-ways-wink.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"go-web-app": patch
3+
---
4+
5+
Show all head of delegation under IFRC Presence

app/src/views/CountryNsOverviewSupportingPartners/Presence/i18n.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"namespace": "countryPresence",
33
"strings": {
44
"countryIFRCPresenceTitle": "IFRC Presence",
5-
"countryIFRCPresenceHeadOfDelegation": "Head of delegation",
5+
"countryIFRCPresenceHeadOfDelegation": "Head of {delegationOfficeType}",
66
"countryIFRCLegalStatus": "IFRC legal status",
77
"countryIFRCContact": "Office contact information",
88
"countryIFRCDisasterLaw": "IFRC disaster law",

app/src/views/CountryNsOverviewSupportingPartners/Presence/index.tsx

Lines changed: 65 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import { useCallback } from 'react';
12
import { useOutletContext } from 'react-router-dom';
23
import {
34
Container,
5+
RawList,
46
TextOutput,
57
} from '@ifrc-go/ui';
68
import { useTranslation } from '@ifrc-go/ui/hooks';
@@ -11,24 +13,73 @@ import {
1113
} from '@togglecorp/fujs';
1214

1315
import Link from '#components/Link';
14-
import { type CountryOutletContext } from '#utils/outletContext';
16+
import {
17+
type CountryOutletContext,
18+
type CountryResponse,
19+
} from '#utils/outletContext';
1520

1621
import i18n from './i18n.json';
1722
import styles from './styles.module.css';
1823

1924
const year = new Date().getFullYear();
25+
2026
const 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+
}
2266
function 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,

app/src/views/CountryNsOverviewSupportingPartners/Presence/styles.module.css

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,21 @@
44
border-radius: var(--go-ui-border-radius-lg);
55
box-shadow: var(--go-ui-box-shadow-md);
66

7-
.ifrc-presence-item {
7+
.content {
88
display: flex;
99
justify-content: space-between;
10-
gap: var(--go-ui-spacing-md);
10+
11+
.delegation-information {
12+
display: flex;
13+
flex-direction: column;
14+
gap: var(--go-ui-spacing-md);
15+
}
16+
17+
.ifrc-presence-item {
18+
display: flex;
19+
flex-direction: column;
20+
gap: var(--go-ui-spacing-xs);
21+
}
1122
}
1223

1324
.icrc-presence-item {

0 commit comments

Comments
 (0)