From 541ddc448ffa8dc99b6b01842952d23c1a3b0b4f Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Mon, 18 Mar 2024 22:43:01 +0200 Subject: [PATCH] Tournament teams UI tweak --- .../tournament/components/TeamWithRoster.tsx | 23 ++++++++++++++++++- app/utils/users.ts | 6 +++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/app/features/tournament/components/TeamWithRoster.tsx b/app/features/tournament/components/TeamWithRoster.tsx index 641b1f6f8..8e1596860 100644 --- a/app/features/tournament/components/TeamWithRoster.tsx +++ b/app/features/tournament/components/TeamWithRoster.tsx @@ -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({ {friendCode ? ( -
SW-{friendCode}
+
+ {tournament.isOrganizer(user) ? ( + + ) : null} + SW-{friendCode} +
) : null} ); @@ -98,6 +106,19 @@ export function TeamWithRoster({ ); } +function FreshAccountEmoji({ discordId }: { discordId: string }) { + if (!accountCreatedInTheLastSixMonths(discordId)) return null; + + return ( + + 👶 + + ); +} + function TeamMapPool({ mapPool, }: { diff --git a/app/utils/users.ts b/app/utils/users.ts index 66318eb90..f7c6c01be 100644 --- a/app/utils/users.ts +++ b/app/utils/users.ts @@ -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; +}