]> git.localhorst.tv Git - alttp.git/blob - resources/js/components/episodes/RestreamEditForm.js
e4cbe134fe5e8980dd60065196601555b221de77
[alttp.git] / resources / js / components / episodes / RestreamEditForm.js
1 import PropTypes from 'prop-types';
2 import React from 'react';
3 import { Button, Modal } from 'react-bootstrap';
4 import { useTranslation } from 'react-i18next';
5
6 import { getName } from '../../helpers/Crew';
7
8 const RestreamEditForm = ({
9         channel,
10         episode,
11         onCancel,
12         onRemoveRestream,
13 }) => {
14         const { t } = useTranslation();
15
16         return <>
17                 <Modal.Body>
18                         {channel ?
19                                 <div>
20                                         {channel.title}
21                                 </div>
22                         : null}
23                         {episode ? <>
24                                 <div>
25                                         {episode.event.title}
26                                 </div>
27                                 <div>
28                                         {t('episodes.startTime', { date: new Date(episode.start) })}
29                                 </div>
30                                 <div>
31                                         {episode.players.map(p => getName(p)).join(', ')}
32                                 </div>
33                         </> : null}
34                 </Modal.Body>
35                 <Modal.Footer className="justify-content-between">
36                         {onRemoveRestream ?
37                                 <Button onClick={() => onRemoveRestream(episode, channel)} variant="outline-danger">
38                                         {t('button.remove')}
39                                 </Button>
40                         : null}
41                         {onCancel ?
42                                 <Button onClick={onCancel} variant="secondary">
43                                         {t('button.close')}
44                                 </Button>
45                         : null}
46                 </Modal.Footer>
47         </>;
48 };
49
50 RestreamEditForm.propTypes = {
51         channel: PropTypes.shape({
52                 title: PropTypes.string,
53         }),
54         episode: PropTypes.shape({
55                 event: PropTypes.shape({
56                         title: PropTypes.string,
57                 }),
58                 players: PropTypes.arrayOf(PropTypes.shape({
59                 })),
60                 start: PropTypes.string,
61         }),
62         onCancel: PropTypes.func,
63         onRemoveRestream: PropTypes.func,
64 };
65
66 export default RestreamEditForm;