]> git.localhorst.tv Git - alttp.git/blob - resources/js/components/users/EditStreamLinkButton.js
allow users to set their stream link
[alttp.git] / resources / js / components / users / EditStreamLinkButton.js
1 import PropTypes from 'prop-types';
2 import React, { useState } from 'react';
3 import { Button } from 'react-bootstrap';
4 import { withTranslation } from 'react-i18next';
5
6 import EditStreamLinkDialog from './EditStreamLinkDialog';
7 import Icon from '../common/Icon';
8 import { mayEditStreamLink } from '../../helpers/permissions';
9 import { withUser } from '../../helpers/UserContext';
10 import i18n from '../../i18n';
11
12 const EditStreamLinkButton = ({ authUser, user }) => {
13         const [showDialog, setShowDialog] = useState(false);
14
15         if (mayEditStreamLink(authUser, user)) {
16                 return <>
17                         <EditStreamLinkDialog
18                                 onHide={() => setShowDialog(false)}
19                                 show={showDialog}
20                                 user={user}
21                         />
22                         <Button
23                                 onClick={() => setShowDialog(true)}
24                                 title={i18n.t('button.edit')}
25                                 variant="outline-secondary"
26                         >
27                                 <Icon.EDIT title="" />
28                         </Button>
29                 </>;
30         }
31         return null;
32 };
33
34 EditStreamLinkButton.propTypes = {
35         authUser: PropTypes.shape({
36         }),
37         user: PropTypes.shape({
38         }),
39 };
40
41 export default withTranslation()(withUser(EditStreamLinkButton, 'authUser'));