Adding an error checker for edit prize and edit rule
This commit is contained in:
1 parent
2389aff531
commit
41ea70838f
2 files changed
+6
-2
No files matched your search
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user