mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-10 15:17:41 +00:00
add company name to invite user entity
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
import { RoleType } from '@app/common/constants/role.type.enum';
|
||||
import { UserStatusEnum } from '@app/common/constants/user-status.enum';
|
||||
import { IsEnum, IsNotEmpty, IsString } from 'class-validator';
|
||||
import { IsEnum, IsNotEmpty, IsOptional, IsString } from 'class-validator';
|
||||
|
||||
export class InviteUserDto {
|
||||
@IsString()
|
||||
@ -12,8 +12,12 @@ export class InviteUserDto {
|
||||
public email: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public jobTitle: string;
|
||||
@IsOptional()
|
||||
public jobTitle?: string;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
public companyName?: string;
|
||||
|
||||
@IsEnum(UserStatusEnum)
|
||||
@IsNotEmpty()
|
||||
|
@ -37,6 +37,11 @@ export class InviteUserEntity extends AbstractEntity<InviteUserDto> {
|
||||
})
|
||||
jobTitle: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
})
|
||||
companyName: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
enum: Object.values(UserStatusEnum),
|
||||
|
@ -44,6 +44,15 @@ export class AddUserInvitationDto {
|
||||
@IsOptional()
|
||||
public jobTitle?: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'The company name of the user',
|
||||
example: 'Tech Corp',
|
||||
required: false,
|
||||
})
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
public companyName?: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'The phone number of the user',
|
||||
example: '+1234567890',
|
||||
|
@ -1,78 +1,10 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import {
|
||||
ArrayMinSize,
|
||||
IsArray,
|
||||
IsBoolean,
|
||||
IsNotEmpty,
|
||||
IsOptional,
|
||||
IsString,
|
||||
} from 'class-validator';
|
||||
import { ApiProperty, OmitType } from '@nestjs/swagger';
|
||||
import { IsBoolean, IsNotEmpty, IsString } from 'class-validator';
|
||||
import { AddUserInvitationDto } from './add.invite-user.dto';
|
||||
|
||||
export class UpdateUserInvitationDto {
|
||||
@ApiProperty({
|
||||
description: 'The first name of the user',
|
||||
example: 'John',
|
||||
required: true,
|
||||
})
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public firstName: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'The last name of the user',
|
||||
example: 'Doe',
|
||||
required: true,
|
||||
})
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public lastName: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'The job title of the user',
|
||||
example: 'Software Engineer',
|
||||
required: false,
|
||||
})
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
public jobTitle?: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'The phone number of the user',
|
||||
example: '+1234567890',
|
||||
required: false,
|
||||
})
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
public phoneNumber?: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'The role uuid of the user',
|
||||
example: 'd290f1ee-6c54-4b01-90e6-d701748f0851',
|
||||
required: true,
|
||||
})
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public roleUuid: string;
|
||||
@ApiProperty({
|
||||
description: 'The project uuid of the user',
|
||||
example: 'd290f1ee-6c54-4b01-90e6-d701748f0851',
|
||||
required: true,
|
||||
})
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public projectUuid: string;
|
||||
@ApiProperty({
|
||||
description: 'The array of space UUIDs (at least one required)',
|
||||
example: ['b5f3c9d2-58b7-4377-b3f7-60acb711d5d9'],
|
||||
required: true,
|
||||
})
|
||||
@IsArray()
|
||||
@ArrayMinSize(1)
|
||||
public spaceUuids: string[];
|
||||
constructor(dto: Partial<UpdateUserInvitationDto>) {
|
||||
Object.assign(this, dto);
|
||||
}
|
||||
}
|
||||
export class UpdateUserInvitationDto extends OmitType(AddUserInvitationDto, [
|
||||
'email',
|
||||
]) {}
|
||||
export class DisableUserInvitationDto {
|
||||
@ApiProperty({
|
||||
description: 'The disable status of the user',
|
||||
|
@ -61,6 +61,7 @@ export class InviteUserService {
|
||||
lastName,
|
||||
email,
|
||||
jobTitle,
|
||||
companyName,
|
||||
phoneNumber,
|
||||
roleUuid,
|
||||
spaceUuids,
|
||||
@ -102,6 +103,7 @@ export class InviteUserService {
|
||||
lastName,
|
||||
email,
|
||||
jobTitle,
|
||||
companyName,
|
||||
phoneNumber,
|
||||
roleType: { uuid: roleUuid },
|
||||
status: UserStatusEnum.INVITED,
|
||||
@ -452,8 +454,15 @@ export class InviteUserService {
|
||||
dto: UpdateUserInvitationDto,
|
||||
invitedUserUuid: string,
|
||||
): Promise<void> {
|
||||
const { firstName, lastName, jobTitle, phoneNumber, roleUuid, spaceUuids } =
|
||||
dto;
|
||||
const {
|
||||
firstName,
|
||||
lastName,
|
||||
jobTitle,
|
||||
companyName,
|
||||
phoneNumber,
|
||||
roleUuid,
|
||||
spaceUuids,
|
||||
} = dto;
|
||||
|
||||
// Update user invitation details
|
||||
await queryRunner.manager.update(
|
||||
@ -463,6 +472,7 @@ export class InviteUserService {
|
||||
firstName,
|
||||
lastName,
|
||||
jobTitle,
|
||||
companyName,
|
||||
phoneNumber,
|
||||
roleType: { uuid: roleUuid },
|
||||
},
|
||||
@ -492,6 +502,7 @@ export class InviteUserService {
|
||||
firstName,
|
||||
lastName,
|
||||
jobTitle,
|
||||
companyName,
|
||||
phoneNumber,
|
||||
roleUuid,
|
||||
spaceUuids,
|
||||
@ -518,6 +529,7 @@ export class InviteUserService {
|
||||
firstName,
|
||||
lastName,
|
||||
jobTitle,
|
||||
companyName,
|
||||
phoneNumber,
|
||||
roleType: { uuid: roleUuid },
|
||||
},
|
||||
|
@ -33,6 +33,7 @@ export class ProjectUserService {
|
||||
'status',
|
||||
'phoneNumber',
|
||||
'jobTitle',
|
||||
'companyName',
|
||||
'invitedBy',
|
||||
'isEnabled',
|
||||
],
|
||||
@ -91,6 +92,7 @@ export class ProjectUserService {
|
||||
'status',
|
||||
'phoneNumber',
|
||||
'jobTitle',
|
||||
'companyName',
|
||||
'invitedBy',
|
||||
'isEnabled',
|
||||
],
|
||||
|
@ -1,28 +1,28 @@
|
||||
import { CommonErrorCodes } from '@app/common/constants/error-codes.enum';
|
||||
import { PermissionType } from '@app/common/constants/permission-type.enum';
|
||||
import { RoleType } from '@app/common/constants/role.type.enum';
|
||||
import { UserStatusEnum } from '@app/common/constants/user-status.enum';
|
||||
import { BaseResponseDto } from '@app/common/dto/base.response.dto';
|
||||
import { SuccessResponseDto } from '@app/common/dto/success.response.dto';
|
||||
import {
|
||||
InviteUserRepository,
|
||||
InviteUserSpaceRepository,
|
||||
} from '@app/common/modules/Invite-user/repositiories';
|
||||
import { InviteSpaceEntity } from '@app/common/modules/space/entities/invite-space.entity';
|
||||
import {
|
||||
InviteSpaceRepository,
|
||||
SpaceRepository,
|
||||
} from '@app/common/modules/space/repositories';
|
||||
import { UserSpaceRepository } from '@app/common/modules/user/repositories';
|
||||
import {
|
||||
BadRequestException,
|
||||
HttpException,
|
||||
HttpStatus,
|
||||
Injectable,
|
||||
} from '@nestjs/common';
|
||||
import { UserSpaceRepository } from '@app/common/modules/user/repositories';
|
||||
import { SuccessResponseDto } from '@app/common/dto/success.response.dto';
|
||||
import { BaseResponseDto } from '@app/common/dto/base.response.dto';
|
||||
import { AddUserSpaceDto, AddUserSpaceUsingCodeDto } from '../dtos';
|
||||
import {
|
||||
InviteSpaceRepository,
|
||||
SpaceRepository,
|
||||
} from '@app/common/modules/space/repositories';
|
||||
import { CommonErrorCodes } from '@app/common/constants/error-codes.enum';
|
||||
import { UserDevicePermissionService } from 'src/user-device-permission/services';
|
||||
import { PermissionType } from '@app/common/constants/permission-type.enum';
|
||||
import { InviteSpaceEntity } from '@app/common/modules/space/entities/invite-space.entity';
|
||||
import { AddUserSpaceDto, AddUserSpaceUsingCodeDto } from '../dtos';
|
||||
import { UserService } from './user.service';
|
||||
import { RoleType } from '@app/common/constants/role.type.enum';
|
||||
import {
|
||||
InviteUserRepository,
|
||||
InviteUserSpaceRepository,
|
||||
} from '@app/common/modules/Invite-user/repositiories';
|
||||
import { UserStatusEnum } from '@app/common/constants/user-status.enum';
|
||||
|
||||
@Injectable()
|
||||
export class UserSpaceService {
|
||||
@ -154,6 +154,7 @@ export class UserSpaceService {
|
||||
lastName: user.lastName,
|
||||
email: user.email,
|
||||
jobTitle: null,
|
||||
companyName: null,
|
||||
phoneNumber: null,
|
||||
roleType: { uuid: user.role.uuid },
|
||||
status: UserStatusEnum.ACTIVE,
|
||||
|
Reference in New Issue
Block a user