'use client';
import styles from '@/components/friends/Friend.module.css';
import Image from 'next/image';
import { IPlayer } from '@/interfaces/player.type';
import { toFixed } from '@/utils/FormatNumber';

type Props = {
    player: IPlayer;
};

const Friend = ({ player }: Props) => {
    return (
        <div className={styles.friend}>
            <div className={styles.friendContent}>
                <div className={styles.friendAvatar}>
                    <Image
                        src={'/icons/friend-icon.svg'}
                        alt={'friend avatar'}
                        height={42}
                        width={42}
                    />
                </div>
                <div className={styles.friendData}>
                    <span>{player?.attributes.telegram_nick}</span>
                    <div className={styles.friendReferrals}>
                        <Image
                            src={'/icons/referrals-icon.svg'}
                            alt={'referrals icon'}
                            width={14}
                            height={14}
                        />
                        <span>{player?.attributes.my_referrals?.data?.length || 0}</span>
                    </div>
                </div>
            </div>
            <div className={styles.friendBalance}>
                <span>{toFixed(player?.attributes.balance)}</span>
            </div>
        </div>
    );
};

export default Friend;
