Skip to content

Commit 29361a6

Browse files
marjisoundJamieB-guandrewHEguardianoliverabrahams
authored
Football tables data types (#13705)
Add FootballTablesPage route in dev server Add frontend types for football tables and their relevant schema Validate frontend tables json response Add DCR type for football tables Rename and create types in order to have a common type for both matches list and tables Add parser for parsing frontend football tables into DCR tables Add logic to decide to render football matches or tables within the football data layout --------- Co-authored-by: Jamie B <[email protected]> Co-authored-by: Andrew Howe-Ely <[email protected]> Co-authored-by: Oliver Abrahams <[email protected]>
1 parent 3748ec1 commit 29361a6

36 files changed

+3636
-1420
lines changed

dotcom-rendering/fixtures/generated/football-live.ts

Lines changed: 971 additions & 66 deletions
Large diffs are not rendered by default.

dotcom-rendering/fixtures/manual/footballData.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import type { FootballMatches, Region } from '../../src/footballMatches';
1+
import type { Region } from '../../src/footballDataPage';
2+
import type { FootballMatches } from '../../src/footballMatches';
23

34
export const regions: Region[] = [
45
{

dotcom-rendering/fixtures/manual/footballMatches.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type {
44
FEMatchByDateAndCompetition,
55
FEMatchDay,
66
FEResult,
7-
} from '../../src/feFootballDataPage';
7+
} from '../../src/frontend/feFootballMatchListPage';
88

99
const matchData = {
1010
id: '1',
@@ -91,6 +91,7 @@ export const emptyMatches: FEMatchByDateAndCompetition[] = [
9191
url: '/football/premierleague',
9292
fullName: 'Premier League',
9393
nation: 'English',
94+
tableDividers: [],
9495
},
9596
matches: [],
9697
},

dotcom-rendering/scripts/jsonSchema/schema.mjs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ const program = TJS.getProgramFromFiles(
1515
path.resolve(`${root}/src/frontend/feTagPage.ts`),
1616
path.resolve(`${root}/src/types/newslettersPage.ts`),
1717
path.resolve(`${root}/src/types/editionsCrossword.ts`),
18-
path.resolve(`${root}/src/feFootballDataPage.ts`),
18+
path.resolve(`${root}/src/frontend/feFootballMatchListPage.ts`),
19+
path.resolve(`${root}/src/frontend/feFootballTablesPage.ts`),
1920
],
2021
{
2122
skipLibCheck: true,
@@ -59,8 +60,12 @@ const schemas = [
5960
file: `${root}/src/model/editions-crossword-schema.json`,
6061
},
6162
{
62-
typeName: 'FEFootballDataPage',
63-
file: `${root}/src/model/fe-football-data-page-schema.json`,
63+
typeName: 'FEFootballMatchListPage',
64+
file: `${root}/src/frontend/schemas/feFootballMatchListPage.json`,
65+
},
66+
{
67+
typeName: 'FEFootballTablesPage',
68+
file: `${root}/src/frontend/schemas/feFootballTablesPage.json`,
6469
},
6570
];
6671

dotcom-rendering/scripts/test-data/gen-fixtures.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const { configOverrides } = require('../../fixtures/config-overrides');
99
const { switchOverrides } = require('../../fixtures/switch-overrides');
1010
const {
1111
validateAsFEArticle,
12-
validateAsFootballDataPageType,
12+
validateAsFootballMatchListPage,
1313
} = require('../../src/model/validate');
1414

1515
const root = resolve(__dirname, '..', '..');
@@ -327,15 +327,16 @@ requests.push(
327327
delete json.config.weatherapiurl;
328328
delete json.config.isAdFree;
329329
delete json.config.userBenefitsApiUrl;
330+
delete json.config.frontendSentryDsn;
330331

331-
const footballDataPageData = validateAsFootballDataPageType(json);
332+
const footballMatchListPage = validateAsFootballMatchListPage(json);
332333

333334
// Write the new frontend fixture data
334335
const contents = `${HEADER}
335-
import type { FEFootballDataPage } from '../../src/feFootballDataPage';
336+
import type { FEFootballMatchListPage } from '../../src/frontend/feFootballMatchListPage';
336337
337-
export const footballData: FEFootballDataPage = ${JSON.stringify(
338-
footballDataPageData,
338+
export const footballData: FEFootballMatchListPage = ${JSON.stringify(
339+
footballMatchListPage,
339340
null,
340341
4,
341342
)}

dotcom-rendering/src/components/FootballCompetitionSelect.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Option, Select } from '@guardian/source/react-components';
2-
import type { FootballMatchKind, Region } from '../footballMatches';
2+
import type { Region } from '../footballDataPage';
3+
import type { FootballMatchKind } from '../footballMatches';
34
import { palette } from '../palette';
45

56
type FootballSelectKind = FootballMatchKind | 'Tables';

dotcom-rendering/src/components/FootballDataPage.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { Global } from '@emotion/react';
22
import { StrictMode } from 'react';
3-
import type { DCRFootballDataPage } from '../footballMatches';
3+
import type {
4+
FootballMatchListPage,
5+
FootballTablesPage,
6+
} from '../footballDataPage';
47
import { FootballDataPageLayout } from '../layouts/FootballDataPageLayout';
58
import { buildAdTargeting } from '../lib/ad-targeting';
69
import { ArticleDesign, ArticleDisplay, Pillar } from '../lib/articleFormat';
@@ -17,7 +20,7 @@ import { SetAdTargeting } from './SetAdTargeting.importable';
1720
import { SkipTo } from './SkipTo';
1821

1922
type Props = {
20-
footballData: DCRFootballDataPage;
23+
footballData: FootballMatchListPage | FootballTablesPage;
2124
};
2225

2326
/**

dotcom-rendering/src/components/FootballMatchList.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ export const FootballMatchList = ({
436436

437437
const [days, setDays] = useState(initialDays);
438438
const [isError, setIsError] = useState<boolean>(false);
439+
439440
return (
440441
<>
441442
{days.map((day) => (

dotcom-rendering/src/components/FootballMatchesPage.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@ import {
55
space,
66
until,
77
} from '@guardian/source/foundations';
8-
import type {
9-
FootballMatches,
10-
FootballMatchKind,
11-
Region,
12-
} from '../footballMatches';
8+
import type { Region } from '../footballDataPage';
9+
import type { FootballMatches, FootballMatchKind } from '../footballMatches';
1310
import { grid } from '../grid';
1411
import type { EditionId } from '../lib/edition';
1512
import type { Result } from '../lib/result';

dotcom-rendering/src/components/FootballMatchesPageWrapper.importable.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { isObject, isUndefined } from '@guardian/libs';
22
import type { Dispatch, SetStateAction } from 'react';
33
import { useState } from 'react';
4-
import type { FEFootballDataPage } from '../feFootballDataPage';
4+
import type { Region } from '../footballDataPage';
55
import {
66
type FootballMatches,
77
type FootballMatchKind,
88
getParserErrorMessage,
99
parse,
10-
type Region,
1110
} from '../footballMatches';
11+
import type { FEFootballMatchListPage } from '../frontend/feFootballMatchListPage';
1212
import type { EditionId } from '../lib/edition';
1313
import type { Result } from '../lib/result';
1414
import { error, ok } from '../lib/result';
@@ -27,7 +27,7 @@ export const getMoreDays =
2727
const responseJson: unknown = await fetchResponse.json();
2828

2929
if (isObject(responseJson)) {
30-
const feFootballData = responseJson as FEFootballDataPage;
30+
const feFootballData = responseJson as FEFootballMatchListPage;
3131
const parsedFootballMatches = parse(feFootballData.matchesList);
3232

3333
if (parsedFootballMatches.kind === 'error') {

0 commit comments

Comments
 (0)