fix: close competition cutover integrity gaps
This commit is contained in:
1 parent
7ea2002975
commit
683d602d63
57 files changed
+4805
-1582
No files matched your search
@@ -1,5 +1,9 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import type {
|
||||
MatchDetailResponse,
|
||||
MatchParticipantView,
|
||||
} from "@lolympus/contracts";
|
||||
import { ChevronLeft, Search, X } from "lucide-react";
|
||||
import { Link, useLocation, useNavigate, useParams } from "react-router";
|
||||
import {
|
||||
@@ -37,8 +41,6 @@ import type {
|
||||
AuctionTopTierThreshold,
|
||||
ApiCommunityUserSearchCandidate,
|
||||
ApiCommunityUserSearchRiotAccount,
|
||||
ApiMatch,
|
||||
ApiMatchParticipant,
|
||||
ApiPositionPreference,
|
||||
ApiTierInfo,
|
||||
ManualTournamentResultCollectResponse,
|
||||
@@ -138,7 +140,7 @@ function parseAuctionSecondsInput(value: string, min: number) {
|
||||
return seconds;
|
||||
}
|
||||
|
||||
function buildAuctionParticipantPool(participants: ApiMatchParticipant[]) {
|
||||
function buildAuctionParticipantPool(participants: MatchParticipantView[]) {
|
||||
const ordered = [...participants].sort(
|
||||
(left, right) =>
|
||||
new Date(left.joinedAt).getTime() - new Date(right.joinedAt).getTime(),
|
||||
@@ -148,7 +150,7 @@ function buildAuctionParticipantPool(participants: ApiMatchParticipant[]) {
|
||||
}
|
||||
|
||||
function buildCaptainSlots(
|
||||
participants: ApiMatchParticipant[],
|
||||
participants: MatchParticipantView[],
|
||||
): CaptainSelectionSlot[] {
|
||||
const teamCount = Math.floor(
|
||||
buildAuctionParticipantPool(participants).length / 5,
|
||||
@@ -1451,7 +1453,7 @@ export default function MatchDetailPage() {
|
||||
},
|
||||
});
|
||||
|
||||
const matchQueryKey = ["match", DEFAULT_COMMUNITY_ID, id ?? null];
|
||||
const matchQueryKey = matchQuery.queryKey;
|
||||
|
||||
const addParticipantMutation = useMutation({
|
||||
mutationFn: ({
|
||||
@@ -1463,7 +1465,7 @@ export default function MatchDetailPage() {
|
||||
preferredPositions: ApiPositionPreference[];
|
||||
riotPuuid?: string;
|
||||
}) =>
|
||||
apiFetch<ApiMatch>(
|
||||
apiFetch<MatchDetailResponse>(
|
||||
`/communities/${DEFAULT_COMMUNITY_ID}/matches/${id}/participants/${userId}`,
|
||||
{
|
||||
method: "POST",
|
||||
@@ -1488,9 +1490,10 @@ export default function MatchDetailPage() {
|
||||
),
|
||||
onMutate: async (userId: string) => {
|
||||
await queryClient.cancelQueries({ queryKey: matchQueryKey });
|
||||
const previous = queryClient.getQueryData<ApiMatch>(matchQueryKey);
|
||||
const previous =
|
||||
queryClient.getQueryData<MatchDetailResponse>(matchQueryKey);
|
||||
if (previous) {
|
||||
queryClient.setQueryData<ApiMatch>(matchQueryKey, {
|
||||
queryClient.setQueryData<MatchDetailResponse>(matchQueryKey, {
|
||||
...previous,
|
||||
participants: previous.participants.filter(
|
||||
(participant) => participant.userId !== userId,
|
||||
@@ -1531,9 +1534,10 @@ export default function MatchDetailPage() {
|
||||
),
|
||||
onMutate: async ({ userId, mainPosition, subPosition }) => {
|
||||
await queryClient.cancelQueries({ queryKey: matchQueryKey });
|
||||
const previous = queryClient.getQueryData<ApiMatch>(matchQueryKey);
|
||||
const previous =
|
||||
queryClient.getQueryData<MatchDetailResponse>(matchQueryKey);
|
||||
if (previous) {
|
||||
queryClient.setQueryData<ApiMatch>(matchQueryKey, {
|
||||
queryClient.setQueryData<MatchDetailResponse>(matchQueryKey, {
|
||||
...previous,
|
||||
participants: previous.participants.map((participant) =>
|
||||
participant.userId === userId
|
||||
@@ -1759,7 +1763,7 @@ export default function MatchDetailPage() {
|
||||
const manualPriorityCandidates = auctionParticipantPool.filter(
|
||||
(participant) => !selectedCaptainIds.includes(participant.userId),
|
||||
);
|
||||
const manualPriorityCandidateIds = new Set(
|
||||
const manualPriorityCandidateIds = new Set<string>(
|
||||
manualPriorityCandidates.map((participant) => participant.userId),
|
||||
);
|
||||
const selectedManualTopTierUserIds =
|
||||
|
||||
Reference in new issue
Block a user