Skip to content

Commit

Permalink
Fix season summary if a conf has 0 teams and a league was exported/im…
Browse files Browse the repository at this point in the history
…ported (so undefined in array became null)
  • Loading branch information
dumbmatter committed Sep 30, 2024
1 parent 6545fb8 commit 1403674
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
8 changes: 5 additions & 3 deletions src/common/types.baseball.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type teamStats from "../worker/core/team/stats.baseball";

// Should all the extra ones be in teamStats["derived"]?
export type TeamStatAttr =
| typeof teamStats["raw"][number]
| (typeof teamStats)["raw"][number]
| "ab"
| "ops"
| "era"
Expand Down Expand Up @@ -43,7 +43,7 @@ export type TeamStatAttr =
| "oppCsp";

export type TeamStatAttrByPos =
| typeof teamStats["byPos"][number]
| (typeof teamStats)["byPos"][number]
| "ch"
| "fldp"
| "rf9"
Expand Down Expand Up @@ -77,7 +77,9 @@ export type AwardPlayer = {
export type Awards = {
season: number;
bestRecord: AwardTeam;
bestRecordConfs: (AwardTeam | undefined)[];

// undefined gets turned into null by JSON.stringify
bestRecordConfs: (AwardTeam | undefined | null)[];

// Only in old leagues
bre?: AwardTeam;
Expand Down
6 changes: 4 additions & 2 deletions src/common/types.basketball.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type teamStats from "../worker/core/team/stats.basketball";

// Should all the extra ones be in teamStats["derived"]?
export type TeamStatAttr =
| typeof teamStats["raw"][number]
| (typeof teamStats)["raw"][number]
| "fgp"
| "oppFgp"
| "fgpAtRim"
Expand Down Expand Up @@ -75,7 +75,9 @@ export type Awards<
> = {
season: number;
bestRecord: AwardTeam;
bestRecordConfs: (AwardTeam | undefined)[];

// undefined gets turned into null by JSON.stringify
bestRecordConfs: (AwardTeam | undefined | null)[];

// Only in old leagues
bre?: AwardTeam;
Expand Down
6 changes: 4 additions & 2 deletions src/common/types.football.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type teamStats from "../worker/core/team/stats.football";

// Should all the extra ones be in teamStats["derived"]?
export type TeamStatAttr =
| typeof teamStats["raw"][number]
| (typeof teamStats)["raw"][number]
| "mov"
| "oppMov"
| "ptsPerGame"
Expand Down Expand Up @@ -58,7 +58,9 @@ export type AwardPlayer = {
export type Awards = {
season: number;
bestRecord: AwardTeam;
bestRecordConfs: (AwardTeam | undefined)[];

// undefined gets turned into null by JSON.stringify
bestRecordConfs: (AwardTeam | undefined | null)[];
oroy: AwardPlayer | undefined;
droy: AwardPlayer | undefined;
allRookie: (AwardPlayer | undefined)[];
Expand Down
6 changes: 4 additions & 2 deletions src/common/types.hockey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type teamStats from "../worker/core/team/stats.hockey";

// Should all the extra ones be in teamStats["derived"]?
export type TeamStatAttr =
| typeof teamStats["raw"][number]
| (typeof teamStats)["raw"][number]
| "g"
| "a"
| "sa"
Expand Down Expand Up @@ -51,7 +51,9 @@ export type AwardPlayer = {
export type Awards = {
season: number;
bestRecord: AwardTeam;
bestRecordConfs: (AwardTeam | undefined)[];

// undefined gets turned into null by JSON.stringify
bestRecordConfs: (AwardTeam | undefined | null)[];

// Only in old leagues
bre?: AwardTeam;
Expand Down
2 changes: 1 addition & 1 deletion src/ui/views/History.basketball/AwardsAndChamp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const AwardsAndChamp = ({
)}
<h2>Best Record</h2>
{awards.bestRecordConfs
.filter((a: any) => a !== undefined)
.filter((a: any) => a !== undefined && a !== null)
.map((t: any, i: number) =>
t !== undefined ? (
<p key={t.tid}>
Expand Down

0 comments on commit 1403674

Please sign in to comment.