update: remove birthday and national code
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
|
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
|
||||||
import { IsMobilePhone, IsNotEmpty, IsNumberString, IsOptional, IsString, Length, MinLength } from "class-validator";
|
import { IsMobilePhone, IsNotEmpty, IsNumberString, IsOptional, IsString, Length, MinLength } from "class-validator";
|
||||||
|
|
||||||
import { IsNationalCode } from "../../../common/decorators/is-national-code.decorator";
|
// import { IsNationalCode } from "../../../common/decorators/is-national-code.decorator";
|
||||||
import { AuthMessage, ReferralMessage } from "../../../common/enums/message.enum";
|
import { AuthMessage, ReferralMessage } from "../../../common/enums/message.enum";
|
||||||
|
|
||||||
export class CompleteRegistrationDto {
|
export class CompleteRegistrationDto {
|
||||||
@@ -29,17 +29,19 @@ export class CompleteRegistrationDto {
|
|||||||
@ApiProperty({ description: "Last name", example: "jamshidi" })
|
@ApiProperty({ description: "Last name", example: "jamshidi" })
|
||||||
lastName: string;
|
lastName: string;
|
||||||
|
|
||||||
@IsNotEmpty({ message: AuthMessage.BIRTH_DATE_NOT_EMPTY })
|
// @IsOptional()
|
||||||
@IsString({ message: AuthMessage.BIRTH_DATE_NOT_EMPTY })
|
// @IsNotEmpty({ message: AuthMessage.BIRTH_DATE_NOT_EMPTY })
|
||||||
@ApiProperty({ description: "Birth date", example: "1403/01/01" })
|
// @IsString({ message: AuthMessage.BIRTH_DATE_NOT_EMPTY })
|
||||||
birthDate: string;
|
// @ApiProperty({ description: "Birth date", example: "1403/01/01" })
|
||||||
|
// birthDate: string;
|
||||||
|
|
||||||
@IsNotEmpty({ message: AuthMessage.NATIONAL_NOT_EMPTY })
|
// @IsOptional()
|
||||||
@IsNumberString({ no_symbols: true }, { message: AuthMessage.NATIONAL_CODE_INCORRECT })
|
// @IsNotEmpty({ message: AuthMessage.NATIONAL_NOT_EMPTY })
|
||||||
@Length(10, 10, { message: AuthMessage.NATIONAL_CODE_INCORRECT })
|
// @IsNumberString({ no_symbols: true }, { message: AuthMessage.NATIONAL_CODE_INCORRECT })
|
||||||
@IsNationalCode({ message: AuthMessage.NATIONAL_CODE_INVALID })
|
// @Length(10, 10, { message: AuthMessage.NATIONAL_CODE_INCORRECT })
|
||||||
@ApiProperty({ description: "iranian format (10 char)", example: "4569852169" })
|
// @IsNationalCode({ message: AuthMessage.NATIONAL_CODE_INVALID })
|
||||||
nationalCode: string;
|
// @ApiProperty({ description: "iranian format (10 char)", example: "4569852169" })
|
||||||
|
// nationalCode: string;
|
||||||
|
|
||||||
@IsNotEmpty({ message: AuthMessage.PASSWORD_NOT_EMPTY })
|
@IsNotEmpty({ message: AuthMessage.PASSWORD_NOT_EMPTY })
|
||||||
@IsString({ message: AuthMessage.PASSWORD_FORMAT_INVALID })
|
@IsString({ message: AuthMessage.PASSWORD_FORMAT_INVALID })
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ export class ZarinpalGateway implements IPaymentGateway {
|
|||||||
|
|
||||||
// If we have error response data from Zarinpal, extract it
|
// If we have error response data from Zarinpal, extract it
|
||||||
if (err.response?.data) {
|
if (err.response?.data) {
|
||||||
const errorData = err.response.data as any;
|
const errorData = err.response.data as ZarinPalPGVerifyData;
|
||||||
this.logger.error(`Zarinpal error response:`, errorData);
|
this.logger.error(`Zarinpal error response:`, errorData);
|
||||||
|
|
||||||
// Return the Zarinpal error response if it has the expected structure
|
// Return the Zarinpal error response if it has the expected structure
|
||||||
@@ -145,7 +145,7 @@ export class ZarinpalGateway implements IPaymentGateway {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
// If it's a Zarinpal error response, extract the error code and return it
|
// If it's a Zarinpal error response, extract the error code and return it
|
||||||
if (error && typeof error === "object" && "errors" in error) {
|
if (error && typeof error === "object" && "errors" in error) {
|
||||||
const zarinpalError = error as any;
|
const zarinpalError = error as ZarinPalPGVerifyData;
|
||||||
const firstError = zarinpalError.errors[0];
|
const firstError = zarinpalError.errors[0];
|
||||||
this.logger.warn(`Zarinpal verification error - Code: ${firstError.code}, Message: ${firstError.message}`);
|
this.logger.warn(`Zarinpal verification error - Code: ${firstError.code}, Message: ${firstError.message}`);
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
import { ApiProperty, PickType } from "@nestjs/swagger";
|
import { ApiProperty, PickType } from "@nestjs/swagger";
|
||||||
import { IsEnum, IsInt, IsNotEmpty, IsNumberString, IsString } from "class-validator";
|
import { IsEnum, IsInt, IsNotEmpty, IsNumberString, IsString, Length } from "class-validator";
|
||||||
|
|
||||||
import { FinancialMessage } from "../../../common/enums/message.enum";
|
import { IsNationalCode } from "../../../common/decorators/is-national-code.decorator";
|
||||||
|
import { AuthMessage, FinancialMessage } from "../../../common/enums/message.enum";
|
||||||
import { CompleteRegistrationDto } from "../../auth/DTO/complete-register.dto";
|
import { CompleteRegistrationDto } from "../../auth/DTO/complete-register.dto";
|
||||||
import { GenderEnum } from "../enums/gender-type.enum";
|
import { GenderEnum } from "../enums/gender-type.enum";
|
||||||
import { NationalityEnum } from "../enums/nationality.enum";
|
import { NationalityEnum } from "../enums/nationality.enum";
|
||||||
|
|
||||||
export class CreateRealUserDto extends PickType(CompleteRegistrationDto, ["firstName", "lastName", "birthDate", "nationalCode", "phone"]) {
|
export class CreateRealUserDto extends PickType(CompleteRegistrationDto, ["firstName", "lastName", "phone"]) {
|
||||||
@IsNotEmpty({ message: FinancialMessage.GENDER_TYPE_REQUIRED })
|
@IsNotEmpty({ message: FinancialMessage.GENDER_TYPE_REQUIRED })
|
||||||
@IsEnum(GenderEnum)
|
@IsEnum(GenderEnum)
|
||||||
@ApiProperty({ enum: GenderEnum, description: "Gender type", example: GenderEnum.MALE })
|
@ApiProperty({ enum: GenderEnum, description: "Gender type", example: GenderEnum.MALE })
|
||||||
@@ -22,6 +23,18 @@ export class CreateRealUserDto extends PickType(CompleteRegistrationDto, ["first
|
|||||||
@ApiProperty({ description: "Nationality" })
|
@ApiProperty({ description: "Nationality" })
|
||||||
nationality: NationalityEnum;
|
nationality: NationalityEnum;
|
||||||
|
|
||||||
|
@IsNotEmpty({ message: AuthMessage.BIRTH_DATE_NOT_EMPTY })
|
||||||
|
@IsString({ message: AuthMessage.BIRTH_DATE_NOT_EMPTY })
|
||||||
|
@ApiProperty({ description: "Birth date", example: "1403/01/01" })
|
||||||
|
birthDate: string;
|
||||||
|
|
||||||
|
@IsNotEmpty({ message: AuthMessage.NATIONAL_NOT_EMPTY })
|
||||||
|
@IsNumberString({ no_symbols: true }, { message: AuthMessage.NATIONAL_CODE_INCORRECT })
|
||||||
|
@Length(10, 10, { message: AuthMessage.NATIONAL_CODE_INCORRECT })
|
||||||
|
@IsNationalCode({ message: AuthMessage.NATIONAL_CODE_INVALID })
|
||||||
|
@ApiProperty({ description: "iranian format (10 char)", example: "4569852169" })
|
||||||
|
nationalCode: string;
|
||||||
|
|
||||||
//for address entity
|
//for address entity
|
||||||
@IsNotEmpty({ message: FinancialMessage.ADDRESS_REQUIRED })
|
@IsNotEmpty({ message: FinancialMessage.ADDRESS_REQUIRED })
|
||||||
@IsString({ message: FinancialMessage.ADDRESS_STRING })
|
@IsString({ message: FinancialMessage.ADDRESS_STRING })
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { ApiPropertyOptional, PartialType, PickType } from "@nestjs/swagger";
|
import { ApiProperty, ApiPropertyOptional, PartialType, PickType } from "@nestjs/swagger";
|
||||||
import { IsNotEmpty, IsOptional, IsString, IsUrl, Length } from "class-validator";
|
import { IsNotEmpty, IsNumberString, IsOptional, IsString, IsUrl, Length } from "class-validator";
|
||||||
|
|
||||||
import { UserMessage } from "../../../common/enums/message.enum";
|
import { IsNationalCode } from "../../../common/decorators/is-national-code.decorator";
|
||||||
|
import { AuthMessage, UserMessage } from "../../../common/enums/message.enum";
|
||||||
import { CompleteRegistrationDto } from "../../auth/DTO/complete-register.dto";
|
import { CompleteRegistrationDto } from "../../auth/DTO/complete-register.dto";
|
||||||
|
|
||||||
export class UpdateProfileDto extends PartialType(PickType(CompleteRegistrationDto, ["firstName", "lastName", "birthDate"] as const)) {
|
export class UpdateProfileDto extends PartialType(PickType(CompleteRegistrationDto, ["firstName", "lastName"] as const)) {
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsNotEmpty({ message: UserMessage.USERNAME_NOT_EMPTY })
|
@IsNotEmpty({ message: UserMessage.USERNAME_NOT_EMPTY })
|
||||||
@Length(3, 50, { message: UserMessage.USERNAME_SHOULD_BE_BETWEEN_3_AND_50 })
|
@Length(3, 50, { message: UserMessage.USERNAME_SHOULD_BE_BETWEEN_3_AND_50 })
|
||||||
@@ -12,6 +13,20 @@ export class UpdateProfileDto extends PartialType(PickType(CompleteRegistrationD
|
|||||||
@ApiPropertyOptional({ description: "User name", example: "mamad24" })
|
@ApiPropertyOptional({ description: "User name", example: "mamad24" })
|
||||||
userName?: string;
|
userName?: string;
|
||||||
|
|
||||||
|
@IsOptional()
|
||||||
|
@IsNotEmpty({ message: AuthMessage.BIRTH_DATE_NOT_EMPTY })
|
||||||
|
@IsString({ message: AuthMessage.BIRTH_DATE_NOT_EMPTY })
|
||||||
|
@ApiProperty({ description: "Birth date", example: "1403/01/01" })
|
||||||
|
birthDate: string;
|
||||||
|
|
||||||
|
@IsOptional()
|
||||||
|
@IsNotEmpty({ message: AuthMessage.NATIONAL_NOT_EMPTY })
|
||||||
|
@IsNumberString({ no_symbols: true }, { message: AuthMessage.NATIONAL_CODE_INCORRECT })
|
||||||
|
@Length(10, 10, { message: AuthMessage.NATIONAL_CODE_INCORRECT })
|
||||||
|
@IsNationalCode({ message: AuthMessage.NATIONAL_CODE_INVALID })
|
||||||
|
@ApiProperty({ description: "iranian format (10 char)", example: "4569852169" })
|
||||||
|
nationalCode: string;
|
||||||
|
|
||||||
@ApiPropertyOptional({ description: "Profile picture", example: "https://www.google.com" })
|
@ApiPropertyOptional({ description: "Profile picture", example: "https://www.google.com" })
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsNotEmpty({ message: UserMessage.PROFILE_PIC_REQUIRED })
|
@IsNotEmpty({ message: UserMessage.PROFILE_PIC_REQUIRED })
|
||||||
|
|||||||
@@ -244,8 +244,8 @@ export class UsersService {
|
|||||||
const existPhone = await queryRunner.manager.findOneBy(User, { phone: registerDto.phone });
|
const existPhone = await queryRunner.manager.findOneBy(User, { phone: registerDto.phone });
|
||||||
if (existPhone) throw new BadRequestException(UserMessage.PHONE_EXIST);
|
if (existPhone) throw new BadRequestException(UserMessage.PHONE_EXIST);
|
||||||
|
|
||||||
const existUser = await queryRunner.manager.findOneBy(User, { nationalCode: registerDto.nationalCode });
|
// const existUser = await queryRunner.manager.findOneBy(User, { nationalCode: registerDto.nationalCode });
|
||||||
if (existUser) throw new BadRequestException(UserMessage.NATIONAL_CODE_EXIST);
|
// if (existUser) throw new BadRequestException(UserMessage.NATIONAL_CODE_EXIST);
|
||||||
|
|
||||||
const userName = slugify(`${registerDto.firstName} ${Date.now().toString().slice(-5)}`, { lower: true, trim: true });
|
const userName = slugify(`${registerDto.firstName} ${Date.now().toString().slice(-5)}`, { lower: true, trim: true });
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user