1 import PropTypes from 'prop-types';
2 import React from 'react';
3 import { Button, Form } from 'react-bootstrap';
4 import { useTranslation } from 'react-i18next';
6 import CrewMember from './CrewMember';
7 import Icon from '../common/Icon';
8 import UserSelect from '../common/UserSelect';
10 const CrewManagement = ({
16 const { t } = useTranslation();
18 const crews = React.useMemo(() =>
20 .filter(c => c.channel_id === channel.id && c.role === role)
21 , [channel, episode, role]);
23 const addCrew = React.useCallback(user_id => {
26 channel_id: channel.id,
27 episode_id: episode.id,
30 }, [channel, episode, manageCrew, role]);
32 const confirmCrew = React.useCallback(crew => {
34 channel_id: channel.id,
36 episode_id: episode.id,
39 }, [channel, episode, manageCrew, role]);
41 const removeCrew = React.useCallback(crew => {
43 channel_id: channel.id,
44 episode_id: episode.id,
48 }, [channel, episode, manageCrew, role]);
50 const unconfirmCrew = React.useCallback(crew => {
52 channel_id: channel.id,
53 episode_id: episode.id,
57 }, [channel, episode, manageCrew, role]);
59 return <div className="mt-2">
60 <div className="fs-4">{t(`crew.roles.${role}`)}</div>
62 <div className="d-flex align-items-center justify-content-between" key={crew.id}>
63 <CrewMember crew={crew} />
64 <div className="button-bar">
67 onClick={() => unconfirmCrew(crew)}
68 title={t('button.unconfirm')}
69 variant="outline-danger"
71 <Icon.REJECT title="" />
76 onClick={() => confirmCrew(crew)}
77 title={t('button.confirm')}
78 variant="outline-success"
84 onClick={() => removeCrew(crew)}
85 title={t('button.remove')}
86 variant="outline-danger"
88 <Icon.DELETE title="" />
93 <Form.Group controlId="crew.addUser">
94 <Form.Label>{t('episodes.restreamDialog.addUser')}</Form.Label>
97 onChange={e => addCrew(e.target.value)}
104 CrewManagement.propTypes = {
105 channel: PropTypes.shape({
106 id: PropTypes.number,
108 episode: PropTypes.shape({
109 crew: PropTypes.arrayOf(PropTypes.shape({
110 channel_id: PropTypes.number,
111 role: PropTypes.string,
113 id: PropTypes.number,
115 manageCrew: PropTypes.func,
116 role: PropTypes.string,
119 export default CrewManagement;