From a3f4b26ac07e5834757303ad69478b476b7a1bee Mon Sep 17 00:00:00 2001 From: giovannilaperna Date: Sat, 24 Sep 2022 16:11:15 +0200 Subject: [PATCH] fix various bugs --- api/routes/db.js | 12 +++++++----- api/routes/grab-actions.js | 30 +++++++++++++++--------------- assets/js/allCities.js | 12 ------------ 3 files changed, 22 insertions(+), 32 deletions(-) diff --git a/api/routes/db.js b/api/routes/db.js index 5260913..42feaf5 100644 --- a/api/routes/db.js +++ b/api/routes/db.js @@ -174,11 +174,13 @@ router.get('/db/messages/filter/grab/:ref/:width', allowOrigin, authorizeUser, a const messages = data.map(({ data, ref: { value: { id }}}) => { data.ref = id - data.attachments.map(attachment => { - attachment.preview = getImageKitPreview(attachment.path) - attachment.modal = getImageKitModal(attachment.path, width) - return attachment - }) + if (data.attachments && data.attachments.length) { + data.attachments.map(attachment => { + attachment.preview = getImageKitPreview(attachment.path) + attachment.modal = getImageKitModal(attachment.path, width) + return attachment + }) + } return data }) diff --git a/api/routes/grab-actions.js b/api/routes/grab-actions.js index ddc0de0..039945c 100644 --- a/api/routes/grab-actions.js +++ b/api/routes/grab-actions.js @@ -58,7 +58,7 @@ router.post('/grab/actions/publish', allowOrigin, authorizeUser, asyncHandler(as ) ) - return res.status(201).json({}) + return res.status(201).json({}).end() })) router.post('/grab/actions/order/:ref', allowOrigin, authorizeUser, asyncHandler(async (req, res) => { @@ -100,7 +100,7 @@ router.post('/grab/actions/order/:ref', allowOrigin, authorizeUser, asyncHandler const availableBudget = travel.budget - (shop.price.product+shop.price.shipping+shop.price.taxes) if (availableBudget < 0) { - return res.status(401).send('unauthorized') + return res.status(401).send('unauthorized').end() } await client.query( @@ -152,7 +152,7 @@ router.post('/grab/actions/order/:ref', allowOrigin, authorizeUser, asyncHandler text: emailContent.content, }) - return res.status(201) + return res.status(201).end() })) router.post('/grab/actions/remove/:ref', allowOrigin, authorizeUser, asyncHandler(async (req, res) => { @@ -164,7 +164,7 @@ router.post('/grab/actions/remove/:ref', allowOrigin, authorizeUser, asyncHandle ) if (grab.buyer.sub !== jwt.sub) { - return res.status(401).send('unauthorized') + return res.status(401).send('unauthorized').end() } await client.query( @@ -183,7 +183,7 @@ router.post('/grab/actions/remove/:ref', allowOrigin, authorizeUser, asyncHandle q.Delete(q.Ref(q.Collection('grabs'), ref)) ) - return res.status(204) + return res.status(204).end() })) router.post('/grab/actions/book/:ref', allowOrigin, authorizeUser, asyncHandler(async (req, res) => { @@ -262,7 +262,7 @@ router.post('/grab/actions/book/:ref', allowOrigin, authorizeUser, asyncHandler( text: emailContent.content, }) - return res.status(201) + return res.status(201).end() })) router.post('/grab/actions/dispute/:ref', allowOrigin, authorizeUser, asyncHandler(async (req, res) => { @@ -275,7 +275,7 @@ router.post('/grab/actions/dispute/:ref', allowOrigin, authorizeUser, asyncHandl if ((grab.buyer.sub !== jwt.sub && grab.traveler.sub !== jwt.sub) || (grab.status === 'published' || grab.status === 'released' || grab.status === 'withdrawn')) { - return res.status(401).send('unauthorized') + return res.status(401).send('unauthorized').end() } const props = { @@ -346,7 +346,7 @@ router.post('/grab/actions/dispute/:ref', allowOrigin, authorizeUser, asyncHandl - return res.status(201) + return res.status(201).end() })) router.post('/grab/actions/bought/:ref', allowOrigin, authorizeUser, asyncHandler(async (req, res) => { @@ -413,7 +413,7 @@ router.post('/grab/actions/bought/:ref', allowOrigin, authorizeUser, asyncHandle text: emailContent.content, }) - return res.status(201) + return res.status(201).end() })) router.post('/grab/actions/delivered/:ref', allowOrigin, authorizeUser, asyncHandler(async (req, res) => { @@ -425,7 +425,7 @@ router.post('/grab/actions/delivered/:ref', allowOrigin, authorizeUser, asyncHan ) if (grab.traveler.sub !== jwt.sub || grab.status !== 'bought') { - res.status(401).send('unauthorized') + res.status(401).send('unauthorized').end() return } @@ -480,7 +480,7 @@ router.post('/grab/actions/delivered/:ref', allowOrigin, authorizeUser, asyncHan text: emailContent.content, }) - return res.status(201) + return res.status(201).end() })) router.post('/grab/actions/release/:ref', allowOrigin, authorizeUser, asyncHandler(async (req, res) => { @@ -492,7 +492,7 @@ router.post('/grab/actions/release/:ref', allowOrigin, authorizeUser, asyncHandl ) if (grab.buyer.sub !== jwt.sub || grab.status !== 'delivered') { - res.status(401).send('unauthorized') + res.status(401).send('unauthorized').end() return } @@ -548,7 +548,7 @@ router.post('/grab/actions/release/:ref', allowOrigin, authorizeUser, asyncHandl text: emailContent.content, }) - return res.status(201) + return res.status(201).end() })) router.post('/grab/actions/withdraw/:ref', allowOrigin, authorizeUser, asyncHandler(async (req, res) => { @@ -598,9 +598,9 @@ router.post('/grab/actions/withdraw/:ref', allowOrigin, authorizeUser, asyncHand ) ) - return res.status(200) + return res.status(200).end() } - return res.status(401).send('unauthorized') + return res.status(401).send('unauthorized').end() })) export default router \ No newline at end of file diff --git a/assets/js/allCities.js b/assets/js/allCities.js index 65765c9..a8ef05f 100644 --- a/assets/js/allCities.js +++ b/assets/js/allCities.js @@ -652,10 +652,6 @@ export const allCities = [ "country": "Argentina" }, { - "name": "Mercedes", - "country": "Argentina" - }, - { "name": "Mar del Plata", "country": "Argentina" }, @@ -872,10 +868,6 @@ export const allCities = [ "country": "Argentina" }, { - "name": "Santo Tomé", - "country": "Argentina" - }, - { "name": "Santiago del Estero", "country": "Argentina" }, @@ -904,10 +896,6 @@ export const allCities = [ "country": "Argentina" }, { - "name": "San Pedro", - "country": "Argentina" - }, - { "name": "San Nicolás de los Arroyos", "country": "Argentina" },