X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fcomponents%2Fepisodes%2FItem.js;h=4fb466669dfdc2591b90fab9778f263cff4a4ab4;hb=9ef9d8cef9ab9ab844082d3d128c2f1fd30a1770;hp=5f43c1248b15fb1df75f6c39477f7dfe223baaf7;hpb=9b4ede72755930de6b0a39bf6f142e598c043844;p=alttp.git
diff --git a/resources/js/components/episodes/Item.js b/resources/js/components/episodes/Item.js
index 5f43c12..4fb4666 100644
--- a/resources/js/components/episodes/Item.js
+++ b/resources/js/components/episodes/Item.js
@@ -1,32 +1,23 @@
-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 { hasPassed, hasSGRestream, isActive } from '../../helpers/Episode';
+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).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, user }) => {
const { t } = useTranslation();
const classNames = [
'episodes-item',
- 'd-flex',
- 'align-items-start',
'my-3',
'p-2',
'border',
@@ -49,53 +40,83 @@ const Item = ({ episode, onAddRestream, onEditRestream, user }) => {
const hasPlayers = episode.players && episode.players.length;
return
-
- {t('schedule.startTime', { date: new Date(episode.start) })}
-
-
-
-
- {episode.title ?
-
- {episode.title}
-
- : null}
- {episode.event ?
-
- {episode.event.title}
-
- : null}
-
-
- {hasChannels ?
-
- : null}
- {!hasChannels && hasPlayers ?
-
- : null}
- {onAddRestream && canRestreamEpisode(user, episode) ?
-
-
-
- : null}
-
+
+
+ {t('schedule.startTime', { date: new Date(episode.start) })}
+
+
+ {episode.title || episode.event ?
+
+ {episode.title || episode.event.title}
+
+ : null}
+ {episode.comment ?
+
+ {episode.comment}
+
+ : null}
+
+ {hasChannels ?
+
+ : null}
+ {!hasChannels && hasPlayers ?
+
+ : null}
+ {episode.raceroom ?
+
+
+
+ : null}
+ {onAddRestream && canRestreamEpisode(user, episode) ?
+
+
+
+ : null}
+
+
+
{hasPlayers ?
: null}
- {episode.crew && episode.crew.length ?
-
+ {(episode.crew && episode.crew.length) || (!hasPassed(episode) && (
+ hasSGRestream(episode)
+ || canApplyForEpisode(user, episode, 'commentary')
+ || canApplyForEpisode(user, episode, 'tracking')
+ )) ?
+
+
+
+ : null}
+ {episode.event ?
+
+ {episode.event.description_id ?
+
+ {episode.event.title}
+
+ :
+ episode.event.title
+ }
+
: null}
;
@@ -105,18 +126,23 @@ Item.propTypes = {
episode: PropTypes.shape({
channels: PropTypes.arrayOf(PropTypes.shape({
})),
+ comment: PropTypes.string,
crew: PropTypes.arrayOf(PropTypes.shape({
})),
event: PropTypes.shape({
corner: PropTypes.string,
+ description_id: PropTypes.number,
+ name: PropTypes.string,
title: PropTypes.string,
}),
players: PropTypes.arrayOf(PropTypes.shape({
})),
+ raceroom: PropTypes.string,
start: PropTypes.string,
title: PropTypes.string,
}),
onAddRestream: PropTypes.func,
+ onApply: PropTypes.func,
onEditRestream: PropTypes.func,
user: PropTypes.shape({
}),