->where('episodes.start', '>=', $after)
->where('episodes.start', '<=', $before)
->where('events.visible', '=', true)
+ ->orderBy('episodes.start')
->limit(1000);
return $episodes->get()->toJson();
}
--- /dev/null
+import PropTypes from 'prop-types';
+import React from 'react';
+import { Button } from 'react-bootstrap';
+
+import { getAvatarUrl } from '../../helpers/User';
+
+const getName = player => {
+ if (player.name_override) {
+ return player.name_override;
+ }
+ if (player.user) {
+ return player.user.nickname || player.user.username;
+ }
+ return '';
+};
+
+const getStreamLink = player => {
+ if (player.stream_override) {
+ return `https://twitch.tv/${player.stream_override}`;
+ }
+ if (player.user && player.user.stream_link) {
+ return player.user.stream_link;
+ }
+ return '';
+};
+
+const Player = ({ player }) => {
+ return <div className="episode-player my-3">
+ <Button
+ className="player-link"
+ href={getStreamLink(player)}
+ rel="noreferrer"
+ target="_blank"
+ variant="outline-twitch"
+ >
+ <img alt="" src={getAvatarUrl(player.user)} />
+ <span className="text-light fs-4">{getName(player)}</span>
+ </Button>
+ </div>;
+};
+
+Player.propTypes = {
+ player: PropTypes.shape({
+ id: PropTypes.number,
+ name_override: PropTypes.string,
+ stream_override: PropTypes.string,
+ user: PropTypes.shape({
+ }),
+ }),
+};
+
+export default Player;
import PropTypes from 'prop-types';
import React from 'react';
-const Players = ({ players }) => {
- return <div className="episode-players">
+import Player from './Player';
+
+const Players = ({ players }) =>
+ <div className="episode-players">
{players.map(player =>
- <div className="episode-player fs-4 my-3" key={player.id}>
- {player.name_override}
- </div>
+ <Player key={player.id} player={player} />
)}
</div>;
-};
Players.propTypes = {
players: PropTypes.arrayOf(PropTypes.shape({