import React, { useEffect, useRef, useState } from 'react'; import { Placeholder } from '@times-components/image'; import { initSettings, initStyleSheet, initScript, initElement, initComponent } from '../../utils/config'; import { PlaceholderContainer } from '../../shared/shared-styles'; import { PageViewContainer, WidgetContainer } from './styles'; export const OptaFootballTournamentTree: React.FC<{ season: string; competition: string; isApp?: boolean; full_width?: boolean; heightSm?: number; heightMd?: number; heightLg?: number; [key: string]: any; }> = React.memo( ({ season, competition, isApp = false, full_width, heightSm, heightMd, heightLg }) => { const ref = useRef(null); const [isReady, setIsReady] = useState(false); useEffect( () => { const sport = 'football'; initSettings(); initStyleSheet(sport); initScript() .then(() => { if (ref.current) { ref.current.innerHTML = initElement('opta-widget', { sport, widget: 'tournament_tree', season, competition, template: 'normal', show_crests: true, show_third_place: true, show_goals_combined: true, branch_navigation: 'sideways', date_format: 'dddd D MMMM YYYY', pre_match: false, show_competition_name: true, competition_naming: 'full', team_naming: 'full', show_live: false, show_logo: true, show_title: true, fixture_height: 120, breakpoints: 500 }).outerHTML; initComponent(); } }) .then(() => { setIsReady(true); }); return undefined; }, [competition, season] ); return ( {!isReady && ( )} ); } );