feat: adding enhancment for zod admin portal kyc and add customer additional fields

This commit is contained in:
Abdalhamid Alhamad
2025-03-02 10:49:58 +03:00
parent dae9cb6323
commit 54ce5b022d
11 changed files with 242 additions and 16 deletions

View File

@ -1,39 +1,69 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsDateString, IsNotEmpty, IsOptional, IsString, IsUUID } from 'class-validator';
import { IsBoolean, IsDateString, IsEnum, IsNotEmpty, IsString, IsUUID } from 'class-validator';
import { i18nValidationMessage as i18n } from 'nestjs-i18n';
import { IsAbove18 } from '~/core/decorators/validations';
import { Gender } from '~/customer/enums';
export class CreateCustomerRequestDto {
@ApiProperty({ example: 'John' })
@IsString({ message: i18n('validation.IsString', { path: 'general', property: 'customer.firstName' }) })
@IsNotEmpty({ message: i18n('validation.IsNotEmpty', { path: 'general', property: 'customer.firstName' }) })
@IsOptional()
firstName!: string;
@ApiProperty({ example: 'Doe' })
@IsString({ message: i18n('validation.IsString', { path: 'general', property: 'customer.lastName' }) })
@IsNotEmpty({ message: i18n('validation.IsNotEmpty', { path: 'general', property: 'customer.lastName' }) })
@IsOptional()
lastName!: string;
@ApiProperty({ example: 'MALE' })
@IsEnum(Gender, { message: i18n('validation.IsEnum', { path: 'general', property: 'customer.gender' }) })
gender!: Gender;
@ApiProperty({ example: 'JO' })
@IsString({ message: i18n('validation.IsString', { path: 'general', property: 'customer.countryOfResidence' }) })
@IsNotEmpty({ message: i18n('validation.IsNotEmpty', { path: 'general', property: 'customer.countryOfResidence' }) })
@IsOptional()
countryOfResidence!: string;
@ApiProperty({ example: '2021-01-01' })
@IsDateString({}, { message: i18n('validation.IsDateString', { path: 'general', property: 'customer.dateOfBirth' }) })
@IsAbove18({ message: i18n('validation.IsAbove18', { path: 'general', property: 'customer.dateOfBirth' }) })
@IsOptional()
dateOfBirth!: Date;
@ApiProperty({ example: '999300024' })
@IsString({ message: i18n('validation.IsString', { path: 'general', property: 'customer.nationalId' }) })
@IsNotEmpty({ message: i18n('validation.IsNotEmpty', { path: 'general', property: 'customer.nationalId' }) })
nationalId!: string;
@ApiProperty({ example: '2021-01-01' })
@IsDateString(
{},
{ message: i18n('validation.IsDateString', { path: 'general', property: 'junior.nationalIdExpiry' }) },
)
nationalIdExpiry!: Date;
@ApiProperty({ example: 'Employee' })
@IsString({ message: i18n('validation.IsString', { path: 'general', property: 'customer.sourceOfIncome' }) })
@IsNotEmpty({ message: i18n('validation.IsNotEmpty', { path: 'general', property: 'customer.sourceOfIncome' }) })
sourceOfIncome!: string;
@ApiProperty({ example: 'Accountant' })
@IsString({ message: i18n('validation.IsString', { path: 'general', property: 'customer.profession' }) })
@IsNotEmpty({ message: i18n('validation.IsNotEmpty', { path: 'general', property: 'customer.profession' }) })
profession!: string;
@ApiProperty({ example: 'Finance' })
@IsString({ message: i18n('validation.IsString', { path: 'general', property: 'customer.professionType' }) })
@IsNotEmpty({ message: i18n('validation.IsNotEmpty', { path: 'general', property: 'customer.professionType' }) })
professionType!: string;
@ApiProperty({ example: false })
@IsBoolean({ message: i18n('validation.IsBoolean', { path: 'general', property: 'junior.isPep' }) })
isPep!: boolean;
@ApiProperty({ example: 'bf342-3f3f-3f3f-3f3f' })
@IsUUID('4', { message: i18n('validation.IsUUID', { path: 'general', property: 'junior.civilIdFrontId' }) })
@IsOptional()
civilIdFrontId!: string;
@ApiProperty({ example: 'bf342-3f3f-3f3f-3f3f' })
@IsUUID('4', { message: i18n('validation.IsUUID', { path: 'general', property: 'junior.civilIdBackId' }) })
@IsOptional()
civilIdBackId!: string;
}

View File

@ -1 +1,3 @@
export * from './customer-response.dto';
export * from './internal.customer-details.response.dto';
export * from './internal.customer-list.response.dto';

View File

@ -0,0 +1,89 @@
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Customer } from '~/customer/entities';
import { CustomerStatus, KycStatus } from '~/customer/enums';
import { DocumentMetaResponseDto } from '~/document/dtos/response';
export class InternalCustomerDetailsResponseDto {
@ApiProperty()
id!: string;
@ApiProperty()
customerStatus!: CustomerStatus;
@ApiProperty()
kycStatus!: KycStatus;
@ApiProperty()
rejectionReason!: string | null;
@ApiProperty()
fullName!: string;
@ApiProperty()
phoneNumber!: string;
@ApiProperty()
dateOfBirth!: Date;
@ApiProperty()
nationalId!: string;
@ApiProperty()
nationalIdExpiry!: Date;
@ApiProperty()
countryOfResidence!: string;
@ApiProperty()
sourceOfIncome!: string;
@ApiProperty()
profession!: string;
@ApiProperty()
professionType!: string;
@ApiProperty()
isPep!: boolean;
@ApiProperty()
gender!: string;
@ApiProperty()
isJunior!: boolean;
@ApiProperty()
isGuardian!: boolean;
@ApiProperty({ type: DocumentMetaResponseDto })
civilIdFront!: DocumentMetaResponseDto;
@ApiProperty({ type: DocumentMetaResponseDto })
civilIdBack!: DocumentMetaResponseDto;
@ApiPropertyOptional({ type: DocumentMetaResponseDto })
profilePicture!: DocumentMetaResponseDto | null;
constructor(customer: Customer) {
this.id = customer.id;
this.customerStatus = customer.customerStatus;
this.kycStatus = customer.kycStatus;
this.rejectionReason = customer.rejectionReason;
this.fullName = `${customer.firstName} ${customer.lastName}`;
this.phoneNumber = customer.user.fullPhoneNumber;
this.dateOfBirth = customer.dateOfBirth;
this.nationalId = customer.nationalId;
this.nationalIdExpiry = customer.nationalIdExpiry;
this.countryOfResidence = customer.countryOfResidence;
this.sourceOfIncome = customer.sourceOfIncome;
this.profession = customer.profession;
this.professionType = customer.professionType;
this.isPep = customer.isPep;
this.gender = customer.gender;
this.isJunior = customer.isJunior;
this.isGuardian = customer.isGuardian;
this.civilIdFront = new DocumentMetaResponseDto(customer.civilIdFront);
this.civilIdBack = new DocumentMetaResponseDto(customer.civilIdBack);
this.profilePicture = customer.profilePicture ? new DocumentMetaResponseDto(customer.profilePicture) : null;
}
}

View File

@ -0,0 +1,44 @@
import { ApiProperty } from '@nestjs/swagger';
import { Customer } from '~/customer/entities';
import { CustomerStatus, KycStatus } from '~/customer/enums';
export class InternalCustomerListResponse {
@ApiProperty()
id!: string;
@ApiProperty()
fullName!: string;
@ApiProperty()
phoneNumber!: string;
@ApiProperty()
customerStatus!: CustomerStatus;
@ApiProperty()
kycStatus!: KycStatus;
@ApiProperty()
dateOfBirth!: Date;
@ApiProperty()
gender!: string;
@ApiProperty()
isJunior!: boolean;
@ApiProperty()
isGuardian!: boolean;
constructor(customer: Customer) {
this.id = customer.id;
this.fullName = `${customer.firstName} ${customer.lastName}`;
this.phoneNumber = customer.user?.fullPhoneNumber;
this.customerStatus = customer.customerStatus;
this.kycStatus = customer.kycStatus;
this.dateOfBirth = customer.dateOfBirth;
this.gender = customer.gender;
this.isGuardian = customer.isGuardian;
this.isJunior = customer.isJunior;
}
}