1 import axios from 'axios';
2 import PropTypes from 'prop-types';
3 import React from 'react';
4 import { Button, ListGroup } from 'react-bootstrap';
5 import { withTranslation } from 'react-i18next';
6 import toastr from 'toastr';
8 import Icon from '../common/Icon';
9 import Box from '../users/Box';
10 import i18n from '../../i18n';
12 const accept = async (tournament, application) => {
14 await axios.post(`/api/application/${application.id}/accept`);
15 toastr.success(i18n.t('applications.acceptSuccess'));
17 toastr.error(i18n.t('applications.acceptError'));
21 const reject = async (tournament, application) => {
23 await axios.post(`/api/application/${application.id}/reject`);
24 toastr.success(i18n.t('applications.rejectSuccess'));
26 toastr.error(i18n.t('applications.rejectError'));
30 const Item = ({ application, tournament }) =>
31 <ListGroup.Item className="d-flex justify-content-between align-items-center">
32 <Box discriminator user={application.user} />
33 <div className="button-bar">
35 onClick={() => accept(tournament, application)}
36 title={i18n.t('applications.accept')}
39 <Icon.ACCEPT title="" />
42 onClick={() => reject(tournament, application)}
43 title={i18n.t('applications.reject')}
46 <Icon.REJECT title="" />
52 application: PropTypes.shape({
53 user: PropTypes.shape({
56 tournament: PropTypes.shape({
60 export default withTranslation()(Item);