import React, { useRef, useState, useEffect } from 'react'; import { Placeholder } from '@times-components/image'; import { initSettings, initStyleSheet, initScript, initElement, initComponent } from '../../../utils/config'; import { PlaceholderContainer } from '../../../shared/shared-styles'; import { WidgetContainer, WidgetContent, TimelineWrapper } from './WidgetContainer'; export const OptaMatchStatsTimeline: React.FC<{ season: string; competition: string; match: string; isApp?: boolean; hasBorder?: boolean; homeTeam?: string; awayTeam?: string; }> = React.memo( ({ season, competition, match, isApp = false, hasBorder = false, homeTeam, awayTeam }) => { const ref = useRef(null); const widgetRef = useRef(null); const [isReady, setIsReady] = useState(false); useEffect(() => { const sport = 'football'; initSettings(); initStyleSheet(sport); initScript() .then(() => { if (widgetRef.current) { widgetRef.current.innerHTML = initElement('opta-widget', { sport, widget: 'timeline', season, competition, match, template: 'normal', live: true, orientation: 'horizontal', vertical_timebar_height: 260, group_substitutions: true, show_match_header: false, show_score: true, show_crests: true, show_assists: 'all', show_team_formation: true, show_clock: true, show_period_dividers: true, show_halftime_score: true, show_date: true, date_format: 'dddd D MMMM YYYY', narrow_date_format: 'DD/MM/YY', show_attendance: false, show_images: true, show_referee: false, show_venue: false, show_cards: 'all', show_goals: true, show_penalties_missed: true, show_subs: true, show_goals_combined: true, show_shootouts: true, show_competition_name: true, competition_naming: 'full', team_naming: 'brief', player_naming: 'full', show_live: true, show_logo: false, show_title: true, breakpoints: '300, 700' }).outerHTML; initComponent(); } }) .then(() => { setIsReady(true); }); }, []); return (

Timeline

{homeTeam || 'Home'} {awayTeam || 'Away'} {!isReady && ( )}
); } );