Skip to content

Commit 89a9b42

Browse files
committed
Move lineup available logic from match info page
1 parent c373554 commit 89a9b42

3 files changed

Lines changed: 16 additions & 8 deletions

File tree

dotcom-rendering/src/components/FootballMatchInfo.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ function teamHasStats({
3939
export const FootballMatchInfo = ({ matchStats, table }: Props) => {
4040
const showStats =
4141
teamHasStats(matchStats.homeTeam) && teamHasStats(matchStats.awayTeam);
42-
const showLineups =
43-
matchStats.homeTeam.players.length > 0 &&
44-
matchStats.awayTeam.players.length > 0;
4542
return (
4643
<section aria-label={'match-info'} css={layoutCss}>
4744
{showStats && (
@@ -106,7 +103,7 @@ export const FootballMatchInfo = ({ matchStats, table }: Props) => {
106103
/>
107104
</>
108105
)}
109-
{showLineups && <Lineups matchStats={matchStats} />}
106+
<Lineups matchStats={matchStats} />
110107
{table && <LeagueTable table={table} />}
111108
</section>
112109
);

dotcom-rendering/src/components/Lineups.stories.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,11 @@ export const WithLineup = {
4848
},
4949
} satisfies Story;
5050

51-
export const ComingSoon = {} satisfies Story;
51+
export const ComingSoon = {
52+
args: {
53+
matchStats: {
54+
homeTeam: { ...matchStats.homeTeam, players: [] },
55+
awayTeam: { ...matchStats.awayTeam, players: [] },
56+
},
57+
},
58+
} satisfies Story;

dotcom-rendering/src/components/Lineups.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,25 @@ import { palette } from '../palette';
1818
import Union from '../static/icons/Union.svg';
1919

2020
type Props = {
21-
matchStats?: FootballMatchStats;
21+
matchStats: FootballMatchStats;
2222
};
2323

2424
const lineupSectionId = 'lineups';
2525
const substitutesSectionId = 'substitutes';
2626

2727
export const Lineups = ({ matchStats }: Props) => {
28+
const lineupAvailable =
29+
matchStats.homeTeam.players.length > 0 &&
30+
matchStats.awayTeam.players.length > 0;
31+
2832
return (
2933
<section css={sectionStyles} aria-label="Team Lineups and Substitutes">
3034
<section
3135
css={playerListSectionGridStyles}
3236
aria-labelledby={lineupSectionId}
3337
>
3438
<Title text="Lineups" id={lineupSectionId} />
35-
{matchStats ? (
39+
{lineupAvailable ? (
3640
<>
3741
<PlayerList
3842
team={matchStats.homeTeam}
@@ -49,7 +53,7 @@ export const Lineups = ({ matchStats }: Props) => {
4953
<span css={comingSoon}>Coming soon</span>
5054
)}
5155
</section>
52-
{matchStats && (
56+
{lineupAvailable && (
5357
<section
5458
css={playerListSectionGridStyles}
5559
aria-labelledby={substitutesSectionId}

0 commit comments

Comments
 (0)