]> git.localhorst.tv Git - alttp.git/commitdiff
show ropunds in reverse order
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 16 Mar 2022 15:18:19 +0000 (16:18 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 16 Mar 2022 15:18:19 +0000 (16:18 +0100)
app/Models/Tournament.php
resources/js/components/pages/Tournament.js
resources/js/components/rounds/Item.js
resources/js/components/rounds/List.js

index f8b4804859fd6b03447901574647cf91941ced9b..217622bb9681c950d6b4113b38464ef6bf4ed167 100644 (file)
@@ -18,7 +18,7 @@ class Tournament extends Model
        }
 
        public function rounds() {
-               return $this->hasMany(Round::class)->orderBy('created_at');
+               return $this->hasMany(Round::class)->orderBy('number', 'DESC');
        }
 
 }
index 90f7d038c3718612d5051dcf9453abbb79e14fe8..a5c43caf01f604055b1c077a08862fe7766f24b9 100644 (file)
@@ -44,7 +44,7 @@ const Tournament = () => {
                                if (e.round) {
                                        setTournament(tournament => ({
                                                ...tournament,
-                                               rounds: [...tournament.rounds, e.round],
+                                               rounds: [e.round, ...tournament.rounds],
                                        }));
                                }
                        })
index c17a5aa6f058cd438d657a79b3b0ac147e1f2725..78e3d1fd9b65d5e58300fc27da19729dc5ca8bf8 100644 (file)
@@ -12,7 +12,6 @@ import { withUser } from '../../helpers/UserContext';
 import i18n from '../../i18n';
 
 const Item = ({
-       index,
        round,
        tournament,
        user,
@@ -20,7 +19,7 @@ const Item = ({
 <li className="round d-flex">
        <div className="info">
                <p className="date">
-                       {`#${index + 1} `}
+                       {round.number ? `#${round.number} ` : '#?'}
                        {i18n.t('rounds.date', { date: new Date(round.created_at) })}
                </p>
                <p className="seed">
@@ -46,10 +45,10 @@ const Item = ({
 </li>;
 
 Item.propTypes = {
-       index: PropTypes.number,
        round: PropTypes.shape({
                code: PropTypes.arrayOf(PropTypes.string),
                created_at: PropTypes.string,
+               number: PropTypes.number,
                seed: PropTypes.string,
        }),
        tournament: PropTypes.shape({
index 928f7b97eac3bb4f5882ae0b35780f942abe1ba7..2ac8f1701d9074094e705035c928f326dd5522f4 100644 (file)
@@ -11,9 +11,8 @@ const List = ({
        tournament,
 }) => rounds && rounds.length ?
        <ol className="rounds">
-               {rounds.map((round, index) =>
+               {rounds.map(round =>
                        <Item
-                               index={index}
                                key={round.id}
                                round={round}
                                tournament={tournament}