Fix tournament logo upload + better flow Closes #1780

This commit is contained in:
Kalle 2024-06-29 12:35:28 +03:00
parent a43743b780
commit e2ea8b1a1b
3 changed files with 24 additions and 8 deletions

View File

@ -5,6 +5,7 @@ import { notFoundIfFalsy } from "~/utils/remix";
import type { Unwrapped } from "~/utils/types";
import { Tournament } from "./Tournament";
import { getServerTournamentManager } from "./brackets-manager/manager.server";
import { HACKY_resolvePicture } from "~/features/tournament/tournament-utils";
const manager = getServerTournamentManager();
@ -45,10 +46,13 @@ function dataMapped({
isAdmin(user);
const revealInfo = tournamentHasStarted || isOrganizer;
const defaultLogo = HACKY_resolvePicture({ name: "default" });
return {
data,
ctx: {
...ctx,
logoSrc: isOrganizer || ctx.logoValidatedAt ? ctx.logoSrc : defaultLogo,
teams: ctx.teams.map((team) => {
const isOwnTeam = team.members.some(
(member) => member.userId === user?.id,

View File

@ -35,14 +35,26 @@ export async function findById(id: number) {
"Tournament.mapPickingStyle",
"Tournament.rules",
"CalendarEvent.name",
"CalendarEvent.avatarImgId",
"CalendarEvent.description",
"CalendarEventDate.startTime",
eb
.selectFrom("UserSubmittedImage")
.select(["UserSubmittedImage.url"])
.whereRef("CalendarEvent.avatarImgId", "=", "UserSubmittedImage.id")
.selectFrom("UnvalidatedUserSubmittedImage")
.select(["UnvalidatedUserSubmittedImage.url"])
.whereRef(
"CalendarEvent.avatarImgId",
"=",
"UnvalidatedUserSubmittedImage.id",
)
.as("logoUrl"),
eb
.selectFrom("UnvalidatedUserSubmittedImage")
.select(["UnvalidatedUserSubmittedImage.validatedAt"])
.whereRef(
"CalendarEvent.avatarImgId",
"=",
"UnvalidatedUserSubmittedImage.id",
)
.as("logoValidatedAt"),
jsonObjectFrom(
eb
.selectFrom("User")

View File

@ -70,8 +70,8 @@ export default function TournamentRegisterPage() {
const startsAtEvenHour = tournament.ctx.startTime.getMinutes() === 0;
const showAvatarPendingApprovalText =
!tournament.ctx.logoUrl &&
tournament.ctx.avatarImgId &&
tournament.ctx.logoUrl &&
!tournament.ctx.logoValidatedAt &&
tournament.isOrganizer(user);
return (
@ -127,8 +127,8 @@ export default function TournamentRegisterPage() {
</div>
{showAvatarPendingApprovalText ? (
<div className="text-warning text-sm font-semi-bold">
Tournament logo pending moderator review. Will be shown automatically
once approved.
Tournament logo pending moderator review. Will be shown publicly once
approved.
</div>
) : null}
<TournamentRegisterInfoTabs />