Save reminder count properly

Earlier, it wasn't being checked at all so everything was being
set to the default of 10.
This commit is contained in:
Hippo 2022-01-05 18:56:13 +05:30
parent 9530362baf
commit 3e0e775af9

View file

@ -144,6 +144,14 @@ router.post('/pledge', async (req, res) => {
} }
let phone = req.body.phone let phone = req.body.phone
let retryTimes
try {
retryTimes = req.body['reminder-count']
} catch (err) {
errors.push('Invalid retry count. Please choose a positive number!')
}
let newsletter = req.body.newsletter == 'yes' ? true : false let newsletter = req.body.newsletter == 'yes' ? true : false
let overseas = req.body.overseas == 'yes' ? true : false let overseas = req.body.overseas == 'yes' ? true : false
let messages = req.body.messages let messages = req.body.messages
@ -162,6 +170,7 @@ router.post('/pledge', async (req, res) => {
pledge.set('anonymous', anonymous) pledge.set('anonymous', anonymous)
pledge.set('email', email) pledge.set('email', email)
pledge.set('phone', phone) pledge.set('phone', phone)
pledge.set('retry_times', retryTimes)
pledge.set('get_newsletter', newsletter) pledge.set('get_newsletter', newsletter)
pledge.set('other_message', messages) pledge.set('other_message', messages)