From: Daniel Karbach Date: Wed, 16 Mar 2022 15:18:19 +0000 (+0100) Subject: show ropunds in reverse order X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=a90987ef670ed4c4de7d4191821e6c863342577d;p=alttp.git show ropunds in reverse order --- diff --git a/app/Models/Tournament.php b/app/Models/Tournament.php index f8b4804..217622b 100644 --- a/app/Models/Tournament.php +++ b/app/Models/Tournament.php @@ -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'); } } diff --git a/resources/js/components/pages/Tournament.js b/resources/js/components/pages/Tournament.js index 90f7d03..a5c43ca 100644 --- a/resources/js/components/pages/Tournament.js +++ b/resources/js/components/pages/Tournament.js @@ -44,7 +44,7 @@ const Tournament = () => { if (e.round) { setTournament(tournament => ({ ...tournament, - rounds: [...tournament.rounds, e.round], + rounds: [e.round, ...tournament.rounds], })); } }) diff --git a/resources/js/components/rounds/Item.js b/resources/js/components/rounds/Item.js index c17a5aa..78e3d1f 100644 --- a/resources/js/components/rounds/Item.js +++ b/resources/js/components/rounds/Item.js @@ -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 = ({
  • - {`#${index + 1} `} + {round.number ? `#${round.number} ` : '#?'} {i18n.t('rounds.date', { date: new Date(round.created_at) })}

    @@ -46,10 +45,10 @@ const Item = ({

  • ; 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({ diff --git a/resources/js/components/rounds/List.js b/resources/js/components/rounds/List.js index 928f7b9..2ac8f17 100644 --- a/resources/js/components/rounds/List.js +++ b/resources/js/components/rounds/List.js @@ -11,9 +11,8 @@ const List = ({ tournament, }) => rounds && rounds.length ?
      - {rounds.map((round, index) => + {rounds.map(round =>