Skip to content

Commit

Permalink
Merge pull request #746 from IFRCGo/fix/minor-issues
Browse files Browse the repository at this point in the history
Fix minor issues in various pages
  • Loading branch information
samshara authored Mar 6, 2024
2 parents b84a70c + e375a12 commit 3ac6dd0
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 10 deletions.
1 change: 0 additions & 1 deletion app/src/components/domain/AppealsTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ function AppealsTable(props: Props) {
createProgressColumn<AppealListItem, string>(
'amount_funded',
strings.appealsTableFundedAmount,
// FIXME: use progress function
(item) => (
getPercentage(
item.amount_funded,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"failedToCreateExport": "Failed to generate export.",
"totalProjectsTitle": "Total Projects",
"ongoingProjectBudgetTitle": "Total Budget (CHF) for Ongoing Projects",
"threeWOngoingProjectsTitle": "All Projects",
"viewAllOngoingProjects": "View All Ongoing Projects",
"threeWOngoingProjectsTitle": "Ongoing Projects",
"viewAllProjects": "View all Projects in this Country",
"threeWInCountryMapSidebarTitle": "Projects by Province",
"provinceProjects": "{provinceName} ({numProjects} Projects)",
"otherProjects": "Others ({numProjects} Projects)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ export function Component() {
urlSearch={`country=${countryResponse?.id}`}
withLinkIcon
>
{strings.viewAllOngoingProjects}
{strings.viewAllProjects}
</Link>
</>
)}
Expand Down
2 changes: 1 addition & 1 deletion app/src/views/GlobalThreeW/Map/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ function GlobalThreeWMap(props: Props) {
onCloseButtonClick={handlePointClose}
heading={(
<Link
to="countriesThreeWLayout"
to="countryOngoingActivitiesThreeWProjects"
urlParams={{
countryId: clickedPointProperties
.countryId,
Expand Down
2 changes: 1 addition & 1 deletion app/src/views/RegionThreeW/MovementActivitiesMap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ function MovementActivitiesMap(props: Props) {
headingLevel={5}
heading={(
<Link
to="countriesLayout"
to="countryOngoingActivitiesThreeWProjects"
urlParams={{ countryId: clickedPointProperties.countryId }}
withUnderline
>
Expand Down
2 changes: 1 addition & 1 deletion app/src/views/RegionThreeW/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export function Component() {
title: (
<div className={styles.countrySectorTitle}>
<Link
to="countryThreeWIndex"
to="countryOngoingActivitiesThreeWProjects"
urlParams={{ countryId: country.id }}
>
{country.name}
Expand Down
2 changes: 1 addition & 1 deletion app/src/views/ThreeWProjectDetail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export function Component() {
value={(
<Link
withUnderline
to="countriesThreeWLayout"
to="countryOngoingActivitiesThreeWProjects"
urlParams={{
countryId: projectResponse?.project_country_detail.id,
}}
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/components/Table/ColumnShortcuts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export function createBooleanColumn<D, K>(
export function createProgressColumn<D, K>(
id: string,
title: string,
accessor: (item: D) => number,
accessor: (item: D) => number | undefined,
options?: Options<D, K, ProgressBarProps, HeaderCellProps>,
) {
const item: Column<D, K, ProgressBarProps, HeaderCellProps> & {
Expand Down
31 changes: 30 additions & 1 deletion packages/ui/src/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,41 @@ export function roundSafe(value: number | undefined | null): number | undefined
return Math.round(value);
}

export function getPercentage(
value: null | undefined,
total: null | undefined,
isBounded?: boolean,
): undefined
export function getPercentage(
value: number,
total: null | undefined,
isBounded?: boolean,
): undefined
export function getPercentage(
value: null | undefined,
total: number,
isBounded?: boolean,
): undefined
export function getPercentage(
value: number,
total: number,
isBounded?: boolean,
): number
export function getPercentage(
value: number | null | undefined,
total: number | null | undefined,
isBounded?: boolean,
): number | undefined
export function getPercentage(
value: number | null | undefined,
total: number | null | undefined,
isBounded = true,
) {
if (isNotDefined(value) || isNotDefined(total) || total === 0) {
if (isNotDefined(value) || isNotDefined(total)) {
return undefined;
}

if (total === 0) {
return 0;
}

Expand Down

0 comments on commit 3ac6dd0

Please sign in to comment.