]> git.localhorst.tv Git - alttp.git/commitdiff
add seed display
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Sat, 12 Mar 2022 12:36:31 +0000 (13:36 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Sat, 12 Mar 2022 12:36:31 +0000 (13:36 +0100)
resources/js/components/pages/Tournament.js
resources/js/components/rounds/Item.js
resources/js/helpers/Participant.js
resources/js/helpers/Tournament.js
resources/js/i18n/de.js

index 64c890609333608f1701941676849ec8308d28f7..aab442346149865aa01f5bc47185a56f6200eede 100644 (file)
@@ -7,7 +7,7 @@ import ErrorMessage from '../common/ErrorMessage';
 import Loading from '../common/Loading';
 import NotFound from '../pages/NotFound';
 import Detail from '../tournament/Detail';
-import { patchResult } from '../../helpers/Tournament';
+import { patchResult, sortParticipants } from '../../helpers/Tournament';
 
 const Tournament = () => {
        const params = useParams();
@@ -24,7 +24,7 @@ const Tournament = () => {
                        .then(response => {
                                setError(null);
                                setLoading(false);
-                               setTournament(response.data);
+                               setTournament(sortParticipants(response.data));
                        })
                        .catch(error => {
                                setError(error);
index c4e337419df5b12e469b989b2b51ba750312fe86..b227e9334798ffe89dae08775a3098458b47a8b1 100644 (file)
@@ -1,5 +1,6 @@
 import PropTypes from 'prop-types';
 import React from 'react';
+import { Button } from 'react-bootstrap';
 import { withTranslation } from 'react-i18next';
 
 import List from '../results/List';
@@ -17,12 +18,21 @@ const Item = ({
 <li className="round d-flex">
        <div className="info">
                <p className="date">{i18n.t('rounds.date', { date: new Date(round.created_at) })}</p>
+               {round.seed ?
+                       <p className="seed">
+                               <Button href={round.seed} target="_blank" variant="primary">
+                                       {i18n.t('rounds.seed')}
+                               </Button>
+                       </p>
+               : null}
                {isParticipant(user, tournament) ?
-                       <ReportButton
-                               participant={findParticipant(tournament, user)}
-                               round={round}
-                               tournament={tournament}
-                       />
+                       <p className="report">
+                               <ReportButton
+                                       participant={findParticipant(tournament, user)}
+                                       round={round}
+                                       tournament={tournament}
+                               />
+                       </p>
                : null}
        </div>
        <List round={round} tournament={tournament} />
@@ -31,6 +41,7 @@ const Item = ({
 Item.propTypes = {
        round: PropTypes.shape({
                created_at: PropTypes.string,
+               seed: PropTypes.string,
        }),
        tournament: PropTypes.shape({
                participants: PropTypes.arrayOf(PropTypes.shape({
index af6eecc4d13aedf4f7aba5765a7218a9ee408410..8ae225c8570e59845c55891a90ecd2033e4e85b3 100644 (file)
@@ -1,3 +1,9 @@
+export const compareUsername = (a, b) => {
+       const a_name = a && a.user && a.user.username ? a.user.username : '';
+       const b_name = b && b.user && b.user.username ? b.user.username : '';
+       return a_name.localeCompare(b_name);
+};
+
 export const findResult = (participant, round) => {
        if (!participant || !participant.user_id) return null;
        if (!round || !round.results || !round.results.length) return null;
@@ -5,5 +11,6 @@ export const findResult = (participant, round) => {
 };
 
 export default {
+       compareUsername,
        findResult,
 };
index 1b808fdf3211f8eede21ee009defb1043db3d4d6..5716e684948b53c84e54262f00d99b553943d755 100644 (file)
@@ -1,3 +1,4 @@
+import Participant from './Participant';
 import Round from './Round';
 
 export const findParticipant = (tournament, user) => {
@@ -18,7 +19,18 @@ export const patchResult = (tournament, result) => {
        };
 };
 
+export const sortParticipants = tournament => {
+       if (!tournament || !tournament.participants || !tournament.participants.length) {
+               return tournament;
+       }
+       return {
+               ...tournament,
+               participants: tournament.participants.sort(Participant.compareUsername),
+       };
+};
+
 export default {
        findParticipant,
        patchResult,
+       sortParticipants,
 };
index 3a2804c0a80359f6a31a11953b608b98f6e5414b..c978ca4fb8b0c4c4317c55381c7cec927acc6af9 100644 (file)
@@ -20,7 +20,10 @@ export default {
                },
                icon: {
                        DiscordIcon: 'Discord',
+                       EditIcon: 'Bearbeiten',
+                       FinishedIcon: 'Abgeschlossen',
                        LogoutIcon: 'Logout',
+                       PendingIcon: 'Ausstehend',
                },
                participants: {
                        empty: 'Noch keine Teilnehmer eingetragen',
@@ -48,6 +51,7 @@ export default {
                        empty: 'Noch keine Runde gestartet',
                        heading: 'Runden',
                        new: 'Neue Runde',
+                       seed: 'Seed',
                },
                validation: {
                        error: {