mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-04-25 07:32:19 -05:00
Fix LUTI league division friend code hiding too early
This commit is contained in:
parent
c9b3a576b6
commit
af15b22f54
|
|
@ -1,3 +1,4 @@
|
|||
import { isAfter, subDays } from "date-fns";
|
||||
import type { LoaderFunctionArgs } from "react-router";
|
||||
import { getUser } from "~/features/auth/core/user.server";
|
||||
import * as TournamentRepository from "~/features/tournament/TournamentRepository.server";
|
||||
|
|
@ -29,9 +30,11 @@ export const loader = async ({ params }: LoaderFunctionArgs) => {
|
|||
|
||||
const tournament = await tournamentDataCached({ tournamentId, user });
|
||||
|
||||
const tournamentStartedInTheLastMonth =
|
||||
databaseTimestampToDate(tournament.ctx.startTime) >
|
||||
new Date(Date.now() - 30 * 24 * 60 * 60 * 1000);
|
||||
const friendCodeVisibilityDays = tournament.ctx.parentTournamentId ? 120 : 30;
|
||||
const tournamentStartedRecently = isAfter(
|
||||
databaseTimestampToDate(tournament.ctx.startTime),
|
||||
subDays(new Date(), friendCodeVisibilityDays),
|
||||
);
|
||||
const isTournamentAdmin =
|
||||
tournament.ctx.author.id === user?.id ||
|
||||
tournament.ctx.staff.some(
|
||||
|
|
@ -53,7 +56,7 @@ export const loader = async ({ params }: LoaderFunctionArgs) => {
|
|||
throw new Response(null, { status: 404 });
|
||||
}
|
||||
|
||||
const showFriendCodes = tournamentStartedInTheLastMonth && isTournamentAdmin;
|
||||
const showFriendCodes = tournamentStartedRecently && isTournamentAdmin;
|
||||
|
||||
const isLeagueSignup = Object.values(LEAGUES)
|
||||
.flat()
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user