]> git.localhorst.tv Git - alttp.git/blob - resources/js/components/rounds/Item.js
1832edb4c13bb5e08f90f1731f1866884ffcd452
[alttp.git] / resources / js / components / rounds / Item.js
1 import PropTypes from 'prop-types';
2 import React from 'react';
3 import { Button } from 'react-bootstrap';
4 import { withTranslation } from 'react-i18next';
5
6 import SeedButton from './SeedButton';
7 import List from '../results/List';
8 import ReportButton from '../results/ReportButton';
9 import { maySetSeed, isParticipant } from '../../helpers/permissions';
10 import { findParticipant } from '../../helpers/Tournament';
11 import { withUser } from '../../helpers/UserContext';
12 import i18n from '../../i18n';
13
14 const Item = ({
15         index,
16         round,
17         tournament,
18         user,
19 }) =>
20 <li className="round d-flex">
21         <div className="info">
22                 <p className="date">
23                         {`#${index + 1} `}
24                         {i18n.t('rounds.date', { date: new Date(round.created_at) })}
25                 </p>
26                 <p className="seed">
27                         <SeedButton
28                                 round={round}
29                                 tournament={tournament}
30                         />
31                 </p>
32                 {isParticipant(user, tournament) ?
33                         <p className="report">
34                                 <ReportButton
35                                         participant={findParticipant(tournament, user)}
36                                         round={round}
37                                         tournament={tournament}
38                                 />
39                         </p>
40                 : null}
41         </div>
42         <List round={round} tournament={tournament} />
43 </li>;
44
45 Item.propTypes = {
46         index: PropTypes.number,
47         round: PropTypes.shape({
48                 created_at: PropTypes.string,
49                 seed: PropTypes.string,
50         }),
51         tournament: PropTypes.shape({
52                 participants: PropTypes.arrayOf(PropTypes.shape({
53                 })),
54         }),
55         user: PropTypes.shape({
56         }),
57 };
58
59 export default withTranslation()(withUser(Item));