]> git.localhorst.tv Git - alttp.git/blob - resources/js/helpers/Round.js
8a8b6ade939cc16e16347ab580ecbeec685f6bf0
[alttp.git] / resources / js / helpers / Round.js
1 export const patchResult = (round, result) => {
2         if (!round) return round;
3         if (!round.results || !round.results.length) {
4                 return { ...round, results: [result] };
5         }
6         if (!round.results.find(r => r.id === result.id)) {
7                 return { ...round, results: [...round.results, result] };
8         }
9         return {
10                 ...round,
11                 results: round.results.map(r => r.id === result.id ? result : r),
12         };
13 };
14
15 export default {
16         patchResult,
17 };