import { useState } from 'react';
import { TProfileData } from '../../../types/profile.ts';
import { useTranslation } from 'react-i18next';
export const ProfileCard = ({ data }: { data: TProfileData }) => {
const [showTrains, setShowTrains] = useState(false);
const [showStations, setShowStations] = useState(false);
const { t } = useTranslation();
return
{data.steam.personname}
{Math.floor(data.player.trainDistance / 1000)}km
{t("profile.stats.distance")}
{Math.floor(data.player.dispatcherTime / 3600000)}h
{t("profile.stats.time")}
{Object.keys(data.player.trainStats || {}).length > 0 &&
setShowTrains(val => !val)}>
{t("profile.trains.header")}
{showTrains &&
{t("profile.trains.train")}
{t("profile.trains.distance")}
{t("profile.trains.points")}
{t("profile.trains.time")}
{Object.keys(data.player.trainStats).map(trainName => {
const train = data.player.trainStats[trainName];
return
{Math.floor(train.distance / 1000)}km
{Math.floor(train.time / 3600000)}h
})}
}
}
{Object.keys(data.player.dispatcherStats || {}).length > 0 &&
setShowStations(val => !val)}>
{t("profile.stations.header")}
{showStations &&
{t("profile.stations.station")}
{t("profile.stations.time")}
{Object.keys(data.player.dispatcherStats).map(stationName => {
const station = data.player.dispatcherStats[stationName];
return
{Math.floor(station.time / 3600000)}h
;
})}
}
}
}