]> git.localhorst.tv Git - alttp.git/blob - resources/js/components/rounds/Item.js
show ropunds in reverse order
[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         round,
16         tournament,
17         user,
18 }) =>
19 <li className="round d-flex">
20         <div className="info">
21                 <p className="date">
22                         {round.number ? `#${round.number} ` : '#?'}
23                         {i18n.t('rounds.date', { date: new Date(round.created_at) })}
24                 </p>
25                 <p className="seed">
26                         {round.code ?
27                                 <SeedCode code={round.code} />
28                         : null}
29                         <SeedButton
30                                 round={round}
31                                 tournament={tournament}
32                         />
33                 </p>
34                 {isParticipant(user, tournament) ?
35                         <p className="report">
36                                 <ReportButton
37                                         participant={findParticipant(tournament, user)}
38                                         round={round}
39                                         tournament={tournament}
40                                 />
41                         </p>
42                 : null}
43         </div>
44         <List round={round} tournament={tournament} />
45 </li>;
46
47 Item.propTypes = {
48         round: PropTypes.shape({
49                 code: PropTypes.arrayOf(PropTypes.string),
50                 created_at: PropTypes.string,
51                 number: PropTypes.number,
52                 seed: PropTypes.string,
53         }),
54         tournament: PropTypes.shape({
55                 participants: PropTypes.arrayOf(PropTypes.shape({
56                 })),
57         }),
58         user: PropTypes.shape({
59         }),
60 };
61
62 export default withTranslation()(withUser(Item));