Skip to content

Commit 073fa1e

Browse files
frozenheliumsamshara
authored andcommitted
Remove personal detail for focal unit point from local units table
- Add a constant for default invalid text in GO UI - Use the default invalid text constant
1 parent 7cf6e56 commit 073fa1e

File tree

20 files changed

+78
-40
lines changed

20 files changed

+78
-40
lines changed

.changeset/great-rivers-wave.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+
Remove personal detail for focal point in local units table
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@ifrc-go/ui": patch
3+
---
4+
5+
Add a constant for default invalid text

app/src/components/domain/AppealsOverYearsChart/PointDetails/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function PointDetails(props: Props) {
8484
/>
8585
<TextOutput
8686
label={strings.timelineChartPeopleTargetedLabel}
87-
value={Number(data.dref?.beneficiaries) ?? '-'}
87+
value={Number(data.dref?.beneficiaries)}
8888
valueType="number"
8989
strongValue
9090
/>

app/src/utils/common.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { DEFAULT_INVALID_TEXT } from '@ifrc-go/ui/utils';
12
import {
23
compareNumber,
34
isNotDefined,
@@ -77,15 +78,18 @@ export function downloadFile(
7778
URL.revokeObjectURL(url);
7879
}
7980

80-
export function chooseName(
81-
primaryName: string | null | undefined,
82-
secondaryName: string | null | undefined,
81+
export function getFirstTruthyString(
82+
primaryStr: string | null | undefined,
83+
secondaryStr: string | null | undefined,
84+
invalidText = DEFAULT_INVALID_TEXT,
8385
) {
84-
if (isTruthyString(primaryName)) {
85-
return primaryName;
86+
if (isTruthyString(primaryStr)) {
87+
return primaryStr;
8688
}
87-
if (isTruthyString(secondaryName)) {
88-
return secondaryName;
89+
90+
if (isTruthyString(secondaryStr)) {
91+
return secondaryStr;
8992
}
90-
return '--';
93+
94+
return invalidText;
9195
}

app/src/views/AccountMyFormsPer/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
createExpansionIndicatorColumn,
2121
createNumberColumn,
2222
createStringColumn,
23+
DEFAULT_INVALID_TEXT,
2324
numericIdSelector,
2425
} from '@ifrc-go/ui/utils';
2526
import {
@@ -137,7 +138,7 @@ export function Component() {
137138
createStringColumn<PerProcessStatusItem, number>(
138139
'phase',
139140
strings.tablePerPhaseTitle,
140-
(item) => (isDefined(item.phase) ? `${item.phase} - ${item.phase_display}` : '-'),
141+
(item) => (isDefined(item.phase) ? `${item.phase} - ${item.phase_display}` : DEFAULT_INVALID_TEXT),
141142
{ sortable: true },
142143
),
143144
createElementColumn<PerProcessStatusItem, number, PerTableActionsProps>(

app/src/views/CountryNsOverviewActivities/Map/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ import {
99
Message,
1010
} from '@ifrc-go/ui';
1111
import { useTranslation } from '@ifrc-go/ui/hooks';
12-
import { resolveToString } from '@ifrc-go/ui/utils';
12+
import {
13+
DEFAULT_INVALID_TEXT,
14+
resolveToString,
15+
} from '@ifrc-go/ui/utils';
1316
import {
1417
_cs,
1518
isDefined,
@@ -348,7 +351,7 @@ function CountryThreeWNationalSocietyProjectsMap(props: Props) {
348351
className={styles.mapContainer}
349352
title={resolveToString(
350353
strings.countryNSMapTitle,
351-
{ countryName: countryResponse?.society_name ?? '-' },
354+
{ countryName: countryResponse?.society_name ?? DEFAULT_INVALID_TEXT },
352355
)}
353356
footer={(
354357
<div className={styles.legend}>

app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsMap/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import MapContainerWithDisclaimer from '#components/MapContainerWithDisclaimer';
4242
import MapPopup from '#components/MapPopup';
4343
import useAuth from '#hooks/domain/useAuth';
4444
import useFilterState from '#hooks/useFilterState';
45-
import { chooseName } from '#utils/common';
45+
import { getFirstTruthyString } from '#utils/common';
4646
import {
4747
COLOR_DARK_GREY,
4848
COLOR_PRIMARY_BLUE,
@@ -349,12 +349,12 @@ function LocalUnitsMap(props: Props) {
349349
&& countryResponse.emails.length > 0;
350350
const hasContactDetails = hasAddress || hasEmails;
351351

352-
const localUnitName = useMemo(() => chooseName(
352+
const localUnitName = useMemo(() => getFirstTruthyString(
353353
localUnitDetail?.local_branch_name,
354354
localUnitDetail?.english_branch_name,
355355
), [localUnitDetail?.local_branch_name, localUnitDetail?.english_branch_name]);
356356

357-
const localUnitAddress = useMemo(() => chooseName(
357+
const localUnitAddress = useMemo(() => getFirstTruthyString(
358358
localUnitDetail?.address_loc,
359359
localUnitDetail?.address_en,
360360
), [localUnitDetail?.address_loc, localUnitDetail?.address_en]);

app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsTable/index.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
} from '@togglecorp/fujs';
1919

2020
import useFilterState from '#hooks/useFilterState';
21-
import { chooseName } from '#utils/common';
21+
import { getFirstTruthyString } from '#utils/common';
2222
import { type CountryOutletContext } from '#utils/outletContext';
2323
import {
2424
type GoApiResponse,
@@ -85,12 +85,12 @@ function LocalUnitsTable() {
8585
createStringColumn<LocalUnitsTableListItem, number>(
8686
'branch_name',
8787
strings.localUnitsTableName,
88-
(item) => chooseName(item.local_branch_name, item.english_branch_name),
88+
(item) => getFirstTruthyString(item.local_branch_name, item.english_branch_name),
8989
),
9090
createStringColumn<LocalUnitsTableListItem, number>(
9191
'address',
9292
strings.localUnitsTableAddress,
93-
(item) => chooseName(item.address_loc, item.address_en),
93+
(item) => getFirstTruthyString(item.address_loc, item.address_en),
9494
),
9595
createStringColumn<LocalUnitsTableListItem, number>(
9696
'type',
@@ -101,17 +101,17 @@ function LocalUnitsTable() {
101101
createStringColumn<LocalUnitsTableListItem, number>(
102102
'focal',
103103
strings.localUnitsTableFocal,
104-
(item) => chooseName(item.focal_person_loc, item.focal_person_en),
104+
(item) => getFirstTruthyString(item.focal_person_loc, item.focal_person_en),
105105
),
106106
createStringColumn<LocalUnitsTableListItem, number>(
107107
'phone',
108108
strings.localUnitsTablePhoneNumber,
109-
(item) => chooseName(item.phone, item?.health_details?.focal_point_phone_number),
109+
(item) => item.phone,
110110
),
111111
createStringColumn<LocalUnitsTableListItem, number>(
112112
'email',
113113
strings.localUnitsTableEmail,
114-
(item) => chooseName(item.email, item?.health_details?.focal_point_email),
114+
(item) => item.email,
115115
),
116116
createBooleanColumn<LocalUnitsTableListItem, number>(
117117
'validated',

app/src/views/CountryNsOverviewContextAndStructure/index.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import { useState } from 'react';
22
import { useOutletContext } from 'react-router-dom';
33
import { Container } from '@ifrc-go/ui';
44
import { useTranslation } from '@ifrc-go/ui/hooks';
5-
import { resolveToString } from '@ifrc-go/ui/utils';
5+
import {
6+
DEFAULT_INVALID_TEXT,
7+
resolveToString,
8+
} from '@ifrc-go/ui/utils';
69
import {
710
compareNumber,
811
isDefined,
@@ -124,7 +127,7 @@ export function Component() {
124127
>
125128
{resolveToString(
126129
strings.countryOnIFRC,
127-
{ countryName: countryResponse?.name ?? '-' },
130+
{ countryName: countryResponse?.name ?? DEFAULT_INVALID_TEXT },
128131
)}
129132
</Link>
130133
)}
@@ -137,7 +140,7 @@ export function Component() {
137140
>
138141
{resolveToString(
139142
strings.countryOnReliefWeb,
140-
{ countryName: countryResponse?.name ?? '-' },
143+
{ countryName: countryResponse?.name ?? DEFAULT_INVALID_TEXT },
141144
)}
142145
</Link>
143146
)}
@@ -150,7 +153,7 @@ export function Component() {
150153
>
151154
{resolveToString(
152155
strings.countryRCHomepage,
153-
{ countryName: countryResponse?.name ?? '-' },
156+
{ countryName: countryResponse?.name ?? DEFAULT_INVALID_TEXT },
154157
)}
155158
</Link>
156159
)}
@@ -163,7 +166,7 @@ export function Component() {
163166
>
164167
{resolveToString(
165168
strings.countryDisasterLaw,
166-
{ countryName: countryResponse?.name ?? '-' },
169+
{ countryName: countryResponse?.name ?? DEFAULT_INVALID_TEXT },
167170
)}
168171
</Link>
169172
)}

app/src/views/CountryOngoingActivitiesThreeWProjects/Map/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
} from '@ifrc-go/ui';
1212
import { useTranslation } from '@ifrc-go/ui/hooks';
1313
import {
14+
DEFAULT_INVALID_TEXT,
1415
denormalizeList,
1516
resolveToString,
1617
} from '@ifrc-go/ui/utils';
@@ -346,7 +347,7 @@ function CountryThreeWMap(props: Props) {
346347
className={styles.mapContainer}
347348
title={resolveToString(
348349
strings.threeWMapTitle,
349-
{ countryName: countryResponse?.name ?? '-' },
350+
{ countryName: countryResponse?.name ?? DEFAULT_INVALID_TEXT },
350351
)}
351352
footer={operationTypeOptions && operationTypeOptions.length > 0 && (
352353
<div className={styles.legend}>

0 commit comments

Comments
 (0)