Skip to content

Commit

Permalink
fix: add all appeals link for country
Browse files Browse the repository at this point in the history
  • Loading branch information
samshara authored and frozenhelium committed Dec 6, 2023
1 parent 34ff0c8 commit d3f5806
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/components/domain/ActiveOperationMap/i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"presentationModeButton":"Presentation Mode",
"operationMapViewAll":"View all Operations",
"operationMapViewAllInRegion":"View all Operations in this Region",
"operationMapViewAllInCountry": "View all Operations in this Country",
"operationPopoverPeopleAffected":"People Targeted",
"operationPopoverAmountRequested":"Amount Requested (CHF)",
"operationPopoverAmountFunded":"Amount Funded (CHF)",
Expand Down
31 changes: 27 additions & 4 deletions src/components/domain/ActiveOperationMap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,31 @@ function ActiveOperationMap(props: Props) {
[countryResponse, countryGroupedAppeal],
);

const allAppealsType = useMemo(() => {
if (isDefined(countryId)) {
return {
searchParam: `country=${countryId}`,
title: strings.operationMapViewAllInCountry,
};
}
if (isDefined(regionId)) {
return {
searchParam: `region=${regionId}`,
title: strings.operationMapViewAllInRegion,
};
}
return {
searchParam: undefined,
title: strings.operationMapViewAll,
};
}, [
countryId,
regionId,
strings.operationMapViewAllInCountry,
strings.operationMapViewAllInRegion,
strings.operationMapViewAll,
]);

const heading = resolveToComponent(
strings.activeOperationsTitle,
{ numAppeals: appealResponse?.count ?? '--' },
Expand Down Expand Up @@ -412,13 +437,11 @@ function ActiveOperationMap(props: Props) {
actions={!presentationMode && (
<Link
to="allAppeals"
urlSearch={isDefined(regionId) ? `region=${regionId}` : undefined}
urlSearch={allAppealsType.searchParam}
withLinkIcon
withUnderline
>
{variant === 'region'
? strings.operationMapViewAllInRegion
: strings.operationMapViewAll}
{allAppealsType.title}
</Link>
)}
>
Expand Down

0 comments on commit d3f5806

Please sign in to comment.