X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;ds=sidebyside;f=resources%2Fjs%2Fcomponents%2Fepisodes%2FItem.js;h=3545e7734586a1f3006ad761621df9061fb15d10;hb=d256e01621a8b1072365ae0893002dccb7661898;hp=2078c6dc6573bb74f554032ae67a3fdc0323cd3d;hpb=e2af94795e9d8e8a2eb8c272201b4e54ebb130f0;p=alttp.git
diff --git a/resources/js/components/episodes/Item.js b/resources/js/components/episodes/Item.js
index 2078c6d..3545e77 100644
--- a/resources/js/components/episodes/Item.js
+++ b/resources/js/components/episodes/Item.js
@@ -1,27 +1,32 @@
import moment from 'moment';
import PropTypes from 'prop-types';
import React from 'react';
+import { Button } from 'react-bootstrap';
import { useTranslation } from 'react-i18next';
import Channels from './Channels';
import Crew from './Crew';
+import MultiLink from './MultiLink';
import Players from './Players';
+import Icon from '../common/Icon';
+import { canApplyForEpisode, canRestreamEpisode } from '../../helpers/permissions';
+import { withUser } from '../../helpers/UserContext';
const isActive = episode => {
if (!episode.start) return false;
const now = moment();
- const start = moment(episode.start);
- const end = moment(start).add(episode.estimate, 'seconds');
+ 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 }) => {
+const Item = ({ episode, onAddRestream, onApply, onEditRestream, user }) => {
const { t } = useTranslation();
const classNames = [
'episodes-item',
'd-flex',
- 'align-items-start',
+ 'align-items-stretch',
'my-3',
'p-2',
'border',
@@ -31,11 +36,23 @@ const Item = ({ episode }) => {
classNames.push('is-active');
}
- return
+ 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
{t('schedule.startTime', { date: new Date(episode.start) })}
-
+
{episode.title ?
@@ -43,23 +60,50 @@ const Item = ({ episode }) => {
{episode.title}
: null}
- {episode.event ?
-
- {episode.event.title}
+ {episode.comment ?
+
+ {episode.comment}
: null}
-
- {episode.channels ?
-
+
+ {hasChannels ?
+
+ : null}
+ {!hasChannels && hasPlayers ?
+
+ : null}
+ {onAddRestream && canRestreamEpisode(user, episode) ?
+
+
+
: null}
- {episode.players && episode.players.length ?
+ {hasPlayers ?
: null}
- {episode.crew && episode.crew.length ?
-
+ {(episode.crew && episode.crew.length)
+ || canApplyForEpisode(user, episode, 'commentary')
+ || canApplyForEpisode(user, episode, 'tracking') ?
+
+
+
+ : null}
+ {episode.event ?
+
+ {episode.event.title}
+
: null}
;
@@ -69,9 +113,11 @@ Item.propTypes = {
episode: PropTypes.shape({
channels: PropTypes.arrayOf(PropTypes.shape({
})),
+ comment: PropTypes.string,
crew: PropTypes.arrayOf(PropTypes.shape({
})),
event: PropTypes.shape({
+ corner: PropTypes.string,
title: PropTypes.string,
}),
players: PropTypes.arrayOf(PropTypes.shape({
@@ -79,6 +125,11 @@ Item.propTypes = {
start: PropTypes.string,
title: PropTypes.string,
}),
+ onAddRestream: PropTypes.func,
+ onApply: PropTypes.func,
+ onEditRestream: PropTypes.func,
+ user: PropTypes.shape({
+ }),
};
-export default Item;
+export default withUser(Item);