1 import PropTypes from 'prop-types';
2 import React from 'react';
3 import { Button, Col, Form, Modal, Row } from 'react-bootstrap';
4 import { useTranslation } from 'react-i18next';
6 import CrewManagement from './CrewManagement';
7 import ToggleSwitch from '../common/ToggleSwitch';
8 import { getName } from '../../helpers/Crew';
10 const RestreamEditForm = ({
18 const { t } = useTranslation();
20 const acceptToggle = React.useCallback(e => {
22 channel_id: channel.id,
23 episode_id: episode.id,
24 [e.target.name]: e.target.value,
26 }, [channel, editRestream, episode]);
40 {t('episodes.startTime', { date: new Date(episode.start) })}
43 {episode.players.map(p => getName(p)).join(', ')}
46 {channel && episode && editRestream ?
48 <Form.Group as={Col} sm={6} controlId="episodes.accept_comms">
49 <Form.Label className="d-block">
50 {t('episodes.restreamDialog.acceptComms')}
55 onChange={acceptToggle}
56 value={!!channel.pivot.accept_comms}
59 <Form.Group as={Col} sm={6} controlId="episodes.accept_tracker">
60 <Form.Label className="d-block">
61 {t('episodes.restreamDialog.acceptTracker')}
66 onChange={acceptToggle}
67 value={!!channel.pivot.accept_tracker}
72 {channel && episode && manageCrew ? <>
76 manageCrew={manageCrew}
82 manageCrew={manageCrew}
88 manageCrew={manageCrew}
93 <Modal.Footer className="justify-content-between">
95 <Button onClick={() => onRemoveRestream(episode, channel)} variant="outline-danger">
100 <Button onClick={onCancel} variant="secondary">
108 RestreamEditForm.propTypes = {
109 channel: PropTypes.shape({
110 id: PropTypes.number,
111 pivot: PropTypes.shape({
112 accept_comms: PropTypes.bool,
113 accept_tracker: PropTypes.bool,
115 title: PropTypes.string,
117 editRestream: PropTypes.func,
118 episode: PropTypes.shape({
119 crew: PropTypes.arrayOf(PropTypes.shape({
120 channel_id: PropTypes.number,
121 role: PropTypes.string,
123 event: PropTypes.shape({
124 title: PropTypes.string,
126 id: PropTypes.number,
127 players: PropTypes.arrayOf(PropTypes.shape({
129 start: PropTypes.string,
131 manageCrew: PropTypes.func,
132 onCancel: PropTypes.func,
133 onRemoveRestream: PropTypes.func,
136 export default RestreamEditForm;