]> git.localhorst.tv Git - alttp.git/blob - resources/js/components/rounds/Item.js
d8fe9d8b1ccc88983b2f843c712481fbffe260b3
[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                                 <>
28                                         <SeedCode code={round.code} />
29                                         {' '}
30                                 </>
31                         : null}
32                         <SeedButton
33                                 round={round}
34                                 tournament={tournament}
35                         />
36                 </p>
37                 {!round.locked && isParticipant(user, tournament) ?
38                         <p className="report">
39                                 <ReportButton
40                                         participant={findParticipant(tournament, user)}
41                                         round={round}
42                                         tournament={tournament}
43                                 />
44                         </p>
45                 : null}
46         </div>
47         <List round={round} tournament={tournament} />
48 </li>;
49
50 Item.propTypes = {
51         round: PropTypes.shape({
52                 code: PropTypes.arrayOf(PropTypes.string),
53                 created_at: PropTypes.string,
54                 locked: PropTypes.bool,
55                 number: PropTypes.number,
56                 seed: PropTypes.string,
57         }),
58         tournament: PropTypes.shape({
59                 participants: PropTypes.arrayOf(PropTypes.shape({
60                 })),
61         }),
62         user: PropTypes.shape({
63         }),
64 };
65
66 export default withTranslation()(withUser(Item));