Initial commit: Tapalka monorepo (bot, front, strapi)
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
function declension(num: number, words: string[]): string {
|
||||
const cases = [2, 0, 1, 1, 1, 2];
|
||||
return words[num % 100 > 4 && num % 100 < 20 ? 2 : cases[num % 10 < 5 ? num % 10 : 5]];
|
||||
}
|
||||
|
||||
export function updateFriendAndReferralCounts(
|
||||
referralsLength: number,
|
||||
referralsCount: number,
|
||||
): { friendsWord: string; referralWord: string } {
|
||||
const friendWord = declension(referralsLength, ['Друг', 'Друга', 'Друзей']);
|
||||
const referralWord = declension(referralsCount, ['Реферал', 'Реферала', 'Рефералов']);
|
||||
|
||||
return {
|
||||
friendsWord: `${referralsLength} ${friendWord}`,
|
||||
referralWord: `${referralsCount} ${referralWord}`,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user