import React from 'react'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import ListGroup from 'react-bootstrap/ListGroup'; import Media from 'react-bootstrap/Media'; import Image from 'react-bootstrap/Image'; import Link from 'next/link'; import { getThumbnailURL } from '../util'; import FormattedDuration from './localization/FormattedDuration'; import style from './VideoListItem.module.scss'; import sanitizeTitle from '../util/sanitizeTitle'; import hourglassImage from '../images/hourglass.svg'; export default function VideoListItem({ thumbnailServerURL, duration, id, fileName, title, sourceVideoStart, sourceVideoEnd, }: { thumbnailServerURL: string, duration: number | string, id: string, fileName: string, title: string, sourceVideoStart: number | string, sourceVideoEnd: number | string, }) { let displayDuration = null; if (duration !== null) { if (typeof duration === 'string') { displayDuration = parseFloat(duration); } else { displayDuration = duration; } } else if ( sourceVideoStart !== null && sourceVideoEnd !== null && sourceVideoStart !== sourceVideoEnd ) { let videoEnd: number; if (typeof sourceVideoEnd === 'string') { videoEnd = parseFloat(sourceVideoEnd); } else { videoEnd = sourceVideoEnd; } let videoStart: number; if (typeof sourceVideoStart === 'string') { videoStart = parseFloat(sourceVideoStart); } else { videoStart = sourceVideoStart; } displayDuration = videoEnd - videoStart; } const titleUrlSlug = sanitizeTitle(title); const listGroupItem = ( [ fileName ? getThumbnailURL(thumbnailServerURL, id, fileName, 90 * 1000, { width, }) : hourglassImage, `${width}w`, ]) .map((item) => item.join(' ')) .join(', ')} alt={title} />
{title}

{!fileName ? ( {' '} Coming up ) : ''} {displayDuration !== null ? ( {' '} ) : ''}

); if (fileName) { return ( {listGroupItem} ); } return listGroupItem; }