import PropTypes from 'prop-types';
import React from 'react';
+import { Button } from 'react-bootstrap';
import { withTranslation } from 'react-i18next';
+import { useNavigate } from 'react-router-dom';
import { getAvatarUrl } from '../../helpers/User';
import i18n from '../../i18n';
-const Box = ({ discriminator, user }) => user ?
- <span className="user-box">
+const Box = ({ discriminator, user }) => {
+ const navigate = useNavigate();
+
+ if (!user) {
+ return <span>{i18n.t('general.anonymous')}</span>;
+ }
+
+ return <Button
+ className="user-box"
+ onClick={() => navigate(`/users/${user.id}`)}
+ variant="link"
+ >
<img alt="" src={getAvatarUrl(user)} />
<span>{user.username}</span>
{discriminator ?
{user.discriminator}
</span>
: null}
- </span>
-:
- <span>{i18n.t('general.anonymous')}</span>
-;
+ </Button>;
+};
Box.propTypes = {
discriminator: PropTypes.bool,
user: PropTypes.shape({
discriminator: PropTypes.string,
+ id: PropTypes.string,
username: PropTypes.string,
}),
};