Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Website: Transparency page (fixing bugs) #972

Merged
merged 4 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Card, CardContent, Typography } from '@socialincome/ui';
import _ from 'lodash';
import { SectionProps } from './page';

export const roundAmount = (amount: number) => Math.round(amount / 10) * 10;
export const roundAmount = (amount: number) => (amount ? Math.round(amount / 10) * 10 : 0);

export async function Section1({ params, paymentStats, contributionStats }: SectionProps) {
const translator = await Translator.getInstance({ language: params.lang, namespaces: ['website-finances'] });
Expand All @@ -22,6 +22,7 @@ export async function Section1({ params, paymentStats, contributionStats }: Sect
contributorCount: contributionStats.totalContributorsCount,
value: roundAmount(contributionStats.totalContributionsAmount),
currency: params.currency,
maximumFractionDigits: 0,
},
}),
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ export async function Section2({ params, contributionStats, expensesStats, payme
<InfoCard
sectionTitle={translator.t('section-2.donations')}
title={translator.t('amount', {
context: { value: roundAmount(contributionStats.totalContributionsAmount), currency: params.currency },
context: {
value: roundAmount(contributionStats.totalContributionsAmount),
currency: params.currency,
maximumFractionDigits: 0,
},
})}
text={translator.t('section-2.amount-since-march-2020')}
firstIcon={<HeartIcon className="h-8 w-8" />}
Expand All @@ -30,6 +34,7 @@ export async function Section2({ params, contributionStats, expensesStats, payme
context: {
value: roundAmount(contributionStats.totalIndividualContributionsAmount),
currency: params.currency,
maximumFractionDigits: 0,
},
})}
</Typography>
Expand All @@ -44,6 +49,7 @@ export async function Section2({ params, contributionStats, expensesStats, payme
context: {
value: roundAmount(paymentStats.totalPaymentsAmount),
currency: params.currency,
maximumFractionDigits: 0,
},
})}
</Typography>
Expand All @@ -54,6 +60,7 @@ export async function Section2({ params, contributionStats, expensesStats, payme
contributionStats.totalIndividualContributionsAmount - paymentStats.totalPaymentsAmount,
),
currency: params.currency,
maximumFractionDigits: 0,
},
})}
</Typography>
Expand All @@ -68,6 +75,7 @@ export async function Section2({ params, contributionStats, expensesStats, payme
context: {
value: roundAmount(contributionStats.totalInstitutionalContributionsAmount),
currency: params.currency,
maximumFractionDigits: 0,
},
})}
</Typography>
Expand All @@ -82,6 +90,7 @@ export async function Section2({ params, contributionStats, expensesStats, payme
context: {
value: roundAmount(expensesProject),
currency: params.currency,
maximumFractionDigits: 0,
},
})}
</Typography>
Expand All @@ -90,6 +99,7 @@ export async function Section2({ params, contributionStats, expensesStats, payme
context: {
value: roundAmount(contributionStats.totalInstitutionalContributionsAmount - expensesProject),
currency: params.currency,
maximumFractionDigits: 0,
},
})}
</Typography>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ export async function Section3({ params, contributionStats }: SectionProps) {
country: translator.t(entry.country),
total: translator.t('section-3.country-amount', {
context: {
contributorsCount: entry.usersCount,
value: roundAmount(entry.amount),
currency: params.currency,
contributorsCount: entry.usersCount,
maximumFractionDigits: 0,
},
}),
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export async function Section4({ params, expensesStats, paymentStats, contributi
context: {
value: roundAmount(expensesTotal),
currency: params.currency,
maximumFractionDigits: 0,
},
})}
text={translator.t('section-4.amount-since-march-2020')}
Expand All @@ -41,6 +42,7 @@ export async function Section4({ params, expensesStats, paymentStats, contributi
context: {
value: roundAmount(paymentStats.totalPaymentsAmount),
currency: params.currency,
maximumFractionDigits: 0,
recipientsCount: paymentStats.totalRecipientsCount,
},
})}
Expand All @@ -51,6 +53,7 @@ export async function Section4({ params, expensesStats, paymentStats, contributi
context: {
value: roundAmount(_.last(paymentStats.totalPaymentsByMonth)?.amount as number),
currency: params.currency,
maximumFractionDigits: 0,
recipientsCount: _.last(paymentStats.totalPaymentsByMonth)?.recipientsCount,
},
})}
Expand All @@ -62,6 +65,7 @@ export async function Section4({ params, expensesStats, paymentStats, contributi
contributionStats.totalIndividualContributionsAmount - paymentStats.totalPaymentsAmount,
),
currency: params.currency,
maximumFractionDigits: 0,
},
})}
</Typography>
Expand All @@ -76,6 +80,7 @@ export async function Section4({ params, expensesStats, paymentStats, contributi
context: {
value: roundAmount(_.sum(Object.values(expensesStats.totalExpensesByType))),
currency: params.currency,
maximumFractionDigits: 0,
},
})}
</Typography>
Expand All @@ -85,6 +90,7 @@ export async function Section4({ params, expensesStats, paymentStats, contributi
context: {
value: roundAmount(expensesStats.totalExpensesByType.donation_fees),
currency: params.currency,
maximumFractionDigits: 0,
},
})}
<TooltipProvider delayDuration={100}>
Expand All @@ -101,6 +107,7 @@ export async function Section4({ params, expensesStats, paymentStats, contributi
context: {
value: roundAmount(expensesStats.totalExpensesByType.delivery_fees),
currency: params.currency,
maximumFractionDigits: 0,
},
})}
<TooltipProvider delayDuration={100}>
Expand All @@ -117,6 +124,7 @@ export async function Section4({ params, expensesStats, paymentStats, contributi
context: {
value: roundAmount(expensesStats.totalExpensesByType.exchange_rate_loss),
currency: params.currency,
maximumFractionDigits: 0,
},
})}
<TooltipProvider delayDuration={100}>
Expand All @@ -133,6 +141,7 @@ export async function Section4({ params, expensesStats, paymentStats, contributi
context: {
value: roundAmount(expensesStats.totalExpensesByType.account_fees),
currency: params.currency,
maximumFractionDigits: 0,
},
})}
<TooltipProvider delayDuration={100}>
Expand All @@ -147,7 +156,11 @@ export async function Section4({ params, expensesStats, paymentStats, contributi

<Typography as="div" className="flex-inline flex items-center">
{translator.t('section-4.staff-costs', {
context: { value: roundAmount(expensesStats.totalExpensesByType.staff), currency: params.currency },
context: {
value: roundAmount(expensesStats.totalExpensesByType.staff),
currency: params.currency,
maximumFractionDigits: 0,
},
})}
<TooltipProvider delayDuration={100}>
<Tooltip>
Expand All @@ -163,6 +176,7 @@ export async function Section4({ params, expensesStats, paymentStats, contributi
context: {
value: roundAmount(expensesStats.totalExpensesByType.fundraising_advertising),
currency: params.currency,
maximumFractionDigits: 0,
},
})}
<TooltipProvider delayDuration={100}>
Expand All @@ -179,6 +193,7 @@ export async function Section4({ params, expensesStats, paymentStats, contributi
context: {
value: roundAmount(expensesStats.totalExpensesByType.administrative),
currency: params.currency,
maximumFractionDigits: 0,
},
})}
<TooltipProvider delayDuration={100}>
Expand All @@ -197,7 +212,11 @@ export async function Section4({ params, expensesStats, paymentStats, contributi
<InfoCard
sectionTitle={translator.t('section-4.reserves')}
title={translator.t('amount', {
context: { value: roundAmount(reservesTotal), currency: params.currency },
context: {
value: roundAmount(reservesTotal),
currency: params.currency,
maximumFractionDigits: 0,
},
})}
text={translator.t('section-4.amount-since-march-2020')}
firstIcon={<DevicePhoneMobileIcon className="h-8 w-8" />}
Expand Down
Loading