Tournament teams UI tweak

This commit is contained in:
Kalle
2024-03-18 22:43:01 +02:00
parent 5078df30af
commit 541ddc448f
2 changed files with 28 additions and 1 deletions

View File

@@ -7,6 +7,8 @@ import type { TournamentDataTeam } from "~/features/tournament-bracket/core/Tour
import { userPage } from "~/utils/urls";
import { useTournament, useTournamentFriendCodes } from "../routes/to.$id";
import { databaseTimestampToDate } from "~/utils/dates";
import { useUser } from "~/features/auth/core/user";
import { accountCreatedInTheLastSixMonths } from "~/utils/users";
export function TeamWithRoster({
team,
@@ -21,6 +23,7 @@ export function TeamWithRoster({
teamPageUrl?: string;
activePlayers?: User["id"][];
}) {
const user = useUser();
const tournament = useTournament();
const friendCodes = useTournamentFriendCodes();
@@ -86,7 +89,12 @@ export function TeamWithRoster({
</Link>
</div>
{friendCode ? (
<div className="text-xs text-lighter">SW-{friendCode}</div>
<div className="text-xs text-lighter">
{tournament.isOrganizer(user) ? (
<FreshAccountEmoji discordId={member.discordId} />
) : null}
SW-{friendCode}
</div>
) : null}
</li>
);
@@ -98,6 +106,19 @@ export function TeamWithRoster({
);
}
function FreshAccountEmoji({ discordId }: { discordId: string }) {
if (!accountCreatedInTheLastSixMonths(discordId)) return null;
return (
<span
className="text-md mr-2"
title="Discord account created in the last 6 months"
>
👶
</span>
);
}
function TeamMapPool({
mapPool,
}: {

View File

@@ -65,3 +65,9 @@ export function userDiscordIdIsAged(user: { discordId: string }) {
return Date.now() - timestamp > AGED_CRITERIA;
}
export function accountCreatedInTheLastSixMonths(discordId: string) {
const timestamp = convertSnowflakeToDate(discordId).getTime();
return Date.now() - timestamp < 1000 * 60 * 60 * 24 * 30 * 6;
}