]> git.localhorst.tv Git - alttp.git/blob - resources/js/components/rounds/Item.js
c4e337419df5b12e469b989b2b51ba750312fe86
[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 List from '../results/List';
6 import ReportButton from '../results/ReportButton';
7 import { isParticipant } from '../../helpers/permissions';
8 import { findParticipant } from '../../helpers/Tournament';
9 import { withUser } from '../../helpers/UserContext';
10 import i18n from '../../i18n';
11
12 const Item = ({
13         round,
14         tournament,
15         user,
16 }) =>
17 <li className="round d-flex">
18         <div className="info">
19                 <p className="date">{i18n.t('rounds.date', { date: new Date(round.created_at) })}</p>
20                 {isParticipant(user, tournament) ?
21                         <ReportButton
22                                 participant={findParticipant(tournament, user)}
23                                 round={round}
24                                 tournament={tournament}
25                         />
26                 : null}
27         </div>
28         <List round={round} tournament={tournament} />
29 </li>;
30
31 Item.propTypes = {
32         round: PropTypes.shape({
33                 created_at: PropTypes.string,
34         }),
35         tournament: PropTypes.shape({
36                 participants: PropTypes.arrayOf(PropTypes.shape({
37                 })),
38         }),
39         user: PropTypes.shape({
40         }),
41 };
42
43 export default withTranslation()(withUser(Item));