FIX: getRole, updateRole, and deleteRole handler
This commit is contained in:
@@ -14,10 +14,7 @@ exports.getAllRoles = catchAsync(async (req, res, next) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
exports.createRole = catchAsync(async (req, res, next) => {
|
exports.createRole = catchAsync(async (req, res, next) => {
|
||||||
const role = await roleService.createRole(
|
const role = await roleService.createRole(req.body)
|
||||||
req.body.englishName,
|
|
||||||
req.body.persianName
|
|
||||||
)
|
|
||||||
|
|
||||||
res.status(201).json({
|
res.status(201).json({
|
||||||
status: 'success',
|
status: 'success',
|
||||||
@@ -26,7 +23,7 @@ exports.createRole = catchAsync(async (req, res, next) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
exports.getRole = 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({
|
res.status(200).json({
|
||||||
status: 'success',
|
status: 'success',
|
||||||
@@ -35,15 +32,15 @@ exports.getRole = catchAsync(async (req, res, next) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
exports.updateRole = 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({
|
res.status(200).json({
|
||||||
status: 'success',
|
status: 'success',
|
||||||
data: role,
|
data: updateRole,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
exports.deleteRole = catchAsync(async (req, res, next) => {
|
exports.deleteRole = catchAsync(async (req, res, next) => {
|
||||||
await roleService.deleteRole(req.body.id)
|
await roleService.deleteRole(req.params.roleId)
|
||||||
|
|
||||||
res.status(204).json({
|
res.status(204).json({
|
||||||
status: 'success',
|
status: 'success',
|
||||||
|
|||||||
Reference in New Issue
Block a user