15 lines
400 B
TypeScript
15 lines
400 B
TypeScript
import { IPlayer } from '@/interfaces/player.type';
|
|
|
|
export function CalculateReferralsCount(player: IPlayer | null): number {
|
|
if (!player) {
|
|
return 0;
|
|
}
|
|
let total = player.attributes.my_referrals.data?.length || 0;
|
|
|
|
player.attributes.my_referrals?.data?.forEach(referral => {
|
|
total += referral.attributes?.my_referrals.data?.length || 0;
|
|
});
|
|
|
|
return total;
|
|
}
|