X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fcomponents%2Fepisodes%2FItem.js;h=612c5ea85f6f76db13ca777f85a93fbebae70bf2;hb=9a4e2305bb37cb8c62e3ad332f4a2bf45f720a18;hp=c911bc3b6e1f54e3ff15d09ceb76de4abbccefd0;hpb=5a575dc29f3af10f1d8e142ff9e1c6ccdfa3b075;p=alttp.git
diff --git a/resources/js/components/episodes/Item.js b/resources/js/components/episodes/Item.js
index c911bc3..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 { hasPassed, hasSGRestream, isActive } from '../../helpers/Episode';
+import { getLink } from '../../helpers/Event';
import { canApplyForEpisode, canRestreamEpisode } from '../../helpers/permissions';
-import { withUser } from '../../helpers/UserContext';
+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, onApply, 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',
@@ -49,54 +42,83 @@ const Item = ({ episode, onAddRestream, onApply, 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') ?
-
+ || canApplyForEpisode(user, episode, 'tracking')
+ )) ?
+
+
+
+ : null}
+ {episode.event ?
+
+ {episode.event.description_id ?
+
+ {episode.event.title}
+
+ :
+ episode.event.title
+ }
+
: null}
;
@@ -106,22 +128,24 @@ 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({
- }),
};
-export default withUser(Item);
+export default Item;