import React from "react" import { Map, List } from "immutable" import PropTypes from "prop-types" import { PolochonMetadata } from "../buttons/polochon" import { DownloadAndStream } from "../buttons/download" import { ImdbBadge } from "../buttons/imdb" const ListDetails = (props) => { if (props.loading) { return null } if (props.data === undefined) { return null } return (

{props.data.get("title")}

{props.data.get("title")}

{props.data.get("year")}

{props.data.get("year")}

{props.data.get("plot")}

{props.children}
); } ListDetails.propTypes = { data: PropTypes.instanceOf(Map), loading: PropTypes.bool, children: PropTypes.object, }; export default ListDetails; const Runtime = (props) => { if (props.runtime === undefined || props.runtime === 0) { return null; } const hours = Math.floor(props.runtime / 60); const minutes = (props.runtime % 60); let duration = ""; if (hours > 0) { duration += hours + "h" } if (minutes > 0) { duration += ("0" + minutes).slice(-2) } if (hours === 0) { duration += " min" } return (

 {duration}

); } Runtime.propTypes = { runtime: PropTypes.number }; const Ratings = (props) => { if (props.rating === undefined) { return null; } return (

 {Number(props.rating).toFixed(1)}  {props.votes !== undefined && ({props.votes} counts) }

); } Ratings.propTypes = { rating: PropTypes.number, votes: PropTypes.number, }; const TrackingLabel = (props) => { let wishlistStr = props.wishlisted ? "Wishlisted" : ""; if (props.trackedEpisode !== null && props.trackedSeason !== null && props.trackedEpisode !== undefined && props.trackedSeason !== undefined) { if ((props.trackedSeason === 0) && (props.trackedEpisode === 0)) { wishlistStr = "Whole show tracked"; } else { wishlistStr = `Tracked from season ${props.trackedSeason} episode ${props.trackedEpisode}`; } } if (wishlistStr === "") { return null; } return (

{wishlistStr}

); } TrackingLabel.propTypes = { wishlisted: PropTypes.bool, trackedSeason: PropTypes.number, trackedEpisode: PropTypes.number, }; const Genres = (props) => { if ((props.genres === undefined) || (props.genres.size === 0)) { return null; } // Uppercase first genres const prettyGenres = props.genres.toJS().map( (word) => word[0].toUpperCase() + word.substr(1) ).join(", "); return (

 {prettyGenres}

); } Genres.propTypes = { genres: PropTypes.instanceOf(List), };