]> git.localhorst.tv Git - alttp.git/blob - resources/js/components/rounds/Item.js
display seed code
[alttp.git] / resources / js / components / rounds / Item.js
1 import PropTypes from 'prop-types';
2 import React from 'react';
3 import { withTranslation } from 'react-i18next';
4
5 import SeedButton from './SeedButton';
6 import SeedCode from './SeedCode';
7 import List from '../results/List';
8 import ReportButton from '../results/ReportButton';
9 import { 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                         {round.code ?
28                                 <SeedCode code={round.code} />
29                         : null}
30                         <SeedButton
31                                 round={round}
32                                 tournament={tournament}
33                         />
34                 </p>
35                 {isParticipant(user, tournament) ?
36                         <p className="report">
37                                 <ReportButton
38                                         participant={findParticipant(tournament, user)}
39                                         round={round}
40                                         tournament={tournament}
41                                 />
42                         </p>
43                 : null}
44         </div>
45         <List round={round} tournament={tournament} />
46 </li>;
47
48 Item.propTypes = {
49         index: PropTypes.number,
50         round: PropTypes.shape({
51                 code: PropTypes.arrayOf(PropTypes.string),
52                 created_at: PropTypes.string,
53                 seed: PropTypes.string,
54         }),
55         tournament: PropTypes.shape({
56                 participants: PropTypes.arrayOf(PropTypes.shape({
57                 })),
58         }),
59         user: PropTypes.shape({
60         }),
61 };
62
63 export default withTranslation()(withUser(Item));