Closed dioveath closed 2 years ago
So, I found out that I was trying to update a match with one of the opponents BYE in it. Here is the change, I made just so anyone would find it helpful.
if(m.status === Status.Locked) {
console.log(m.status);
return;
}
let score1 = opponent1[index]?.current.value || 0;
let score2 = opponent2[index]?.current.value || 0;
await manager.update.match({
id: m.id,
opponent1: { id: m.opponent1.id, score: score1, result: score1 > score2 ? 'win' : 'loss' },
opponent2: { id: m?.opponent2?.id, score: score2, result: score2 > score1 ? 'win' : 'loss' }
})
const data = await manager.get.tournamentData(1234);
render();
The BYE could be in both opponent1 and opponent2 so I suggest you do the following change:
if(m.status === Status.Locked) {
console.log(m.status);
return;
}
let score1 = opponent1[index]?.current.value || 0;
let score2 = opponent2[index]?.current.value || 0;
await manager.update.match({
id: m.id,
- opponent1: { id: m.opponent1.id, score: score1, result: score1 > score2 ? 'win' : 'loss' },
+ opponent1: { id: m?.opponent1?.id, score: score1, result: score1 > score2 ? 'win' : 'loss' },
opponent2: { id: m?.opponent2?.id, score: score2, result: score2 > score1 ? 'win' : 'loss' }
})
const data = await manager.get.tournamentData(1234);
render();
Okay sure. Thanks for the update!
So, I want to update the scores as a manager/organizer. It says it's currently locked. or Where should I be handling the matches?