fix(InviteUsers): fix invite users bugs.

This commit is contained in:
a.bouhuolia
2021-03-23 18:57:04 +02:00
parent ff559180fd
commit 5855d3f368
22 changed files with 543 additions and 404 deletions

View File

@@ -30,12 +30,6 @@ export default class ExpensesController extends BaseController {
asyncMiddleware(this.newExpense.bind(this)),
this.catchServiceErrors
);
router.post(
'/publish',
[...this.bulkSelectSchema],
this.bulkPublishExpenses.bind(this),
this.catchServiceErrors
);
router.post(
'/:id/publish',
[...this.expenseParamSchema],
@@ -57,13 +51,6 @@ export default class ExpensesController extends BaseController {
asyncMiddleware(this.deleteExpense.bind(this)),
this.catchServiceErrors
);
router.delete(
'/',
[...this.bulkSelectSchema],
this.validationResult,
asyncMiddleware(this.bulkDeleteExpenses.bind(this)),
this.catchServiceErrors
);
router.get(
'/',
[...this.expensesListSchema],
@@ -250,63 +237,6 @@ export default class ExpensesController extends BaseController {
}
}
/**
* Deletes the expenses in bulk.
* @param {Request} req
* @param {Response} res
* @param {NextFunction} next
*/
async bulkDeleteExpenses(req: Request, res: Response, next: NextFunction) {
const { tenantId, user } = req;
const { ids: expensesIds } = req.query;
try {
await this.expensesService.deleteBulkExpenses(
tenantId,
expensesIds,
user
);
return res.status(200).send({
ids: expensesIds,
message: 'The expenses have been deleted successfully.',
});
} catch (error) {
next(error);
}
}
/**
* Publishes the given expenses in bulk.
* @param {Request} req
* @param {Response} res
* @param {NextFunction} next
*/
async bulkPublishExpenses(req: Request, res: Response, next: NextFunction) {
const { tenantId, user } = req;
const { ids: expensesIds } = req.query;
try {
const {
meta: { alreadyPublished, published, total },
} = await this.expensesService.publishBulkExpenses(
tenantId,
expensesIds,
user
);
return res.status(200).send({
ids: expensesIds,
message: 'The expenses have been published successfully.',
meta: {
alreadyPublished,
published,
total,
},
});
} catch (error) {
next(error);
}
}
/**
* Retrieve expneses list.
* @param {Request} req