Skip to content

Commit

Permalink
update data model to support changes in frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
marjisound committed Dec 17, 2024
1 parent 6adc8fb commit f8e0fdb
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 24 deletions.
14 changes: 5 additions & 9 deletions dotcom-rendering/src/components/Football/LiveScoresPage.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { FELiveScoresType } from 'src/types/sports';
import { FEFootballPageType } from 'src/types/sports';

Check failure on line 1 in dotcom-rendering/src/components/Football/LiveScoresPage.tsx

View workflow job for this annotation

GitHub Actions / lint / check

'src/types/sports' import is restricted from being used by a pattern. Paths starting with “src/” are forbidden. Please use a relative path instead

Check failure on line 1 in dotcom-rendering/src/components/Football/LiveScoresPage.tsx

View workflow job for this annotation

GitHub Actions / lint / check

All imports in the declaration are only used as types. Use `import type`
import { css } from '@emotion/react';

Check failure on line 2 in dotcom-rendering/src/components/Football/LiveScoresPage.tsx

View workflow job for this annotation

GitHub Actions / lint / check

`@emotion/react` import should occur before import of `src/types/sports`
import { MatchList } from './MatchList';

interface Props {
liveScores: FELiveScoresType;
liveScores: FEFootballPageType;
}

const sportsPageStyles = css`
Expand Down Expand Up @@ -34,13 +34,9 @@ export const LiveScoresPage = ({ liveScores }: Props) => {
css={[matchContainerStyles]}
data-show-more-contains="football-matches"
>
{liveScores.matchesGroupedByDateAndCompetition.map(
(item) => {
return (
<MatchList dateCompetition={item}></MatchList>
);
},
)}
{liveScores.matchesList.map((item) => {
return <MatchList dateCompetition={item}></MatchList>;

Check failure on line 38 in dotcom-rendering/src/components/Football/LiveScoresPage.tsx

View workflow job for this annotation

GitHub Actions / lint / check

Missing "key" prop for element in iterator
})}
</div>
</div>
</article>
Expand Down
6 changes: 3 additions & 3 deletions dotcom-rendering/src/components/Football/MatchList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ export const MatchList: React.FC<Props> = ({ dateCompetition }) => {
return (
<>
<div>{dateCompetition.date}</div>
{dateCompetition.competitions.map((comp) => (
<div key={comp.competition.id}>
<h3>{comp.competition.fullName}</h3>
{dateCompetition.competitionMatches.map((comp) => (
<div key={comp.competitionSummary.id}>
<h3>{comp.competitionSummary.fullName}</h3>
<table>
<thead hidden>

Check failure on line 15 in dotcom-rendering/src/components/Football/MatchList.tsx

View workflow job for this annotation

GitHub Actions / lint / check

Value must be set for boolean attributes
<tr>
Expand Down
6 changes: 5 additions & 1 deletion dotcom-rendering/src/model/sports-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
"properties": {
"pageTitle": {
"type": "string"
},
"pageType": {
"type": "string"
}
},
"required": [
"pageTitle"
"pageTitle",
"pageType"
],
"$schema": "http://json-schema.org/draft-07/schema#"
}
6 changes: 3 additions & 3 deletions dotcom-rendering/src/model/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import sportSchema from './sports-schema.json';
import frontSchema from './front-schema.json';
import newslettersPageSchema from './newsletter-page-schema.json';
import tagPageSchema from './tag-page-schema.json';
import { FELiveScoresType } from 'src/types/sports';
import { FEFootballPageType } from 'src/types/sports';

const options: Options = {
verbose: false,
Expand All @@ -38,7 +38,7 @@ const validateEditionsCrossword = ajv.compile<FEEditionsCrosswords>(
editionsCrosswordSchema,
);

const validateSports = ajv.compile<FELiveScoresType>(sportSchema);
const validateSports = ajv.compile<FEFootballPageType>(sportSchema);

export const validateAsArticleType = (data: unknown): FEArticleType => {
if (validateArticle(data)) return data;
Expand All @@ -64,7 +64,7 @@ export const validateAsEditionsCrosswordType = (
);
};

export const validateAsSports = (data: unknown): FELiveScoresType => {
export const validateAsSports = (data: unknown): FEFootballPageType => {
if (validateSports(data)) {
return data;
}
Expand Down
4 changes: 2 additions & 2 deletions dotcom-rendering/src/server/render.sports.web.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { FELiveScoresType } from '../types/sports';
import { FEFootballPageType } from '../types/sports';
import { LiveScoresPage } from '../components/Football/LiveScoresPage';
import { renderToStringWithEmotion } from '../lib/emotion';
import { getPathFromManifest } from '../lib/assets';
import { polyfillIO } from '../lib/polyfill.io';
import { isString } from '@guardian/libs';

interface Props {
sports: FELiveScoresType;
sports: FEFootballPageType;
}

export const renderSportsHtml = ({
Expand Down
18 changes: 12 additions & 6 deletions dotcom-rendering/src/types/sports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ type MatchDayTeam = {
scorers?: string;
};

type Competition = {
id: string;
name: string;
};

type FootballMatch = {
id: string;
date: Date;
Expand Down Expand Up @@ -47,6 +52,7 @@ type MatchDay = FootballMatch & {
matchStatus: string;
attendance?: string;
referee?: string;
competition?: Competition;
};

type Result = FootballMatch & {
Expand Down Expand Up @@ -87,7 +93,7 @@ type LeagueTeam = {

type LeagueTableEntry = { stageNumber: string; round: Round; team: LeagueTeam };

type Competition = {
type CompetitionSummary = {
id: string;
url: string;
fullName: string;
Expand All @@ -102,17 +108,17 @@ type Competition = {
};

type CompetitionMatch = {
competition: Competition;
competitionSummary: CompetitionSummary;
matches: FootballMatchType[];
};

export type DateCompetitionMatch = {
date: string;
competitions: CompetitionMatch[];
competitionMatches: CompetitionMatch[];
};

export type FELiveScoresType = {
export type FEFootballPageType = {
pageTitle: string;
type: string;
matchesGroupedByDateAndCompetition: DateCompetitionMatch[];
pageType: string;
matchesList: DateCompetitionMatch[];
};

0 comments on commit f8e0fdb

Please sign in to comment.