2024-04-13 17:56:33 +02:00
|
|
|
import { useEffect, useState } from 'react';
|
|
|
|
import './PlayerInfo.css'
|
|
|
|
import { PlayerResponse, getPlayer } from './serverCalls';
|
|
|
|
|
|
|
|
export default function PlayerInfo({ playerId }: { playerId: string }) {
|
|
|
|
const [player, setPlayer] = useState<PlayerResponse | null>();
|
|
|
|
|
|
|
|
const refresh = () => {
|
|
|
|
getPlayer(playerId).then(setPlayer);
|
|
|
|
};
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
const timer = setInterval(refresh, 5000);
|
|
|
|
return () => clearInterval(timer);
|
|
|
|
});
|
|
|
|
|
|
|
|
return <div className='TankWelcome'>
|
|
|
|
<h1 className='Elems' style={{ "color": "white" }}>
|
|
|
|
Tanks
|
|
|
|
</h1>
|
|
|
|
<div className="ScoreForm">
|
|
|
|
<div className='ElemGroup'>
|
|
|
|
<p className='Elems' style={{ "color": "white" }}>
|
2024-04-13 18:06:44 +02:00
|
|
|
name:
|
2024-04-13 17:56:33 +02:00
|
|
|
</p>
|
|
|
|
<p className='Elems' style={{ "color": "white" }}>
|
|
|
|
{player?.name}
|
|
|
|
</p>
|
|
|
|
</div>
|
2024-04-13 18:06:44 +02:00
|
|
|
<div className='ElemGroup'>
|
|
|
|
<p className='Elems' style={{ "color": "white" }}>
|
|
|
|
kills:
|
|
|
|
</p>
|
|
|
|
<p className='Elems' style={{ "color": "white" }}>
|
|
|
|
{player?.kills}
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
<div className='ElemGroup'>
|
|
|
|
<p className='Elems' style={{ "color": "white" }}>
|
|
|
|
deaths:
|
|
|
|
</p>
|
|
|
|
<p className='Elems' style={{ "color": "white" }}>
|
|
|
|
{player?.deaths}
|
|
|
|
</p>
|
|
|
|
</div>
|
2024-04-13 17:56:33 +02:00
|
|
|
</div>
|
|
|
|
</div >;
|
|
|
|
}
|