Skip to content

Commit 07436a3

Browse files
shreeyash07frozenhelium
authored andcommitted
fix(surge): handle undefined society name
1 parent b0a4c33 commit 07436a3

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

.changeset/pink-plants-design.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+
Fix the undefined society name issue in surge page [#1899](https://github.com/IFRCGo/go-web-app/issues/1899)

app/src/hooks/domain/useNationalSociety.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export type NationalSociety = Omit<Country, 'society_name'> & {
2323
function isValidNationalSociety(country: PartialCountry): country is NationalSociety {
2424
return (
2525
isValidCountry(country)
26-
&& isTruthyString(country.society_name)
26+
&& isTruthyString(country?.society_name)
2727
);
2828
}
2929

app/src/views/ActiveSurgeDeployments/ActiveSurgeSupport/SurgeCard/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@ function SurgeCard(props: Props) {
8787

8888
const eruDeployingOrganizations = useMemo(() => (
8989
unique(erus
90-
.map((eru) => eru.eru_owner_details.national_society_country_details.society_name)
90+
.map((eru) => eru.eru_owner_details.national_society_country_details?.society_name)
9191
.filter(isDefined)
9292
.map((nationalSociety) => ({ name: nationalSociety })))
9393
), [erus]);
9494

9595
const personnelDeployingOrganizations = useMemo(() => (
9696
unique(personnel
97-
.map((person) => (person.country_from.society_name))
97+
.map((person) => (person.country_from?.society_name))
9898
.filter(isDefined)
9999
.map((nationalSociety) => ({ name: nationalSociety })))
100100
), [personnel]);

app/src/views/ActiveSurgeDeployments/OngoingEruDeployments/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ function OngoingEruDeployments() {
207207
createStringColumn<EruListItem, number>(
208208
'society_name',
209209
strings.eruOrganisation,
210-
(item) => item?.eru_owner_details?.national_society_country_details.society_name,
210+
(item) => item?.eru_owner_details?.national_society_country_details?.society_name,
211211
),
212212
createLinkColumn<EruListItem, number>(
213213
'country',

0 commit comments

Comments
 (0)