1 import PropTypes from 'prop-types';
2 import React, { useState } from 'react';
3 import { Button } from 'react-bootstrap';
4 import { useTranslation } from 'react-i18next';
6 import EditNicknameDialog from './EditNicknameDialog';
7 import Icon from '../common/Icon';
8 import { mayEditNickname } from '../../helpers/permissions';
9 import { useUser } from '../../hooks/user';
11 const EditNicknameButton = ({ user }) => {
12 const [showDialog, setShowDialog] = useState(false);
14 const { t } = useTranslation();
15 const { user: authUser } = useUser();
17 if (mayEditNickname(authUser, user)) {
20 onHide={() => setShowDialog(false)}
25 onClick={() => setShowDialog(true)}
26 title={t('button.edit')}
27 variant="outline-secondary"
29 <Icon.EDIT title="" />
36 EditNicknameButton.propTypes = {
37 user: PropTypes.shape({
41 export default EditNicknameButton;