mirror of
https://github.com/pawelmalak/flame.git
synced 2024-12-27 04:21:37 +03:00
23 lines
542 B
JavaScript
23 lines
542 B
JavaScript
const asyncWrapper = require('../../middleware/asyncWrapper');
|
|
const Category = require('../../models/Category');
|
|
// @desc Reorder categories
|
|
// @route PUT /api/categories/0/reorder
|
|
// @access Public
|
|
const reorderCategories = asyncWrapper(async (req, res, next) => {
|
|
req.body.categories.forEach(async ({ id, orderId }) => {
|
|
await Category.update(
|
|
{ orderId },
|
|
{
|
|
where: { id },
|
|
}
|
|
);
|
|
});
|
|
|
|
res.status(200).json({
|
|
success: true,
|
|
data: {},
|
|
});
|
|
});
|
|
|
|
module.exports = reorderCategories;
|