X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;ds=inline;f=resources%2Fjs%2Fcomponents%2Fepisodes%2FItem.js;h=612c5ea85f6f76db13ca777f85a93fbebae70bf2;hb=5fe70ee6bc5380c556169756a375956799093604;hp=71fe49ed5c6875eb00d34848143160a75576fc02;hpb=638802eaf20d636c16d7ce337ace508708705f2c;p=alttp.git diff --git a/resources/js/components/episodes/Item.js b/resources/js/components/episodes/Item.js index 71fe49e..612c5ea 100644 --- a/resources/js/components/episodes/Item.js +++ b/resources/js/components/episodes/Item.js @@ -1,32 +1,25 @@ -import moment from 'moment'; import PropTypes from 'prop-types'; import React from 'react'; import { Button } from 'react-bootstrap'; import { useTranslation } from 'react-i18next'; +import { Link } from 'react-router-dom'; import Channels from './Channels'; import Crew from './Crew'; import MultiLink from './MultiLink'; import Players from './Players'; import Icon from '../common/Icon'; -import { canRestreamEpisode } from '../../helpers/permissions'; -import { withUser } from '../../helpers/UserContext'; +import { hasPassed, hasSGRestream, isActive } from '../../helpers/Episode'; +import { getLink } from '../../helpers/Event'; +import { canApplyForEpisode, canRestreamEpisode } from '../../helpers/permissions'; +import { useUser } from '../../hooks/user'; -const isActive = episode => { - if (!episode.start) return false; - const now = moment(); - const start = moment(episode.start).subtract(10, 'minutes'); - const end = moment(episode.start).add(episode.estimate, 'seconds'); - return start.isBefore(now) && end.isAfter(now); -}; - -const Item = ({ episode, onAddRestream, onEditRestream, user }) => { +const Item = ({ episode, onAddRestream, onApply, onEditRestream }) => { const { t } = useTranslation(); + const { user } = useUser(); const classNames = [ 'episodes-item', - 'd-flex', - 'align-items-start', 'my-3', 'p-2', 'border', @@ -36,57 +29,96 @@ const Item = ({ episode, onAddRestream, onEditRestream, user }) => { classNames.push('is-active'); } + const style = React.useMemo(() => { + if (episode.event && episode.event.corner) { + return { + backgroundImage: `url(${episode.event.corner})`, + }; + } + return null; + }, [episode.event && episode.event.corner]); + const hasChannels = episode.channels && episode.channels.length; const hasPlayers = episode.players && episode.players.length; - return