1 import PropTypes from 'prop-types';
2 import React from 'react';
3 import { Alert, Button, Table } from 'react-bootstrap';
4 import { withTranslation } from 'react-i18next';
5 import { useNavigate } from 'react-router-dom';
7 import i18n from '../../i18n';
9 const Participation = ({ user }) => {
10 const navigate = useNavigate();
12 if (!user || !user.participation || !user.participation.length) {
13 return <Alert variant="info">
14 {i18n.t('users.participationEmpty')}
17 return <Table className="participation">
20 <th>{i18n.t('participants.tournament')}</th>
21 <th>{i18n.t('participants.roles')}</th>
25 {user.participation.map(p => <tr key={p.id}>
28 onClick={() => navigate(`/tournaments/${p.tournament_id}`)}
35 {p.roles ? p.roles.map((role, index) =>
37 {index === 0 ? '' : ', '}
38 {i18n.t(`participants.roleNames.${role}`)}
47 Participation.propTypes = {
48 user: PropTypes.shape({
49 participation: PropTypes.arrayOf(PropTypes.shape({
55 export default withTranslation()(Participation);