/* * Copyright (C) 2024 Aleksander WilczyƄski (aleks@alekswilc.dev) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * See LICENSE for more. */ import { useTranslation } from "react-i18next"; import { Link } from "react-router-dom"; import { TTrainRecord } from "../../../types/train.ts"; import dayjs from "dayjs"; import { UserIcons } from "../../mini/icons/UserIcons.tsx"; import { toast } from "react-toastify"; // setSearchItem: Dispatch> export const TrainTable = ({ trains }: { trains: TTrainRecord[] }) => { const { t } = useTranslation(); const report = (data: TTrainRecord) => { toast.info(t("log.toasts.report"), { autoClose: 5000, }); void navigator.clipboard.writeText(`;user: \`${ data.player.username }\`\n;steam: \`https://steamcommunity.com/profiles/${ data.player.id }\`\n;server: \`${ data.server.toUpperCase() }\`\n;left: ${ data.joinedDate ? `\n;joined: ` : "" }\n;train: \`${ data.trainNumber }\`\n;link: https://${ location.hostname }/log/${ data.id }\n\n`); }; return (
{ trains.map((train) => { return
Player

{ train.player.username }

{ t("log.train.train", { name: train.trainName, number: train.trainNumber }) }

{ t("log.train.server", { server: train.server.toUpperCase() }) }

{ train.joinedDate &&

{ t("log.train.joined", { date: dayjs(train.joinedDate).format("HH:mm DD/MM/YYYY") }) }

}

{ t("log.train.left", { date: dayjs(train.leftDate).format("HH:mm DD/MM/YYYY") }) }

{ train.joinedDate &&

{ t("log.train.spent", { date: dayjs.duration(train.leftDate - train.joinedDate).format("H[h] m[m]") }) }

}

{ t("log.train.distance", { distance: train.distance ? (train.distance / 1000).toFixed(2) : "--" }) }

{ t("log.train.points", { points: train.points || "--" }) }

; }) }
); };