Skip to content

Commit

Permalink
Merge pull request #234 from souravbhowmik1999/deleteUser
Browse files Browse the repository at this point in the history
Task PS-1226 Update user status with reason
  • Loading branch information
snehal0904 authored Jul 9, 2024
2 parents d9bee7a + 9556dab commit 3ac02b5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/user/dto/user-update.dto.ts
Original file line number Diff line number Diff line change
@@ -1,77 +1,99 @@
import { IsString, IsOptional, IsArray, ValidateNested, IsNotEmpty, IsEnum, ValidateIf } from 'class-validator';
import { Expose, Type } from 'class-transformer';
import { UserStatus } from '../entities/user-entity';
import { ApiProperty } from '@nestjs/swagger';

class UserDataDTO {

@ApiProperty({ type: () => String })
@IsString()
@IsOptional()
username: string;

@ApiProperty({ type: () => String })
@IsString()
@IsNotEmpty()
@IsOptional()
name: string;

@ApiProperty({ type: () => String })
@IsString()
@IsOptional()
role: string;

@ApiProperty({ type: () => String })
@IsOptional()
@IsString()
dob: string | null;

@ApiProperty({ type: () => String })
@IsOptional()
@IsString()
email: string | null;

@ApiProperty({ type: () => String })
@IsOptional()
@IsString()
district: string | null;

@ApiProperty({ type: () => String })
@IsOptional()
@IsString()
state: string | null;

@ApiProperty({ type: () => String })
@IsOptional()
@IsString()
address: string | null;

@ApiProperty({ type: () => String })
@IsOptional()
@IsString()
pincode: string | null;

@ApiProperty({ type: () => String })
@IsString()
@IsOptional()
createdAt: string;

@ApiProperty({ type: () => String })
@IsString()
@IsOptional()
updatedAt: string;

@ApiProperty({ type: () => String })
@IsString()
@IsOptional()
createdBy: string;

@ApiProperty({ type: () => String })
@IsString()
@IsOptional()
updatedBy: string;

@ApiProperty({ type: () => String })
@IsString()
@IsOptional()
tenantId: string;

@ApiProperty({ type: () => String })
@IsString()
@IsOptional()
@IsEnum(UserStatus)
status: UserStatus;

@ApiProperty({ type: () => String })
@IsString()
@IsOptional()
reason: string;
}
class CustomFieldDTO {

@ApiProperty({ type: () => String })
@IsString()
@Expose()
@IsNotEmpty()
fieldId: string;

@ApiProperty({ type: () => String })
@ValidateIf(o => o.value !== '')
@IsNotEmpty()
@Expose()
Expand All @@ -82,12 +104,14 @@ export class UserUpdateDTO {

userId: string;

@ApiProperty({ type: () => [UserDataDTO] })
@Expose()
@ValidateNested()
@IsNotEmpty()
@Type(() => UserDataDTO)
userData: UserDataDTO;

@ApiProperty({ type: () => [CustomFieldDTO] })
@IsArray()
@IsOptional()
@ValidateNested({ each: true })
Expand Down
3 changes: 3 additions & 0 deletions src/user/entities/user-entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ export class User {
})
status: UserStatus;

@Column({ nullable: true })
reason: string;

userRoleMappings: User;

// @OneToMany(() => CohortMembers, cohortMember => cohortMember.cohort)
Expand Down

0 comments on commit 3ac02b5

Please sign in to comment.