diff --git a/app/components/league/DraftInfoCard.tsx b/app/components/league/DraftInfoCard.tsx index e2b7d5b..a7d3bab 100644 --- a/app/components/league/DraftInfoCard.tsx +++ b/app/components/league/DraftInfoCard.tsx @@ -121,7 +121,7 @@ function DraftInfoCardVariant({ ) : queueBuilderHref ? ( - Set Pre-Draft Rankings + Set Pre-Draft Queue ) : null} diff --git a/app/routes/leagues/$leagueId.draft-queue.$seasonId.tsx b/app/routes/leagues/$leagueId.draft-queue.$seasonId.tsx index 2899cc6..896222f 100644 --- a/app/routes/leagues/$leagueId.draft-queue.$seasonId.tsx +++ b/app/routes/leagues/$leagueId.draft-queue.$seasonId.tsx @@ -13,7 +13,7 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from "~/components/ui/tabs"; import type { Route } from "./+types/$leagueId.draft-queue.$seasonId"; export function meta({ data }: Route.MetaArgs): Route.MetaDescriptors { - return [{ title: `Pre-Draft Rankings — ${data?.season?.league?.name ?? "League"} - Brackt` }]; + return [{ title: `Set Pre-Draft Queue — ${data?.season?.league?.name ?? "League"} - Brackt` }]; } export async function loader(args: Route.LoaderArgs) { @@ -41,7 +41,7 @@ export async function loader(args: Route.LoaderArgs) { } if (!userId) { - throw new Response("You must be logged in to set pre-draft rankings", { status: 401 }); + throw new Response("You must be logged in to set pre-draft queue", { status: 401 }); } const userTeam = season.teams.find((t) => t.ownerId === userId); @@ -79,6 +79,8 @@ export default function PreDraftRankings() { // Always-current ref so reorder callback stays stable (no localQueue dependency) const queueRef = useRef(localQueue); + // Track in-flight removes to prevent add racing ahead of a pending remove + const pendingRemovesRef = useRef(new Set()); useEffect(() => { queueRef.current = localQueue; }, [localQueue]); @@ -90,7 +92,7 @@ export default function PreDraftRankings() { const handleAdd = useCallback( async (participantId: string) => { - if (queuedParticipantIds.has(participantId)) return; + if (queuedParticipantIds.has(participantId) || pendingRemovesRef.current.has(participantId)) return; const tempId = `temp-${Date.now()}-${participantId}`; setLocalQueue((prev) => [...prev, { id: tempId, participantId }]); @@ -118,7 +120,11 @@ export default function PreDraftRankings() { const handleRemove = useCallback( async (queueId: string) => { - setLocalQueue((prev) => prev.filter((item) => item.id !== queueId)); + const item = queueRef.current.find((q) => q.id === queueId); + const participantId = item?.participantId; + + setLocalQueue((prev) => prev.filter((q) => q.id !== queueId)); + if (participantId) pendingRemovesRef.current.add(participantId); const formData = new FormData(); formData.append("queueId", queueId); @@ -134,6 +140,8 @@ export default function PreDraftRankings() { } catch { toast.error("Network error — failed to remove from rankings"); revalidate(); + } finally { + if (participantId) pendingRemovesRef.current.delete(participantId); } }, [userTeam.id, revalidate] @@ -194,11 +202,6 @@ export default function PreDraftRankings() { {p.name} {p.sport.name} - {p.vorpValue !== null && p.vorpValue !== undefined && ( - - {Number(p.vorpValue).toFixed(1)} - - )} {inQueue ? ( - Pre-Draft Rankings + Set Pre-Draft Queue Rank the players you want. Your rankings carry into the live draft as your autopick @@ -296,9 +299,6 @@ export default function PreDraftRankings() { - - Sorted by VORP - {allPlayersPanel} {rankingsPanel} @@ -310,7 +310,6 @@ export default function PreDraftRankings() { All Players - Sorted by VORP {allPlayersPanel} diff --git a/app/routes/leagues/__tests__/draft-queue-access.test.ts b/app/routes/leagues/__tests__/draft-queue-access.test.ts index c5969d5..9cbdf5a 100644 --- a/app/routes/leagues/__tests__/draft-queue-access.test.ts +++ b/app/routes/leagues/__tests__/draft-queue-access.test.ts @@ -57,7 +57,7 @@ function checkPreDraftRankingsAccess(opts: { } if (!userId) { - return { status: 401, message: 'You must be logged in to set pre-draft rankings' }; + return { status: 401, message: 'You must be logged in to set pre-draft queue' }; } if (!hasTeam) { @@ -141,7 +141,7 @@ describe('Pre-Draft Rankings Access - Authentication', () => { userId: null, hasTeam: false, }); - expect(result).toMatchObject({ message: 'You must be logged in to set pre-draft rankings' }); + expect(result).toMatchObject({ message: 'You must be logged in to set pre-draft queue' }); }); });
{p.name}
{p.sport.name}
Rank the players you want. Your rankings carry into the live draft as your autopick @@ -296,9 +299,6 @@ export default function PreDraftRankings() { - - Sorted by VORP - {allPlayersPanel} {rankingsPanel} @@ -310,7 +310,6 @@ export default function PreDraftRankings() {