]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/components/pages/Tournament.js
allow setting seeds
[alttp.git] / resources / js / components / pages / Tournament.js
index 64c890609333608f1701941676849ec8308d28f7..5a9c8b05c207ce74db4c159559bdef5b5511b106 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, patchRound, 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);
@@ -48,6 +48,11 @@ const Tournament = () => {
                                                rounds: [...tournament.rounds, e.round],
                                        }));
                                }
+                       })
+                       .listen('RoundChanged', e => {
+                               if (e.round) {
+                                       setTournament(tournament => patchRound(tournament, e.round));
+                               }
                        });
                return () => {
                        window.Echo.leave(`Tournament.${id}`);