From 0dc408f014a535b6feb860b6d57173637d139414 Mon Sep 17 00:00:00 2001 From: MohammadHMazarei Date: Wed, 25 Dec 2024 19:44:58 +0330 Subject: [PATCH] FIX: getRole, updateRole, and deleteRole handler --- components/role/roleController.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/components/role/roleController.js b/components/role/roleController.js index 3aed3e7..42e165e 100644 --- a/components/role/roleController.js +++ b/components/role/roleController.js @@ -14,10 +14,7 @@ exports.getAllRoles = catchAsync(async (req, res, next) => { }) exports.createRole = catchAsync(async (req, res, next) => { - const role = await roleService.createRole( - req.body.englishName, - req.body.persianName - ) + const role = await roleService.createRole(req.body) res.status(201).json({ status: 'success', @@ -26,7 +23,7 @@ exports.createRole = catchAsync(async (req, res, next) => { }) exports.getRole = catchAsync(async (req, res, next) => { - const role = await roleService.getRole(req.body.id) + const role = await roleService.getRole(req.params.roleId) res.status(200).json({ status: 'success', @@ -35,15 +32,15 @@ exports.getRole = catchAsync(async (req, res, next) => { }) exports.updateRole = catchAsync(async (req, res, next) => { - const updateRole = await roleService.updateRole(data) + const updateRole = await roleService.updateRole(req.params.roleId, req.body) res.status(200).json({ status: 'success', - data: role, + data: updateRole, }) }) exports.deleteRole = catchAsync(async (req, res, next) => { - await roleService.deleteRole(req.body.id) + await roleService.deleteRole(req.params.roleId) res.status(204).json({ status: 'success',