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 OptaFootballStandingsPageView: React.FC<{ season: string; competition: string; isApp?: boolean; full_width?: boolean; isStandingLive?: boolean; heightSm?: number; heightMd?: number; heightLg?: number; [key: string]: any; }> = React.memo( ({ season, competition, isApp = false, full_width, isStandingLive = false, 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: 'standings', season, competition, template: 'normal', live: isStandingLive, default_nav: '1', side: 'combined', data_detail: 'default', show_key: true, show_crests: true, points_in_first_column: false, lose_before_draw: true, show_form: 6, competition_naming: 'full', team_naming: 'full', date_format: 'dddd D MMMM YYYY', sorting: false, show_live: true, show_live_results: true, show_relegation_average: true, show_logo: true, show_title: true, breakpoints: 1 }).outerHTML; initComponent(); } }) .then(() => { setIsReady(true); }); return undefined; }, [competition, season] ); return ( {!isReady && ( )} ); } );