X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fhelpers%2FRound.js;fp=resources%2Fjs%2Fhelpers%2FRound.js;h=086517e2f897ec1a79bc709800a0c4b08114b5ad;hb=c59d0714d62f9028135cc9cff829d16b91e5fb4f;hp=8a8b6ade939cc16e16347ab580ecbeec685f6bf0;hpb=d748feb96453d74aeffec648d6f5f68d9ef3b520;p=alttp.git diff --git a/resources/js/helpers/Round.js b/resources/js/helpers/Round.js index 8a8b6ad..086517e 100644 --- a/resources/js/helpers/Round.js +++ b/resources/js/helpers/Round.js @@ -1,3 +1,10 @@ +export const isComplete = (tournament, round) => { + if (!tournament || !tournament.participants) return false; + if (!round || !round.results) return false; + return tournament.participants.length === round.results.length && + round.results.filter(r => !r.has_finished).length === 0; +}; + export const patchResult = (round, result) => { if (!round) return round; if (!round.results || !round.results.length) { @@ -13,5 +20,6 @@ export const patchResult = (round, result) => { }; export default { + isComplete, patchResult, };