Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dumbmatter committed Jan 21, 2025
1 parent 7d2b667 commit a7f8e1e
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 22 deletions.
2 changes: 2 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -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

Expand Down
63 changes: 45 additions & 18 deletions src/ui/views/FreeAgents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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([
Expand Down Expand Up @@ -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: (
<>
<a
href={helpers.leagueUrl([
"roster",
`${freeAgentTransaction.abbrev}_${freeAgentTransaction.tid}`,
rosterSeason,
])}
>
{freeAgentTransaction.abbrev}
</a>
, {(PHASE_TEXT as any)[freeAgentTransaction.phase]}
</>
),
searchValue: `${freeAgentTransaction.abbrev}, ${(PHASE_TEXT as any)[freeAgentTransaction.phase]}`,
};
};

const FreeAgents = ({
capSpace,
challengeNoFreeAgents,
Expand Down Expand Up @@ -194,23 +232,12 @@ const FreeAgents = ({
),
searchValue: p.mood.user.willing ? "Negotiate Sign" : "Refuses!",
}
: {
value: (
<>
<a
href={helpers.leagueUrl([
"roster",
`${p.freeAgentTransaction.abbrev}_${p.freeAgentTransaction.tid}`,
freeAgencySeason + 1,
])}
>
{p.freeAgentTransaction.abbrev}
</a>
, {(PHASE_TEXT as any)[p.freeAgentTransaction.phase]}
</>
),
searchValue: `${p.freeAgentTransaction.abbrev}, ${(PHASE_TEXT as any)[p.freeAgentTransaction.phase]}`,
},
: signedFreeAgentWrapped(
p.freeAgentTransaction,
freeAgencySeason,
season,
phase,
),
],
};
});
Expand Down
10 changes: 6 additions & 4 deletions src/worker/views/freeAgents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ const isSeason = (
);
};

export type FreeAgentTransaction = Extract<
NonNullable<Player["transactions"]>[number],
{ type: "freeAgent" }
>;

const getPlayers = async (
season: number | "current",
freeAgencySeason: number,
Expand Down Expand Up @@ -86,10 +91,7 @@ const getPlayers = async (

const processedSigned: (Player & {
freeAgentType: "signed";
freeAgentTransaction: Extract<
NonNullable<Player["transactions"]>[number],
{ type: "freeAgent" }
>;
freeAgentTransaction: FreeAgentTransaction;
})[] = [];
for (const p of signed) {
const freeAgentTransaction = p.transactions?.findLast(
Expand Down

0 comments on commit a7f8e1e

Please sign in to comment.