// @flow import React, { useState, useEffect } from 'react'; import * as ICONS from 'constants/icons'; import Icon from 'component/common/icon'; import moment from 'moment'; import 'scss/component/livestream-scheduled-info.scss'; type Props = { release: any, }; export default function LivestreamScheduledInfo(props: Props) { const { release } = props; const [startDateFromNow, setStartDateFromNow] = useState(release.fromNow()); const [inPast, setInPast] = useState('pending'); useEffect(() => { const calcTime = () => { setStartDateFromNow(release.fromNow()); setInPast(release.isBefore(moment())); }; calcTime(); const intervalId = setInterval(calcTime, 1000); return () => { clearInterval(intervalId); }; }, [release]); const startDate = release.format('MMMM Do, h:mm a'); return ( inPast !== 'pending' && (

{!inPast && ( {__('Live %time_date%', { time_date: startDateFromNow })}
{startDate}
)} {inPast && {__('Starting Soon')}}

) ); }