Adding an error checker for edit prize and edit rule

This commit is contained in:
Nikola Bjelo committed 2018-10-28 13:13:24 +01:00
1 parent 2389aff531
commit 41ea70838f
2 files changed
+6 -2

No files matched your search

+3 -1
View File
@@ -31,7 +31,9 @@ const resolve = (parent, { eventDesignator, rank, amount }, context) => {
prizeIndex = index
}
})
if (!prizeIndex) {
reject(new DatabaseError('There is no prize for that index'))
}
event.prizes[prizeIndex].amount = amount || event.prizes[prizeIndex].amount
event.save((err) => {
if (err) reject(err)
+3 -1
View File
@@ -32,7 +32,9 @@ const resolve = (parent, { eventDesignator, title, newtitle, description }, cont
ruleIndex = index
}
})
if (!ruleIndex) {
reject(new DatabaseError('There is no rule with that title'))
}
event.rules[ruleIndex].description = description || event.rules[ruleIndex].description
if (event.rules.some(rule => rule.title === newtitle)) {
// need to add an error message here TODO