Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 4x 4x 1x 1x 1x 1x 1x 1x 1x | import { sum } from 'lodash-es';
import { CurrencySymbolsEnum } from '@amalia/ext/iso-4217';
import { type CurrencyValue } from '@amalia/kernel/monetary/types';
import { type UserComputed } from '@amalia/tenants/users/types';
export interface DataLeaderboard {
stats: Record<string, CurrencyValue>;
user: Pick<UserComputed, 'email' | 'firstName' | 'lastName' | 'pictureURL'>;
}
export interface DataBenchmarkByRule {
stats: Record<string, CurrencyValue>;
label: string;
}
export const getUserAmounts = (dataLeaderBoard: DataBenchmarkByRule | DataLeaderboard): number[] =>
Object.values(dataLeaderBoard.stats)
.map((s) => s.value)
.filter(Boolean);
export const sumTotalForUser = (dataLeaderBoard: DataBenchmarkByRule | DataLeaderboard): number =>
sum(getUserAmounts(dataLeaderBoard));
export const getUserCurrency = (dataBenchmarkByRule: DataBenchmarkByRule | DataLeaderboard): CurrencySymbolsEnum =>
Object.values(dataBenchmarkByRule.stats).at(0)?.symbol || CurrencySymbolsEnum.EUR;
|