fix: make packages/medusa/src/api/routes/store/shipping-options pass linting (#648)
This commit is contained in:
@@ -54,7 +54,7 @@
|
||||
/packages/medusa/src/api/routes/store/regions
|
||||
/packages/medusa/src/api/routes/store/return-reasons
|
||||
/packages/medusa/src/api/routes/store/returns
|
||||
/packages/medusa/src/api/routes/store/shipping-options
|
||||
|
||||
/packages/medusa/src/api/routes/store/swaps
|
||||
|
||||
# END OF FILES TODO
|
||||
|
||||
@@ -25,34 +25,29 @@ export default async (req, res) => {
|
||||
const productIds =
|
||||
(req.query.product_ids && req.query.product_ids.split(",")) || []
|
||||
const regionId = req.query.region_id
|
||||
const productService = req.scope.resolve("productService")
|
||||
const shippingOptionService = req.scope.resolve("shippingOptionService")
|
||||
|
||||
try {
|
||||
const productService = req.scope.resolve("productService")
|
||||
const shippingOptionService = req.scope.resolve("shippingOptionService")
|
||||
const query = {}
|
||||
|
||||
const query = {}
|
||||
|
||||
if ("is_return" in req.query) {
|
||||
query.is_return = req.query.is_return === "true"
|
||||
}
|
||||
|
||||
if (regionId) {
|
||||
query.region_id = regionId
|
||||
}
|
||||
|
||||
query.admin_only = false
|
||||
|
||||
if (productIds.length) {
|
||||
const prods = await productService.list({ id: productIds })
|
||||
query.profile_id = prods.map((p) => p.profile_id)
|
||||
}
|
||||
|
||||
const options = await shippingOptionService.list(query, {
|
||||
relations: ["requirements"],
|
||||
})
|
||||
|
||||
res.status(200).json({ shipping_options: options })
|
||||
} catch (err) {
|
||||
throw err
|
||||
if ("is_return" in req.query) {
|
||||
query.is_return = req.query.is_return === "true"
|
||||
}
|
||||
|
||||
if (regionId) {
|
||||
query.region_id = regionId
|
||||
}
|
||||
|
||||
query.admin_only = false
|
||||
|
||||
if (productIds.length) {
|
||||
const prods = await productService.list({ id: productIds })
|
||||
query.profile_id = prods.map((p) => p.profile_id)
|
||||
}
|
||||
|
||||
const options = await shippingOptionService.list(query, {
|
||||
relations: ["requirements"],
|
||||
})
|
||||
|
||||
res.status(200).json({ shipping_options: options })
|
||||
}
|
||||
|
||||
@@ -31,19 +31,15 @@ export default async (req, res) => {
|
||||
throw new MedusaError(MedusaError.Types.INVALID_DATA, error.details)
|
||||
}
|
||||
|
||||
try {
|
||||
const cartService = req.scope.resolve("cartService")
|
||||
const shippingProfileService = req.scope.resolve("shippingProfileService")
|
||||
const cartService = req.scope.resolve("cartService")
|
||||
const shippingProfileService = req.scope.resolve("shippingProfileService")
|
||||
|
||||
const cart = await cartService.retrieve(value.cart_id, {
|
||||
select: ["subtotal"],
|
||||
relations: ["region", "items", "items.variant", "items.variant.product"],
|
||||
})
|
||||
const cart = await cartService.retrieve(value.cart_id, {
|
||||
select: ["subtotal"],
|
||||
relations: ["region", "items", "items.variant", "items.variant.product"],
|
||||
})
|
||||
|
||||
const options = await shippingProfileService.fetchCartOptions(cart)
|
||||
const options = await shippingProfileService.fetchCartOptions(cart)
|
||||
|
||||
res.status(200).json({ shipping_options: options })
|
||||
} catch (err) {
|
||||
throw err
|
||||
}
|
||||
res.status(200).json({ shipping_options: options })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user