diff --git a/src/public/js/components/list/details.js b/src/public/js/components/list/details.js index dc93eab..f848afb 100644 --- a/src/public/js/components/list/details.js +++ b/src/public/js/components/list/details.js @@ -1,63 +1,96 @@ import React from "react" export default function ListDetails(props) { - let genres = props.data.get("genres"); - if (genres !== undefined) { - // Uppercase first genres - genres = genres.toJS().map( - (word) => word[0].toUpperCase() + word.substr(1) - ).join(", "); - } - - let wishlistStr = ""; - if (props.data.get("wishlisted") === true) { - wishlistStr = "Wishlisted"; - } - - const trackedSeason = props.data.get("tracked_season"); - const trackedEpisode = props.data.get("tracked_episode"); - if (trackedEpisode !== null && trackedSeason !== null - && trackedEpisode !== undefined && trackedSeason !== undefined) { - if ((trackedSeason === 0) && (trackedEpisode === 0)) { - wishlistStr = "Whole show tracked"; - } else { - wishlistStr = `Tracked from season ${trackedSeason} episode ${trackedEpisode}`; - } - } - return (
- - {props.data.get("runtime")} min -
- } - {genres !== undefined && -- - {genres} -
- } -- - {Number(props.data.get("rating")).toFixed(1)} - {props.data.get("votes") !== undefined && - ({props.data.get("votes")} counts) - } -
+{props.data.get("plot")}
+ + {props.runtime} min +
+ ); +} + +function Ratings(props) { + if (props.rating === undefined) { + return null; + } + + return ( ++ + {Number(props.rating).toFixed(1)} + {props.votes !== undefined && + ({props.votes} counts) + } +
+ ); +} + +function 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} + + ); +} + +function Genres(props) { + if (props.genres === undefined) { + return null; + } + + // Uppercase first genres + const prettyGenres = props.genres.toJS().map( + (word) => word[0].toUpperCase() + word.substr(1) + ).join(", "); + + return ( ++ + {prettyGenres} +
+ ); +}