Inventory: fixes / layout (#11948)

Co-authored-by: Sabe Jones <sabrecat@gmail.com>
This commit is contained in:
negue
2020-10-19 23:54:51 +02:00
committed by GitHub
parent d62930b9da
commit bad3f82dfb
48 changed files with 1612 additions and 431 deletions

View File

@@ -1,6 +1,7 @@
import { authWithHeaders } from '../../middlewares/auth';
import * as userLib from '../../libs/user';
import { verifyDisplayName } from '../../libs/user/validation';
import common from '../../../common';
const api = {};
@@ -244,4 +245,38 @@ api.verifyDisplayName = {
},
};
/**
* @api {post} /api/v4/user/unequip/:type Unequip all items by type
* @apiName UserUnEquipByType
* @apiGroup User
*
* @apiParam (Path) {String="pet-mount-background","costume","equipped"} type The type of items
* to unequip.
*
* @apiParamExample {URL} Example-URL
* https://habitica.com/api/v4/user/unequip/equipped
*
* @apiSuccess {Object} data user.items
* @apiSuccess {String} message Optional success message for unequipping an items
*
* @apiSuccessExample {json} Example return:
* {
* "success": true,
* "data": {---DATA TRUNCATED---},
* "message": "Battle Gear unequipped.
* }
*
*/
api.unequip = {
method: 'POST',
middlewares: [authWithHeaders()],
url: '/user/unequip/:type',
async handler (req, res) {
const { user } = res.locals;
const equipRes = common.ops.unEquipByType(user, req);
await user.save();
res.respond(200, ...equipRes);
},
};
export default api;