Merge branch 'development' of https://gitlab.com/empatnusabangsa/ppob/ppob-backend into development
This commit is contained in:
commit
7df999b455
|
@ -272,7 +272,11 @@ export class UsersController {
|
||||||
@Put('approve-user/:id')
|
@Put('approve-user/:id')
|
||||||
async approveUser(@Param('id', ParseUUIDPipe) id: string, @Request() req) {
|
async approveUser(@Param('id', ParseUUIDPipe) id: string, @Request() req) {
|
||||||
return {
|
return {
|
||||||
data: await this.usersService.confirmationUser(id, req.user, 'approved'),
|
data: await this.usersService.confirmationUser(
|
||||||
|
id,
|
||||||
|
req.user.userId,
|
||||||
|
'approved',
|
||||||
|
),
|
||||||
statusCode: HttpStatus.OK,
|
statusCode: HttpStatus.OK,
|
||||||
message: 'success',
|
message: 'success',
|
||||||
};
|
};
|
||||||
|
@ -281,7 +285,11 @@ export class UsersController {
|
||||||
@Put('reject-user/:id')
|
@Put('reject-user/:id')
|
||||||
async rejectUser(@Param('id', ParseUUIDPipe) id: string, @Request() req) {
|
async rejectUser(@Param('id', ParseUUIDPipe) id: string, @Request() req) {
|
||||||
return {
|
return {
|
||||||
data: await this.usersService.confirmationUser(id, req.user, 'rejected'),
|
data: await this.usersService.confirmationUser(
|
||||||
|
id,
|
||||||
|
req.user.userId,
|
||||||
|
'rejected',
|
||||||
|
),
|
||||||
statusCode: HttpStatus.OK,
|
statusCode: HttpStatus.OK,
|
||||||
message: 'success',
|
message: 'success',
|
||||||
};
|
};
|
||||||
|
|
|
@ -309,7 +309,7 @@ export class UsersService {
|
||||||
const baseQuery = this.usersRepository
|
const baseQuery = this.usersRepository
|
||||||
.createQueryBuilder('user')
|
.createQueryBuilder('user')
|
||||||
.where(
|
.where(
|
||||||
'user.id != :id and user.superior_id = :superior and status_approval = :status and is_rejected is false',
|
'user.id != :id and status_approval = :status and is_rejected is false',
|
||||||
{
|
{
|
||||||
id: superrior.userId,
|
id: superrior.userId,
|
||||||
status: superrior.userId,
|
status: superrior.userId,
|
||||||
|
@ -569,7 +569,7 @@ export class UsersService {
|
||||||
async confirmationUser(id: string, user: string, status: string) {
|
async confirmationUser(id: string, user: string, status: string) {
|
||||||
try {
|
try {
|
||||||
const dataUser = await this.usersRepository.findOneOrFail(id);
|
const dataUser = await this.usersRepository.findOneOrFail(id);
|
||||||
const supervisorUser = await this.usersRepository.findOneOrFail(id);
|
const supervisorUser = await this.findExist(user);
|
||||||
|
|
||||||
if (status == 'approved') {
|
if (status == 'approved') {
|
||||||
dataUser.status_approval = supervisorUser.superior.id;
|
dataUser.status_approval = supervisorUser.superior.id;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user