mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-25 17:19:48 +00:00
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
import { Body, Controller, Param, Patch, Post } from '@nestjs/common';
|
|
import { ApiOperation, ApiTags } from '@nestjs/swagger';
|
|
import { UsersApplication } from './Users.application';
|
|
import { SendInviteUserDto } from './dtos/InviteUser.dto';
|
|
|
|
@Controller('invite')
|
|
@ApiTags('Users')
|
|
export class UsersInviteController {
|
|
constructor(private readonly usersApplication: UsersApplication) {}
|
|
|
|
/**
|
|
* Send an invitation to a new user.
|
|
*/
|
|
@Patch()
|
|
@ApiOperation({ summary: 'Send an invitation to a new user.' })
|
|
async sendInvite(@Body() sendInviteDTO: SendInviteUserDto) {
|
|
const result = await this.usersApplication.sendInvite(sendInviteDTO);
|
|
|
|
return {
|
|
invitedUser: result.invitedUser,
|
|
message: 'The invitation has been sent successfully.',
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Resend an invitation to an existing user.
|
|
*/
|
|
@Post('users/:id/resend')
|
|
@ApiOperation({ summary: 'Resend an invitation to an existing user.' })
|
|
async resendInvite(@Param('id') userId: number) {
|
|
const result = await this.usersApplication.resendInvite(userId);
|
|
|
|
return {
|
|
user: result.user,
|
|
message: 'The invitation has been resent successfully.',
|
|
};
|
|
}
|
|
}
|