From e9531928bb76d852197c1e26be462550311c6c15 Mon Sep 17 00:00:00 2001 From: Jeremy Scheff Date: Fri, 11 Oct 2024 23:15:01 -0400 Subject: [PATCH] Sort pos by position number --- TODO | 7 +++---- src/common/getCols.ts | 1 + src/common/types.ts | 3 ++- src/ui/components/DataTable/getSortVal.tsx | 5 +++++ src/ui/views/TradingBlock.tsx | 3 +-- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/TODO b/TODO index 94c82f9660..50251cbe26 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,6 @@ +support sorting mobile trade tables (like saved trades, trading block) +- or have toggle to switch between them? + move from my iterate function to async iterators - regex search: [\t ]iterate\( @@ -226,8 +229,6 @@ more options to set real rookie ratings https://old.reddit.com/r/BasketballGM/co - rookie season, draft position, peak performance, and career performance - allow weight of each of those for how important it is - also random (generate a random players draft class and just put the real names on it) -support sorting mobile trade tables (like saved trades, trading block) - new achievements - moneyball 4 - win 3 championships with hardest constraint https://old.reddit.com/r/BasketballGM/comments/1bgxksp/auto_played_almost_9000_seasons_to_get_longevity/lhgnwm1/?context=3 - force challenge mode to remain on @@ -2164,8 +2165,6 @@ live game --- -in table, sort position by constants.POSITIONS order (like roster page in football) - everywhere contract is displayed, make it in italics if not guaranteed - currently only on roster i think. make a component! diff --git a/src/common/getCols.ts b/src/common/getCols.ts index 5b90d34db4..64fbde126e 100644 --- a/src/common/getCols.ts +++ b/src/common/getCols.ts @@ -3134,6 +3134,7 @@ const cols: { }, Pos: { desc: "Position", + sortType: "pos", }, Pot: { desc: "Potential Rating", diff --git a/src/common/types.ts b/src/common/types.ts index 6c0d837b7e..c4cc4bb842 100644 --- a/src/common/types.ts +++ b/src/common/types.ts @@ -1515,7 +1515,8 @@ export type SortType = | "name" | "number" | "record" - | "string"; + | "string" + | "pos"; export type Team = { tid: number; diff --git a/src/ui/components/DataTable/getSortVal.tsx b/src/ui/components/DataTable/getSortVal.tsx index a829b3f449..0ea1a70fc3 100644 --- a/src/ui/components/DataTable/getSortVal.tsx +++ b/src/ui/components/DataTable/getSortVal.tsx @@ -4,6 +4,7 @@ import textContent from "react-addons-text-content"; import type { SortType } from "../../../common/types"; import { helpers } from "../../util"; import { normalizeIntl } from "../../../common/normalizeIntl"; +import { POSITIONS } from "../../../common"; const getSortVal = ( value: any = null, @@ -135,6 +136,10 @@ const getSortVal = ( return parts.join(", "); } + if (sortType === "pos") { + return POSITIONS.indexOf(sortVal); + } + if (typeof sortVal === "string") { return normalizeIntl(sortVal); } diff --git a/src/ui/views/TradingBlock.tsx b/src/ui/views/TradingBlock.tsx index ed3d8907f8..c413183189 100644 --- a/src/ui/views/TradingBlock.tsx +++ b/src/ui/views/TradingBlock.tsx @@ -450,7 +450,6 @@ const TradingBlock = (props: View<"tradingBlock">) => { pids: props.initialPid !== undefined ? [props.initialPid] : [], dpids: props.initialDpid !== undefined ? [props.initialDpid] : [], }); - console.log(state); const handleChangeAsset = (type: "pids" | "dpids", id: number) => { setState(prevState => { @@ -568,7 +567,7 @@ const TradingBlock = (props: View<"tradingBlock">) => { sumContracts += p.contract.amount; } } - console.log(sumContracts); + let footer; if (sumContracts !== 0) { footer = [];