diff --git a/TODO b/TODO index 951b4f5b0..fe3252b09 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,5 @@ +ivestigate trade weirdness https://discord.com/channels/290013534023057409/290015591216054273/1330946762017607751 + GOAT lab and GOAT season date range filters https://discord.com/channels/290013534023057409/331882115119448065/1327680226477604895 - for players, implement similar to Advanced Player Search diff --git a/src/ui/views/FreeAgents.tsx b/src/ui/views/FreeAgents.tsx index b32eccb05..211dfdf58 100644 --- a/src/ui/views/FreeAgents.tsx +++ b/src/ui/views/FreeAgents.tsx @@ -9,7 +9,7 @@ import { } from "../components"; import useTitleBar from "../hooks/useTitleBar"; import { confirm, getCols, helpers, toWorker, useLocalPartial } from "../util"; -import type { View } from "../../common/types"; +import type { Phase, View } from "../../common/types"; import { dataTableWrappedMood } from "../components/Mood"; import { wrappedContractAmount, @@ -19,6 +19,7 @@ import { wrappedPlayerNameLabels } from "../components/PlayerNameLabels"; import clsx from "clsx"; import { range } from "../../common/utils"; import type { DropdownOption } from "../hooks/useDropdownOptions"; +import type { FreeAgentTransaction } from "../../worker/views/freeAgents"; const useSeasonsFreeAgents = () => { const { phase, season, startingSeason } = useLocalPartial([ @@ -60,6 +61,43 @@ const useSeasonsFreeAgents = () => { return options; }; +const signedFreeAgentWrapped = ( + freeAgentTransaction: FreeAgentTransaction & { + abbrev: string; + }, + freeAgencySeason: number, + season: number | "current", + phase: Phase, +) => { + let rosterSeason; + + if (season === "current" && phase >= PHASE.PLAYOFFS) { + // Link to current season roster, because there is no next season roster + rosterSeason = freeAgencySeason; + } else { + // Link to next season roster, because freeAgencySeason starts after the regular season ends + rosterSeason = freeAgencySeason + 1; + } + + return { + value: ( + <> + + {freeAgentTransaction.abbrev} + + , {(PHASE_TEXT as any)[freeAgentTransaction.phase]} + + ), + searchValue: `${freeAgentTransaction.abbrev}, ${(PHASE_TEXT as any)[freeAgentTransaction.phase]}`, + }; +}; + const FreeAgents = ({ capSpace, challengeNoFreeAgents, @@ -194,23 +232,12 @@ const FreeAgents = ({ ), searchValue: p.mood.user.willing ? "Negotiate Sign" : "Refuses!", } - : { - value: ( - <> - - {p.freeAgentTransaction.abbrev} - - , {(PHASE_TEXT as any)[p.freeAgentTransaction.phase]} - - ), - searchValue: `${p.freeAgentTransaction.abbrev}, ${(PHASE_TEXT as any)[p.freeAgentTransaction.phase]}`, - }, + : signedFreeAgentWrapped( + p.freeAgentTransaction, + freeAgencySeason, + season, + phase, + ), ], }; }); diff --git a/src/worker/views/freeAgents.ts b/src/worker/views/freeAgents.ts index 7aebdcd70..dd6cd1948 100644 --- a/src/worker/views/freeAgents.ts +++ b/src/worker/views/freeAgents.ts @@ -44,6 +44,11 @@ const isSeason = ( ); }; +export type FreeAgentTransaction = Extract< + NonNullable[number], + { type: "freeAgent" } +>; + const getPlayers = async ( season: number | "current", freeAgencySeason: number, @@ -86,10 +91,7 @@ const getPlayers = async ( const processedSigned: (Player & { freeAgentType: "signed"; - freeAgentTransaction: Extract< - NonNullable[number], - { type: "freeAgent" } - >; + freeAgentTransaction: FreeAgentTransaction; })[] = []; for (const p of signed) { const freeAgentTransaction = p.transactions?.findLast(