import React, { useState } from "react"; import { Player } from "csgogsi"; import Weapon from "./../Weapon/Weapon"; import Avatar from "./Avatar"; import TeamLogo from "./../MatchBar/TeamLogo"; import "./observed.scss"; import { getCountry } from "./../countries"; import { ArmorHelmet, ArmorFull, HealthFull, Bullets } from './../../assets/Icons'; import { apiUrl } from './../../API'; import { useAction } from "../../API/contexts/actions"; const Statistic = React.memo(({ label, value }: { label: string; value: string | number, }) => { return (
{label}
{value}
); }); const Observed = ({ player }: { player: Player | null }) => { const [ showCam, setShowCam ] = useState(true); useAction('toggleCams', () => { setShowCam(p => !p); }); if (!player) return null; const country = player.country || player.team.country; const currentWeapon = player.weapons.filter(weapon => weapon.state === "active")[0]; const grenades = player.weapons.filter(weapon => weapon.type === "Grenade"); const { stats } = player; const ratio = stats.deaths === 0 ? stats.kills : stats.kills / stats.deaths; const countryName = country ? getCountry(country) : null; return (
{player.name}
{player.realName}
{countryName ? {countryName} : ''}
{grenades.map(grenade => { grenade.ammo_reserve === 2 ? : null} )}
{player.state.health}
{player.state.helmet ? : }
{player.state.armor}
{(currentWeapon && currentWeapon.ammo_clip) || "-"}
/{(currentWeapon && currentWeapon.ammo_reserve) || "-"}
); } export default Observed;