Skip to content

Commit

Permalink
fix various bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
learntheropes committed Sep 24, 2022
1 parent 3a4a9ed commit a3f4b26
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 32 deletions.
12 changes: 7 additions & 5 deletions api/routes/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
})

Expand Down
30 changes: 15 additions & 15 deletions api/routes/grab-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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) => {
Expand All @@ -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(
Expand All @@ -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) => {
Expand Down Expand Up @@ -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) => {
Expand All @@ -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 = {
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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) => {
Expand All @@ -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
}

Expand Down Expand Up @@ -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) => {
Expand All @@ -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
}

Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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
12 changes: 0 additions & 12 deletions assets/js/allCities.js
Original file line number Diff line number Diff line change
Expand Up @@ -652,10 +652,6 @@ export const allCities = [
"country": "Argentina"
},
{
"name": "Mercedes",
"country": "Argentina"
},
{
"name": "Mar del Plata",
"country": "Argentina"
},
Expand Down Expand Up @@ -872,10 +868,6 @@ export const allCities = [
"country": "Argentina"
},
{
"name": "Santo Tomé",
"country": "Argentina"
},
{
"name": "Santiago del Estero",
"country": "Argentina"
},
Expand Down Expand Up @@ -904,10 +896,6 @@ export const allCities = [
"country": "Argentina"
},
{
"name": "San Pedro",
"country": "Argentina"
},
{
"name": "San Nicolás de los Arroyos",
"country": "Argentina"
},
Expand Down

0 comments on commit a3f4b26

Please sign in to comment.